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.

1324 lines
35 KiB

  1. /************************************************/
  2. /* Common Library Component public include file */
  3. /************************************************/
  4. #if !defined (COMSTF_INCLUDED )
  5. #define COMSTF_INCLUDED
  6. #include <windows.h>
  7. // avoid warnings on every file from including stdlib.h
  8. #if defined(min)
  9. #undef min
  10. #undef max
  11. #endif /* min */
  12. #include <port1632.h>
  13. #define _dt_begin_ignore
  14. #define _dt_end_ignore
  15. _dt_begin_ignore
  16. #define _dt_public
  17. #define _dt_private
  18. #define _dt_hidden
  19. #define _dt_system(s)
  20. #define _dt_subsystem(s)
  21. _dt_end_ignore
  22. #include <ids.h>
  23. _dt_system(Common Library)
  24. /*
  25. ** Global variable macro for DLL portability
  26. */
  27. _dt_public
  28. #define GLOBAL(x) (x)
  29. /* standard datatypes
  30. */
  31. _dt_public typedef BYTE * PB;
  32. _dt_public typedef unsigned CB;
  33. _dt_public typedef LONG * PLONG_STF;
  34. /* BOOLean datatype
  35. */
  36. #define fFalse ((BOOL)0)
  37. #define fTrue ((BOOL)1)
  38. /* To avoid compiler warnings for unused parameters
  39. */
  40. #define Unused(x) (x)=(x)
  41. /* If new GRCs are added, they should as well be handled
  42. in EercErrorHandler() in ERROR1.C */
  43. /*
  44. ** General Return Code datatype
  45. */
  46. typedef USHORT GRC;
  47. #define grcFirst ((GRC)0)
  48. #define grcLast ((GRC)57)
  49. #define grcOkay ((GRC)0)
  50. #define grcNotOkay ((GRC)1)
  51. #define grcOutOfMemory ((GRC)2)
  52. #define grcInvalidStruct ((GRC)3)
  53. #define grcOpenFileErr ((GRC)4)
  54. #define grcCreateFileErr ((GRC)5)
  55. #define grcReadFileErr ((GRC)6)
  56. #define grcWriteFileErr ((GRC)7)
  57. #define grcRemoveFileErr ((GRC)8)
  58. #define grcRenameFileErr ((GRC)9)
  59. #define grcReadDiskErr ((GRC)10)
  60. #define grcCreateDirErr ((GRC)11)
  61. #define grcRemoveDirErr ((GRC)12)
  62. #define grcBadINF ((GRC)13)
  63. #define grcINFStartNonSection ((GRC)14)
  64. #define grcINFBadSectionLabel ((GRC)15)
  65. #define grcINFBadLine ((GRC)16)
  66. #define grcINFBadKey ((GRC)17)
  67. #define grcINFContainsZeros ((GRC)18)
  68. #define grcTooManyINFSections ((GRC)19)
  69. #define grcCloseFileErr ((GRC)20)
  70. #define grcChangeDirErr ((GRC)21)
  71. #define grcINFSrcDescrSect ((GRC)22)
  72. #define grcTooManyINFKeys ((GRC)23)
  73. #define grcWriteInf ((GRC)24)
  74. #define grcInvalidPoer ((GRC)25)
  75. #define grcINFMissingLine ((GRC)26)
  76. #define grcINFBadFDLine ((GRC)27)
  77. #define grcINFBadRSLine ((GRC)28)
  78. #define grcBadInstallLine ((GRC)29)
  79. #define grcMissingDidErr ((GRC)30)
  80. #define grcInvalidPathErr ((GRC)31)
  81. #define grcWriteIniValueErr ((GRC)32)
  82. #define grcReplaceIniValueErr ((GRC)33)
  83. #define grcIniValueTooLongErr ((GRC)34)
  84. #define grcDDEInitErr ((GRC)35)
  85. #define grcDDEExecErr ((GRC)36)
  86. #define grcBadWinExeFileFormatErr ((GRC)37)
  87. #define grcResourceTooLongErr ((GRC)38)
  88. #define grcMissingSysIniSectionErr ((GRC)39)
  89. #define grcDecompGenericErr ((GRC)40)
  90. #define grcDecompUnknownAlgErr ((GRC)41)
  91. #define grcDecompBadHeaderErr ((GRC)42)
  92. #define grcReadFile2Err ((GRC)43)
  93. #define grcWriteFile2Err ((GRC)44)
  94. #define grcWriteInf2Err ((GRC)45)
  95. #define grcMissingResourceErr ((GRC)46)
  96. #define grcLibraryLoadErr ((GRC)47)
  97. #define grcBadLibEntry ((GRC)48)
  98. #define grcApplet ((GRC)49)
  99. #define grcExternal ((GRC)50)
  100. #define grcSpawn ((GRC)51)
  101. #define grcDiskFull ((GRC)52)
  102. #define grcDDEAddItem ((GRC)53)
  103. #define grcDDERemoveItem ((GRC)54)
  104. #define grcINFMissingSection ((GRC)55)
  105. #define grcRunTimeParseErr ((GRC)56)
  106. #define grcOpenSameFileErr ((GRC)57)
  107. /**************************************/
  108. /* common library function prototypes */
  109. /**************************************/
  110. _dt_subsystem(String Handling)
  111. /* CHaracter Physical representation datatype
  112. */
  113. _dt_public typedef BYTE CHP;
  114. _dt_public typedef CHP * PCHP;
  115. _dt_public typedef CB CCHP;
  116. _dt_public
  117. #define CbFromCchp(cchp) ((CB)(cchp))
  118. /* CHaracter Logical representation datatype
  119. */
  120. _dt_public typedef CHP CHL;
  121. _dt_public typedef CHL * PCHL;
  122. _dt_public typedef PCHL * PPCHL;
  123. _dt_public typedef CB CCHL;
  124. _dt_public typedef CB ICHL;
  125. _dt_hidden
  126. #define cbFullPathMax ((CB)(MAX_PATH-1))
  127. _dt_hidden
  128. #define cchlFullPathMax ((CCHL)(MAX_PATH-1))
  129. _dt_hidden
  130. #define cchlFullDirMax cchlFullPathMax
  131. _dt_hidden
  132. #define cchpFullPathMax ((CCHP)(MAX_PATH-1))
  133. _dt_public
  134. #define cbFullPathBuf ((CB)(cbFullPathMax + 1))
  135. _dt_public
  136. #define cchlFullPathBuf ((CCHL)(cchlFullPathMax + 1))
  137. _dt_public
  138. #define cchpFullPathBuf ((CCHP)(cchpFullPathMax + 1))
  139. /* String Zero terminated datatype
  140. */
  141. _dt_public typedef PCHL SZ;
  142. _dt_hidden
  143. #define PSZ PPSZ
  144. _dt_public typedef PPCHL PSZ;
  145. _dt_public typedef PPCHL RGSZ;
  146. /* Comparison Return Code datatype
  147. */
  148. _dt_public typedef INT CRC;
  149. _dt_public
  150. #define crcError ((CRC)(-2))
  151. _dt_public
  152. #define crcEqual ((CRC)0)
  153. _dt_public
  154. #define crcFirstHigher ((CRC)1)
  155. _dt_public
  156. #define crcSecondHigher ((CRC)(-1))
  157. /* String manipulation routines */
  158. extern SZ APIENTRY SzDupl(SZ);
  159. extern CRC APIENTRY CrcStringCompare(SZ, SZ);
  160. extern CRC APIENTRY CrcStringCompareI(SZ, SZ);
  161. extern SZ APIENTRY SzLastChar(SZ);
  162. /*
  163. ** Purpose:
  164. ** Advances a string pointer to the beginning of the next valid
  165. ** character. This may include skipping a double-byte character.
  166. ** Arguments:
  167. ** sz: the string pointer to advance. It can be NULL or empty, or else
  168. ** it must point at the beginning of a valid character.
  169. ** Returns:
  170. ** NULL if sz was NULL.
  171. ** sz unchanged if it was an empty string (*sz == '\0').
  172. ** sz advanced past the current character and to the beginning of the
  173. ** next valid character.
  174. */
  175. _dt_public
  176. #define SzNextChar(sz) ((SZ)AnsiNext(sz))
  177. /*
  178. ** Purpose:
  179. ** Retreats a string pointer to the beginning of the previous valid
  180. ** character. This may include skipping a double-byte character.
  181. ** Arguments:
  182. ** szStart: string pointer to the beginning of a valid character that
  183. ** equals or preceeds the character szCur.
  184. ** szCur: string pointer to retreat. It can be NULL or empty, or
  185. ** can point to any byte in a valid character.
  186. ** Returns:
  187. ** NULL if szCur was NULL.
  188. ** sz unchanged if szStart was NULL or if szCur equaled szStart.
  189. ** sz retreated past the current character and to the beginning of the
  190. ** previous valid character.
  191. */
  192. _dt_public
  193. #define SzPrevChar(szStart, szCur) ((SZ)AnsiPrev(szStart,szCur))
  194. /*
  195. ** Purpose:
  196. ** Copies a string from one buffer to another.
  197. ** Arguments:
  198. ** szDst: string pointer to destination buffer. This can be NULL or
  199. ** else it must contain enough storage to copy szSrc with its
  200. ** terminating zero character.
  201. ** szSrc: string pointer to source buffer. This can be NULL or else
  202. ** must point to a zero terminated string (can be empty).
  203. ** Returns:
  204. ** NULL if either szDst or szSrc is NULL.
  205. ** szDst signifying the operation succeeded.
  206. */
  207. _dt_public
  208. #define SzStrCopy(szDst, szSrc) ((SZ)lstrcpy((LPSTR)szDst,(LPSTR)szSrc))
  209. /*
  210. ** Purpose:
  211. ** Appends a string from one buffer to another.
  212. ** Arguments:
  213. ** szDst: string pointer to destination buffer. This can be NULL or
  214. ** else it must contain a zero terminated string (can be empty)
  215. ** and enough storage to append szSrc with its terminating zero
  216. ** character.
  217. ** szSrc: string pointer to source buffer. This can be NULL or else
  218. ** must point to a zero terminated string (can be empty).
  219. ** Returns:
  220. ** NULL if either szDst or szSrc is NULL.
  221. ** szDst signifying the operation succeeded.
  222. */
  223. _dt_public
  224. #define SzStrCat(szDst, szSrc) ((SZ)lstrcat((LPSTR)szDst,(LPSTR)szSrc))
  225. /*
  226. ** Purpose:
  227. ** Calculates the number of Physical Characters that a string occupies
  228. ** (not including the terminating zero character).
  229. ** Arguments:
  230. ** sz: string whose length is to be calculated.
  231. ** Returns:
  232. ** 0 if sz was NULL.
  233. ** The number of Physical Characters from the beginning of the string
  234. ** to its terminating zero character.
  235. */
  236. _dt_public
  237. #define CchpStrLen(sz) ((CCHP)CbStrLen(sz))
  238. /*
  239. ** Purpose:
  240. ** Calculates the number of Logical Characters that a string occupies
  241. ** (not including the terminating zero character).
  242. ** Arguments:
  243. ** sz: string whose length is to be calculated.
  244. ** Returns:
  245. ** 0 if sz was NULL.
  246. ** The number of Logical Characters from the beginning of the string
  247. ** to its terminating zero character.
  248. */
  249. _dt_public
  250. #define CchlStrLen(sz) ((CCHL)CbStrLen(sz))
  251. /*
  252. ** Purpose:
  253. ** Calculates the number of bytes that a string occupies (not including
  254. ** the terminating zero character).
  255. ** Arguments:
  256. ** sz: string whose length is to be calculated.
  257. ** Returns:
  258. ** 0 if sz was NULL.
  259. ** The number of bytes from the beginning of the string to its
  260. ** terminating zero character.
  261. */
  262. _dt_public
  263. #define CbStrLen(sz) ((CB)lstrlen((LPSTR)sz))
  264. /*
  265. ** Purpose:
  266. ** Determines whether the current character is a single Physical
  267. ** Character.
  268. ** Arguments:
  269. ** sz: string pointer which can be NULL, empty, or pointing to the
  270. ** beginning of a valid character.
  271. ** Returns:
  272. ** fFalse if sz is NULL or points to the beginning of a multiple
  273. ** Physical Character character.
  274. ** fTrue if sz is empty or points to the beginning of a single
  275. ** Physical Character character.
  276. */
  277. _dt_public
  278. #define FSingleByteCharSz(sz) ((BOOL)((sz)!=(SZ)NULL))
  279. /*
  280. ** Purpose:
  281. ** Determines whether a character is an End-Of-Line character.
  282. ** Arguments:
  283. ** chp: Physical Character (eg a single byte Logical Character).
  284. ** Returns:
  285. ** fFalse if chp is not either a '\n' or a '\r' character.
  286. ** fTrue if chp is either a '\n' or a '\r' character.
  287. */
  288. _dt_public
  289. #define FEolChp(chp) ((BOOL)((chp) == '\n' || (chp) == '\r'))
  290. /*
  291. ** Purpose:
  292. ** Determines whether a character is whitespace.
  293. ** Arguments:
  294. ** chp: Physical Character (eg a single byte Logical Character).
  295. ** Returns:
  296. ** fFalse if chp is not either a space or a tab character.
  297. ** fTrue if chp is either a space or a tab character.
  298. */
  299. _dt_public
  300. #define FWhiteSpaceChp(chp) ((BOOL)((chp) == ' ' || (chp) == '\t'))
  301. /*
  302. ** Purpose:
  303. ** Converts a zero-terminated string to upper case.
  304. ** Arguments:
  305. ** sz: the string to convert to upper case. sz must be non-NULL though
  306. ** it can be empty.
  307. ** Returns:
  308. ** A pointer to the converted string.
  309. */
  310. _dt_public
  311. #define SzStrUpper(sz) (SZ)(AnsiUpper((LPSTR)(sz)))
  312. /*
  313. ** Purpose:
  314. ** Converts a zero-terminated string to lower case.
  315. ** Arguments:
  316. ** sz: the string to convert to lower case. sz must be non-NULL though
  317. ** it can be empty.
  318. ** Returns:
  319. ** A pointer to the converted string.
  320. */
  321. _dt_public
  322. #define SzStrLower(sz) (SZ)(AnsiLower((LPSTR)(sz)))
  323. _dt_subsystem(Memory Handling)
  324. #define cbSymbolMax (64*1024)
  325. #define cbAllocMax (65520*5)
  326. #define cbIntStrMax 16
  327. /* Memory Handling routines */
  328. #if defined(DBG) && defined(MEMORY_CHECK)
  329. PVOID MyMalloc(unsigned, char *, int) malloc
  330. PVOID MyRealloc(PVOID,unsigned, char *, int);
  331. VOID MyFree(PVOID, char *, int);
  332. VOID MemCheck(VOID);
  333. VOID MemDump(VOID);
  334. #define PbAlloc(cb) ((PB)MyMalloc((unsigned)(cb), __FILE__, __LINE__ ))
  335. #define PbRealloc(pb,cbn,cbo) ((PB)MyRealloc(pb,(unsigned)(cbn), __FILE__, __LINE__))
  336. #define FFree(pb,cb) (MyFree(pb, __FILE__, __LINE__),TRUE)
  337. #define MemChk() MemCheck()
  338. #else // ! (DBG && MEMORY_CHECK)
  339. PVOID MyMalloc(unsigned);
  340. PVOID MyRealloc(PVOID,unsigned);
  341. VOID MyFree(PVOID);
  342. #define PbAlloc(cb) ((PB)MyMalloc((unsigned)(cb)))
  343. #define PbRealloc(pb,cbn,cbo) ((PB)MyRealloc(pb,(unsigned)(cbn)))
  344. #define FFree(pb,cb) (MyFree(pb),TRUE)
  345. #define MemChk()
  346. #endif // DBG && MEMORY_CHECK
  347. /*
  348. ** Purpose:
  349. ** Frees the memory used by an sz. This assumes the terminating
  350. ** zero occupies the final byte of the allocated buffer.
  351. ** Arguments:
  352. ** sz: the buffer to free. this must be non-NULL though it can point
  353. ** at an empty string.
  354. ** Returns:
  355. ** fTrue if the Free() operation succeeds.
  356. ** fFalse if the Free() operation fails.
  357. */
  358. _dt_public
  359. #define FFreeSz(sz) FFree((PB)(sz),CbStrLen(sz)+1)
  360. /*
  361. ** Purpose:
  362. ** Shrinks a buffer to exactly fit a string.
  363. ** Arguments:
  364. ** sz: the string for which the buffer should shrink to. sz must be
  365. ** non-NULL though it can be empty.
  366. ** cb: the size in bytes for the buffer that was originally allocated.
  367. ** cb must be greater than or equal to CbStrLen(sz) + 1.
  368. ** Returns:
  369. ** A pointer to the original string if the Realloc() operation succeeds.
  370. ** NULL if the Realloc() operation fails.
  371. */
  372. _dt_public
  373. #define SzReallocSz(sz,cb) (SZ)(PbRealloc((PB)(sz),CbStrLen(sz)+1,cb))
  374. #ifdef MEM_STATS
  375. /* Memory Stats Flags */
  376. _dt_private
  377. #define wModeMemStatNone 0x0000
  378. _dt_private
  379. #define wModeMemStatAll 0xFFFF
  380. _dt_private
  381. #define wModeMemStatAlloc 0x0001
  382. _dt_private
  383. #define wModeMemStatFree 0x0002
  384. _dt_private
  385. #define wModeMemStatRealloc 0x0004
  386. _dt_private
  387. #define wModeMemStatSysAlloc 0x0008
  388. _dt_private
  389. #define wModeMemStatFLAlloc 0x0010
  390. _dt_private
  391. #define wModeMemStatFLFree 0x0020
  392. _dt_private
  393. #define wModeMemStatFLRealloc 0x0040
  394. _dt_private
  395. #define wModeMemStatHistAlloc 0x0080
  396. _dt_private
  397. #define wModeMemStatHistFree 0x0100
  398. _dt_private
  399. #define wModeMemStatGarbage 0x0200
  400. extern BOOL APIENTRY FOpenMemStats(SZ, WORD);
  401. extern BOOL APIENTRY FCloseMemStats(void);
  402. #endif /* MEM_STATS */
  403. _dt_subsystem(File Handling)
  404. /* Long File Address datatype
  405. */
  406. _dt_public typedef unsigned long LFA;
  407. _dt_public
  408. #define lfaSeekError ((LFA)-1)
  409. /*
  410. ** File Handle structure
  411. ** Fields:
  412. ** iDosfh: DOS file handle.
  413. ** ofstruct: OFSTRUCT used when the file was opened.
  414. */
  415. _dt_public typedef struct _fh
  416. {
  417. INT iDosfh;
  418. OFSTRUCT ofstruct;
  419. } FH;
  420. /* File Handle datatype
  421. */
  422. _dt_public typedef FH * PFH;
  423. /* Open File Mode datatype
  424. */
  425. _dt_public typedef USHORT OFM;
  426. _dt_public
  427. #define ofmExistRead ((OFM)OF_EXIST | OF_READ)
  428. _dt_public
  429. #define ofmExistReadWrite ((OFM)OF_EXIST | OF_READWRITE)
  430. // _dt_public
  431. // #define ofmRead ((OFM)OF_READ | OF_SHARE_DENY_WRITE)
  432. _dt_public
  433. #define ofmRead ((OFM)OF_READ)
  434. _dt_public
  435. #define ofmWrite ((OFM)OF_WRITE | OF_SHARE_EXCLUSIVE)
  436. _dt_public
  437. #define ofmReadWrite ((OFM)OF_READWRITE | OF_SHARE_EXCLUSIVE)
  438. _dt_public
  439. #define ofmCreate ((OFM)OF_CREATE | OF_SHARE_EXCLUSIVE)
  440. /* Seek File Mode datatype
  441. */
  442. _dt_public typedef WORD SFM;
  443. _dt_public
  444. #define sfmSet ((SFM)0)
  445. _dt_public
  446. #define sfmCur ((SFM)1)
  447. _dt_public
  448. #define sfmEnd ((SFM)2)
  449. /* File handling routines */
  450. extern PFH APIENTRY PfhOpenFile(SZ, OFM);
  451. extern BOOL APIENTRY FCloseFile(PFH);
  452. extern CB APIENTRY CbReadFile(PFH, PB, CB);
  453. extern CB APIENTRY CbWriteFile(PFH, PB, CB);
  454. extern LFA APIENTRY LfaSeekFile(PFH, LONG, SFM);
  455. extern BOOL APIENTRY FEndOfFile(PFH);
  456. extern BOOL APIENTRY FRemoveFile(SZ);
  457. extern BOOL APIENTRY FWriteSzToFile(PFH, SZ);
  458. extern BOOL APIENTRY FFileExists(SZ);
  459. extern SZ APIENTRY szGetFileName(SZ szPath);
  460. extern VOID APIENTRY FreePfh(PFH pfh);
  461. _dt_subsystem(Path Handling)
  462. /* Path manipulation routines */
  463. BOOL FMakeFATPathFromPieces(SZ, SZ, SZ, SZ, CCHP);
  464. BOOL FMakeFATPathFromDirAndSubPath(SZ, SZ, SZ, CCHP);
  465. LPSTR LocateFilenameInFullPathSpec(LPSTR);
  466. #define FValidFATDir(sz) fTrue
  467. #define FValidFATPath(sz) fTrue
  468. #define CchlValidFATSubPath(sz) CbStrLen(sz) // no checking for WIN32
  469. /*
  470. ** Purpose:
  471. ** Determines if a path is a valid FAT directory.
  472. ** Arguments:
  473. ** szDir: the directory string to check.
  474. ** Returns:
  475. ** fTrue if the szDir is a valid FAT directory.
  476. ** fFalse if the szDir is an invalid FAT directory.
  477. */
  478. _dt_public
  479. #define FValidDir(szDir) FValidFATDir(szDir)
  480. /*
  481. ** Purpose:
  482. ** Determines if a string is a valid FAT SubPath (eg subdirs and filename).
  483. ** Arguments:
  484. ** szSubPath: the SubPath string to check.
  485. ** Returns:
  486. ** zero if the string is an invalid FAT subPath.
  487. ** non-zero count of characters in sz if it is a valid FAT subPath.
  488. */
  489. _dt_public
  490. #define CchlValidSubPath(szSubPath) CchlValidFATSubPath(szSubPath)
  491. /*
  492. ** Purpose:
  493. ** Determines if a path is a valid FAT path.
  494. ** Arguments:
  495. ** szPath: the path to check.
  496. ** Returns:
  497. ** fTrue if the szPath is a valid FAT path.
  498. ** fFalse if the szPath is an invalid FAT path.
  499. */
  500. _dt_public
  501. #define FValidPath(szPath) FValidFATPath(szPath)
  502. /*
  503. ** Purpose:
  504. ** Creates a valid path from volume, path, and filename arguments
  505. ** if possible and stores it in a supplied buffer.
  506. ** Arguments:
  507. ** szVolume: string containing the volume.
  508. ** szPath: string containing the path.
  509. ** szFile: string containing the filename.
  510. ** szBuf: the buffer in which to store the newly created path.
  511. ** cchpBufMax: the maximum number of physical characters (including the
  512. ** terminating zero) that can be stored in the buffer.
  513. ** Returns:
  514. ** fTrue if a valid FAT path can be created and stored in szBuf.
  515. ** fFalse if szVolume is NULL or invalid (first character must be in the
  516. ** 'a' to 'z' or 'A' to 'Z', and the second character must be either
  517. ** a ':' or a terminating zero), if szPath is NULL or invalid (it must
  518. ** start with a '\\' and conform to 8.3 format), if szFile is NULL,
  519. ** empty or invalid (first character cannot be a '\\' and it must
  520. ** conform to 8.3 format), if szBuf is NULL, or if cchpBufMax is not
  521. ** large enough to hold the resultant path.
  522. */
  523. _dt_public
  524. #define FMakePathFromPieces(szVolume, szPath, szFile, szBuffer, cchpBufMax) \
  525. FMakeFATPathFromPieces(szVolume,szPath,szFile,szBuffer,cchpBufMax)
  526. /*
  527. ** Purpose:
  528. ** Creates a valid path from subpath, and filename arguments if possible
  529. ** and stores it in a supplied buffer.
  530. ** Arguments:
  531. ** szDir: string containing the volume and subdirs.
  532. ** szSubPath: string containing subdirs and the filename.
  533. ** szBuf: the buffer in which to store the newly created path.
  534. ** cchpBufMax: the maximum number of physical characters (including the
  535. ** terminating zero) that can be stored in the buffer.
  536. ** Returns:
  537. ** fTrue if a valid FAT path can be created and stored in szBuf.
  538. ** fFalse if szDir is NULL or invalid (first character must be in the
  539. ** 'a' to 'z' or 'A' to 'Z', the second character must be either
  540. ** a ':' or a terminating zero, and the third character must be
  541. ** a '\\' and the rest must conform to 8.3 format), if szSubPath is
  542. ** NULL, empty or invalid (first character cannot be a '\\' and it must
  543. ** conform to 8.3 format), if szBuf is NULL, or if cchpBufMax is not
  544. ** large enough to hold the resultant path.
  545. */
  546. _dt_public
  547. #define FMakePathFromDirAndSubPath(szDir, szSubPath, szBuffer, cchpBufMax) \
  548. FMakeFATPathFromDirAndSubPath(szDir,szSubPath,szBuffer,cchpBufMax)
  549. #define AssertDataSeg()
  550. #if DBG
  551. #define Assert(f) \
  552. ((f) ? (void)0 : (void)AssertSzUs(__FILE__,__LINE__))
  553. #define AssertRet(f, retVal) \
  554. {if (!(f)) {AssertSzUs(__FILE__,__LINE__); return(retVal);}}
  555. #define EvalAssert(f) \
  556. ((f) ? (void)0 : (void)AssertSzUs(__FILE__,__LINE__))
  557. #define EvalAssertRet(f, retVal) \
  558. {if (!(f)) {AssertSzUs(__FILE__,__LINE__); return(retVal);}}
  559. #define PreCondition(f, retVal) \
  560. {if (!(f)) {PreCondSzUs(__FILE__,__LINE__); return(retVal);}}
  561. #define ChkArg(f, iArg, retVal) \
  562. {if (!(f)) {BadParamUs(iArg, __FILE__, __LINE__); return(retVal);}}
  563. #else
  564. #define Assert(f) ((void)0)
  565. #define AssertRet(f, retVal) ((void)0)
  566. #define EvalAssert(f) ((void)(f))
  567. #define EvalAssertRet(f, retVal) ((void)(f))
  568. #define PreCondition(f, retVal) ((void)0)
  569. #define ChkArg(f, iArg, retVal) ((void)0)
  570. #endif
  571. /*
  572. ** Purpose:
  573. ** Generates a task modal message box.
  574. ** Arguments:
  575. ** szTitle: title for message box.
  576. ** szText: text for message box.
  577. ** Returns:
  578. ** none
  579. */
  580. _dt_private
  581. #define MessBoxSzSz(szTitle, szText) \
  582. MessageBox((HWND)NULL, (LPSTR)szText, (LPSTR)szTitle, \
  583. MB_TASKMODAL | MB_ICONHAND | MB_OK)
  584. #define AssertSzUs(x, y) TRUE
  585. #define PreCondSzUs(x, y) TRUE
  586. #define BadParamUs(x, y, z) TRUE
  587. _dt_subsystem(INF Handling)
  588. /*
  589. ** Inf Data Block structure
  590. **
  591. ** Fields:
  592. ** pidbNext: next IDB in linked list.
  593. ** pchpBuffer: character buffer.
  594. ** cchpBuffer: number of useful characters in pchpBuffer.
  595. ** cchpAllocated: number of characters actually allocated with
  596. ** pchpBuffer. May be zero.
  597. */
  598. _dt_public typedef struct _idb
  599. {
  600. struct _idb * pidbNext;
  601. PCHP pchpBuffer;
  602. CCHP cchpBuffer;
  603. CCHP cchpAllocated;
  604. } IDB;
  605. /* Inf Data Block datatypes
  606. */
  607. _dt_public typedef IDB * PIDB;
  608. _dt_public typedef PIDB * PPIDB;
  609. /*
  610. The following equate is used because of a situation like
  611. "abcd"+
  612. "efgh"
  613. When parsed, this will be "abcd""efgh" -- is this two strings or
  614. one string with a double quote in the middle? If it's the latter,
  615. we'll actually store "abcd.efgh" where . is DOUBLE_QUOTE.
  616. */
  617. #define DOUBLE_QUOTE '\001'
  618. #define INFLINE_SECTION 0x01
  619. #define INFLINE_KEY 0x02
  620. /* INF File Handling routines */
  621. GRC APIENTRY GrcOpenInf(SZ IniFileName, PVOID pInfTempInfo);
  622. BOOL APIENTRY FFreeInf(void);
  623. UINT APIENTRY CKeysFromInfSection(SZ Section, BOOL IncludeAllLines);
  624. BOOL APIENTRY FKeyInInfLine(INT Line);
  625. RGSZ APIENTRY RgszFromInfLineFields(INT Line,UINT StartField,UINT NumFields);
  626. BOOL APIENTRY FFreeRgsz(RGSZ);
  627. UINT APIENTRY CFieldsInInfLine(INT Line);
  628. INT APIENTRY FindInfSectionLine(SZ Section);
  629. INT APIENTRY FindNthLineFromInfSection(SZ Section,UINT n);
  630. INT APIENTRY FindLineFromInfSectionKey(SZ Section,SZ Key);
  631. INT APIENTRY FindNextLineFromInf(INT Line);
  632. SZ APIENTRY SzGetNthFieldFromInfLine(INT Line,UINT n);
  633. SZ APIENTRY SzGetNthFieldFromInfSectionKey(SZ Section,SZ Key,UINT n);
  634. BOOL APIENTRY FUpdateInfSectionUsingSymTab(SZ);
  635. SZ APIENTRY InterpretField(SZ);
  636. #define RgszFromInfScriptLine(Line,NumFields) \
  637. RgszFromInfLineFields(Line,1,NumFields)
  638. #define FindFirstLineFromInfSection(Section) FindNthLineFromInfSection(Section,1)
  639. /*
  640. ** Option-Element Flags datatype for SFD
  641. */
  642. _dt_public typedef WORD OEF;
  643. _dt_public
  644. #define oefVital ((OEF)0x0001)
  645. _dt_public
  646. #define oefCopy ((OEF)0x0002)
  647. _dt_public
  648. #define oefUndo ((OEF)0x0004)
  649. _dt_public
  650. #define oefRoot ((OEF)0x0008)
  651. _dt_public
  652. #define oefDecompress ((OEF)0x0010)
  653. _dt_public
  654. #define oefTimeStamp ((OEF)0x0020)
  655. _dt_public
  656. #define oefReadOnly ((OEF)0x0040)
  657. _dt_public
  658. #define oefBackup ((OEF)0x0080)
  659. _dt_public
  660. #define oefUpgradeOnly ((OEF)0x0100)
  661. //
  662. // The following oef means that the source file should not be deleted
  663. // after it is copied, even if the source is the DOS setup local source.
  664. // (Files coming from anywhere below that directory are usually deleted
  665. // after they are copied).
  666. //
  667. #define oefNoDeleteSource ((OEF)0x0200)
  668. _dt_public
  669. #define oefNone ((OEF)0x0000)
  670. _dt_public
  671. #define oefAll ((OEF)0xFFFF)
  672. /*
  673. ** Copy-Time Unit datatype for SFD
  674. */
  675. _dt_public typedef WORD CTU;
  676. /*
  677. ** OverWrite Mode datatype for SFD
  678. */
  679. _dt_public typedef WORD OWM;
  680. _dt_public
  681. #define owmNever ((OWM)0x0001)
  682. _dt_public
  683. #define owmAlways ((OWM)0x0002)
  684. _dt_public
  685. #define owmUnprotected ((OWM)0x0004)
  686. _dt_public
  687. #define owmOlder ((OWM)0x0008)
  688. _dt_public
  689. #define owmVerifySourceOlder ((OWM)0x0010)
  690. /*
  691. ** Option-Element Record for SFD
  692. */
  693. _dt_public typedef struct _oer
  694. {
  695. OEF oef;
  696. CTU ctuCopyTime;
  697. OWM owm;
  698. LONG lSize;
  699. SZ szRename;
  700. SZ szAppend;
  701. SZ szBackup;
  702. SZ szDescription;
  703. ULONG ulVerMS;
  704. ULONG ulVerLS;
  705. SZ szDate;
  706. SZ szDest;
  707. } OER;
  708. /*
  709. ** Option-Element Record datatype for SFD
  710. */
  711. _dt_public typedef OER * POER;
  712. _dt_public typedef POER * PPOER;
  713. _dt_public
  714. #define poerNull ((POER)NULL)
  715. /*
  716. ** Disk ID datatype for SFD
  717. */
  718. _dt_public typedef WORD DID;
  719. _dt_public
  720. #define didMin 1
  721. _dt_public
  722. #define didMost 999
  723. /*
  724. ** Section-File Description structure
  725. ** Fields:
  726. */
  727. _dt_public typedef struct _sfd
  728. {
  729. DID did;
  730. UINT InfId;
  731. SZ szFile;
  732. OER oer;
  733. } SFD;
  734. /*
  735. ** Section-File Description datatype
  736. */
  737. _dt_public typedef SFD * PSFD;
  738. _dt_public typedef PSFD * PPSFD;
  739. _dt_public
  740. #define psfdNull ((PSFD)NULL)
  741. extern POER APIENTRY PoerAlloc(VOID);
  742. extern BOOL APIENTRY FFreePoer(POER);
  743. extern BOOL APIENTRY FPrintPoer(PFH, POER);
  744. extern BOOL APIENTRY FValidPoer(POER);
  745. extern PSFD APIENTRY PsfdAlloc(VOID);
  746. extern BOOL APIENTRY FFreePsfd(PSFD);
  747. extern GRC APIENTRY GrcGetSectionFileLine(INT, PPSFD, POER);
  748. extern BOOL APIENTRY FPrintPsfd(PFH, PSFD);
  749. #if DBG
  750. extern BOOL APIENTRY FValidPsfd(PSFD);
  751. #endif
  752. extern BOOL APIENTRY FValidOerDate(SZ);
  753. extern BOOL APIENTRY FParseVersion(SZ, PULONG, PULONG);
  754. extern BOOL APIENTRY FListIncludeStatementLine(INT Line);
  755. extern GRC APIENTRY GrcGetListIncludeSectionLine(INT, PSZ, PSZ);
  756. _dt_subsystem(INF Media Prompting)
  757. /*
  758. ** Source Description List Element data structure
  759. */
  760. _dt_public typedef struct _sdle
  761. {
  762. struct _sdle * psdleNext;
  763. DID did; // disk id as specified in the inf
  764. DID didGlobal; // a universal id across infs
  765. SZ szLabel;
  766. SZ szTagFile;
  767. SZ szNetPath;
  768. } SDLE;
  769. _dt_public typedef SDLE * PSDLE;
  770. _dt_public typedef PSDLE * PPSDLE;
  771. extern PSDLE APIENTRY PsdleAlloc(VOID);
  772. extern BOOL APIENTRY FFreePsdle(PSDLE);
  773. extern GRC APIENTRY GrcFillSrcDescrListFromInf(VOID);
  774. _dt_subsystem(List Building)
  775. /*
  776. ** Copy List Node data structure
  777. */
  778. _dt_public typedef struct _cln
  779. {
  780. SZ szSrcDir;
  781. SZ szDstDir;
  782. PSFD psfd;
  783. struct _cln * pclnNext;
  784. } CLN;
  785. _dt_public typedef CLN * PCLN;
  786. _dt_public typedef PCLN * PPCLN;
  787. _dt_public typedef PPCLN * PPPCLN;
  788. /*
  789. ** Section Files Operation data structure
  790. ** REVIEW -- not really used
  791. */
  792. _dt_public typedef WORD SFO;
  793. _dt_public
  794. #define sfoCopy 1
  795. _dt_public
  796. #define sfoBackup 2
  797. _dt_public
  798. #define sfoRemove 3
  799. /* in LIST.C */
  800. extern PCLN pclnHead;
  801. extern PPCLN ppclnTail;
  802. extern GRC APIENTRY GrcFillPoerFromSymTab(POER);
  803. extern BOOL APIENTRY FSetPoerToEmpty(POER);
  804. extern GRC APIENTRY GrcAddSectionFilesToCopyList(SZ, SZ, SZ);
  805. extern GRC APIENTRY GrcAddSectionKeyFileToCopyList(SZ, SZ, SZ, SZ);
  806. extern GRC APIENTRY GrcAddNthSectionFileToCopyList(SZ, UINT, SZ, SZ);
  807. extern GRC APIENTRY GrcAddSectionFilesToCList(SFO, SZ, SZ, SZ, SZ, POER);
  808. extern GRC APIENTRY GrcAddLineToCList(INT, SFO, SZ, SZ, POER);
  809. extern GRC APIENTRY GrcAddPsfdToCList(SZ, SZ, PSFD);
  810. extern PCLN APIENTRY PclnAlloc(VOID);
  811. extern BOOL APIENTRY FFreePcln(PCLN);
  812. extern BOOL APIENTRY FPrintPcln(PFH, PCLN);
  813. #if DBG
  814. extern BOOL APIENTRY FValidPcln(PCLN);
  815. #endif
  816. /* Symbol Table constants */
  817. #define cchpSymMax ((CCHP)255)
  818. #define cchpSymBuf (cchpSymMax + 1)
  819. /* Symbol Table routines */
  820. extern BOOL APIENTRY FAddSymbolValueToSymTab(SZ, SZ);
  821. extern GRC APIENTRY GrcAddSymsFromInfSection(SZ);
  822. /* Message Box Routine */
  823. extern int APIENTRY ExtMessageBox(HANDLE, HWND, WORD, WORD, WORD);
  824. /*
  825. ** Purpose:
  826. ** Determines whether a symbol is defined in the symbol table.
  827. ** Arguments:
  828. ** szSymbol: symbol to search for. szSymbol must be non-NULL, non-empty,
  829. ** and start with a non-whitespace character.
  830. ** Returns:
  831. ** fTrue if szSymbol is defined in the symbol table (even if the associated
  832. ** is an empty string).
  833. ** fFalse if szSymbol is not defined in the symbol table.
  834. */
  835. _dt_public
  836. #define FSymbolDefinedInSymTab(szSymbol) \
  837. ((BOOL)(SzFindSymbolValueInSymTab(szSymbol)!=(SZ)NULL))
  838. extern SZ APIENTRY SzFindSymbolValueInSymTab(SZ);
  839. extern BOOL APIENTRY FRemoveSymbolFromSymTab(SZ);
  840. extern RGSZ APIENTRY RgszFromSzListValue(SZ);
  841. extern SZ APIENTRY SzListValueFromRgsz(RGSZ);
  842. extern BOOL APIENTRY FFreeInfTempInfo(PVOID);
  843. extern BOOL APIENTRY FCheckSymTabIntegrity(VOID);
  844. extern BOOL APIENTRY FDumpSymTabToFile(PFH);
  845. extern SZ APIENTRY SzGetSubstitutedValue(SZ);
  846. extern SZ APIENTRY SzProcessSzForSyms(HWND, SZ);
  847. _dt_subsystem(Parse Table)
  848. /* String Parse Code
  849. */
  850. _dt_public typedef unsigned SPC;
  851. _dt_public typedef SPC * PSPC;
  852. /*
  853. ** String-Code Pair structure
  854. ** Fields:
  855. ** sz: string.
  856. ** spc: String Parse Code to associate with string.
  857. */
  858. _dt_public typedef struct _scp
  859. {
  860. SZ sz;
  861. SPC spc;
  862. } SCP;
  863. /* String-Code Pair datatype
  864. */
  865. _dt_public typedef SCP * PSCP;
  866. /* String Parse Table datatypes
  867. */
  868. ///////////////////////////////////
  869. // _dt_public typedef SCP SPT;
  870. ///////////////////////////////////
  871. _dt_public typedef struct _pspt
  872. {
  873. PSCP pscpSorted ; // Generated for binary search
  874. long cItems ; // Number of items in table
  875. PSCP pscpBase ; // Original as given to PsptInitParsingTable()
  876. SPC spcDelim ; // Table delimiter entry
  877. } SPT ;
  878. _dt_public typedef SPT * PSPT;
  879. /* Symbol Table routines */
  880. extern PSPT APIENTRY PsptInitParsingTable(PSCP);
  881. extern SPC APIENTRY SpcParseString(PSPT, SZ);
  882. extern BOOL APIENTRY FDestroyParsingTable(PSPT);
  883. /* Flow handling routines */
  884. /* external program, library */
  885. BOOL APIENTRY FParseLoadLibrary(INT Line, UINT *pcFields);
  886. BOOL APIENTRY FParseFreeLibrary(INT Line, UINT *pcFields);
  887. BOOL APIENTRY FParseLibraryProcedure(INT Line,UINT *pcFields);
  888. BOOL APIENTRY FParseRunExternalProgram(INT Line,UINT *pcFields);
  889. BOOL APIENTRY FParseInvokeApplet(INT Line, UINT *pcFields);
  890. BOOL APIENTRY FParseStartDetachedProcess(INT Line, UINT *pcFields);
  891. /* registry */
  892. BOOL APIENTRY FParseRegistrySection(INT Line, UINT *pcFields, SPC spc);
  893. BOOL APIENTRY FParseCreateRegKey(INT Line, UINT *pcFields, SZ szHandle);
  894. BOOL APIENTRY FParseOpenRegKey(INT Line, UINT *pcFields, SZ szHandle);
  895. BOOL APIENTRY FParseFlushRegKey(INT Line, UINT *pcFields, SZ szHandle);
  896. BOOL APIENTRY FParseCloseRegKey(INT Line, UINT *pcFields, SZ szHandle);
  897. BOOL APIENTRY FParseDeleteRegKey(INT Line, UINT *pcFields, SZ szHandle);
  898. BOOL APIENTRY FParseDeleteRegTree(INT Line, UINT *pcFields, SZ szHandle);
  899. BOOL APIENTRY FParseEnumRegKey(INT Line, UINT *pcFields, SZ szHandle);
  900. BOOL APIENTRY FParseSetRegValue(INT Line, UINT *pcFields, SZ szHandle);
  901. BOOL APIENTRY FParseGetRegValue(INT Line, UINT *pcFields, SZ szHandle);
  902. BOOL APIENTRY FParseDeleteRegValue(INT Line, UINT *pcFields, SZ szHandle);
  903. BOOL APIENTRY FParseEnumRegValue(INT Line, UINT *pcFields, SZ szHandle);
  904. BOOL APIENTRY FParseAddFileToDeleteList(INT Line, UINT *pcFields);
  905. BOOL APIENTRY FParseWaitOnEvent(INT Line,UINT *pcFields);
  906. BOOL APIENTRY FParseSignalEvent(INT Line,UINT *pcFields);
  907. BOOL APIENTRY FParseSleep(INT Line, UINT *pcFields);
  908. BOOL APIENTRY FParseFlushInf(INT Line, UINT *pcFields);
  909. /*
  910. ** String Parse Codes for Flow Handling
  911. */
  912. #define spcError 0
  913. #define spcUnknown 1
  914. #define spcSet 2
  915. #define spcIfStr 3
  916. #define spcIfStrI 4
  917. #define spcIfInt 5
  918. #define spcIfContains 6
  919. #define spcIfContainsI 7
  920. #define spcIfFirst spcIfStr
  921. #define spcIfLast spcIfContainsI
  922. #define spcEndIf 8
  923. #define spcElse 9
  924. #define spcElseIfStr 10
  925. #define spcElseIfStrI 11
  926. #define spcElseIfInt 12
  927. #define spcElseIfContains 13
  928. #define spcElseIfContainsI 14
  929. #define spcEQ 15
  930. #define spcNE 16
  931. #define spcLT 17
  932. #define spcLE 18
  933. #define spcGT 19
  934. #define spcGE 20
  935. #define spcIn 21
  936. #define spcNotIn 22
  937. #define spcGoTo 23
  938. #define spcForListDo 24
  939. #define spcEndForListDo 25
  940. #define spcSetSubst 26
  941. #define spcSetSubsym 27
  942. #define spcDebugMsg 28
  943. #define spcHourglass 29
  944. #define spcArrow 30
  945. #define spcSetInstructionText 31
  946. #define spcSetHelpFile 32
  947. #define spcCreateRegKey 33
  948. #define spcOpenRegKey 34
  949. #define spcFlushRegKey 35
  950. #define spcCloseRegKey 36
  951. #define spcDeleteRegKey 37
  952. #define spcDeleteRegTree 38
  953. #define spcEnumRegKey 39
  954. #define spcSetRegValue 40
  955. #define spcGetRegValue 41
  956. #define spcDeleteRegValue 42
  957. #define spcEnumRegValue 43
  958. #define spcSetAdd 50
  959. #define spcSetSub 51
  960. #define spcSetMul 52
  961. #define spcSetDiv 53
  962. #define spcGetDriveInPath 54
  963. #define spcGetDirInPath 55
  964. #define spcLoadLibrary 56
  965. #define spcFreeLibrary 57
  966. #define spcLibraryProcedure 58
  967. #define spcRunExternalProgram 59
  968. #define spcInvokeApplet 60
  969. #define spcDebugOutput 61
  970. #define spcSplitString 62
  971. #define spcQueryListSize 63
  972. #define spcSetOr 64
  973. #define spcAddFileToDeleteList 65
  974. #define spcInitRestoreDiskLog 66
  975. #define spcStartDetachedProcess 67
  976. #define spcWaitOnEvent 68
  977. #define spcSignalEvent 69
  978. #define spcSleep 70
  979. #define spcSetHexToDec 71
  980. #define spcSetDecToHex 72
  981. #define spcFlushInf 73
  982. extern PSPT psptFlow;
  983. extern SCP rgscpFlow[];
  984. extern BOOL APIENTRY FHandleFlowStatements(INT *, HWND, SZ, UINT *,RGSZ *);
  985. extern BOOL APIENTRY FInitFlowPspt(VOID);
  986. extern BOOL APIENTRY FDestroyFlowPspt(VOID);
  987. _dt_subsystem(Error Handling)
  988. /*
  989. ** Expanded Error Return Code
  990. */
  991. _dt_public typedef unsigned EERC;
  992. _dt_public
  993. #define eercAbort ((EERC)0)
  994. _dt_public
  995. #define eercRetry ((EERC)1)
  996. _dt_public
  997. #define eercIgnore ((EERC)2)
  998. #define EercErrorHandler(HWND, GRC, BOOL, x, y, z) TRUE
  999. #define FHandleOOM(HWND) TRUE
  1000. extern BOOL APIENTRY FGetSilent(VOID);
  1001. extern BOOL APIENTRY FSetSilent(BOOL);
  1002. VOID SetSupportLibHandle(HANDLE Handle);
  1003. extern HCURSOR CurrentCursor;
  1004. //
  1005. // Utility functions for dealing with multisz's.
  1006. //
  1007. RGSZ
  1008. MultiSzToRgsz(
  1009. IN PVOID MultiSz
  1010. );
  1011. PCHAR
  1012. RgszToMultiSz(
  1013. IN RGSZ rgsz
  1014. );
  1015. BOOL AddFileToDeleteList(PCHAR Filename);
  1016. // floppy operations/repair diskette stuff
  1017. BOOL
  1018. InitializeFloppySup(
  1019. VOID
  1020. );
  1021. VOID
  1022. TerminateFloppySup(
  1023. VOID
  1024. );
  1025. BOOL
  1026. FormatFloppyDisk(
  1027. IN CHAR DriveLetter,
  1028. IN HWND hwndOwner,
  1029. OUT PBOOL Fatal
  1030. );
  1031. BOOL
  1032. CopyFloppyDisk(
  1033. IN CHAR DriveLetter,
  1034. IN HWND hwndOwner,
  1035. IN DWORD SourceDiskPromptId,
  1036. IN DWORD TargetDiskPromptId
  1037. );
  1038. UINT
  1039. __cdecl
  1040. xMsgBox(
  1041. HWND hwnd,
  1042. UINT CaptionResId,
  1043. UINT MessageResId,
  1044. UINT MsgBoxFlags,
  1045. ...
  1046. );
  1047. #endif // COMSTF_INCLUDED