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.

173 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name: conmgr.hxx
  4. Abstract:
  5. Manages list of containers (CConList)
  6. Author:
  7. Adriaan Canter (adriaanc) 04-02-97
  8. --*/
  9. #ifndef _CONMGR_HXX
  10. #define _CONMGR_HXX
  11. // Total number of containers is 3: CONTENT, COOKIE and HISTORY.
  12. #define CONTENT 0
  13. #define COOKIE 1
  14. #define HISTORY 2
  15. #define NCONTAINERS 3
  16. // Alias for old names
  17. #define _coContent (_coContainer[CONTENT])
  18. #define _coCookies (_coContainer[COOKIE])
  19. #define _coHistory (_coContainer[HISTORY])
  20. class IE5_REGISTRYSET;
  21. /*-----------------------------------------------------------------------------
  22. Container manager class
  23. ---------------------------------------------------------------------------*/
  24. class CConMgr
  25. {
  26. private:
  27. DWORD _dwStatus;
  28. BOOL _fProfilesCapable, _fUsingBackupContainers;
  29. BOOL _fNewCacheVersion;
  30. DWORD _dwModifiedCount; // count last time we polled
  31. HANDLE _hMutexExtensible;// used to Mutex access to extensible containers registry
  32. DWORD _dwLastUnmap; // time of last UnMap sweep
  33. // Array of containers.
  34. CConList ConList;
  35. // Cached (not ref-counted - not needed) special containers
  36. URL_CONTAINER *_coContainer[NCONTAINERS];
  37. // Init function called by constructor.
  38. DWORD Init();
  39. // Initializes containers.
  40. DWORD InitFixedContainers();
  41. // Config info get and set functions.
  42. // Utilities.
  43. DWORD FindIndexFromPrefix(LPCSTR);
  44. BOOL PathPrefixMatch(LPCSTR, LPCSTR);
  45. DWORD ConfigureCache();
  46. DWORD GetCacheConfigInfo();
  47. DWORD SetLegacyCacheConfigInfo();
  48. DWORD GetSysRootCacheConfigInfo();
  49. void IncrementModifiedCount();
  50. DWORD ReadModifiedCount(BOOL fUpdateMemory);
  51. BOOL WasModified(BOOL fUpdateMemory);
  52. DWORD GetExtensibleCacheConfigInfo(BOOL fAlways);
  53. DWORD FindExtensibleContainer(LPCSTR Name);
  54. VOID DiscoverRegistrySettings(IE5_REGISTRYSET* pie5rs);
  55. VOID DiscoverIE3Settings(IE5_REGISTRYSET* pie5rs);
  56. BOOL DiscoverIE4Settings(IE5_REGISTRYSET* pie5rs);
  57. BOOL DiscoverAnyIE5Settings(IE5_REGISTRYSET* pie5rs);
  58. public:
  59. CConMgr();
  60. ~CConMgr();
  61. static DWORD DeleteIE3Cache();
  62. // Methods specific to CConMgr.
  63. DWORD LoadContent();
  64. DWORD GetContainerInfo(LPSTR szUrl, LPINTERNET_CACHE_CONTAINER_INFOA pCI, LPDWORD pcbCI);
  65. DWORD GetStatus();
  66. DWORD FreeFindHandle(HANDLE hFind);
  67. BOOL DeleteFileIfNotRegistered(URL_CONTAINER *coDelete);
  68. DWORD CreateContainer(LPCSTR Name, LPCSTR CachePrefix, LPCSTR CachePath, DWORD KBCacheLimit, DWORD dwOptions);
  69. DWORD DeleteContainer(LPCSTR Name, DWORD dwOptions);
  70. HANDLE FindFirstContainer(DWORD *pdwModified, LPINTERNET_CACHE_CONTAINER_INFOA lpContainerInfo, LPDWORD lpdwContainerInfoBufferSize, DWORD dwOptions);
  71. BOOL FindNextContainer(HANDLE hFind, LPINTERNET_CACHE_CONTAINER_INFOA lpContainerInfo, LPDWORD lpdwContainerInfoBufferSize);
  72. #ifdef CHECKLOCK_PARANOID
  73. void CheckNoLocks(DWORD dwThreadId);
  74. #endif
  75. // Methods corresponding to URL_CONTAINER.
  76. DWORD UnlockUrl(LPCSTR);
  77. DWORD DeleteUrl(LPCSTR);
  78. BOOL GetHeaderData(DWORD, LPDWORD);
  79. BOOL SetHeaderData(DWORD, DWORD);
  80. BOOL IncrementHeaderData(DWORD, LPDWORD);
  81. DWORD SetUrlGroup(LPCSTR, DWORD, GROUPID);
  82. DWORD CreateUniqueFile(LPCSTR, DWORD, LPCSTR, LPTSTR, HANDLE*, BOOL = FALSE);
  83. DWORD AddUrl(AddUrlArg*);
  84. DWORD RetrieveUrl(LPCSTR, LPCACHE_ENTRY_INFOA*, LPDWORD, DWORD, DWORD);
  85. DWORD GetUrlInfo(LPCSTR, LPCACHE_ENTRY_INFOA*, LPDWORD, DWORD, DWORD, DWORD);
  86. DWORD GetUrlInfo(LPCSTR, LPCACHE_ENTRY_INFOA, LPDWORD, DWORD, DWORD);
  87. DWORD SetUrlInfo(LPCSTR, LPCACHE_ENTRY_INFOA, DWORD);
  88. DWORD FindNextEntry(HANDLE*, LPCSTR, LPCACHE_ENTRY_INFOA* ppNextCacheEntryInfo, LPDWORD, DWORD, GROUPID, DWORD, DWORD);
  89. DWORD FindNextEntry(HANDLE*, LPCSTR, LPCACHE_ENTRY_INFOA pNextCacheEntryInfo, LPDWORD, DWORD, GROUPID, DWORD);
  90. DWORD CleanupUrls(LPCTSTR szCachePath, DWORD dwFactor, DWORD dwFilter);
  91. DWORD GetUrlInGroup(LPCSTR, GROUPID*, LPDWORD);
  92. VOID SetCacheLimit(LONGLONG, DWORD);
  93. VOID GetCacheInfo(LPCSTR, LPSTR, LONGLONG*);
  94. // Methods corresponding to cache configuration APIs
  95. BOOL SetContentPath(PTSTR pszNewPath);
  96. BOOL GetUrlCacheConfigInfo(LPCACHE_CONFIG_INFO, LPDWORD, DWORD);
  97. BOOL SetUrlCacheConfigInfo(LPCACHE_CONFIG_INFO, DWORD);
  98. // Methods corresponding to cache group APIs
  99. DWORD CreateGroup(DWORD, GROUPID*);
  100. DWORD CreateDefaultGroups();
  101. DWORD DeleteGroup(GROUPID, DWORD);
  102. DWORD FindNextGroup(HANDLE*, DWORD, GROUPID*);
  103. DWORD GetGroupAttributes(
  104. GROUPID, DWORD, LPINTERNET_CACHE_GROUP_INFOA, LPDWORD);
  105. DWORD SetGroupAttributes(GROUPID, DWORD, LPINTERNET_CACHE_GROUP_INFOA );
  106. // notification api
  107. DWORD RegisterCacheNotify(HWND, UINT, GROUPID, DWORD);
  108. DWORD SendCacheNotification(DWORD);
  109. DWORD AddLeakFile (LPCSTR pszFile)
  110. {
  111. return _coContent->AddLeakFile (pszFile);
  112. }
  113. // allows content import to create a directory with a known name
  114. BOOL CreateContentDirWithSecureName( LPSTR szDirName)
  115. {
  116. return _coContainer[CONTENT]->CreateDirWithSecureName( szDirName);
  117. }
  118. // Creates a redirect from TargetUrl to OriginUrl
  119. BOOL CreateContentRedirect( LPSTR szTargetUrl, LPSTR szOriginUrl)
  120. {
  121. return _coContainer[CONTENT]->CreateRedirect( szTargetUrl, szOriginUrl);
  122. }
  123. VOID SetCacheSize(DWORD dwEnum, LONGLONG dlSize)
  124. {
  125. INET_ASSERT(dwEnum<NCONTAINERS);
  126. _coContainer[dwEnum]->SetCacheSize(dlSize);
  127. }
  128. VOID WalkLeakList(DWORD dwEnum)
  129. {
  130. INET_ASSERT(dwEnum<NCONTAINERS);
  131. if (_coContainer[dwEnum]->WalkLeakList())
  132. {
  133. _coContainer[dwEnum]->UnlockContainer();
  134. }
  135. }
  136. };
  137. #endif // _CONMGR_HXX