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.

362 lines
6.9 KiB

  1. #ifndef _URLINFO_HXX_
  2. #define _URLINFO_HXX_
  3. #include "usercache.hxx"
  4. class W3_URL_INFO_KEY : public CACHE_KEY
  5. {
  6. public:
  7. W3_URL_INFO_KEY()
  8. : _strKey( _achKey, sizeof( _achKey ) ),
  9. _pszKey( NULL ),
  10. _cchKey( 0 ),
  11. _cchSitePrefix( 0 )
  12. {
  13. }
  14. HRESULT
  15. CreateCacheKey(
  16. WCHAR * pszKey,
  17. DWORD cchKey,
  18. DWORD cchSitePrefix,
  19. BOOL fCopy
  20. );
  21. BOOL
  22. QueryIsEqual(
  23. const CACHE_KEY * pCompareKey
  24. ) const
  25. {
  26. W3_URL_INFO_KEY * pUriKey = (W3_URL_INFO_KEY*) pCompareKey;
  27. DBG_ASSERT( pUriKey != NULL );
  28. return _cchKey == pUriKey->_cchKey &&
  29. !wcscmp( _pszKey, pUriKey->_pszKey );
  30. }
  31. STRU *
  32. QueryMetadataPath(
  33. VOID
  34. )
  35. {
  36. return &_strKey;
  37. }
  38. WCHAR *
  39. QueryUrl(
  40. VOID
  41. ) const
  42. {
  43. return _pszKey + _cchSitePrefix;
  44. }
  45. DWORD
  46. QueryKeyHash(
  47. VOID
  48. ) const
  49. {
  50. return HashString( _pszKey );
  51. }
  52. private:
  53. WCHAR _achKey[ 64 ];
  54. STRU _strKey;
  55. WCHAR * _pszKey;
  56. DWORD _cchSitePrefix;
  57. DWORD _cchKey;
  58. };
  59. #define W3_URL_INFO_SIGNATURE 'TIRU'
  60. #define W3_URL_INFO_FREE_SIGNATURE 'xiru'
  61. class W3_URL_INFO : public CACHE_ENTRY
  62. {
  63. public:
  64. W3_URL_INFO( OBJECT_CACHE * pObjectCache,
  65. W3_METADATA * pMetaData )
  66. : CACHE_ENTRY( pObjectCache ),
  67. _dwSignature( W3_URL_INFO_SIGNATURE ),
  68. _pMetaData( pMetaData ),
  69. _pFileInfo( NULL ),
  70. _strPhysicalPath( _achPhysicalPath, sizeof( _achPhysicalPath ) ),
  71. _strPathInfo( _achPathInfo, sizeof( _achPathInfo ) ),
  72. _strProcessedUrl( _achProcessedUrl, sizeof( _achProcessedUrl ) ),
  73. _strUrlTranslated( _achUrlTranslated, sizeof( _achUrlTranslated ) ),
  74. _pScriptMapEntry( NULL ),
  75. _Gateway( GATEWAY_UNKNOWN ),
  76. _pUrlInfoPathTranslated( NULL )
  77. {
  78. }
  79. CACHE_KEY *
  80. QueryCacheKey(
  81. VOID
  82. ) const
  83. {
  84. return (CACHE_KEY*) &_cacheKey;
  85. }
  86. STRU *
  87. QueryMetadataPath(
  88. VOID
  89. )
  90. {
  91. return _cacheKey.QueryMetadataPath();
  92. }
  93. BOOL
  94. QueryIsOkToFlushDirmon(
  95. WCHAR * pszPath,
  96. DWORD cchPath
  97. )
  98. {
  99. DBG_ASSERT( FALSE );
  100. return FALSE;
  101. }
  102. BOOL
  103. CheckSignature(
  104. VOID
  105. ) const
  106. {
  107. return _dwSignature == W3_URL_INFO_SIGNATURE;
  108. }
  109. HRESULT
  110. Create(
  111. STRU & strUrl,
  112. STRU & strMetadataPath
  113. );
  114. VOID *
  115. operator new(
  116. size_t size
  117. )
  118. {
  119. DBG_ASSERT( size == sizeof( W3_URL_INFO ) );
  120. DBG_ASSERT( sm_pachW3UrlInfo != NULL );
  121. return sm_pachW3UrlInfo->Alloc();
  122. }
  123. VOID
  124. operator delete(
  125. VOID * pW3UrlInfo
  126. )
  127. {
  128. DBG_ASSERT( pW3UrlInfo != NULL );
  129. DBG_ASSERT( sm_pachW3UrlInfo != NULL );
  130. DBG_REQUIRE( sm_pachW3UrlInfo->Free( pW3UrlInfo ) );
  131. }
  132. HRESULT
  133. GetFileInfo(
  134. FILE_CACHE_USER * pOpeningUser,
  135. BOOL fDoCache,
  136. W3_FILE_INFO ** ppFileInfo
  137. );
  138. W3_METADATA *
  139. QueryMetaData(
  140. VOID
  141. ) const
  142. {
  143. return _pMetaData;
  144. }
  145. STRU *
  146. QueryPhysicalPath(
  147. VOID
  148. )
  149. {
  150. return &_strPhysicalPath;
  151. }
  152. STRU *
  153. QueryProcessedUrl(
  154. VOID
  155. )
  156. {
  157. return &_strProcessedUrl;
  158. }
  159. WCHAR *
  160. QueryUrl(
  161. VOID
  162. ) const
  163. {
  164. return _cacheKey.QueryUrl();
  165. }
  166. META_SCRIPT_MAP_ENTRY *
  167. QueryScriptMapEntry(
  168. VOID
  169. ) const
  170. {
  171. return _pScriptMapEntry;
  172. }
  173. HRESULT
  174. GetPathTranslated(
  175. W3_CONTEXT * pW3Context,
  176. BOOL fUsePathInfo,
  177. STRU * pstrPathTranslated
  178. );
  179. STRU *
  180. QueryPathInfo(
  181. VOID
  182. )
  183. {
  184. return &_strPathInfo;
  185. }
  186. STRU *
  187. QueryUrlTranslated(
  188. VOID
  189. )
  190. {
  191. return &_strUrlTranslated;
  192. }
  193. STRA *
  194. QueryContentType(
  195. VOID
  196. )
  197. {
  198. return &_strContentType;
  199. }
  200. GATEWAY_TYPE
  201. QueryGateway(
  202. VOID
  203. ) const
  204. {
  205. return _Gateway;
  206. }
  207. HRESULT
  208. ProcessUrl(
  209. STRU & strUrl
  210. );
  211. static
  212. HRESULT
  213. Initialize(
  214. VOID
  215. );
  216. static
  217. VOID
  218. Terminate(
  219. VOID
  220. );
  221. private:
  222. ~W3_URL_INFO()
  223. {
  224. if ( _pFileInfo != NULL )
  225. {
  226. _pFileInfo->DereferenceCacheEntry();
  227. _pFileInfo = NULL;
  228. }
  229. if ( _pMetaData != NULL )
  230. {
  231. _pMetaData->DereferenceCacheEntry();
  232. _pMetaData = NULL;
  233. }
  234. if ( _pUrlInfoPathTranslated != NULL )
  235. {
  236. _pUrlInfoPathTranslated->DereferenceCacheEntry();
  237. _pUrlInfoPathTranslated = NULL;
  238. }
  239. _dwSignature = W3_URL_INFO_FREE_SIGNATURE;
  240. }
  241. DWORD _dwSignature;
  242. STRU _strPhysicalPath;
  243. WCHAR _achPhysicalPath[ 64 ];
  244. STRU _strProcessedUrl;
  245. WCHAR _achProcessedUrl[ 64 ];
  246. STRU _strPathInfo;
  247. WCHAR _achPathInfo[ 64 ];
  248. STRU _strUrlTranslated;
  249. WCHAR _achUrlTranslated[ 64 ];
  250. STRA _strContentType;
  251. META_SCRIPT_MAP_ENTRY * _pScriptMapEntry;
  252. GATEWAY_TYPE _Gateway;
  253. W3_FILE_INFO * _pFileInfo;
  254. W3_METADATA * _pMetaData;
  255. W3_URL_INFO_KEY _cacheKey;
  256. W3_URL_INFO * _pUrlInfoPathTranslated;
  257. //
  258. // Allocation cache for W3_URL_INFO's
  259. //
  260. static ALLOC_CACHE_HANDLER * sm_pachW3UrlInfo;
  261. //
  262. // Max dots (DoS attack protection)
  263. //
  264. static DWORD sm_cMaxDots;
  265. };
  266. #define DEFAULT_W3_URL_INFO_CACHE_TTL (30)
  267. class W3_URL_INFO_CACHE : public OBJECT_CACHE
  268. {
  269. public:
  270. HRESULT
  271. GetUrlInfo(
  272. W3_CONTEXT * pW3Context,
  273. STRU & strUrl,
  274. W3_URL_INFO ** ppUriEntry
  275. );
  276. WCHAR *
  277. QueryName(
  278. VOID
  279. ) const
  280. {
  281. return L"W3_URL_INFO_CACHE";
  282. }
  283. HRESULT
  284. Initialize(
  285. VOID
  286. );
  287. VOID
  288. Terminate(
  289. VOID
  290. )
  291. {
  292. return W3_URL_INFO::Terminate();
  293. }
  294. private:
  295. HRESULT
  296. CreateNewUrlInfo(
  297. W3_CONTEXT * pW3Context,
  298. STRU & strUrl,
  299. STRU & strMetadataPath,
  300. W3_URL_INFO ** ppCacheEntry
  301. );
  302. };
  303. #endif