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.

400 lines
9.4 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name :
  4. metacach.cxx
  5. Abstract:
  6. Declares the constants, data strutcures and function prototypes
  7. available for metadata cache management from Tsunami.lib
  8. Author:
  9. Phillich ( extracted from tsunami.hxx )
  10. Project:
  11. Internet Services Common Functionality ( Tsunami Library)
  12. --*/
  13. # ifndef _METACACH_HXX_
  14. # define _METACACH_HXX_
  15. /************************************************************
  16. * Symbolic Constants
  17. ************************************************************/
  18. #define METACACHE_W3_SERVER_ID 1
  19. #define METACACHE_FTP_SERVER_ID 2
  20. #define METACACHE_SMTP_SERVER_ID 3
  21. #define METACACHE_NNTP_SERVER_ID 4
  22. #define METACACHE_POP3_SERVER_ID 5
  23. #define METACACHE_IMAP_SERVER_ID 6
  24. //
  25. // Define the type of a metadata free routine.
  26. //
  27. typedef void (*PMDFREERTN)(PVOID pMetaData);
  28. class COMMON_METADATA;
  29. extern
  30. dllexp
  31. PVOID TsAddMetaData(
  32. IN COMMON_METADATA *pMetaData,
  33. IN PMDFREERTN pFreeRoutine,
  34. IN DWORD dwDataSetNumber,
  35. IN DWORD dwServiceID
  36. );
  37. extern
  38. dllexp
  39. PVOID TsFindMetaData(
  40. IN DWORD dwDataSetNumber,
  41. IN DWORD dwServiceID
  42. );
  43. extern
  44. dllexp
  45. VOID TsFreeMetaData(
  46. IN PVOID pCacheEntry
  47. );
  48. extern
  49. dllexp
  50. VOID TsAddRefMetaData(
  51. IN PVOID pCacheEntry
  52. );
  53. extern
  54. dllexp
  55. VOID
  56. TsFlushMetaCache(
  57. DWORD dwService,
  58. BOOL bTerminating
  59. );
  60. extern
  61. dllexp
  62. VOID
  63. TsReferenceMetaData(
  64. IN PVOID pEntry
  65. );
  66. extern
  67. dllexp
  68. VOID
  69. _TsValidateMetaCache(
  70. VOID
  71. );
  72. #if DBG
  73. #define TsValidateMetaCache _TsValidateMetaCache
  74. #else
  75. #define TsValidateMetaCache()
  76. #endif
  77. #define CMD_SIG 0x20444D43 // 'CMD '
  78. #define METADATA_ERROR_TYPE 0
  79. #define METADATA_ERROR_VALUE 1
  80. #define METADATA_ERROR_WIN32 2
  81. typedef struct _METADATA_ERROR_INFO
  82. {
  83. BOOL IsValid;
  84. DWORD ErrorParameter;
  85. DWORD ErrorReason;
  86. DWORD Win32Error;
  87. } METADATA_ERROR_INFO, *PMETADATA_ERROR_INFO;
  88. class COMMON_METADATA {
  89. public:
  90. dllexp
  91. COMMON_METADATA(VOID);
  92. dllexp
  93. virtual ~COMMON_METADATA(VOID);
  94. dllexp
  95. BOOL ReadMetaData(
  96. PIIS_SERVER_INSTANCE pInstance,
  97. MB * pmb,
  98. LPSTR pszURL,
  99. PMETADATA_ERROR_INFO pError
  100. );
  101. dllexp
  102. BOOL BuildPhysicalPath(
  103. LPSTR pszURL,
  104. STR * pstrPhysicalPath
  105. );
  106. dllexp
  107. BOOL BuildPhysicalPathWithAltRoot(
  108. LPSTR pszURL,
  109. STR * pstrPhysicalPath,
  110. PCSTR pstrAltRoot
  111. );
  112. dllexp
  113. BOOL BuildApplPhysicalPath(
  114. MB * pmb,
  115. STR * pstrApplPhysicalPath
  116. ) const;
  117. dllexp
  118. virtual BOOL HandlePrivateProperty(
  119. LPSTR pszURL,
  120. PIIS_SERVER_INSTANCE pInstance,
  121. METADATA_GETALL_INTERNAL_RECORD *pMDRecord,
  122. PVOID pDataPointer,
  123. BUFFER *pBuffer,
  124. DWORD *pdwBytesUsed,
  125. PMETADATA_ERROR_INFO pError
  126. )
  127. { return TRUE; }
  128. dllexp
  129. virtual BOOL FinishPrivateProperties(
  130. BUFFER *pBuffer,
  131. DWORD dwBytesUsed,
  132. BOOL bSucceeded
  133. )
  134. { return TRUE; }
  135. //
  136. // This is not inline to avoid pulling-in metadata & mb declaration in
  137. // this header file.
  138. //
  139. dllexp
  140. VOID FreeMdTag( DWORD dwTag );
  141. //
  142. // Query Methods
  143. //
  144. STR * QueryVrPath( VOID )
  145. { return &m_strVrPath; }
  146. STR * QueryAppPath( VOID )
  147. { return &m_strAppPath; }
  148. DWORD QueryAccessPerms( VOID ) const
  149. { return m_dwAccessPerm | m_dwSslAccessPerm; }
  150. DWORD QuerySslAccessPerms( VOID ) const
  151. { return m_dwSslAccessPerm; }
  152. PVOID QueryCacheInfo(VOID) const
  153. { return m_pCacheCookie; }
  154. BOOL DontLog( VOID ) const
  155. { return m_fDontLog; }
  156. PVOID QueryAcl(VOID) const
  157. { return m_pAcl; }
  158. LPVOID QueryIpDnsAccessCheckPtr()
  159. { return m_IpDnsAccessCheckPtr; }
  160. DWORD QueryIpDnsAccessCheckSize()
  161. { return m_IpDnsAccessCheckSize; }
  162. BOOL IsIpDnsAccessCheckPresent()
  163. { return m_IpDnsAccessCheckSize; }
  164. DWORD QueryVrLevel() const
  165. { return m_dwVrLevel; }
  166. DWORD QueryVrLen() const
  167. { return m_dwVrLen; }
  168. HANDLE QueryVrAccessToken()
  169. { return m_hVrToken ? TsTokenToImpHandle( m_hVrToken ) : NULL; }
  170. HANDLE QueryVrPrimaryAccessToken()
  171. { return m_hVrToken ? TsTokenToHandle( m_hVrToken ) : NULL; }
  172. BOOL QueryDoCache() const
  173. { return m_fDoCache; }
  174. BOOL ImpersonateVrAccessToken()
  175. { return m_hVrToken ? TsImpersonateUser( m_hVrToken ) : NULL; }
  176. BOOL QueryVrPassThrough()
  177. { return m_fVrPassThrough; }
  178. DWORD QueryVrError()
  179. { return m_dwVrError; }
  180. //
  181. // Set Methods
  182. //
  183. dllexp
  184. VOID SetAccessPerms( DWORD dwAccessPerm )
  185. { m_dwAccessPerm = dwAccessPerm /*& MD_NONSLL_ACCESS_MASK*/; }
  186. VOID SetSslAccessPerms( DWORD dwAccessPerm )
  187. { m_dwSslAccessPerm = dwAccessPerm & MD_SSL_ACCESS_MASK; }
  188. VOID SetCacheInfo( PVOID CacheInfo )
  189. { m_pCacheCookie = CacheInfo; }
  190. BOOL SetIpDnsAccessCheck( LPVOID pV, DWORD dwV, DWORD dwTag )
  191. {
  192. if ( dwTag == 0 )
  193. {
  194. // If tag is 0, then the property didn't have the REFERENCE
  195. // attribute set. Allocate memory and copy the data.
  196. m_IpDnsAccessCheckPtr = LocalAlloc( LPTR, dwV );
  197. if ( m_IpDnsAccessCheckPtr == NULL )
  198. {
  199. return FALSE;
  200. }
  201. memcpy( m_IpDnsAccessCheckPtr, pV, dwV );
  202. }
  203. else
  204. {
  205. m_IpDnsAccessCheckPtr = pV;
  206. }
  207. m_IpDnsAccessCheckSize = dwV;
  208. m_IpDnsAccessCheckTag = dwTag;
  209. return TRUE;
  210. }
  211. VOID SetAcl( LPVOID pV, DWORD dwV, DWORD dwTag )
  212. {
  213. if ( dwV )
  214. {
  215. m_pAcl = pV;
  216. m_dwAclTag = dwTag;
  217. }
  218. else
  219. {
  220. FreeMdTag( dwTag );
  221. }
  222. }
  223. VOID SetDontLogFlag( BOOL fDontLog )
  224. { m_fDontLog = fDontLog; }
  225. VOID SetVrLevelAndLen( DWORD dwL, DWORD dwVrLen )
  226. { m_dwVrLevel = dwL; m_dwVrLen = dwVrLen; }
  227. BOOL SetVrUserNameAndPassword( PIIS_SERVER_INSTANCE, LPSTR pszUserName, LPSTR pszPassword );
  228. VOID SetVrPassThrough( BOOL f ) { m_fVrPassThrough = f; }
  229. VOID SetDoCache( BOOL f ) { m_fDoCache = f; }
  230. VOID CheckSignature(VOID) const {DBG_ASSERT(m_Signature == CMD_SIG); }
  231. private:
  232. DWORD m_Signature;
  233. STR m_strVrPath;
  234. STR m_strAppPath;
  235. DWORD m_dwAccessPerm;
  236. DWORD m_dwSslAccessPerm;
  237. PVOID m_pCacheCookie;
  238. LPVOID m_IpDnsAccessCheckPtr;
  239. DWORD m_IpDnsAccessCheckSize;
  240. DWORD m_IpDnsAccessCheckTag;
  241. BOOL m_fDontLog;
  242. LPVOID m_pAcl;
  243. DWORD m_dwAclTag;
  244. DWORD m_dwVrLevel;
  245. DWORD m_dwVrLen;
  246. TS_TOKEN m_hVrToken;
  247. BOOL m_fVrPassThrough;
  248. DWORD m_dwVrError;
  249. BOOL m_fDoCache;
  250. PIIS_SERVER_INSTANCE m_pInstance;
  251. };
  252. typedef COMMON_METADATA *PCOMMON_METADATA;
  253. class METADATA_REF_HANDLER {
  254. public:
  255. METADATA_REF_HANDLER()
  256. {
  257. m_dwMdDataTag = 0;
  258. m_pvMdData = NULL;
  259. }
  260. ~METADATA_REF_HANDLER() {}
  261. VOID Set( LPVOID pV, DWORD dwS, DWORD dwR )
  262. {
  263. m_dwMdDataTag = dwR;
  264. m_pvMdData = pV;
  265. m_dwMdDataSize = dwS;
  266. m_fIsCopy = FALSE;
  267. }
  268. VOID Reset( IMDCOM* pIMDCOM )
  269. {
  270. if ( m_dwMdDataTag )
  271. {
  272. HRESULT hRes;
  273. if ( !m_fIsCopy )
  274. {
  275. hRes = pIMDCOM->ComMDReleaseReferenceData( m_dwMdDataTag );
  276. }
  277. else
  278. {
  279. m_fIsCopy = FALSE;
  280. }
  281. m_dwMdDataTag = 0;
  282. m_pvMdData = NULL;
  283. }
  284. }
  285. BOOL CopyFrom( METADATA_REF_HANDLER* pSrc )
  286. {
  287. m_dwMdDataTag = pSrc->m_dwMdDataTag;
  288. m_pvMdData = pSrc->m_pvMdData;
  289. m_dwMdDataSize = pSrc->m_dwMdDataSize;
  290. m_fIsCopy = TRUE;
  291. return TRUE;
  292. }
  293. LPVOID GetPtr() { return m_pvMdData; }
  294. DWORD GetSize() { return m_dwMdDataSize; }
  295. private:
  296. DWORD m_dwMdDataTag;
  297. LPVOID m_pvMdData;
  298. DWORD m_dwMdDataSize;
  299. BOOL m_fIsCopy;
  300. } ;
  301. #endif