Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

752 lines
30 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) Microsoft Corporation, 1996 - 2000.
  4. //
  5. // File: param.cxx
  6. //
  7. // Contents: Used to replace variables in strings
  8. //
  9. // History: 96/Jan/3 DwightKr Created
  10. //
  11. //----------------------------------------------------------------------------
  12. #include <pch.cxx>
  13. #pragma hdrstop
  14. //
  15. // These ISAPI variables are Ci values available on HTX generated output.
  16. //
  17. const WCHAR * ISAPI_CI_ADMIN_OPERATION = L"CIADMINOPERATION";
  18. const WCHAR * ISAPI_CI_BOOKMARK = L"CIBOOKMARK";
  19. const WCHAR * ISAPI_CI_BOOKMARK_SKIP_COUNT = L"CIBOOKMARKSKIPCOUNT";
  20. const WCHAR * ISAPI_CI_BOOL_VECTOR_PREFIX = L"CIBOOLVECTORPREFIX";
  21. const WCHAR * ISAPI_CI_BOOL_VECTOR_SEPARATOR = L"CIBOOLVECTORSEPARATOR";
  22. const WCHAR * ISAPI_CI_BOOL_VECTOR_SUFFIX = L"CIBOOLVECTORSUFFIX";
  23. const WCHAR * ISAPI_CI_CANONICAL_OUTPUT = L"CICANONICALOUTPUT";
  24. const WCHAR * ISAPI_CI_CATALOG = L"CICATALOG";
  25. const WCHAR * ISAPI_CI_CODEPAGE = L"CICODEPAGE";
  26. const char * ISAPI_CI_CODEPAGE_A = "CICODEPAGE";
  27. const WCHAR * ISAPI_CI_COLUMNS = L"CICOLUMNS";
  28. const WCHAR * ISAPI_CI_CONTAINS_FIRST_RECORD = L"CICONTAINSFIRSTRECORD";
  29. const WCHAR * ISAPI_CI_CONTAINS_LAST_RECORD = L"CICONTAINSLASTRECORD";
  30. const WCHAR * ISAPI_CI_CURRENCY_VECTOR_PREFIX = L"CICURRENCYVECTORPREFIX";
  31. const WCHAR * ISAPI_CI_CURRENCY_VECTOR_SEPARATOR=L"CICURRENCYVECTORSEPARATOR";
  32. const WCHAR * ISAPI_CI_CURRENCY_VECTOR_SUFFIX = L"CICURRENCYVECTORSUFFIX";
  33. const WCHAR * ISAPI_CI_CURRENT_PAGE_NUMBER = L"CICURRENTPAGENUMBER";
  34. const WCHAR * ISAPI_CI_CURRENT_RECORD_NUMBER = L"CICURRENTRECORDNUMBER";
  35. const WCHAR * ISAPI_CI_DATE_VECTOR_PREFIX = L"CIDATEVECTORPREFIX";
  36. const WCHAR * ISAPI_CI_DATE_VECTOR_SEPARATOR = L"CIDATEVECTORSEPARATOR";
  37. const WCHAR * ISAPI_CI_DATE_VECTOR_SUFFIX = L"CIDATEVECTORSUFFIX";
  38. const WCHAR * ISAPI_CI_DIALECT = L"CIDIALECT";
  39. const WCHAR * ISAPI_CI_DONT_TIMEOUT = L"CIDONTTIMEOUT";
  40. const WCHAR * ISAPI_CI_ERROR_MESSAGE = L"CIERRORMESSAGE";
  41. const WCHAR * ISAPI_CI_ERROR_NUMBER = L"CIERRORNUMBER";
  42. const WCHAR * ISAPI_CI_FIRST_RECORD_NUMBER = L"CIFIRSTRECORDNUMBER";
  43. const WCHAR * ISAPI_CI_FLAGS = L"CIFLAGS";
  44. const WCHAR * ISAPI_CI_FORCE_USE_CI = L"CIFORCEUSECI";
  45. const WCHAR * ISAPI_CI_DEFER_NONINDEXED_TRIMMING = L"CIDEFERNONINDEXEDTRIMMING";
  46. const WCHAR * ISAPI_CI_LAST_RECORD_NUMBER = L"CILASTRECORDNUMBER";
  47. const WCHAR * ISAPI_CI_LOCALE = L"CILOCALE";
  48. const WCHAR * ISAPI_CI_MATCHED_RECORD_COUNT = L"CIMATCHEDRECORDCOUNT";
  49. const WCHAR * ISAPI_CI_MAX_RECORDS_IN_RESULTSET = L"CIMAXRECORDSINRESULTSET";
  50. const WCHAR * ISAPI_CI_MAX_RECORDS_PER_PAGE = L"CIMAXRECORDSPERPAGE";
  51. const WCHAR * ISAPI_CI_FIRST_ROWS_IN_RESULTSET = L"CIFIRSTROWSINRESULTSET";
  52. const WCHAR * ISAPI_CI_NUMBER_VECTOR_PREFIX = L"CINUMBERVECTORPREFIX";
  53. const WCHAR * ISAPI_CI_NUMBER_VECTOR_SEPARATOR= L"CINUMBERVECTORSEPARATOR";
  54. const WCHAR * ISAPI_CI_NUMBER_VECTOR_SUFFIX = L"CINUMBERVECTORSUFFIX";
  55. const WCHAR * ISAPI_CI_OUT_OF_DATE = L"CIOUTOFDATE";
  56. const WCHAR * ISAPI_CI_QUERY_INCOMPLETE = L"CIQUERYINCOMPLETE";
  57. const WCHAR * ISAPI_CI_QUERY_TIMEDOUT = L"CIQUERYTIMEDOUT";
  58. const WCHAR * ISAPI_CI_QUERY_DATE = L"CIQUERYDATE";
  59. const WCHAR * ISAPI_CI_QUERY_TIME = L"CIQUERYTIME";
  60. const WCHAR * ISAPI_CI_QUERY_TIMEZONE = L"CIQUERYTIMEZONE";
  61. const WCHAR * ISAPI_CI_RESTRICTION = L"CIRESTRICTION";
  62. const WCHAR * ISAPI_CI_RECORDS_NEXT_PAGE = L"CIRECORDSNEXTPAGE";
  63. const WCHAR * ISAPI_CI_SCOPE = L"CISCOPE";
  64. const WCHAR * ISAPI_CI_SORT = L"CISORT";
  65. const WCHAR * ISAPI_CI_STRING_VECTOR_PREFIX = L"CISTRINGVECTORPREFIX";
  66. const WCHAR * ISAPI_CI_STRING_VECTOR_SEPARATOR= L"CISTRINGVECTORSEPARATOR";
  67. const WCHAR * ISAPI_CI_STRING_VECTOR_SUFFIX = L"CISTRINGVECTORSUFFIX";
  68. const WCHAR * ISAPI_CI_TEMPLATE = L"CITEMPLATE";
  69. const WCHAR * ISAPI_CI_TOTAL_NUMBER_PAGES = L"CITOTALNUMBERPAGES";
  70. const WCHAR * ISAPI_CI_VERSION_MAJOR = L"CIVERSIONMAJOR";
  71. const WCHAR * ISAPI_CI_VERSION_MINOR = L"CIVERSIONMINOR";
  72. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_WORDLISTS = L"CIADMININDEXCOUNTWORDLISTS";
  73. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_PERSINDEX = L"CIADMININDEXCOUNTPERSINDEX";
  74. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_QUERIES = L"CIADMININDEXCOUNTQUERIES";
  75. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_UNIQUE = L"CIADMININDEXCOUNTUNIQUE";
  76. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_FRESHTEST = L"CIADMININDEXCOUNTDELTAS";
  77. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_TOFILTER = L"CIADMININDEXCOUNTTOFILTER";
  78. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_FILTERED = L"CIADMININDEXCOUNTFILTERED";
  79. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_PENDINGSCANS = L"CIADMININDEXCOUNTPENDINGSCANS";
  80. const WCHAR * ISAPI_CI_ADMIN_INDEX_COUNT_TOTAL = L"CIADMININDEXCOUNTTOTAL";
  81. const WCHAR * ISAPI_CI_ADMIN_INDEX_SIZE = L"CIADMININDEXSIZE";
  82. const WCHAR * ISAPI_CI_ADMIN_INDEX_MERGE_PROGRESS = L"CIADMININDEXMERGEPROGRESS";
  83. const WCHAR * ISAPI_CI_ADMIN_INDEX_STATE_SHADOWMERGE = L"CIADMININDEXSTATESHADOWMERGE";
  84. const WCHAR * ISAPI_CI_ADMIN_INDEX_STATE_MASTERMERGE = L"CIADMININDEXSTATEMASTERMERGE";
  85. const WCHAR * ISAPI_CI_ADMIN_INDEX_STATE_ANNEALINGMERGE = L"CIADMININDEXSTATEANNEALINGMERGE";
  86. const WCHAR * ISAPI_CI_ADMIN_INDEX_STATE_SCANREQUIRED = L"CIADMININDEXSTATESCANREQUIRED";
  87. const WCHAR * ISAPI_CI_ADMIN_INDEX_STATE_SCANNING = L"CIADMININDEXSTATESCANNING";
  88. const WCHAR * ISAPI_CI_ADMIN_INDEX_STATE_RECOVERING = L"CIADMININDEXSTATERECOVERING";
  89. const WCHAR * ISAPI_CI_ADMIN_CACHE_HITS = L"CIADMINCACHEHITS";
  90. const WCHAR * ISAPI_CI_ADMIN_CACHE_MISSES = L"CIADMINCACHEMISSES";
  91. const WCHAR * ISAPI_CI_ADMIN_CACHE_ACTIVE = L"CIADMINCACHEACTIVE";
  92. const WCHAR * ISAPI_CI_ADMIN_CACHE_COUNT = L"CIADMINCACHECOUNT";
  93. const WCHAR * ISAPI_CI_ADMIN_CACHE_PENDING = L"CIADMINCACHEPENDING";
  94. const WCHAR * ISAPI_CI_ADMIN_CACHE_REJECTED = L"CIADMINCACHEREJECTED";
  95. const WCHAR * ISAPI_CI_ADMIN_CACHE_TOTAL = L"CIADMINCACHETOTAL";
  96. const WCHAR * ISAPI_CI_ADMIN_CACHE_QPM = L"CIADMINCACHERATE";
  97. const WCHAR * ISAPI_ALL_HTTP = L"ALL_HTTP";
  98. const WCHAR * ISAPI_AUTH_TYPE = L"AUTH_TYPE";
  99. const WCHAR * ISAPI_CONTENT_LENGTH = L"CONTENT_LENGTH";
  100. const WCHAR * ISAPI_CONTENT_TYPE = L"CONTENT_TYPE";
  101. const WCHAR * ISAPI_GATEWAY_INTERFACE = L"GATEWAY_INTERFACE";
  102. const WCHAR * ISAPI_HTTP_ACCEPT = L"HTTP_ACCEPT";
  103. const WCHAR * ISAPI_HTTP_ACCEPT_LANGUAGE = L"HTTP_ACCEPT_LANGUAGE";
  104. const WCHAR * ISAPI_HTTP_COOKIE = L"HTTP_COOKIE";
  105. const WCHAR * ISAPI_HTTP_CONNECTION = L"HTTP_CONNECTION";
  106. const WCHAR * ISAPI_HTTP_CONTENT_TYPE = L"HTTP_CONTENT_TYPE";
  107. const WCHAR * ISAPI_HTTP_CONTENT_LENGTH = L"HTTP_CONTENT_LENGTH";
  108. const WCHAR * ISAPI_HTTP_PRAGMA = L"HTTP_PRAGMA";
  109. const WCHAR * ISAPI_HTTP_REFERER = L"HTTP_REFERER";
  110. const WCHAR * ISAPI_HTTP_USER_AGENT = L"HTTP_USER_AGENT";
  111. const WCHAR * ISAPI_PATH_INFO = L"PATH_INFO";
  112. const WCHAR * ISAPI_PATH_TRANSLATED = L"PATH_TRANSLATED";
  113. const WCHAR * ISAPI_QUERY_STRING = L"QUERY_STRING";
  114. const WCHAR * ISAPI_REMOTE_ADDR = L"REMOTE_ADDR";
  115. const WCHAR * ISAPI_REMOTE_HOST = L"REMOTE_HOST";
  116. const WCHAR * ISAPI_REMOTE_USER = L"REMOTE_USER";
  117. const WCHAR * ISAPI_REQUEST_METHOD = L"REQUEST_METHOD";
  118. const WCHAR * ISAPI_SCRIPT_NAME = L"SCRIPT_NAME";
  119. const WCHAR * ISAPI_SERVER_NAME = L"SERVER_NAME";
  120. const WCHAR * ISAPI_SERVER_PORT = L"SERVER_PORT";
  121. const WCHAR * ISAPI_SERVER_PROTOCOL = L"SERVER_PROTOCOL";
  122. const WCHAR * ISAPI_SERVER_SOFTWARE = L"SERVER_SOFTWARE";
  123. const struct tagCiGlobalVars aCiGlobalVars[] =
  124. {
  125. { ISAPI_CI_BOOKMARK, VT_EMPTY, 0, 0 },
  126. { ISAPI_CI_BOOKMARK_SKIP_COUNT, VT_I4, 0, 0 },
  127. { ISAPI_CI_CANONICAL_OUTPUT, VT_EMPTY, 0, 0 },
  128. { ISAPI_CI_CATALOG, VT_EMPTY, 0, 0 },
  129. { ISAPI_CI_COLUMNS, VT_EMPTY, 0, 0 },
  130. { ISAPI_CI_CONTAINS_FIRST_RECORD, VT_BOOL, VARIANT_TRUE, 0 },
  131. { ISAPI_CI_CONTAINS_LAST_RECORD, VT_BOOL, VARIANT_FALSE, 0 },
  132. { ISAPI_CI_CURRENT_RECORD_NUMBER, VT_I4, 0, 0 },
  133. { ISAPI_CI_CURRENT_PAGE_NUMBER, VT_I4, 0, 0 },
  134. { ISAPI_CI_DIALECT, VT_UI4, ISQLANG_V2, 0 },
  135. { ISAPI_CI_DONT_TIMEOUT, VT_LPWSTR, 0, 0 },
  136. { ISAPI_CI_ERROR_MESSAGE, VT_EMPTY, 0, 0 },
  137. { ISAPI_CI_ERROR_NUMBER, VT_I4, 0, 0 },
  138. { ISAPI_CI_FIRST_RECORD_NUMBER, VT_I4, 1, 0 },
  139. { ISAPI_CI_FLAGS, VT_EMPTY, 0, 0 },
  140. { ISAPI_CI_FORCE_USE_CI, VT_EMPTY, 0, 0 },
  141. { ISAPI_CI_LAST_RECORD_NUMBER, VT_UI4, 1, 0 },
  142. { ISAPI_CI_LOCALE, VT_EMPTY, 0, 0 },
  143. { ISAPI_CI_MATCHED_RECORD_COUNT, VT_I4, 0, eParamRequiresNonSequentialCursor },
  144. { ISAPI_CI_MAX_RECORDS_IN_RESULTSET, VT_I4, 0, 0 },
  145. { ISAPI_CI_MAX_RECORDS_PER_PAGE, VT_I4, 10, 0 },
  146. { ISAPI_CI_FIRST_ROWS_IN_RESULTSET, VT_I4, 0, 0 },
  147. { ISAPI_CI_OUT_OF_DATE, VT_BOOL, VARIANT_FALSE, 0 },
  148. { ISAPI_CI_QUERY_INCOMPLETE, VT_BOOL, VARIANT_FALSE, 0 },
  149. { ISAPI_CI_QUERY_TIMEDOUT, VT_BOOL, VARIANT_FALSE, 0 },
  150. { ISAPI_CI_QUERY_DATE, VT_EMPTY, 0, 0 },
  151. { ISAPI_CI_QUERY_TIME, VT_EMPTY, 0, 0 },
  152. { ISAPI_CI_QUERY_TIMEZONE, VT_EMPTY, 0, 0 },
  153. { ISAPI_CI_RESTRICTION, VT_EMPTY, 0, 0 },
  154. { ISAPI_CI_RECORDS_NEXT_PAGE, VT_I4, 0, eParamRequiresNonSequentialCursor },
  155. { ISAPI_CI_SCOPE, VT_EMPTY, 0, 0 },
  156. { ISAPI_CI_SORT, VT_EMPTY, 0, 0 },
  157. { ISAPI_CI_TEMPLATE, VT_EMPTY, 0, 0 },
  158. { ISAPI_CI_TOTAL_NUMBER_PAGES, VT_I4, 1, eParamRequiresNonSequentialCursor },
  159. { ISAPI_CI_VERSION_MAJOR, VT_I4, 3, 0 },
  160. { ISAPI_CI_VERSION_MINOR, VT_I4, 0, 0 },
  161. };
  162. const struct tagCiGlobalVars aISAPIGlobalVars[] =
  163. {
  164. { ISAPI_ALL_HTTP, VT_LPWSTR, 0, eParamDeferredValue },
  165. { ISAPI_AUTH_TYPE, VT_LPWSTR, 0, eParamDeferredValue },
  166. { ISAPI_CONTENT_LENGTH, VT_EMPTY, 0, 0 },
  167. { ISAPI_CONTENT_TYPE, VT_EMPTY, 0, 0 },
  168. { ISAPI_GATEWAY_INTERFACE, VT_LPWSTR, 0, eParamDeferredValue },
  169. { ISAPI_HTTP_ACCEPT, VT_EMPTY, 0, 0 },
  170. { ISAPI_HTTP_ACCEPT_LANGUAGE, VT_EMPTY, 0, 0 },
  171. { ISAPI_HTTP_COOKIE, VT_EMPTY, 0, 0 },
  172. { ISAPI_HTTP_CONNECTION, VT_EMPTY, 0, 0 },
  173. { ISAPI_HTTP_CONTENT_TYPE, VT_EMPTY, 0, 0 },
  174. { ISAPI_HTTP_CONTENT_LENGTH, VT_EMPTY, 0, 0 },
  175. { ISAPI_HTTP_PRAGMA, VT_EMPTY, 0, 0 },
  176. { ISAPI_HTTP_REFERER, VT_EMPTY, 0, 0 },
  177. { ISAPI_HTTP_USER_AGENT, VT_EMPTY, 0, 0 },
  178. { ISAPI_PATH_INFO, VT_EMPTY, 0, 0 },
  179. { ISAPI_PATH_TRANSLATED, VT_EMPTY, 0, 0 },
  180. { ISAPI_QUERY_STRING, VT_EMPTY, 0, 0 },
  181. { ISAPI_REMOTE_ADDR, VT_LPWSTR, 0, eParamDeferredValue },
  182. { ISAPI_REMOTE_HOST, VT_LPWSTR, 0, eParamDeferredValue },
  183. { ISAPI_REMOTE_USER, VT_LPWSTR, 0, eParamDeferredValue },
  184. { ISAPI_REQUEST_METHOD, VT_EMPTY, 0, 0 },
  185. { ISAPI_SCRIPT_NAME, VT_LPWSTR, 0, eParamDeferredValue },
  186. { ISAPI_SERVER_NAME, VT_LPWSTR, 0, eParamDeferredValue },
  187. { ISAPI_SERVER_PORT, VT_LPWSTR, 0, eParamDeferredValue },
  188. { ISAPI_SERVER_PROTOCOL, VT_LPWSTR, 0, eParamDeferredValue },
  189. { ISAPI_SERVER_SOFTWARE, VT_LPWSTR, 0, eParamDeferredValue },
  190. };
  191. const unsigned cCiGlobalVars = sizeof(aCiGlobalVars) / sizeof(aCiGlobalVars[0]);
  192. const unsigned cISAPIGlobalVars = sizeof(aISAPIGlobalVars) / sizeof(aISAPIGlobalVars[0]);
  193. const WCHAR * aISAPI_CiParams[] =
  194. {
  195. ISAPI_CI_BOOKMARK,
  196. ISAPI_CI_BOOKMARK_SKIP_COUNT,
  197. ISAPI_CI_BOOL_VECTOR_PREFIX,
  198. ISAPI_CI_BOOL_VECTOR_SEPARATOR,
  199. ISAPI_CI_BOOL_VECTOR_SUFFIX,
  200. ISAPI_CI_CANONICAL_OUTPUT,
  201. ISAPI_CI_CATALOG,
  202. ISAPI_CI_COLUMNS,
  203. ISAPI_CI_CONTAINS_FIRST_RECORD,
  204. ISAPI_CI_CONTAINS_LAST_RECORD,
  205. ISAPI_CI_CURRENCY_VECTOR_PREFIX,
  206. ISAPI_CI_CURRENCY_VECTOR_SEPARATOR,
  207. ISAPI_CI_CURRENCY_VECTOR_SUFFIX,
  208. ISAPI_CI_CURRENT_PAGE_NUMBER,
  209. ISAPI_CI_CURRENT_RECORD_NUMBER,
  210. ISAPI_CI_DATE_VECTOR_PREFIX,
  211. ISAPI_CI_DATE_VECTOR_SEPARATOR,
  212. ISAPI_CI_DATE_VECTOR_SUFFIX,
  213. ISAPI_CI_DIALECT,
  214. ISAPI_CI_DONT_TIMEOUT,
  215. ISAPI_CI_ERROR_MESSAGE,
  216. ISAPI_CI_FIRST_RECORD_NUMBER,
  217. ISAPI_CI_FORCE_USE_CI,
  218. ISAPI_CI_DEFER_NONINDEXED_TRIMMING,
  219. ISAPI_CI_FLAGS,
  220. ISAPI_CI_LAST_RECORD_NUMBER,
  221. ISAPI_CI_LOCALE,
  222. ISAPI_CI_MATCHED_RECORD_COUNT,
  223. ISAPI_CI_MAX_RECORDS_IN_RESULTSET,
  224. ISAPI_CI_MAX_RECORDS_PER_PAGE,
  225. ISAPI_CI_FIRST_ROWS_IN_RESULTSET,
  226. ISAPI_CI_NUMBER_VECTOR_PREFIX,
  227. ISAPI_CI_NUMBER_VECTOR_SEPARATOR,
  228. ISAPI_CI_NUMBER_VECTOR_SUFFIX,
  229. ISAPI_CI_OUT_OF_DATE,
  230. ISAPI_CI_QUERY_INCOMPLETE,
  231. ISAPI_CI_QUERY_DATE,
  232. ISAPI_CI_QUERY_TIME,
  233. ISAPI_CI_QUERY_TIMEZONE,
  234. ISAPI_CI_RESTRICTION,
  235. ISAPI_CI_RECORDS_NEXT_PAGE,
  236. ISAPI_CI_SCOPE,
  237. ISAPI_CI_SORT,
  238. ISAPI_CI_STRING_VECTOR_PREFIX,
  239. ISAPI_CI_STRING_VECTOR_SEPARATOR,
  240. ISAPI_CI_STRING_VECTOR_SUFFIX,
  241. ISAPI_CI_TEMPLATE,
  242. ISAPI_CI_TOTAL_NUMBER_PAGES,
  243. ISAPI_CI_VERSION_MAJOR,
  244. ISAPI_CI_VERSION_MINOR,
  245. ISAPI_ALL_HTTP,
  246. ISAPI_AUTH_TYPE,
  247. ISAPI_CONTENT_LENGTH,
  248. ISAPI_CONTENT_TYPE,
  249. ISAPI_GATEWAY_INTERFACE,
  250. ISAPI_HTTP_ACCEPT,
  251. ISAPI_HTTP_ACCEPT_LANGUAGE,
  252. ISAPI_HTTP_COOKIE,
  253. ISAPI_HTTP_CONNECTION,
  254. ISAPI_HTTP_CONTENT_TYPE,
  255. ISAPI_HTTP_CONTENT_LENGTH,
  256. ISAPI_HTTP_PRAGMA,
  257. ISAPI_HTTP_REFERER,
  258. ISAPI_HTTP_USER_AGENT,
  259. ISAPI_PATH_INFO,
  260. ISAPI_PATH_TRANSLATED,
  261. ISAPI_QUERY_STRING,
  262. ISAPI_REMOTE_ADDR,
  263. ISAPI_REMOTE_HOST,
  264. ISAPI_REMOTE_USER,
  265. ISAPI_REQUEST_METHOD,
  266. ISAPI_SCRIPT_NAME,
  267. ISAPI_SERVER_NAME,
  268. ISAPI_SERVER_PORT,
  269. ISAPI_SERVER_PROTOCOL,
  270. ISAPI_SERVER_SOFTWARE,
  271. };
  272. const unsigned cISAPI_CiParams = sizeof(aISAPI_CiParams) / sizeof(aISAPI_CiParams[0]);
  273. extern const CDbColId dbColIdVirtualPath;
  274. //+---------------------------------------------------------------------------
  275. //
  276. // Member: CParameterNode::~CParameterNode - public destructor
  277. //
  278. // Synopsis: Deletes all nodes attached to this one
  279. //
  280. // History: 96/Jan/03 DwightKr Created.
  281. //
  282. //----------------------------------------------------------------------------
  283. CParameterNode::~CParameterNode()
  284. {
  285. if ( 0 != _pTrueNode )
  286. {
  287. _pTrueNode->DecrementRefCount();
  288. if ( 0 == _pTrueNode->GetRefCount() )
  289. {
  290. delete _pTrueNode;
  291. }
  292. }
  293. if ( 0 != _pFalseNode )
  294. {
  295. _pFalseNode->DecrementRefCount();
  296. if ( 0 == _pFalseNode->GetRefCount() )
  297. {
  298. delete _pFalseNode;
  299. }
  300. }
  301. }
  302. //+---------------------------------------------------------------------------
  303. //
  304. // Member: CParameterNodeIter::CParameterNodeIter - public constructor
  305. //
  306. // Synopsis: Iteraties over a CParameterNode tree
  307. //
  308. // Arguments: [pNode] - root of the tree to iterate over
  309. // [variableSet] - a list of replaceable parameters
  310. //
  311. // History: 96/Jan/03 DwightKr Created.
  312. //
  313. //----------------------------------------------------------------------------
  314. CParameterNodeIter::CParameterNodeIter( CParameterNode *pNode,
  315. CVariableSet & variableSet,
  316. COutputFormat & outputFormat ) :
  317. _root( pNode ),
  318. _variableSet(variableSet),
  319. _outputFormat(outputFormat)
  320. {
  321. }
  322. //+---------------------------------------------------------------------------
  323. //
  324. // Member: CParameterNodeIter::EvaluateExpression - private
  325. //
  326. // Synopsis: Evaluates an IF expression
  327. //
  328. // Arguments: [wcsCondition] - the string containing the condition to
  329. // evaluate
  330. //
  331. // History: 96/Jan/03 DwightKr Created.
  332. //
  333. //----------------------------------------------------------------------------
  334. BOOL CParameterNodeIter::EvaluateExpression( WCHAR const * wcsCondition )
  335. {
  336. CTokenizeString scanner( wcsCondition );
  337. CHTXIfExpression ifExpression( scanner, _variableSet, _outputFormat );
  338. return ifExpression.Evaluate();
  339. }
  340. //+---------------------------------------------------------------------------
  341. //
  342. // Member: CParameterReplacer - public constructor
  343. //
  344. // Synopsis: Initializes the variableSet and parses the string
  345. //
  346. // Arguments: [wcsString] - the string to parse and replace parameters in
  347. // [wcsPrefix] - the prefix delimiting parameters
  348. // [wcsSuffix] - the suffix delimiting parameters
  349. //
  350. // History: 96/Jan/03 DwightKr Created.
  351. //
  352. //----------------------------------------------------------------------------
  353. CParameterReplacer::CParameterReplacer( WCHAR const * wcsString,
  354. WCHAR const * wcsPrefix,
  355. WCHAR const * wcsSuffix ) :
  356. _wcsString(0),
  357. _wcsPrefix(wcsPrefix),
  358. _wcsSuffix(wcsSuffix),
  359. _ulFlags(0),
  360. _paramNode(L"Top")
  361. {
  362. Win4Assert( 0 != wcsString );
  363. Win4Assert( 0 != wcsPrefix );
  364. Win4Assert( 0 != wcsSuffix );
  365. ULONG cwcString = wcslen(wcsString) + 1;
  366. _wcsString = new WCHAR[ cwcString ];
  367. RtlCopyMemory( _wcsString, wcsString, cwcString * sizeof(WCHAR) );
  368. }
  369. //+---------------------------------------------------------------------------
  370. //
  371. // Member: CParameterReplacer::ParseString - public
  372. //
  373. // Arguments: [variableSet] - the list of replaceable parameter values
  374. //
  375. // Synopsis: Parses the string and builds a tree of replaceable parameters.
  376. //
  377. // History: 96/Jan/03 DwightKr Created.
  378. //
  379. //----------------------------------------------------------------------------
  380. void CParameterReplacer::ParseString( CVariableSet & variableSet )
  381. {
  382. CHTXScanner scanner( variableSet, _wcsPrefix, _wcsSuffix );
  383. scanner.Init( _wcsString );
  384. CDynStackInPlace<ULONG> ifStack;
  385. BuildTree( scanner, &_paramNode, ifStack );
  386. if ( ifStack.Count() != 0 )
  387. {
  388. THROW( CHTXException(MSG_CI_HTX_EXPECTING_ELSE_ENDIF, 0, 0) );
  389. }
  390. }
  391. //+---------------------------------------------------------------------------
  392. //
  393. // Member: CParameterReplacer::ReplaceParams - public
  394. //
  395. // Synopsis: Generates a new string replacing all %values% in the original
  396. // string
  397. //
  398. // Arguments: [StrResult] - a safe string to append the new params to
  399. // [variableSet] - the list of replaceable parameter values
  400. //
  401. // Notes: If expressions are handled in the parameter node iterator.
  402. //
  403. // History: 96/Jan/03 DwightKr Created.
  404. //
  405. //----------------------------------------------------------------------------
  406. void CParameterReplacer::ReplaceParams( CVirtualString & StrResult,
  407. CVariableSet & variableSet,
  408. COutputFormat & outputFormat )
  409. {
  410. BOOL fIsIDQ = ( L'%' == _wcsPrefix[0] );
  411. for ( CParameterNodeIter iter(&_paramNode, variableSet, outputFormat);
  412. !iter.AtEnd();
  413. iter.Next() )
  414. {
  415. CParameterNode * pNode = iter.Get();
  416. ULONG type = pNode->Type() & eJustParamMask;
  417. // Always escape variables in .idq files as RAW
  418. if ( ( fIsIDQ ) && ( eParameter == type ) )
  419. {
  420. type = eEscapeRAW;
  421. }
  422. switch ( type )
  423. {
  424. case eString:
  425. StrResult.StrCat( pNode->String(), pNode->Length() );
  426. break;
  427. case eParameter:
  428. case eEscapeHTML:
  429. {
  430. if (! variableSet.GetStringValueHTML( pNode->String(),
  431. pNode->Hash(),
  432. outputFormat,
  433. StrResult ) )
  434. {
  435. ciGibDebugOut(( DEB_IWARN,
  436. "Warning: CParameterReplacer::ReplaceParams GetStringValueHTML returned FALSE for '%ws'\n",
  437. pNode->String() ));
  438. if ( eParameter == type )
  439. StrResult.StrCat( _wcsPrefix );
  440. HTMLEscapeW( pNode->String(),
  441. StrResult,
  442. outputFormat.CodePage() );
  443. if ( eParameter == type )
  444. StrResult.StrCat( _wcsSuffix );
  445. }
  446. }
  447. break;
  448. case eEscapeURL:
  449. {
  450. if (! variableSet.GetStringValueURL( pNode->String(),
  451. pNode->Hash(),
  452. outputFormat,
  453. StrResult ) )
  454. {
  455. ciGibDebugOut(( DEB_IWARN,
  456. "Warning: CParameterReplacer::ReplaceParams GetStringValueURL returned FALSE for '%ws'\n",
  457. pNode->String() ));
  458. URLEscapeW( pNode->String(),
  459. StrResult,
  460. outputFormat.CodePage() );
  461. }
  462. }
  463. break;
  464. case eEscapeRAW:
  465. {
  466. ULONG cwcValue;
  467. WCHAR const * wcsValue = variableSet.GetStringValueRAW( pNode->String(),
  468. pNode->Hash(),
  469. outputFormat,
  470. cwcValue );
  471. if ( 0 != wcsValue )
  472. {
  473. StrResult.StrCat( wcsValue, cwcValue );
  474. }
  475. else
  476. {
  477. ciGibDebugOut(( DEB_IWARN,
  478. "Warning: CParameterReplacer::ReplaceParams GetStringValueRAW returned NULL for '%ws'\n",
  479. pNode->String() ));
  480. StrResult.StrCat( pNode->String(), pNode->Length() );
  481. }
  482. }
  483. break;
  484. #if DBG==1
  485. case eNone :
  486. case eIf :
  487. case eElse :
  488. case eEndIf :
  489. break;
  490. default :
  491. ciGibDebugOut(( DEB_ERROR, "unexpected param type: %#x\n", type ) );
  492. Win4Assert( !"unexpected parameter type" );
  493. break;
  494. #endif // DBG==1
  495. }
  496. }
  497. }
  498. //+---------------------------------------------------------------------------
  499. //
  500. // Member: CParameterReplacer::BuildTree - private
  501. //
  502. // Synposis: Parses the string contained in the scanner object and builds
  503. // a parse tree which can later be walked
  504. //
  505. // Arguments: [scanner] - contains the string to build the tree from
  506. // [pBranch] - the branch which new nodes should be attached to
  507. // [ifStack] - depth of the 'if/else/endif' clauses seen thus far
  508. //
  509. // History: 96/Jan/03 DwightKr Created.
  510. //
  511. //----------------------------------------------------------------------------
  512. void CParameterReplacer::BuildTree( CHTXScanner & scanner,
  513. CParameterNode *pBranch,
  514. CDynStackInPlace<ULONG> & ifStack )
  515. {
  516. CParameterNode *pNode = 0;
  517. while ( scanner.FindNextToken() )
  518. {
  519. switch ( scanner.TokenType() & eParamMask )
  520. {
  521. case eString:
  522. {
  523. //
  524. // A non-replaceable wcsString was found before any replaceable/
  525. // conditional nodes. Save the wcsString in a node;
  526. //
  527. pNode = new CParameterNode( scanner.GetToken(), eString );
  528. pBranch->SetNextNode( pNode );
  529. pBranch = pNode;
  530. break;
  531. }
  532. case eParameter | eParamRequiresNonSequentialCursor:
  533. _ulFlags |= eParamRequiresNonSequentialCursor;
  534. // Fall through
  535. case eParameter:
  536. {
  537. //
  538. // We've found a replaceable node.
  539. //
  540. WCHAR * wcsParameter = scanner.GetToken();
  541. Win4Assert( 0 != wcsParameter );
  542. pNode = new CParameterNode( wcsParameter, eParameter );
  543. pBranch->SetNextNode( pNode );
  544. pBranch = pNode;
  545. break;
  546. }
  547. case eIf:
  548. {
  549. ifStack.Push( eIf );
  550. //
  551. // We've found an IF node. Build the IF and ELSE clauses upto
  552. // and including the ENDIF node for this IF.
  553. //
  554. // If there is an IF enbedded within the IF or ELSE clause,
  555. // we'll recurse down to build that IF tree.
  556. //
  557. CParameterNode *pIfNode = new CParameterNode( scanner.GetToken(), eIf );
  558. XPtr<CParameterNode> xIfNode( pIfNode );
  559. CParameterNode trueNode(L"true");
  560. CParameterNode falseNode(L"false");
  561. //
  562. // Build the TRUE node/clause of the IF statement
  563. //
  564. BuildTree( scanner, &trueNode, ifStack );
  565. //
  566. // Build the FALSE node/clause of the IF statement
  567. //
  568. if ( scanner.TokenType() == eElse )
  569. {
  570. scanner.GetToken();
  571. BuildTree( scanner, &falseNode, ifStack );
  572. }
  573. if ( scanner.TokenType() != eEndIf )
  574. {
  575. // 'if' without matching 'else' or 'endif'
  576. THROW( CHTXException(MSG_CI_HTX_EXPECTING_ELSE_ENDIF, 0, 0) );
  577. }
  578. scanner.GetToken();
  579. //
  580. // Build the TRUE and FALSE branches on the IF node and
  581. // join the bottom of the TRUE and FALSE branches together
  582. // to a common ENDIF node.
  583. //
  584. CParameterNode *pEndifNode = new CParameterNode( L"endif", eEndIf );
  585. XPtr<CParameterNode> xEndifNode( pEndifNode );
  586. Win4Assert( trueNode.GetNextNode() );
  587. trueNode.GetEndNode()->SetNextNode( pEndifNode );
  588. pIfNode->SetTrueNode( trueNode.QueryNextNode() );
  589. pEndifNode->IncrementRefCount();
  590. //
  591. // If there is a ELSE clause to this tree, attach it's bottom
  592. // node to the ENDIF node.
  593. //
  594. if ( falseNode.GetNextNode() )
  595. {
  596. falseNode.GetEndNode()->SetNextNode( pEndifNode );
  597. pIfNode->SetFalseNode( falseNode.QueryNextNode() );
  598. }
  599. else
  600. {
  601. pIfNode->SetFalseNode( pEndifNode );
  602. }
  603. pBranch->SetNextNode( xIfNode.Acquire() );
  604. pBranch = xEndifNode.Acquire();
  605. break;
  606. }
  607. case eElse:
  608. {
  609. if ( ifStack.Count() == 0 )
  610. {
  611. THROW( CHTXException(MSG_CI_HTX_ELSEENDIF_WITHOUT_IF, 0, 0) );
  612. }
  613. int eStackValue = ifStack.Pop();
  614. if ( eStackValue != eIf )
  615. {
  616. THROW( CHTXException(MSG_CI_HTX_ELSEENDIF_WITHOUT_IF, 0, 0) );
  617. }
  618. ifStack.Push( eElse );
  619. return;
  620. break;
  621. }
  622. case eEndIf:
  623. {
  624. if ( ifStack.Count() == 0 )
  625. {
  626. THROW( CHTXException(MSG_CI_HTX_ELSEENDIF_WITHOUT_IF, 0, 0) );
  627. }
  628. int eStackValue = ifStack.Pop();
  629. if ( (eStackValue != eIf) && (eStackValue != eElse) )
  630. {
  631. THROW( CHTXException(MSG_CI_HTX_ELSEENDIF_WITHOUT_IF, 0, 0) );
  632. }
  633. return;
  634. break;
  635. }
  636. case eEscapeHTML:
  637. {
  638. WCHAR * wcsParameter = scanner.GetToken();
  639. if ( 0 == wcsParameter )
  640. THROW( CException( E_INVALIDARG ) );
  641. pNode = new CParameterNode( wcsParameter, eEscapeHTML );
  642. pBranch->SetNextNode( pNode );
  643. pBranch = pNode;
  644. }
  645. break;
  646. case eEscapeURL:
  647. {
  648. WCHAR * wcsParameter = scanner.GetToken();
  649. pNode = new CParameterNode( wcsParameter, eEscapeURL );
  650. pBranch->SetNextNode( pNode );
  651. pBranch = pNode;
  652. }
  653. break;
  654. case eEscapeRAW:
  655. {
  656. WCHAR * wcsParameter = scanner.GetToken();
  657. pNode = new CParameterNode( wcsParameter, eEscapeRAW );
  658. pBranch->SetNextNode( pNode );
  659. pBranch = pNode;
  660. }
  661. break;
  662. }
  663. }
  664. }