Source code of Windows XP (NT5)
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.

198 lines
5.9 KiB

  1. #ifndef _SERVERVAR_HXX_
  2. #define _SERVERVAR_HXX_
  3. //
  4. // Function used to retrieve a server variable
  5. //
  6. typedef HRESULT
  7. (SERVER_VARIABLE_ROUTINE)
  8. (
  9. W3_CONTEXT *pW3Context,
  10. STRA *pstrValue
  11. );
  12. typedef HRESULT
  13. (SERVER_VARIABLE_ROUTINE_W)
  14. (
  15. W3_CONTEXT *pW3Context,
  16. STRU *pstrValue
  17. );
  18. typedef SERVER_VARIABLE_ROUTINE *PFN_SERVER_VARIABLE_ROUTINE;
  19. typedef SERVER_VARIABLE_ROUTINE_W *PFN_SERVER_VARIABLE_ROUTINE_W;
  20. //
  21. // Forward declaration for each server variable function
  22. //
  23. extern SERVER_VARIABLE_ROUTINE GetServerVariableQueryString;
  24. extern SERVER_VARIABLE_ROUTINE GetServerVariableAllHttp;
  25. extern SERVER_VARIABLE_ROUTINE GetServerVariableAllRaw;
  26. extern SERVER_VARIABLE_ROUTINE GetServerVariableContentLength;
  27. extern SERVER_VARIABLE_ROUTINE GetServerVariableContentType;
  28. extern SERVER_VARIABLE_ROUTINE GetServerVariablePathInfo;
  29. extern SERVER_VARIABLE_ROUTINE GetServerVariablePathTranslated;
  30. extern SERVER_VARIABLE_ROUTINE GetServerVariableRequestMethod;
  31. extern SERVER_VARIABLE_ROUTINE GetServerVariableInstanceId;
  32. extern SERVER_VARIABLE_ROUTINE GetServerVariableRemoteAddr;
  33. extern SERVER_VARIABLE_ROUTINE GetServerVariableRemoteHost;
  34. extern SERVER_VARIABLE_ROUTINE GetServerVariableServerName;
  35. extern SERVER_VARIABLE_ROUTINE GetServerVariableServerPort;
  36. extern SERVER_VARIABLE_ROUTINE GetServerVariableServerPortSecure;
  37. extern SERVER_VARIABLE_ROUTINE GetServerVariableServerSoftware;
  38. extern SERVER_VARIABLE_ROUTINE GetServerVariableUrl;
  39. extern SERVER_VARIABLE_ROUTINE GetServerVariableInstanceMetaPath;
  40. extern SERVER_VARIABLE_ROUTINE GetServerVariableRemoteUser;
  41. extern SERVER_VARIABLE_ROUTINE GetServerVariableLogonUser;
  42. extern SERVER_VARIABLE_ROUTINE GetServerVariableAuthType;
  43. extern SERVER_VARIABLE_ROUTINE GetServerVariableAuthPassword;
  44. extern SERVER_VARIABLE_ROUTINE GetServerVariableApplMdPath;
  45. extern SERVER_VARIABLE_ROUTINE GetServerVariableApplPhysicalPath;
  46. extern SERVER_VARIABLE_ROUTINE GetServerVariableGatewayInterface;
  47. extern SERVER_VARIABLE_ROUTINE GetServerVariableHttps;
  48. extern SERVER_VARIABLE_ROUTINE GetServerVariableLocalAddr;
  49. extern SERVER_VARIABLE_ROUTINE GetServerVariableHttpsServerIssuer;
  50. extern SERVER_VARIABLE_ROUTINE GetServerVariableHttpsServerSubject;
  51. extern SERVER_VARIABLE_ROUTINE GetServerVariableHttpsSecretKeySize;
  52. extern SERVER_VARIABLE_ROUTINE GetServerVariableHttpsKeySize;
  53. extern SERVER_VARIABLE_ROUTINE GetServerVariableClientCertIssuer;
  54. extern SERVER_VARIABLE_ROUTINE GetServerVariableClientCertSubject;
  55. extern SERVER_VARIABLE_ROUTINE GetServerVariableClientCertCookie;
  56. extern SERVER_VARIABLE_ROUTINE GetServerVariableClientCertSerialNumber;
  57. extern SERVER_VARIABLE_ROUTINE GetServerVariableClientCertFlags;
  58. extern SERVER_VARIABLE_ROUTINE GetServerVariableHttpUrl;
  59. extern SERVER_VARIABLE_ROUTINE GetServerVariableHttpVersion;
  60. extern SERVER_VARIABLE_ROUTINE GetServerVariableAppPoolId;
  61. extern SERVER_VARIABLE_ROUTINE GetServerVariableScriptTranslated;
  62. extern SERVER_VARIABLE_ROUTINE GetServerVariableUnencodedUrl;
  63. extern SERVER_VARIABLE_ROUTINE_W GetServerVariablePathInfoW;
  64. extern SERVER_VARIABLE_ROUTINE_W GetServerVariablePathTranslatedW;
  65. extern SERVER_VARIABLE_ROUTINE_W GetServerVariableUrlW;
  66. extern SERVER_VARIABLE_ROUTINE_W GetServerVariableRemoteUserW;
  67. extern SERVER_VARIABLE_ROUTINE_W GetServerVariableLogonUserW;
  68. extern SERVER_VARIABLE_ROUTINE_W GetServerVariableApplMdPathW;
  69. extern SERVER_VARIABLE_ROUTINE_W GetServerVariableApplPhysicalPathW;
  70. extern SERVER_VARIABLE_ROUTINE_W GetServerVariableAppPoolIdW;
  71. extern SERVER_VARIABLE_ROUTINE_W GetServerVariableScriptTranslatedW;
  72. //
  73. // Server variable hash table
  74. //
  75. struct SERVER_VARIABLE_RECORD
  76. {
  77. CHAR * _pszName;
  78. PFN_SERVER_VARIABLE_ROUTINE _pfnRoutine;
  79. PFN_SERVER_VARIABLE_ROUTINE_W _pfnRoutineW;
  80. };
  81. //
  82. // SERVER_VARIABLE_HASH maps server variable string to routines to eval them
  83. //
  84. class SERVER_VARIABLE_HASH
  85. : public CTypedHashTable< SERVER_VARIABLE_HASH,
  86. SERVER_VARIABLE_RECORD,
  87. CHAR * >
  88. {
  89. public:
  90. SERVER_VARIABLE_HASH()
  91. : CTypedHashTable< SERVER_VARIABLE_HASH,
  92. SERVER_VARIABLE_RECORD,
  93. CHAR * >
  94. ("SERVER_VARIABLE_HASH")
  95. {
  96. }
  97. static
  98. CHAR *
  99. ExtractKey(
  100. const SERVER_VARIABLE_RECORD * pRecord
  101. )
  102. {
  103. DBG_ASSERT( pRecord != NULL );
  104. return pRecord->_pszName;
  105. }
  106. static
  107. DWORD
  108. CalcKeyHash(
  109. CHAR * pszKey
  110. )
  111. {
  112. return Hash( pszKey );
  113. }
  114. static
  115. bool
  116. EqualKeys(
  117. CHAR * pszKey1,
  118. CHAR * pszKey2
  119. )
  120. {
  121. return strcmp( pszKey1, pszKey2 ) == 0;
  122. }
  123. static
  124. void
  125. AddRefRecord(
  126. SERVER_VARIABLE_RECORD * pEntry,
  127. int nIncr
  128. )
  129. {
  130. }
  131. static
  132. HRESULT
  133. Initialize(
  134. VOID
  135. );
  136. static
  137. VOID
  138. Terminate(
  139. VOID
  140. );
  141. static
  142. HRESULT
  143. GetServerVariable(
  144. W3_CONTEXT * pContext,
  145. CHAR * pszVariableName,
  146. CHAR * pszBuffer,
  147. DWORD * pcbBuffer
  148. );
  149. static
  150. HRESULT
  151. GetServerVariable(
  152. W3_CONTEXT * pContext,
  153. CHAR * pszVariableName,
  154. STRA * pstrVal
  155. );
  156. static
  157. HRESULT
  158. GetServerVariableW(
  159. W3_CONTEXT * pContext,
  160. CHAR * pszVariableName,
  161. STRU * pstrVal
  162. );
  163. private:
  164. static SERVER_VARIABLE_HASH * sm_pRequestHash;
  165. static SERVER_VARIABLE_RECORD sm_rgServerRoutines[];
  166. static
  167. HRESULT
  168. GetServerVariableRoutine(
  169. CHAR * pszName,
  170. PFN_SERVER_VARIABLE_ROUTINE * ppfnRoutine,
  171. PFN_SERVER_VARIABLE_ROUTINE_W * ppfnRoutineW
  172. );
  173. };
  174. #endif