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.

1574 lines
37 KiB

  1. /*
  2. * stock.h - Stock header file.
  3. */
  4. /* Constants
  5. ************/
  6. #define INVALID_SEEK_POSITION (0xffffffff)
  7. #define EMPTY_STRING TEXT("")
  8. #define SLASH_SLASH TEXT("\\\\")
  9. #define EQUAL TEXT('=')
  10. #define SPACE TEXT(' ')
  11. #define TAB TEXT('\t')
  12. #define COLON TEXT(':')
  13. #define COMMA TEXT(',')
  14. #define PERIOD TEXT('.')
  15. #define SLASH TEXT('\\')
  16. #define BACKSLASH TEXT('/')
  17. #define ASTERISK TEXT('*')
  18. #define QMARK TEXT('?')
  19. /* limits */
  20. #define WORD_MAX USHRT_MAX
  21. #define DWORD_MAX ULONG_MAX
  22. #define SIZE_T_MAX DWORD_MAX
  23. #define PTR_MAX ((PCVOID)MAXULONG_PTR)
  24. /* file system constants */
  25. #define MAX_PATH_LEN MAX_PATH
  26. #define MAX_NAME_LEN MAX_PATH
  27. #define MAX_FOLDER_DEPTH (MAX_PATH / 2)
  28. #define DRIVE_ROOT_PATH_LEN (4)
  29. /* size macros */
  30. #define SIZEOF(a) sizeof(a)
  31. /* invalid thread ID */
  32. #define INVALID_THREAD_ID (0xffffffff)
  33. /* file-related flag combinations */
  34. #define ALL_FILE_ACCESS_FLAGS (GENERIC_READ |\
  35. GENERIC_WRITE)
  36. #define ALL_FILE_SHARING_FLAGS (FILE_SHARE_READ |\
  37. FILE_SHARE_WRITE)
  38. #define ALL_FILE_ATTRIBUTES (FILE_ATTRIBUTE_READONLY |\
  39. FILE_ATTRIBUTE_HIDDEN |\
  40. FILE_ATTRIBUTE_SYSTEM |\
  41. FILE_ATTRIBUTE_DIRECTORY |\
  42. FILE_ATTRIBUTE_ARCHIVE |\
  43. FILE_ATTRIBUTE_NORMAL |\
  44. FILE_ATTRIBUTE_TEMPORARY)
  45. #define ALL_FILE_FLAGS (FILE_FLAG_WRITE_THROUGH |\
  46. FILE_FLAG_OVERLAPPED |\
  47. FILE_FLAG_NO_BUFFERING |\
  48. FILE_FLAG_RANDOM_ACCESS |\
  49. FILE_FLAG_SEQUENTIAL_SCAN |\
  50. FILE_FLAG_DELETE_ON_CLOSE |\
  51. FILE_FLAG_BACKUP_SEMANTICS |\
  52. FILE_FLAG_POSIX_SEMANTICS)
  53. #define ALL_FILE_ATTRIBUTES_AND_FLAGS (ALL_FILE_ATTRIBUTES |\
  54. ALL_FILE_FLAGS)
  55. /* Macros
  56. *********/
  57. #ifndef DECLARE_STANDARD_TYPES
  58. /*
  59. * For a type "FOO", define the standard derived types PFOO, CFOO, and PCFOO.
  60. */
  61. #define DECLARE_STANDARD_TYPES(type) typedef type *P##type; \
  62. typedef const type C##type; \
  63. typedef const type *PC##type;
  64. #endif
  65. /* character manipulation */
  66. #define IS_SLASH(ch) ((ch) == SLASH || (ch) == BACKSLASH)
  67. /* bit flag manipulation */
  68. #define SET_FLAG(dwAllFlags, dwFlag) ((dwAllFlags) |= (dwFlag))
  69. #define CLEAR_FLAG(dwAllFlags, dwFlag) ((dwAllFlags) &= (~dwFlag))
  70. #define IS_FLAG_SET(dwAllFlags, dwFlag) ((BOOL)((dwAllFlags) & (dwFlag)))
  71. #define IS_FLAG_CLEAR(dwAllFlags, dwFlag) (! (IS_FLAG_SET(dwAllFlags, dwFlag)))
  72. /* array element count */
  73. #define ARRAY_ELEMENTS(rg) (sizeof(rg) / sizeof((rg)[0]))
  74. /* file attribute manipulation */
  75. #define IS_ATTR_DIR(attr) (IS_FLAG_SET((attr), FILE_ATTRIBUTE_DIRECTORY))
  76. #define IS_ATTR_VOLUME(attr) (IS_FLAG_SET((attr), FILE_ATTRIBUTE_VOLUME))
  77. /* Types
  78. ********/
  79. typedef const void *PCVOID;
  80. typedef const INT CINT;
  81. typedef const INT *PCINT;
  82. typedef const UINT CUINT;
  83. typedef const UINT *PCUINT;
  84. typedef const BYTE CBYTE;
  85. typedef const BYTE *PCBYTE;
  86. typedef const WORD CWORD;
  87. typedef const WORD *PCWORD;
  88. typedef const DWORD CDWORD;
  89. typedef const DWORD *PCDWORD;
  90. typedef const CRITICAL_SECTION CCRITICAL_SECTION;
  91. typedef const CRITICAL_SECTION *PCCRITICAL_SECTION;
  92. typedef const FILETIME CFILETIME;
  93. typedef const FILETIME *PCFILETIME;
  94. typedef const SECURITY_ATTRIBUTES CSECURITY_ATTRIBUTES;
  95. typedef const SECURITY_ATTRIBUTES *PCSECURITY_ATTRIBUTES;
  96. typedef const WIN32_FIND_DATA CWIN32_FIND_DATA;
  97. typedef const WIN32_FIND_DATA *PCWIN32_FIND_DATA;
  98. DECLARE_STANDARD_TYPES(HICON);
  99. DECLARE_STANDARD_TYPES(NMHDR);
  100. #ifndef _COMPARISONRESULT_DEFINED_
  101. /* comparison result */
  102. typedef enum _comparisonresult
  103. {
  104. CR_FIRST_SMALLER = -1,
  105. CR_EQUAL = 0,
  106. CR_FIRST_LARGER = +1
  107. }
  108. COMPARISONRESULT;
  109. DECLARE_STANDARD_TYPES(COMPARISONRESULT);
  110. #define _COMPARISONRESULT_DEFINED_
  111. #endif
  112. /*
  113. * debug.h - Debug macros and their retail translations.
  114. */
  115. /* Macros
  116. *********/
  117. /* debug output macros */
  118. /*
  119. * Do not call SPEW_OUT directly. Instead, call TRACE_OUT, WARNING_OUT,
  120. * ERROR_OUT, or FATAL_OUT.
  121. */
  122. /*
  123. * call like printf(), but with an extra pair of parentheses:
  124. *
  125. * ERROR_OUT(("'%s' too big by %d bytes.", pszName, nExtra));
  126. */
  127. #ifdef DEBUG
  128. #define SPEW_OUT(args) 0
  129. #define PLAIN_TRACE_OUT(args) 0
  130. #define TRACE_OUT(args) 0
  131. #define WARNING_OUT(args) 0
  132. #define ERROR_OUT(args) 0
  133. #define FATAL_OUT(args) 0
  134. #else
  135. #define PLAIN_TRACE_OUT(args)
  136. #define TRACE_OUT(args)
  137. #define WARNING_OUT(args)
  138. #define ERROR_OUT(args)
  139. #define FATAL_OUT(args)
  140. #endif
  141. /* parameter validation macros */
  142. /*
  143. * call as:
  144. *
  145. * bPTwinOK = IS_VALID_READ_PTR(ptwin, CTWIN);
  146. *
  147. * bHTwinOK = IS_VALID_HANDLE(htwin, TWIN);
  148. */
  149. #ifdef DEBUG
  150. #define IS_VALID_READ_PTR(ptr, type) \
  151. (IsBadReadPtr((ptr), sizeof(type)) ? \
  152. (ERROR_OUT((TEXT("invalid %s read pointer - %#08lx"), (LPCTSTR)TEXT("P")TEXT(#type), (ptr))), FALSE) : \
  153. TRUE)
  154. #define IS_VALID_WRITE_PTR(ptr, type) \
  155. (IsBadWritePtr((PVOID)(ptr), sizeof(type)) ? \
  156. (ERROR_OUT((TEXT("invalid %s write pointer - %#08lx"), (LPCTSTR)TEXT("P")TEXT(#type), (ptr))), FALSE) : \
  157. TRUE)
  158. #define IS_VALID_STRING_PTRA(ptr, type) \
  159. (IsBadStringPtrA((ptr), (UINT)-1) ? \
  160. (ERROR_OUT((TEXT("invalid %s pointer - %#08lx"), (LPCTSTR)TEXT("P")TEXT(#type), (ptr))), FALSE) : \
  161. TRUE)
  162. #define IS_VALID_STRING_PTRW(ptr, type) \
  163. (IsBadStringPtrW((ptr), (UINT)-1) ? \
  164. (ERROR_OUT((TEXT("invalid %s pointer - %#08lx"), (LPCTSTR)TEXT("P")TEXT(#type), (ptr))), FALSE) : \
  165. TRUE)
  166. #ifdef UNICODE
  167. #define IS_VALID_STRING_PTR(ptr, type) IS_VALID_STRING_PTRW(ptr, type)
  168. #else
  169. #define IS_VALID_STRING_PTR(ptr, type) IS_VALID_STRING_PTRA(ptr, type)
  170. #endif
  171. #define IS_VALID_CODE_PTR(ptr, type) \
  172. (IsBadCodePtr((PROC)(ptr)) ? \
  173. (ERROR_OUT((TEXT("invalid %s code pointer - %#08lx"), (LPCTSTR)TEXT(#type), (ptr))), FALSE) : \
  174. TRUE)
  175. #define IS_VALID_READ_BUFFER_PTR(ptr, type, len) \
  176. (IsBadReadPtr((ptr), len) ? \
  177. (ERROR_OUT((TEXT("invalid %s read pointer - %#08lx"), (LPCTSTR)TEXT("P")TEXT(#type), (ptr))), FALSE) : \
  178. TRUE)
  179. #define IS_VALID_WRITE_BUFFER_PTR(ptr, type, len) \
  180. (IsBadWritePtr((ptr), len) ? \
  181. (ERROR_OUT((TEXT("invalid %s write pointer - %#08lx"), (LPCTSTR)TEXT("P")TEXT(#type), (ptr))), FALSE) : \
  182. TRUE)
  183. #define FLAGS_ARE_VALID(dwFlags, dwAllFlags) \
  184. (((dwFlags) & (~(dwAllFlags))) ? \
  185. (ERROR_OUT((TEXT("invalid flags set - %#08lx"), ((dwFlags) & (~(dwAllFlags))))), FALSE) : \
  186. TRUE)
  187. #else
  188. #define IS_VALID_READ_PTR(ptr, type) \
  189. (! IsBadReadPtr((ptr), sizeof(type)))
  190. #define IS_VALID_WRITE_PTR(ptr, type) \
  191. (! IsBadWritePtr((PVOID)(ptr), sizeof(type)))
  192. #define IS_VALID_STRING_PTR(ptr, type) \
  193. (! IsBadStringPtr((ptr), (UINT)-1))
  194. #define IS_VALID_CODE_PTR(ptr, type) \
  195. (! IsBadCodePtr((PROC)(ptr)))
  196. #define IS_VALID_READ_BUFFER_PTR(ptr, type, len) \
  197. (! IsBadReadPtr((ptr), len))
  198. #define IS_VALID_WRITE_BUFFER_PTR(ptr, type, len) \
  199. (! IsBadWritePtr((ptr), len))
  200. #define FLAGS_ARE_VALID(dwFlags, dwAllFlags) \
  201. (((dwFlags) & (~(dwAllFlags))) ? FALSE : TRUE)
  202. #endif
  203. /* handle validation macros */
  204. #define IS_VALID_HANDLE(hnd, type) TRUE
  205. /* structure validation macros */
  206. #ifdef DEBUG
  207. #define IS_VALID_STRUCT_PTR(ptr, type) TRUE
  208. #endif
  209. /* debug assertion macro */
  210. /*
  211. * ASSERT() may only be used as a statement, not as an expression.
  212. *
  213. * call as:
  214. *
  215. * ASSERT(pszRest);
  216. */
  217. /*
  218. #ifdef DEBUG
  219. #define ASSERT(exp) \
  220. if (exp) \
  221. ; \
  222. else \
  223. MessageBox(NULL, TEXT("assertion failed"), TEXT("TEST"), MB_OK)
  224. #else
  225. */
  226. //#define ASSERT(exp)
  227. /*
  228. #endif
  229. */
  230. /* debug evaluation macro */
  231. /*
  232. * EVAL() may be used as an expression.
  233. *
  234. * call as:
  235. *
  236. * if (EVAL(pszFoo))
  237. * bResult = TRUE;
  238. */
  239. #ifdef DEBUG
  240. #define EVAL(exp) \
  241. ((exp) || (ERROR_OUT((TEXT("evaluation failed '%s'"), (LPCTSTR)TEXT(#exp))), 0))
  242. #else
  243. #define EVAL(exp) \
  244. (exp)
  245. #endif
  246. /* debug break */
  247. #ifndef DEBUG
  248. #define DebugBreak()
  249. #endif
  250. /* debug exported function entry */
  251. #define DebugEntry(szFunctionName)
  252. /* debug exported function exit */
  253. #define DebugExitVOID(szFunctionName)
  254. #define DebugExit(szFunctionName, szResult)
  255. #define DebugExitINT(szFunctionName, n)
  256. #define DebugExitULONG(szFunctionName, ul)
  257. #define DebugExitBOOL(szFunctionName, bool)
  258. #define DebugExitHRESULT(szFunctionName, hr)
  259. #define DebugExitCOMPARISONRESULT(szFunctionName, cr)
  260. #define DebugExitTWINRESULT(szFunctionName, tr)
  261. #define DebugExitRECRESULT(szFunctionName, rr)
  262. /* Types
  263. ********/
  264. /* GdwSpewFlags flags */
  265. typedef enum _spewflags
  266. {
  267. SPEW_FL_SPEW_PREFIX = 0x0001,
  268. SPEW_FL_SPEW_LOCATION = 0x0002,
  269. ALL_SPEW_FLAGS = (SPEW_FL_SPEW_PREFIX |
  270. SPEW_FL_SPEW_LOCATION)
  271. }
  272. SPEWFLAGS;
  273. /* GuSpewSev values */
  274. typedef enum _spewsev
  275. {
  276. SPEW_TRACE = 1,
  277. SPEW_WARNING = 2,
  278. SPEW_ERROR = 3,
  279. SPEW_FATAL = 4
  280. }
  281. SPEWSEV;
  282. /* Prototypes
  283. *************/
  284. /* debug.c */
  285. #ifdef DEBUG
  286. extern BOOL SetDebugModuleIniSwitches(void);
  287. extern BOOL InitDebugModule(void);
  288. extern void ExitDebugModule(void);
  289. extern void StackEnter(void);
  290. extern void StackLeave(void);
  291. extern ULONG GetStackDepth(void);
  292. extern void __cdecl SpewOut(LPCTSTR pcszFormat, ...);
  293. #endif
  294. /* Global Variables
  295. *******************/
  296. #ifdef DEBUG
  297. /* debug.c */
  298. extern DWORD GdwSpewFlags;
  299. extern UINT GuSpewSev;
  300. extern UINT GuSpewLine;
  301. extern LPCTSTR GpcszSpewFile;
  302. /* defined by client */
  303. extern LPCTSTR GpcszSpewModule;
  304. #endif
  305. /* Prototypes
  306. *************/
  307. /* memmgr.c */
  308. extern COMPARISONRESULT MyMemComp(PCVOID, PCVOID, DWORD);
  309. extern BOOL AllocateMemory(DWORD, PVOID *);
  310. extern void FreeMemory(PVOID);
  311. extern BOOL ReallocateMemory(PVOID, DWORD, DWORD, PVOID *);
  312. /*
  313. * ptrarray.h - Pointer array ADT description.
  314. */
  315. /* Constants
  316. ************/
  317. /*
  318. * ARRAYINDEX_MAX is set such that (ARRAYINDEX_MAX + 1) does not overflow an
  319. * ARRAYINDEX. This guarantee allows GetPtrCount() to return a count of
  320. * pointers as an ARRAYINDEX.
  321. */
  322. #define ARRAYINDEX_MAX (LONG_MAX - 1)
  323. /* Types
  324. ********/
  325. /* handles */
  326. DECLARE_HANDLE(HPTRARRAY);
  327. DECLARE_STANDARD_TYPES(HPTRARRAY);
  328. /* array index */
  329. typedef LONG ARRAYINDEX;
  330. DECLARE_STANDARD_TYPES(ARRAYINDEX);
  331. /*
  332. * pointer comparison callback function
  333. *
  334. * In sorting functions, both pointers are pointer array elements. In
  335. * searching functions, the first pointer is reference data and the second
  336. * pointer is a pointer array element.
  337. */
  338. typedef COMPARISONRESULT (*COMPARESORTEDPTRSPROC)(PCVOID, PCVOID);
  339. /*
  340. * pointer comparison callback function
  341. *
  342. * In searching functions, the first pointer is reference data and the second
  343. * pointer is a pointer array element.
  344. */
  345. typedef BOOL (*COMPAREUNSORTEDPTRSPROC)(PCVOID, PCVOID);
  346. /* new pointer array flags */
  347. typedef enum _newptrarrayflags
  348. {
  349. /* Insert elements in sorted order. */
  350. NPA_FL_SORTED_ADD = 0x0001,
  351. /* flag combinations */
  352. ALL_NPA_FLAGS = NPA_FL_SORTED_ADD
  353. }
  354. NEWPTRARRAYFLAGS;
  355. /* new pointer array description */
  356. typedef struct _newptrarray
  357. {
  358. DWORD dwFlags;
  359. ARRAYINDEX aicInitialPtrs;
  360. ARRAYINDEX aicAllocGranularity;
  361. }
  362. NEWPTRARRAY;
  363. DECLARE_STANDARD_TYPES(NEWPTRARRAY);
  364. /* Prototypes
  365. *************/
  366. /* ptrarray.c */
  367. extern BOOL CreatePtrArray(PCNEWPTRARRAY, PHPTRARRAY);
  368. extern void DestroyPtrArray(HPTRARRAY);
  369. extern BOOL InsertPtr(HPTRARRAY, COMPARESORTEDPTRSPROC, ARRAYINDEX, PCVOID);
  370. extern BOOL AddPtr(HPTRARRAY, COMPARESORTEDPTRSPROC, PCVOID, PARRAYINDEX);
  371. extern void DeletePtr(HPTRARRAY, ARRAYINDEX);
  372. extern void DeleteAllPtrs(HPTRARRAY);
  373. extern ARRAYINDEX GetPtrCount(HPTRARRAY);
  374. extern PVOID GetPtr(HPTRARRAY, ARRAYINDEX);
  375. extern void SortPtrArray(HPTRARRAY, COMPARESORTEDPTRSPROC);
  376. extern BOOL SearchSortedArray(HPTRARRAY, COMPARESORTEDPTRSPROC, PCVOID, PARRAYINDEX);
  377. extern BOOL LinearSearchArray(HPTRARRAY, COMPAREUNSORTEDPTRSPROC, PCVOID, PARRAYINDEX);
  378. extern BOOL IsValidHPTRARRAY(HPTRARRAY);
  379. extern BOOL IsValidHGLOBAL(HGLOBAL);
  380. /*
  381. * list.h - List ADT description.
  382. */
  383. /* Types
  384. ********/
  385. /* handles */
  386. DECLARE_HANDLE(HLIST);
  387. DECLARE_STANDARD_TYPES(HLIST);
  388. DECLARE_HANDLE(HNODE);
  389. DECLARE_STANDARD_TYPES(HNODE);
  390. /*
  391. * sorted list node comparison callback function
  392. *
  393. * The first pointer is reference data and the second pointer is a list node
  394. * data element.
  395. */
  396. typedef COMPARISONRESULT (*COMPARESORTEDNODESPROC)(PCVOID, PCVOID);
  397. /*
  398. * unsorted list node comparison callback function
  399. *
  400. * The first pointer is reference data and the second pointer is a list node
  401. * data element.
  402. */
  403. typedef BOOL (*COMPAREUNSORTEDNODESPROC)(PCVOID, PCVOID);
  404. /*
  405. * WalkList() callback function - called as:
  406. *
  407. * bContinue = WalkList(pvNodeData, pvRefData);
  408. */
  409. typedef BOOL (*WALKLIST)(PVOID, PVOID);
  410. /* new list flags */
  411. typedef enum _newlistflags
  412. {
  413. /* Insert nodes in sorted order. */
  414. NL_FL_SORTED_ADD = 0x0001,
  415. /* flag combinations */
  416. ALL_NL_FLAGS = NL_FL_SORTED_ADD
  417. }
  418. NEWLISTFLAGS;
  419. /* new list description */
  420. typedef struct _newlist
  421. {
  422. DWORD dwFlags;
  423. }
  424. NEWLIST;
  425. DECLARE_STANDARD_TYPES(NEWLIST);
  426. /* Prototypes
  427. *************/
  428. /* list.c */
  429. extern BOOL CreateList(PCNEWLIST, PHLIST);
  430. extern void DestroyList(HLIST);
  431. extern BOOL AddNode(HLIST, COMPARESORTEDNODESPROC, PCVOID, PHNODE);
  432. extern BOOL InsertNodeAtFront(HLIST, COMPARESORTEDNODESPROC, PCVOID, PHNODE);
  433. extern BOOL InsertNodeBefore(HNODE, COMPARESORTEDNODESPROC, PCVOID, PHNODE);
  434. extern BOOL InsertNodeAfter(HNODE, COMPARESORTEDNODESPROC, PCVOID, PHNODE);
  435. extern void DeleteNode(HNODE);
  436. extern void DeleteAllNodes(HLIST);
  437. extern PVOID GetNodeData(HNODE);
  438. extern void SetNodeData(HNODE, PCVOID);
  439. extern ULONG GetNodeCount(HLIST);
  440. extern BOOL BreifcaseIsListEmpty(HLIST);
  441. extern BOOL GetFirstNode(HLIST, PHNODE);
  442. extern BOOL GetNextNode(HNODE, PHNODE);
  443. extern BOOL GetPrevNode(HNODE, PHNODE);
  444. extern void AppendList(HLIST, HLIST);
  445. extern BOOL SearchSortedList(HLIST, COMPARESORTEDNODESPROC, PCVOID, PHNODE);
  446. extern BOOL SearchUnsortedList(HLIST, COMPAREUNSORTEDNODESPROC, PCVOID, PHNODE);
  447. extern BOOL WalkList(HLIST, WALKLIST, PVOID);
  448. #ifdef DEBUG
  449. HLIST GetList(HNODE);
  450. #endif
  451. /*
  452. * hndtrans.h - Handle translation description.
  453. */
  454. /* Types
  455. ********/
  456. /* handles */
  457. DECLARE_HANDLE(HHANDLETRANS);
  458. DECLARE_STANDARD_TYPES(HHANDLETRANS);
  459. DECLARE_HANDLE(HGENERIC);
  460. DECLARE_STANDARD_TYPES(HGENERIC);
  461. /* Prototypes
  462. *************/
  463. /* hndtrans.c */
  464. extern BOOL CreateHandleTranslator(LONG, PHHANDLETRANS);
  465. extern void DestroyHandleTranslator(HHANDLETRANS);
  466. extern BOOL AddHandleToHandleTranslator(HHANDLETRANS, HGENERIC, HGENERIC);
  467. extern void PrepareForHandleTranslation(HHANDLETRANS);
  468. extern BOOL TranslateHandle(HHANDLETRANS, HGENERIC, PHGENERIC);
  469. #ifdef DEBUG
  470. extern BOOL IsValidHHANDLETRANS(HHANDLETRANS);
  471. #endif
  472. /*
  473. * string.h - String table ADT description.
  474. */
  475. /* Types
  476. ********/
  477. /* handles */
  478. DECLARE_HANDLE(HSTRING);
  479. DECLARE_STANDARD_TYPES(HSTRING);
  480. DECLARE_HANDLE(HSTRINGTABLE);
  481. DECLARE_STANDARD_TYPES(HSTRINGTABLE);
  482. /* count of hash buckets in a string table */
  483. typedef UINT HASHBUCKETCOUNT;
  484. DECLARE_STANDARD_TYPES(HASHBUCKETCOUNT);
  485. /* string table hash function */
  486. typedef HASHBUCKETCOUNT (*STRINGTABLEHASHFUNC)(LPCTSTR, HASHBUCKETCOUNT);
  487. /* new string table */
  488. typedef struct _newstringtable
  489. {
  490. HASHBUCKETCOUNT hbc;
  491. }
  492. NEWSTRINGTABLE;
  493. DECLARE_STANDARD_TYPES(NEWSTRINGTABLE);
  494. /* Prototypes
  495. *************/
  496. /* string.c */
  497. extern BOOL CreateStringTable(PCNEWSTRINGTABLE, PHSTRINGTABLE);
  498. extern void DestroyStringTable(HSTRINGTABLE);
  499. extern BOOL AddString(LPCTSTR pcsz, HSTRINGTABLE hst, STRINGTABLEHASHFUNC pfnHashFunc, PHSTRING phs);
  500. extern void DeleteString(HSTRING);
  501. extern void LockString(HSTRING);
  502. extern COMPARISONRESULT CompareStringsI(HSTRING, HSTRING);
  503. extern LPCTSTR GetBfcString(HSTRING);
  504. extern BOOL IsValidHSTRING(HSTRING);
  505. extern BOOL IsValidHSTRINGTABLE(HSTRINGTABLE);
  506. #ifdef DEBUG
  507. extern ULONG GetStringCount(HSTRINGTABLE);
  508. #endif
  509. /*
  510. * comc.h - Shared routines description.
  511. */
  512. /* Prototypes
  513. *************/
  514. /* comc.c */
  515. extern void CatPath(LPTSTR, LPCTSTR);
  516. extern COMPARISONRESULT MapIntToComparisonResult(int);
  517. extern void MyLStrCpyN(LPTSTR, LPCTSTR, int);
  518. #ifdef DEBUG
  519. extern BOOL IsStringContained(LPCTSTR, LPCTSTR);
  520. #endif /* DEBUG */
  521. #if defined(_SYNCENG_) || defined(_LINKINFO_)
  522. extern void DeleteLastPathElement(LPTSTR);
  523. extern LONG GetDefaultRegKeyValue(HKEY, LPCTSTR, LPTSTR, PDWORD);
  524. extern BOOL StringCopy2(LPCTSTR, LPTSTR *);
  525. extern void CopyRootPath(LPCTSTR, LPTSTR);
  526. extern COMPARISONRESULT ComparePathStrings(LPCTSTR, LPCTSTR);
  527. extern BOOL MyStrChr(LPCTSTR, TCHAR, LPCTSTR *);
  528. extern BOOL PathExists(LPCTSTR);
  529. extern BOOL IsDrivePath(LPCTSTR);
  530. extern BOOL IsValidDriveType(UINT);
  531. extern BOOL IsValidPathSuffix(LPCTSTR);
  532. #ifdef DEBUG
  533. extern BOOL IsRootPath(LPCTSTR);
  534. extern BOOL IsTrailingSlashCanonicalized(LPCTSTR);
  535. extern BOOL IsFullPath(LPCTSTR);
  536. extern BOOL IsCanonicalPath(LPCTSTR);
  537. extern BOOL IsValidCOMPARISONRESULT(COMPARISONRESULT);
  538. #endif /* DEBUG */
  539. #endif /* _SYNCENG_ || _LINKINFO_ */
  540. /*
  541. * util.h - Miscellaneous utility functions module description.
  542. */
  543. /* Constants
  544. ************/
  545. /* maximum length of buffer required by SeparatePath() */
  546. #define MAX_SEPARATED_PATH_LEN (MAX_PATH_LEN + 1)
  547. /* events for NotifyShell */
  548. typedef enum _notifyshellevent
  549. {
  550. NSE_CREATE_ITEM,
  551. NSE_DELETE_ITEM,
  552. NSE_CREATE_FOLDER,
  553. NSE_DELETE_FOLDER,
  554. NSE_UPDATE_ITEM,
  555. NSE_UPDATE_FOLDER
  556. }
  557. NOTIFYSHELLEVENT;
  558. DECLARE_STANDARD_TYPES(NOTIFYSHELLEVENT);
  559. /* Prototypes
  560. *************/
  561. /* util.c */
  562. extern void NotifyShell(LPCTSTR, NOTIFYSHELLEVENT);
  563. extern COMPARISONRESULT ComparePathStringsByHandle(HSTRING, HSTRING);
  564. extern COMPARISONRESULT MyLStrCmpNI(LPCTSTR, LPCTSTR, int);
  565. extern void ComposePath(LPTSTR, LPCTSTR, LPCTSTR);
  566. extern LPCTSTR ExtractFileName(LPCTSTR);
  567. extern LPCTSTR ExtractExtension(LPCTSTR);
  568. extern HASHBUCKETCOUNT GetHashBucketIndex(LPCTSTR, HASHBUCKETCOUNT);
  569. extern COMPARISONRESULT MyCompareStrings(LPCTSTR, LPCTSTR, BOOL);
  570. extern BOOL RegKeyExists(HKEY, LPCTSTR);
  571. extern BOOL CopyLinkInfo(PCLINKINFO, PLINKINFO *);
  572. extern BOOL IsValidPCLINKINFO(PCLINKINFO);
  573. /*
  574. * path.h - Path ADT module description.
  575. */
  576. /* Types
  577. ********/
  578. /* handles */
  579. DECLARE_HANDLE(HPATHLIST);
  580. DECLARE_STANDARD_TYPES(HPATHLIST);
  581. DECLARE_HANDLE(HPATH);
  582. DECLARE_STANDARD_TYPES(HPATH);
  583. /* path results returned by AddPath() */
  584. typedef enum _pathresult
  585. {
  586. PR_SUCCESS,
  587. PR_UNAVAILABLE_VOLUME,
  588. PR_OUT_OF_MEMORY,
  589. PR_INVALID_PATH
  590. }
  591. PATHRESULT;
  592. DECLARE_STANDARD_TYPES(PATHRESULT);
  593. /* Prototypes
  594. *************/
  595. /* path.c */
  596. extern BOOL CreatePathList(DWORD, HWND, PHPATHLIST);
  597. extern void DestroyPathList(HPATHLIST);
  598. extern void InvalidatePathListInfo(HPATHLIST);
  599. extern void ClearPathListInfo(HPATHLIST);
  600. extern PATHRESULT AddPath(HPATHLIST, LPCTSTR, PHPATH);
  601. extern BOOL AddChildPath(HPATHLIST, HPATH, LPCTSTR, PHPATH);
  602. extern void DeletePath(HPATH);
  603. extern BOOL CopyPath(HPATH, HPATHLIST, PHPATH);
  604. extern void GetPathString(HPATH, LPTSTR);
  605. extern void GetPathRootString(HPATH, LPTSTR);
  606. extern void GetPathSuffixString(HPATH, LPTSTR);
  607. extern BOOL AllocatePathString(HPATH, LPTSTR *);
  608. #ifdef DEBUG
  609. extern LPCTSTR DebugGetPathString(HPATH);
  610. extern ULONG GetPathCount(HPATHLIST);
  611. #endif
  612. extern BOOL IsPathVolumeAvailable(HPATH);
  613. extern HVOLUMEID GetPathVolumeID(HPATH);
  614. extern BOOL MyIsPathOnVolume(LPCTSTR, HPATH);
  615. extern COMPARISONRESULT ComparePaths(HPATH, HPATH);
  616. extern COMPARISONRESULT ComparePathVolumes(HPATH, HPATH);
  617. extern BOOL IsPathPrefix(HPATH, HPATH);
  618. extern BOOL SubtreesIntersect(HPATH, HPATH);
  619. extern LPTSTR FindEndOfRootSpec(LPCTSTR, HPATH);
  620. extern COMPARISONRESULT ComparePointers(PCVOID, PCVOID);
  621. extern LPTSTR FindChildPathSuffix(HPATH, HPATH, LPTSTR);
  622. extern TWINRESULT TWINRESULTFromLastError(TWINRESULT);
  623. extern BOOL IsValidHPATH(HPATH);
  624. extern BOOL IsValidHVOLUMEID(HVOLUMEID);
  625. extern BOOL IsValidHPATHLIST(HPATHLIST);
  626. /*
  627. * fcache.h - File cache ADT description.
  628. */
  629. /* Types
  630. ********/
  631. /* return code */
  632. typedef enum _fcresult
  633. {
  634. FCR_SUCCESS,
  635. FCR_OUT_OF_MEMORY,
  636. FCR_OPEN_FAILED,
  637. FCR_CREATE_FAILED,
  638. FCR_WRITE_FAILED,
  639. FCR_FILE_LOCKED
  640. }
  641. FCRESULT;
  642. DECLARE_STANDARD_TYPES(FCRESULT);
  643. /* handles */
  644. #ifdef NOFCACHE
  645. typedef HANDLE HCACHEDFILE;
  646. #else
  647. DECLARE_HANDLE(HCACHEDFILE);
  648. #endif
  649. DECLARE_STANDARD_TYPES(HCACHEDFILE);
  650. /* cached file description */
  651. typedef struct _cachedfile
  652. {
  653. LPCTSTR pcszPath;
  654. DWORD dwcbDefaultCacheSize;
  655. DWORD dwOpenMode;
  656. DWORD dwSharingMode;
  657. PSECURITY_ATTRIBUTES psa;
  658. DWORD dwCreateMode;
  659. DWORD dwAttrsAndFlags;
  660. HANDLE hTemplateFile;
  661. }
  662. CACHEDFILE;
  663. DECLARE_STANDARD_TYPES(CACHEDFILE);
  664. /* Prototypes
  665. *************/
  666. /* fcache.c */
  667. extern FCRESULT CreateCachedFile(PCCACHEDFILE, PHCACHEDFILE);
  668. extern FCRESULT SetCachedFileCacheSize(HCACHEDFILE, DWORD);
  669. extern DWORD SeekInCachedFile(HCACHEDFILE, DWORD, DWORD);
  670. extern BOOL SetEndOfCachedFile(HCACHEDFILE);
  671. extern DWORD GetCachedFilePointerPosition(HCACHEDFILE);
  672. extern DWORD GetCachedFileSize(HCACHEDFILE);
  673. extern BOOL ReadFromCachedFile(HCACHEDFILE, PVOID, DWORD, PDWORD);
  674. extern BOOL WriteToCachedFile(HCACHEDFILE, PCVOID, DWORD, PDWORD);
  675. extern BOOL CommitCachedFile(HCACHEDFILE);
  676. extern HANDLE GetFileHandle(HCACHEDFILE);
  677. extern BOOL CloseCachedFile(HCACHEDFILE);
  678. extern HANDLE GetFileHandle(HCACHEDFILE);
  679. extern BOOL IsValidHCACHEDFILE(HCACHEDFILE);
  680. /*
  681. * brfcase.h - Briefcase ADT description.
  682. */
  683. /* Prototypes
  684. *************/
  685. /* brfcase.c */
  686. #define BeginExclusiveBriefcaseAccess() TRUE
  687. #define EndExclusiveBriefcaseAccess()
  688. extern BOOL SetBriefcaseModuleIniSwitches(void);
  689. extern BOOL InitBriefcaseModule(void);
  690. extern void ExitBriefcaseModule(void);
  691. extern HSTRINGTABLE GetBriefcaseNameStringTable(HBRFCASE);
  692. extern HPTRARRAY GetBriefcaseTwinFamilyPtrArray(HBRFCASE);
  693. extern HPTRARRAY GetBriefcaseFolderPairPtrArray(HBRFCASE);
  694. extern HPATHLIST GetBriefcasePathList(HBRFCASE);
  695. #ifdef DEBUG
  696. extern BOOL BriefcaseAccessIsExclusive(void);
  697. #endif
  698. extern BOOL IsValidHBRFCASE(HBRFCASE);
  699. /*
  700. * twin.h - Twin ADT description.
  701. */
  702. /* Types
  703. ********/
  704. /*
  705. * EnumTwins() callback function - called as:
  706. *
  707. * bContinue = EnumTwinsProc(htwin, pData);
  708. */
  709. typedef BOOL (*ENUMTWINSPROC)(HTWIN, LPARAM);
  710. /* Prototypes
  711. *************/
  712. /* twin.c */
  713. extern COMPARISONRESULT CompareNameStrings(LPCTSTR, LPCTSTR);
  714. extern COMPARISONRESULT CompareNameStringsByHandle(HSTRING, HSTRING);
  715. extern TWINRESULT TranslatePATHRESULTToTWINRESULT(PATHRESULT);
  716. extern BOOL CreateTwinFamilyPtrArray(PHPTRARRAY);
  717. extern void DestroyTwinFamilyPtrArray(HPTRARRAY);
  718. extern HBRFCASE GetTwinBriefcase(HTWIN);
  719. extern BOOL FindObjectTwinInList(HLIST, HPATH, PHNODE);
  720. extern BOOL EnumTwins(HBRFCASE, ENUMTWINSPROC, LPARAM, PHTWIN);
  721. extern BOOL IsValidHTWIN(HTWIN);
  722. extern BOOL IsValidHTWINFAMILY(HTWINFAMILY);
  723. extern BOOL IsValidHOBJECTTWIN(HOBJECTTWIN);
  724. /*
  725. * foldtwin.h - Folder twin ADT description.
  726. */
  727. /* Prototypes
  728. *************/
  729. /* foldtwin.c */
  730. extern BOOL CreateFolderPairPtrArray(PHPTRARRAY);
  731. extern void DestroyFolderPairPtrArray(HPTRARRAY);
  732. extern TWINRESULT MyTranslateFolder(HBRFCASE, HPATH, HPATH);
  733. extern BOOL IsValidHFOLDERTWIN(HFOLDERTWIN);
  734. /*
  735. * db.c - Twin database module description.
  736. */
  737. /* Types
  738. ********/
  739. /* database header version numbers */
  740. #define HEADER_MAJOR_VER (0x0001)
  741. #define HEADER_MINOR_VER (0x0005)
  742. /* old (but supported) version numbers */
  743. #define HEADER_M8_MINOR_VER (0x0004)
  744. typedef struct _dbversion
  745. {
  746. DWORD dwMajorVer;
  747. DWORD dwMinorVer;
  748. }
  749. DBVERSION;
  750. DECLARE_STANDARD_TYPES(DBVERSION);
  751. /* Prototypes
  752. *************/
  753. /* db.c */
  754. extern TWINRESULT WriteTwinDatabase(HCACHEDFILE, HBRFCASE);
  755. extern TWINRESULT ReadTwinDatabase(HBRFCASE, HCACHEDFILE);
  756. extern TWINRESULT WriteDBSegmentHeader(HCACHEDFILE, LONG, PCVOID, UINT);
  757. extern TWINRESULT TranslateFCRESULTToTWINRESULT(FCRESULT);
  758. /* path.c */
  759. extern TWINRESULT WritePathList(HCACHEDFILE, HPATHLIST);
  760. extern TWINRESULT ReadPathList(HCACHEDFILE, HPATHLIST, PHHANDLETRANS);
  761. /* brfcase.c */
  762. extern TWINRESULT WriteBriefcaseInfo(HCACHEDFILE, HBRFCASE);
  763. extern TWINRESULT ReadBriefcaseInfo(HCACHEDFILE, HBRFCASE, HHANDLETRANS);
  764. /* string.c */
  765. extern TWINRESULT WriteStringTable(HCACHEDFILE, HSTRINGTABLE);
  766. extern TWINRESULT ReadStringTable(HCACHEDFILE, HSTRINGTABLE, PHHANDLETRANS);
  767. /* twin.c */
  768. extern TWINRESULT WriteTwinFamilies(HCACHEDFILE, HPTRARRAY);
  769. extern TWINRESULT ReadTwinFamilies(HCACHEDFILE, HBRFCASE, PCDBVERSION, HHANDLETRANS, HHANDLETRANS);
  770. /* foldtwin.c */
  771. extern TWINRESULT WriteFolderPairList(HCACHEDFILE, HPTRARRAY);
  772. extern TWINRESULT ReadFolderPairList(HCACHEDFILE, HBRFCASE, HHANDLETRANS, HHANDLETRANS);
  773. /*
  774. * stub.h - Stub ADT description.
  775. */
  776. /* Types
  777. ********/
  778. /* stub types */
  779. typedef enum _stubtype
  780. {
  781. ST_OBJECTTWIN,
  782. ST_TWINFAMILY,
  783. ST_FOLDERPAIR
  784. }
  785. STUBTYPE;
  786. DECLARE_STANDARD_TYPES(STUBTYPE);
  787. /* stub flags */
  788. typedef enum _stubflags
  789. {
  790. /* This stub was marked for deletion while it was locked. */
  791. STUB_FL_UNLINKED = 0x0001,
  792. /* This stub has already been used for some operation. */
  793. STUB_FL_USED = 0x0002,
  794. /*
  795. * The file stamp of this object twin stub is valid. (Only used for object
  796. * twins to cache file stamp from folder twin expansion for RECNODE
  797. * creation.)
  798. */
  799. STUB_FL_FILE_STAMP_VALID = 0x0004,
  800. /*
  801. * This twin family stub or folder twin stub is in the process of being
  802. * deleted. (Only used for twin families and folder twins.)
  803. */
  804. STUB_FL_BEING_DELETED = 0x0008,
  805. /*
  806. * This folder twin stub is in the process of being translated. (Only used
  807. * for folder twins.)
  808. */
  809. STUB_FL_BEING_TRANSLATED = 0x0010,
  810. /*
  811. * This object twin stub was explicitly added a an object twin through
  812. * AddObjectTwin(). (Only used for object twins.)
  813. */
  814. STUB_FL_FROM_OBJECT_TWIN = 0x0100,
  815. /*
  816. * This object twin stub was not reconciled the last time its twin family
  817. * was reconciled, and some members of the twin family were known to have
  818. * changed. (Only used for object twins.)
  819. */
  820. STUB_FL_NOT_RECONCILED = 0x0200,
  821. /*
  822. * The subtree of the root folder of this folder twin stub is to be included
  823. * in reconciliation. (Only used for folder twins.)
  824. */
  825. STUB_FL_SUBTREE = 0x0400,
  826. /*
  827. * The object twins in this twin family are pending deletion because an
  828. * object twin was deleted, and no object twins have changed since that
  829. * object twins was deleted. This folder twin is pending deletion because
  830. * its folder root is last known deleted. (Only used for twin families and
  831. * folder twins.)
  832. */
  833. STUB_FL_DELETION_PENDING = 0x0800,
  834. /*
  835. * The client indicated that this object twin should not be deleted. (Only
  836. * used for object twins.)
  837. */
  838. STUB_FL_KEEP = 0x1000,
  839. /* stub flag combinations */
  840. ALL_STUB_FLAGS = (STUB_FL_UNLINKED |
  841. STUB_FL_USED |
  842. STUB_FL_FILE_STAMP_VALID |
  843. STUB_FL_BEING_DELETED |
  844. STUB_FL_BEING_TRANSLATED |
  845. STUB_FL_FROM_OBJECT_TWIN |
  846. STUB_FL_NOT_RECONCILED |
  847. STUB_FL_SUBTREE |
  848. STUB_FL_DELETION_PENDING |
  849. STUB_FL_KEEP),
  850. ALL_OBJECT_TWIN_FLAGS = (STUB_FL_UNLINKED |
  851. STUB_FL_USED |
  852. STUB_FL_FILE_STAMP_VALID |
  853. STUB_FL_NOT_RECONCILED |
  854. STUB_FL_FROM_OBJECT_TWIN |
  855. STUB_FL_KEEP),
  856. ALL_TWIN_FAMILY_FLAGS = (STUB_FL_UNLINKED |
  857. STUB_FL_USED |
  858. STUB_FL_BEING_DELETED |
  859. STUB_FL_DELETION_PENDING),
  860. ALL_FOLDER_TWIN_FLAGS = (STUB_FL_UNLINKED |
  861. STUB_FL_USED |
  862. STUB_FL_BEING_DELETED |
  863. STUB_FL_BEING_TRANSLATED |
  864. STUB_FL_SUBTREE |
  865. STUB_FL_DELETION_PENDING),
  866. /* bit mask used to save stub flags in briefcase database */
  867. DB_STUB_FLAGS_MASK = 0xff00
  868. }
  869. STUBFLAGS;
  870. /*
  871. * common stub - These fields must appear at the start of TWINFAMILY,
  872. * OBJECTTWIN, and FOLDERPAIR in the same order.
  873. */
  874. typedef struct _stub
  875. {
  876. /* structure tag */
  877. STUBTYPE st;
  878. /* lock count */
  879. ULONG ulcLock;
  880. /* flags */
  881. DWORD dwFlags;
  882. }
  883. STUB;
  884. DECLARE_STANDARD_TYPES(STUB);
  885. /* object twin family */
  886. typedef struct _twinfamily
  887. {
  888. /* common stub */
  889. STUB stub;
  890. /* handle to name string */
  891. HSTRING hsName;
  892. /* handle to list of object twins */
  893. HLIST hlistObjectTwins;
  894. /* handle to parent briefcase */
  895. HBRFCASE hbr;
  896. }
  897. TWINFAMILY;
  898. DECLARE_STANDARD_TYPES(TWINFAMILY);
  899. /* object twin */
  900. typedef struct _objecttwin
  901. {
  902. /* common stub */
  903. STUB stub;
  904. /* handle to folder path */
  905. HPATH hpath;
  906. /* file stamp at last reconciliation time */
  907. FILESTAMP fsLastRec;
  908. /* pointer to parent twin family */
  909. PTWINFAMILY ptfParent;
  910. /* source folder twins count */
  911. ULONG ulcSrcFolderTwins;
  912. /*
  913. * current file stamp, only valid if STUB_FL_FILE_STAMP_VALID is set in
  914. * stub's flags
  915. */
  916. FILESTAMP fsCurrent;
  917. }
  918. OBJECTTWIN;
  919. DECLARE_STANDARD_TYPES(OBJECTTWIN);
  920. /* folder pair data */
  921. typedef struct _folderpairdata
  922. {
  923. /* handle to name of included objects - may contain wildcards */
  924. HSTRING hsName;
  925. /* attributes to match */
  926. DWORD dwAttributes;
  927. /* handle to parent briefcase */
  928. HBRFCASE hbr;
  929. }
  930. FOLDERPAIRDATA;
  931. DECLARE_STANDARD_TYPES(FOLDERPAIRDATA);
  932. /* folder pair */
  933. typedef struct _folderpair
  934. {
  935. /* common stub */
  936. STUB stub;
  937. /* handle to folder path */
  938. HPATH hpath;
  939. /* pointer to folder pair data */
  940. PFOLDERPAIRDATA pfpd;
  941. /* pointer to other half of folder pair */
  942. struct _folderpair *pfpOther;
  943. }
  944. FOLDERPAIR;
  945. DECLARE_STANDARD_TYPES(FOLDERPAIR);
  946. /*
  947. * EnumGeneratedObjectTwins() callback function
  948. *
  949. * Called as:
  950. *
  951. * bContinue = EnumGeneratedObjectTwinsProc(pot, pvRefData);
  952. */
  953. typedef BOOL (*ENUMGENERATEDOBJECTTWINSPROC)(POBJECTTWIN, PVOID);
  954. /*
  955. * EnumGeneratingFolderTwins() callback function
  956. *
  957. * Called as:
  958. *
  959. * bContinue = EnumGeneratingFolderTwinsProc(pfp, pvRefData);
  960. */
  961. typedef BOOL (*ENUMGENERATINGFOLDERTWINSPROC)(PFOLDERPAIR, PVOID);
  962. /* Prototypes
  963. *************/
  964. /* stub.c */
  965. extern void InitStub(PSTUB, STUBTYPE);
  966. extern TWINRESULT DestroyStub(PSTUB);
  967. extern void LockStub(PSTUB);
  968. extern void UnlockStub(PSTUB);
  969. extern DWORD GetStubFlags(PCSTUB);
  970. extern void SetStubFlag(PSTUB, DWORD);
  971. extern void ClearStubFlag(PSTUB, DWORD);
  972. extern BOOL IsStubFlagSet(PCSTUB, DWORD);
  973. extern BOOL IsStubFlagClear(PCSTUB, DWORD);
  974. extern BOOL IsValidPCSTUB(PCSTUB);
  975. /* twin.c */
  976. extern BOOL FindObjectTwin(HBRFCASE, HPATH, LPCTSTR, PHNODE);
  977. extern BOOL CreateObjectTwin(PTWINFAMILY, HPATH, POBJECTTWIN *);
  978. extern TWINRESULT UnlinkObjectTwin(POBJECTTWIN);
  979. extern void DestroyObjectTwin(POBJECTTWIN);
  980. extern TWINRESULT UnlinkTwinFamily(PTWINFAMILY);
  981. extern void MarkTwinFamilyNeverReconciled(PTWINFAMILY);
  982. extern void MarkObjectTwinNeverReconciled(PVOID);
  983. extern void DestroyTwinFamily(PTWINFAMILY);
  984. extern void MarkTwinFamilyDeletionPending(PTWINFAMILY);
  985. extern void UnmarkTwinFamilyDeletionPending(PTWINFAMILY);
  986. extern BOOL IsTwinFamilyDeletionPending(PCTWINFAMILY);
  987. extern void ClearTwinFamilySrcFolderTwinCount(PTWINFAMILY);
  988. extern BOOL EnumObjectTwins(HBRFCASE, ENUMGENERATEDOBJECTTWINSPROC, PVOID);
  989. extern BOOL ApplyNewFolderTwinsToTwinFamilies(PCFOLDERPAIR);
  990. extern TWINRESULT TransplantObjectTwin(POBJECTTWIN, HPATH, HPATH);
  991. extern BOOL IsFolderObjectTwinName(LPCTSTR);
  992. extern BOOL IsValidPCTWINFAMILY(PCTWINFAMILY);
  993. extern BOOL IsValidPCOBJECTTWIN(PCOBJECTTWIN);
  994. /* foldtwin.c */
  995. extern void LockFolderPair(PFOLDERPAIR);
  996. extern void UnlockFolderPair(PFOLDERPAIR);
  997. extern TWINRESULT UnlinkFolderPair(PFOLDERPAIR);
  998. extern void DestroyFolderPair(PFOLDERPAIR);
  999. extern BOOL ApplyNewObjectTwinsToFolderTwins(HLIST);
  1000. extern BOOL BuildPathForMatchingObjectTwin(PCFOLDERPAIR, PCOBJECTTWIN, HPATHLIST, PHPATH);
  1001. extern BOOL EnumGeneratedObjectTwins(PCFOLDERPAIR, ENUMGENERATEDOBJECTTWINSPROC, PVOID);
  1002. extern BOOL EnumGeneratingFolderTwins(PCOBJECTTWIN, ENUMGENERATINGFOLDERTWINSPROC, PVOID, PULONG);
  1003. extern BOOL FolderTwinGeneratesObjectTwin(PCFOLDERPAIR, HPATH, LPCTSTR);
  1004. extern BOOL IsValidPCFOLDERPAIR(PCFOLDERPAIR);
  1005. extern void RemoveObjectTwinFromAllFolderPairs(POBJECTTWIN);
  1006. /* expandft.c */
  1007. extern BOOL ClearStubFlagWrapper(PSTUB, PVOID);
  1008. extern BOOL SetStubFlagWrapper(PSTUB, PVOID);
  1009. extern TWINRESULT ExpandIntersectingFolderTwins(PFOLDERPAIR, CREATERECLISTPROC, LPARAM);
  1010. extern TWINRESULT TryToGenerateObjectTwin(HBRFCASE, HPATH, LPCTSTR, PBOOL, POBJECTTWIN *);
  1011. /*
  1012. * volume.h - Volume ADT module description.
  1013. */
  1014. /* Types
  1015. ********/
  1016. /* handles */
  1017. DECLARE_HANDLE(HVOLUMELIST);
  1018. DECLARE_STANDARD_TYPES(HVOLUMELIST);
  1019. DECLARE_HANDLE(HVOLUME);
  1020. DECLARE_STANDARD_TYPES(HVOLUME);
  1021. /* volume results returned by AddVolume() */
  1022. typedef enum _volumeresult
  1023. {
  1024. VR_SUCCESS,
  1025. VR_UNAVAILABLE_VOLUME,
  1026. VR_OUT_OF_MEMORY,
  1027. VR_INVALID_PATH
  1028. }
  1029. VOLUMERESULT;
  1030. DECLARE_STANDARD_TYPES(VOLUMERESULT);
  1031. /* Prototypes
  1032. *************/
  1033. /* volume.c */
  1034. extern BOOL CreateVolumeList(DWORD, HWND, PHVOLUMELIST);
  1035. extern void DestroyVolumeList(HVOLUMELIST);
  1036. extern void InvalidateVolumeListInfo(HVOLUMELIST);
  1037. void ClearVolumeListInfo(HVOLUMELIST);
  1038. extern VOLUMERESULT AddVolume(HVOLUMELIST, LPCTSTR, PHVOLUME, LPTSTR);
  1039. extern void DeleteVolume(HVOLUME);
  1040. extern COMPARISONRESULT CompareVolumes(HVOLUME, HVOLUME);
  1041. extern BOOL CopyVolume(HVOLUME, HVOLUMELIST, PHVOLUME);
  1042. extern BOOL IsVolumeAvailable(HVOLUME);
  1043. extern void GetVolumeRootPath(HVOLUME, LPTSTR);
  1044. #ifdef DEBUG
  1045. extern LPTSTR DebugGetVolumeRootPath(HVOLUME, LPTSTR);
  1046. extern ULONG GetVolumeCount(HVOLUMELIST);
  1047. #endif
  1048. extern void DescribeVolume(HVOLUME, PVOLUMEDESC);
  1049. extern TWINRESULT WriteVolumeList(HCACHEDFILE, HVOLUMELIST);
  1050. extern TWINRESULT ReadVolumeList(HCACHEDFILE, HVOLUMELIST, PHHANDLETRANS);
  1051. extern BOOL IsValidHVOLUME(HVOLUME);
  1052. extern BOOL IsValidHVOLUMELIST(HVOLUMELIST);
  1053. /*
  1054. * sortsrch.c - Generic array sorting and searching description.
  1055. */
  1056. /* Types
  1057. ********/
  1058. /* array element comparison callback function */
  1059. typedef COMPARISONRESULT (*COMPARESORTEDELEMSPROC)(PCVOID, PCVOID);
  1060. /* Prototypes
  1061. *************/
  1062. /* sortsrch.c */
  1063. extern void HeapSort(PVOID, LONG, size_t, COMPARESORTEDELEMSPROC, PVOID);
  1064. extern BOOL BinarySearch(PVOID, LONG, size_t, COMPARESORTEDELEMSPROC, PCVOID, PLONG);
  1065. #define WINSHELLAPI DECLSPEC_IMPORT
  1066. WINSHELLAPI BOOL SheShortenPathA(LPSTR pPath, BOOL bShorten);
  1067. WINSHELLAPI BOOL SheShortenPathW(LPWSTR pPath, BOOL bShorten);
  1068. #ifdef UNICODE
  1069. #define SheShortenPath SheShortenPathW
  1070. #else
  1071. #define SheShortenPath SheShortenPathA
  1072. #endif // !UNICODE
  1073. typedef struct {
  1074. HPATHLIST PathList;
  1075. HPATH Path;
  1076. TCHAR PathString[MAX_PATH];
  1077. ULONG Max;
  1078. ULONG Index;
  1079. } BRFPATH_ENUM, *PBRFPATH_ENUM;
  1080. extern POOLHANDLE g_BrfcasePool;
  1081. BOOL
  1082. EnumFirstBrfcasePath (
  1083. IN HBRFCASE Brfcase,
  1084. OUT PBRFPATH_ENUM e
  1085. );
  1086. BOOL
  1087. EnumNextBrfcasePath (
  1088. IN OUT PBRFPATH_ENUM e
  1089. );
  1090. BOOL
  1091. ReplaceBrfcasePath (
  1092. IN PBRFPATH_ENUM PathEnum,
  1093. IN PCTSTR NewPath
  1094. );