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.

244 lines
7.6 KiB

  1. //
  2. // cache.h: Declares data, defines and struct types for the
  3. // cache list module.
  4. //
  5. //
  6. #ifndef __CACHE_H__
  7. #define __CACHE_H__
  8. /////////////////////////////////////////////////////////////
  9. //
  10. // Generic cache structures
  11. //
  12. /////////////////////////////////////////////////////////////
  13. typedef void (CALLBACK *PFNFREEVALUE)(void * pv, HWND hwndOwner);
  14. typedef struct tagCACHE
  15. {
  16. CRITICAL_SECTION cs;
  17. HDSA hdsa; // Actual list of CITEMs
  18. HDPA hdpa; // Sorted ptr list
  19. HDPA hdpaFree; // Free list
  20. int iPrev; // Index into hdpa. Used by FindFirst/FindNext
  21. int atomPrev;
  22. } CACHE;
  23. // Generic cache APIs
  24. //
  25. BOOL PUBLIC Cache_Init (CACHE * pcache);
  26. void PUBLIC Cache_InitCS(CACHE * pcache);
  27. void PUBLIC Cache_Term (CACHE * pcache, HWND hwndOwner, PFNFREEVALUE pfnFree);
  28. void PUBLIC Cache_DeleteCS(CACHE * pcache);
  29. BOOL PUBLIC Cache_AddItem (CACHE * pcache, int atomKey, LPVOID pvValue);
  30. int PUBLIC Cache_DeleteItem (CACHE * pcache, int atomKey, BOOL bNuke, HWND hwndOwner, PFNFREEVALUE pfnFree);
  31. BOOL PUBLIC Cache_ReplaceItem (CACHE * pcache, int atomKey, LPVOID pvBuf, int cbBuf);
  32. LPVOID PUBLIC Cache_GetPtr (CACHE * pcache, int atomKey);
  33. BOOL PUBLIC Cache_GetItem(CACHE * pcache, int atomKey, LPVOID pvBuf, int cbBuf);
  34. int PUBLIC Cache_FindFirstKey(CACHE * pcache);
  35. int PUBLIC Cache_FindNextKey(CACHE * pcache, int atomPrev);
  36. UINT PUBLIC Cache_GetRefCount(CACHE * pcache, int atomKey);
  37. /////////////////////////////////////////////////////////////
  38. //
  39. // Cached briefcase handle list
  40. //
  41. /////////////////////////////////////////////////////////////
  42. // Cache briefcase structure
  43. //
  44. typedef struct tagCBS
  45. {
  46. int atomBrf; // Useful for reference
  47. HBRFCASE hbrf; // Opened on add, closed on delete
  48. HWND hwndParent; // Volatile
  49. PABORTEVT pabortevt; // Abort event object
  50. UINT uFlags; // One of CBSF_ flags
  51. } CBS, * PCBS;
  52. #define CBSF_LFNDRIVE 0x0002
  53. extern CACHE g_cacheCBS; // Briefcase structure cache
  54. void CALLBACK CBS_Free(LPVOID lpv, HWND hwnd);
  55. DEBUG_CODE( void PUBLIC CBS_DumpAll(); )
  56. // BOOL CBS_Init(void);
  57. //
  58. #define CBS_Init() Cache_Init(&g_cacheCBS)
  59. // void CBS_InitCS(void);
  60. //
  61. #define CBS_InitCS() Cache_InitCS(&g_cacheCBS)
  62. // void CBS_Term(HWND hwndOwner);
  63. //
  64. #define CBS_Term(hwndOwner) Cache_Term(&g_cacheCBS, hwndOwner, CBS_Free)
  65. // void CBS_DeleteCS(void);
  66. //
  67. #define CBS_DeleteCS() Cache_DeleteCS(&g_cacheCBS)
  68. // HRESULT CBS_Add(PCBS * ppcbs, int atomPath, HWND hwndOwner);
  69. // Must call CBS_Delete for each call to this guy.
  70. //
  71. HRESULT PUBLIC CBS_Add(PCBS * ppcbs, int atomPath, HWND hwndOwner);
  72. // CBS FAR * CBS_Get(int atomPath);
  73. // Must call CBS_Delete for each call to this guy.
  74. //
  75. #define CBS_Get(atomPath) Cache_GetPtr(&g_cacheCBS, atomPath)
  76. // int CBS_Delete(int atomPath, HWND hwndOwner);
  77. // Returns reference count (0 if deleted)
  78. //
  79. #define CBS_Delete(atomPath, hwndOwner) Cache_DeleteItem(&g_cacheCBS, atomPath, FALSE, hwndOwner, CBS_Free)
  80. // int CBS_Nuke(int atomPath, HWND hwndOwner);
  81. // Returns 0
  82. //
  83. #define CBS_Nuke(atomPath, hwndOwner) Cache_DeleteItem(&g_cacheCBS, atomPath, TRUE, hwndOwner, CBS_Free)
  84. /////////////////////////////////////////////////////////////
  85. //
  86. // Cached reclist
  87. //
  88. /////////////////////////////////////////////////////////////
  89. // Cache reclist structure
  90. //
  91. typedef struct tagCRL
  92. {
  93. int atomPath; // Inside path for this CRL
  94. int atomOutside; // Outside path of the sync copy pair
  95. UINT idsStatus; // resource ID for status string
  96. PABORTEVT pabortevt; // Abort event object, owned by CBS
  97. HBRFCASE hbrf; // Briefcase this reclist belongs to
  98. int atomBrf;
  99. PRECLIST lprl; // Created
  100. PFOLDERTWINLIST lpftl; // Created. May be NULL
  101. UINT ucUse; // Use count (dirty entry is not cleaned until
  102. // ucUse == 0)
  103. UINT uFlags; // CRLF_* flags
  104. } CRL, * PCRL;
  105. // Flags for CRL
  106. #define CRLF_DIRTY 0x00000001 // cache item is dirty
  107. #define CRLF_NUKE 0x00000002 // nuke when use count is 0
  108. #define CRLF_SUBFOLDERTWIN 0x00000004 // folder is subfolder of subtree twin
  109. #define CRLF_ISFOLDER 0x00000008 // atomPath is a folder
  110. #define CRLF_ISLFNDRIVE 0x00000010 // is on an LFN drive
  111. #define CRLF_ORPHAN 0x00000020 // item is orphan
  112. extern CACHE g_cacheCRL; // Reclist cache
  113. void CALLBACK CRL_Free(LPVOID lpv, HWND hwndOwner);
  114. DEBUG_CODE( void PUBLIC CRL_DumpAll(); )
  115. #define CRL_IsOrphan(pcrl) IsFlagSet((pcrl)->uFlags, CRLF_ORPHAN)
  116. #define CRL_IsSubfolderTwin(pcrl) IsFlagSet((pcrl)->uFlags, CRLF_SUBFOLDERTWIN)
  117. #define CRL_IsFolder(pcrl) IsFlagSet((pcrl)->uFlags, CRLF_ISFOLDER)
  118. // BOOL CRL_Init(void);
  119. //
  120. #define CRL_Init() Cache_Init(&g_cacheCRL)
  121. // void CRL_InitCS(void);
  122. //
  123. #define CRL_InitCS() Cache_InitCS(&g_cacheCRL)
  124. // void CRL_Term(void);
  125. //
  126. #define CRL_Term() Cache_Term(&g_cacheCRL, NULL, CRL_Free)
  127. // void CRL_DeleteCS(void);
  128. //
  129. #define CRL_DeleteCS() Cache_DeleteCS(&g_cacheCRL)
  130. BOOL PUBLIC IsSubfolderTwin(HBRFCASE hbrf, LPCTSTR pcszPath);
  131. // HRESULT CRL_Add(PCBS pcbs, int atomPath);
  132. // Must call CRL_Delete for each call to this function.
  133. //
  134. HRESULT PUBLIC CRL_Add(PCBS pcbs, int atomPath);
  135. // HRESULT CRL_Get(int atomPath, PCRL * ppcrl);
  136. // Must call CRL_Delete for each successful call to this function.
  137. //
  138. HRESULT PUBLIC CRL_Get(int atomPath, PCRL * ppcrl);
  139. // HRESULT CRL_Replace(int atomPath);
  140. //
  141. HRESULT PUBLIC CRL_Replace(int atomPath);
  142. // void CRL_Delete(int atomPath);
  143. //
  144. void PUBLIC CRL_Delete(int atomPath);
  145. // int CRL_Nuke(int atomPath);
  146. //
  147. void PUBLIC CRL_Nuke(int atomPath);
  148. // BOOL CRL_Dirty(int atomPath);
  149. BOOL PUBLIC CRL_Dirty(int atomPath, int atomCabinetFolder, LONG lEvent, LPBOOL pbRefresh);
  150. // void CRL_DirtyAll(int atomBrf);
  151. //
  152. void PUBLIC CRL_DirtyAll(int atomBrf);
  153. /////////////////////////////////////////////////////////////
  154. //
  155. // Cached briefcase paths
  156. //
  157. /////////////////////////////////////////////////////////////
  158. typedef struct tagCPATH
  159. {
  160. int atomPath; // Useful for reference
  161. } CPATH;
  162. extern CACHE g_cacheCPATH; // Volume ID cache
  163. void CALLBACK CPATH_Free(LPVOID lpv, HWND hwndOwner);
  164. DEBUG_CODE( void PUBLIC CPATH_DumpAll(); )
  165. // BOOL CPATH_Init(void);
  166. //
  167. #define CPATH_Init() Cache_Init(&g_cacheCPATH)
  168. // void CPATH_InitCS(void);
  169. //
  170. #define CPATH_InitCS() Cache_InitCS(&g_cacheCPATH)
  171. // void CPATH_Term();
  172. //
  173. #define CPATH_Term() Cache_Term(&g_cacheCPATH, NULL, CPATH_Free)
  174. // void CPATH_DeleteCS(void);
  175. //
  176. #define CPATH_DeleteCS() Cache_DeleteCS(&g_cacheCPATH)
  177. // CPATH FAR * CPATH_Replace(int atomPath);
  178. // Must call CPATH_Delete for each call to this function.
  179. //
  180. CPATH * PUBLIC CPATH_Replace(int atomPath);
  181. // UINT CPATH_GetLocality(LPCSTR pszPath, LPSTR pszBuf);
  182. //
  183. UINT PUBLIC CPATH_GetLocality(LPCTSTR pszPath, LPTSTR pszBuf, int cchMax);
  184. #endif // __CACHE_H__