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.

1087 lines
41 KiB

  1. //*********************************************************************
  2. //
  3. // DOSDLL.H
  4. //
  5. // Copyright (c) 1992 - Microsoft Corp.
  6. // All rights reserved.
  7. // Microsoft Confidential
  8. //
  9. // This header file contains the typedefs and #defines needed when
  10. // calling into and calling back from a DOS type DLL.
  11. //
  12. // PROGRAMMER CAVEAT:
  13. // Remember that all pointers in the DLL must be far because
  14. // the C runtime libraries which use near pointers always assume
  15. // that DS == SS which is not the case with a DLL.
  16. //*********************************************************************
  17. #define CMD_YIELD 0 // Standard callback cmd to call Yield()
  18. #define SIGNAL_ABORT 1 // Signal to abort DLL process
  19. //*********************************************************************
  20. // Windows memory allocation functions used in the implementation
  21. // of GetMemory() and FreeMemory().
  22. //*********************************************************************
  23. #ifndef GMEM_FIXED
  24. #define GMEM_FIXED 0
  25. unsigned _far _pascal GlobalAlloc( unsigned Flags, unsigned long Bytes );
  26. unsigned _far _pascal GlobalFree( unsigned );
  27. void * _far _pascal GlobalLock( unsigned );
  28. unsigned _far _pascal GlobalUnlock( unsigned );
  29. unsigned long _far _pascal GlobalHandle( unsigned );
  30. #endif
  31. //#define DllYield() ((void)(*CallBackAddr)( NULL, CMD_YIELD, 0, 0, 0, 0 ))
  32. //*********************************************************************
  33. // TO_DLL - Declaration for a DLL entry function.
  34. // TO_DLL_PTR - Declaration for a pointer to a DLL entry function.
  35. //*********************************************************************
  36. // #define TO_DLL unsigned long _far _cdecl
  37. typedef unsigned long _far _cdecl TO_DLL( unsigned, unsigned, ... );
  38. typedef unsigned long (_far _cdecl *TO_DLL_PTR)();
  39. //*********************************************************************
  40. // FROM_DLL - Declaration for a callback dispatcher function.
  41. // FROM_DLL_PTR- Declaration for a pointer to a callback dispatcher funct.
  42. // FROM_DLL_ARGS- Argument prototype for callback dispatcher function.
  43. //*********************************************************************
  44. #define FROM_DLL unsigned long _loadds _far _pascal
  45. #define FROM_DLL_ARGS CB_FUNC_PTR,unsigned,unsigned,unsigned long,unsigned, unsigned
  46. typedef unsigned long (_loadds _far _pascal *FROM_DLL_PTR)();
  47. //*********************************************************************
  48. // CB_FUNC - Declaration for a callback function.
  49. // CB_FUNC_PTR - Declaration for a pointer to a callback function.
  50. // CB_FUNC_ARGS- Argument prototype for callback function.
  51. //*********************************************************************
  52. #define CB_FUNC unsigned long _far
  53. #define CB_FUNC_ARGS unsigned,unsigned,unsigned long
  54. typedef unsigned long (_far *CB_FUNC_PTR)();
  55. //*********************************************************************
  56. #define PTR_TYPE FPTR_TYPE
  57. #define SZPTR_TYPE FSZPTR_TYPE
  58. #define CODE_PTR_TYPE DWORD_TYPE
  59. //*********************************************************************
  60. #define WORD_TYPE 00
  61. #define DWORD_TYPE 01U
  62. #define NPTR_TYPE 02U
  63. #define FPTR_TYPE 03U
  64. #define NSZPTR_TYPE 04U
  65. #define FSZPTR_TYPE 05U
  66. #define VARI_TYPE 07U
  67. #define TRANS_NONE 00
  68. #define TRANS_SRC (01U << 14)
  69. #define TRANS_DEST (02U << 14)
  70. #define TRANS_BOTH (03U << 14)
  71. #define LEN_SHIFT 12
  72. //*********************************************************************
  73. // DllCall() - Entry function for call DLL.
  74. // CallBack() - Function in control program which dispatches callbacks
  75. //*********************************************************************
  76. // TO_DLL DllCall( unsigned Cmd, unsigned ArgCount, unsigned Descriptor, ... );
  77. // FROM_DLL CallBack( unsigned long (_far *Func)(CB_FUNC_ARGS),
  78. // unsigned Cmd, unsigned uParam, unsigned long lParam,
  79. // unsigned Descriptor, unsigned Size );
  80. //*********************************************************************
  81. // The following #defines are used to simulate a function call from the
  82. // control program to the DLL. There is only one entry point into the
  83. // DLL so a function number is used to specify the function being called.
  84. // A complete and detailed description of how the transport descriptors
  85. // should be specified is in ENTRY.ASM.
  86. //
  87. // PROGRAMMER CAVEAT:
  88. // Remember that these are #defines and not function prototypes
  89. // so all references to types must be done as casts....
  90. // Also remember that any pointer to data must be FAR because
  91. // DS is always set to the DLL own heap on entry and SS != DS.
  92. //*********************************************************************
  93. #define DLL_SIGNAL 0 // DllSignal()
  94. #define DLL_SET_CALLBACK 1 // SetCallBackAddr()
  95. #define DLL_COPY 2 // DllCopyMain()
  96. #define DLL_DELETE 3 // DllDeleteMain()
  97. #define DLL_DIR 4 // DllDirMain()
  98. #define DLL_GET_DISK_FREE 5 // DllGetDiskFree()
  99. #define DLL_LOAD_MSGS 6 // DllLoadMsgs()
  100. #define DLL_LOAD_STRING 7 // DllLoadString()
  101. #define DLL_EXT_OPEN_FILE 8 // DllDosExtOpen()
  102. #define DLL_OPEN_FILE 9 // DllDosOpen()
  103. #define DLL_READ_FILE 10 // DllDosRead()
  104. #define DLL_WRITE_FILE 11 // DllDosWrite()
  105. #define DLL_CLOSE_FILE 12 // DllDosClose()
  106. #define DLL_SEEK_FILE 13 // DllDosSeek()
  107. #define DLL_GET_MEDIA_ID 14 // DllDosGetMediaId()
  108. #define DLL_GET_CWD_ID 15 // DllGetCwd()
  109. #define DLL_SET_CWD_ID 16 // DllSetCwd()
  110. #define DLL_GET_DRV_ID 17 // DllGetDrive()
  111. #define DLL_SET_DRV_ID 18 // DllSetDrive()
  112. #define DLL_MKDIR 19 // DllMakeDir()
  113. #define DLL_RMDIR 20 // DllRemoveDir()
  114. #define DLL_MKDIR_TREE 21 // DllCreateDirTree()
  115. #define DLL_RENAME 22 // DllRenameFiles()
  116. #define DLL_MOVE 23 // DllRenameFiles()
  117. #define DLL_FIND 24 // DllFindFiles()
  118. #define DLL_TOUCH 25 // DllTouchFiles()
  119. #define DLL_ATTRIB 26 // DllAttribFiles()
  120. #define DLL_SET_CNTRY_INF 27 // DllSetCntryInfo()
  121. #define DLL_RELEASE 28 // DllReleaseInstance()
  122. //*********************************************************************
  123. // DLL function which is called by the user of the DLL to set a global
  124. // callback address where all callback will be routed thru. The
  125. // callback function must follow the criteria exampled in CB_ENTRY.ASM.
  126. // This function will initialize the SignalValue and the DOS version
  127. // number.
  128. //
  129. // void DllSetCallBackAddr( long (far cdecl *FuncPtr)() )
  130. //
  131. // ARGUMENTS:
  132. // FunctPtr - Pointer to callback entry function (TO_DLL_PTR)
  133. // RETURNS:
  134. // int - OK
  135. //
  136. //*********************************************************************
  137. #define DllSetCallBackAddr( CallBackAddr )\
  138. ((void)(*DllEntry)( DLL_SET_CALLBACK, 1,\
  139. DWORD_TYPE + TRANS_NONE,\
  140. CallBackAddr ))
  141. //*********************************************************************
  142. // DLL function to set a signal value which will cause the currently
  143. // executing function to abort and return an error code. If the
  144. // SignalValue is < 0 it will be returned returned unchanged as the
  145. // error code. If the value > 0 it will be considered a user abort
  146. // and ERR_USER_ABORT will be returned.
  147. //
  148. // void DllSignal( int Signal )
  149. //
  150. // ARGUMENTS:
  151. // Signal - Signal value.
  152. // RETURNS:
  153. // void
  154. //
  155. //*********************************************************************
  156. #define DllSignal( x )\
  157. ((void)(*DllEntry)( DLL_SIGNAL, 1,\
  158. WORD_TYPE + TRANS_NONE,\
  159. (int)x ))
  160. //*********************************************************************
  161. // Main entry point for the copy/move engine. Accepts a command line and
  162. // copies the files meeting the specified criteria.
  163. //
  164. // int DllCopyFiles( char *szCmdLine, char *szEnvStr, CPY_CALLBACK CpyCallBack )
  165. // int DllMoveFiles( char *szCmdLine, char *szEnvStr, CPY_CALLBACK CpyCallBack )
  166. //
  167. // ARGUMENTS:
  168. // szCmdLine - Ptr to command line string, less command name
  169. // szEnvStr - Ptr to optional enviroment cmd string or NULL
  170. // CpyCallBack - Ptr to copy callback function.
  171. // RETURNS:
  172. // int - OK if all files copies successfull else error code
  173. // which is < 0 if a parse error and > 0 if a DOS
  174. // or C runtime error.
  175. //
  176. // szCmdLine is ptr to commandline string.
  177. //
  178. // "srcfiles [dest] [SrchCriteria] [/E][/M][/N][/P][/R][/S][/U][/V][/W]
  179. //
  180. // source Specifies the file or files to be copied.
  181. // and may be substituted with /F:filename
  182. // to use filespecs from a text file.
  183. //
  184. // destination Specifies the directory and/or filename
  185. // for the new file(s).
  186. //
  187. // SrchCriteria Any extended search criteria supported by
  188. // by the findfile engine.
  189. //
  190. // /C Confirm on overwrite of existing file.
  191. //
  192. // /D Prompt for next disk when current on is full
  193. //
  194. // /E Copies any subdirectories, even if empty.
  195. //
  196. // /M Turns the source files archive attribute bit off after
  197. // copying the file.
  198. //
  199. // /N Adds new files to destination directory. "CAN" be used
  200. // with /S or /U switches.
  201. //
  202. // /O Replace existing files regardless of date not compable
  203. // with /N or /U.
  204. //
  205. // /P Prompts for confirmation before copying each file.
  206. //
  207. // /R Overwrites read-only files as well as reqular files.
  208. //
  209. // /S Copies files from specified directory and it's
  210. // subdirectories.
  211. //
  212. // /U Replaces (updates) only files that are older than
  213. // source files (May be used with /A)
  214. //
  215. // /V Verifies that new files are written correctly.
  216. //
  217. // /W Prompts you to press a key before copying. (Not implemented)
  218. //
  219. // /X Emulate XCOPY's ablity to read as many files as possible
  220. // before writing them to the destination.
  221. //
  222. // CpyCallBack is a ptr to a callback function which supports these
  223. // these callback functions.
  224. //
  225. // int far CPY_CALLBACK)( int Func, unsigned long ulArg0, void far *pArg1,
  226. // void far *pArg2, void far *pArg3 );
  227. //
  228. // CB_CPY_FLGS 0x0001 // Passing back parsed copy flags
  229. // CB_CPY_ENVERR 0x0002 // Passing back non-fatal error
  230. // CB_CPY_SWITCH 0x0003 // Passing back unrecongized switch
  231. // CB_CPY_ERR_STR 0x0004 // Passing back error error string
  232. // CB_CPY_FOUND 0x0005 // File was found and ready to copy
  233. // CB_CPY_FWRITE 0x0006 // Destination is about to be written
  234. // CB_CPY_QISDIR 0x0007 // Query user if dest is file or dir
  235. //
  236. // Option bits which may be passed by by CB_CPY_FLGS are:
  237. //
  238. // CPY_CONFIRM 0x0001 /C Confirm before overwrite existing file
  239. // CPY_EMPTY 0x0002 /E Copy empty subdirectories
  240. // CPY_MODIFY 0x0004 /M Set the archive bit on source
  241. // CPY_NEW 0x0008 /N Copy if file !exist on destination
  242. // CPY_EXISTING 0x0010 /O Copy over existing files only.
  243. // CPY_PROMPT 0x0020 /P Prompt before copying file
  244. // CPY_RDONLY 0x0040 /R Overwrite readonly files
  245. // CPY_UPDATE 0x0080 /U Copy only files new than destin
  246. // CPY_VERIFY 0x0100 /V Turn DOS verify to ON
  247. // CPY_WAIT 0x0200 /W Prompt before first file
  248. // CPY_XCOPY 0x0400 /X Use buffered copy.
  249. // CPY_FULL 0x1000 /D Prompt for next disk when current is full
  250. // CPY_HELP 0x0800 /? Display help
  251. //
  252. //*********************************************************************
  253. #define DllCopyFiles( szCmdLine, szEnv, CB_CpyCallBack )\
  254. ((int)(*DllEntry)( DLL_COPY, 3,\
  255. FSZPTR_TYPE + TRANS_SRC,\
  256. FSZPTR_TYPE + TRANS_SRC,\
  257. DWORD_TYPE + TRANS_NONE,\
  258. (char far *)szCmdLine,\
  259. (char far *)szEnv,\
  260. (int (far pascal *)())CB_CpyCallBack ))
  261. //*********************************************************************
  262. #define DllMoveFiles( szCmdLine, szEnv, CB_CpyCallBack )\
  263. ((int)(*DllEntry)( DLL_MOVE, 3,\
  264. FSZPTR_TYPE + TRANS_SRC,\
  265. FSZPTR_TYPE + TRANS_SRC,\
  266. DWORD_TYPE + TRANS_NONE,\
  267. (char far *)szCmdLine,\
  268. (char far *)szEnv,\
  269. (int (far pascal *)())CB_CpyCallBack ))
  270. //*********************************************************************
  271. // Main entry point for the file delete engine. Accepts a command line
  272. // and deletes the files meeting the specified criteria.
  273. //
  274. // int DllDelFiles( char *szCmdLine, char *szEnvStr, DEL_CALLBACK DelCallBack )
  275. //
  276. // ARGUMENTS:
  277. // szCmdLine - Ptr to command line string, less command name
  278. // szEnvStr - Ptr to optional enviroment cmd string or NULL
  279. // DelCallBack - Ptr to delete callback function.
  280. // RETURNS:
  281. // int - OK if all files deleted successfull else error code
  282. // which is < 0 if a parse error and > 0 if a DOS
  283. // or C runtime error.
  284. //
  285. // szCmdLine is ptr to commandline string.
  286. //
  287. // "srcfiles [SrchCriteria] [/E] [/P] [/R] [/S] [/U]"
  288. //
  289. // source Specifies the file or files to be deleted
  290. // and may be substituted with /F:filename
  291. // to use filespecs from a text file.
  292. //
  293. // SrchCriteria Any extended search criteria supported by
  294. // by the findfile engine.
  295. //
  296. // /E Delete empty subdirectories
  297. // /P Prompts for confirmation before copying each file
  298. // /R Delete readonly files which match search criteria
  299. // /S Delete files in specified path and all its subdirectories
  300. // /U Alias for /A*/R/E
  301. //
  302. //
  303. // DelCallBack is a ptr to a callback function which supports these
  304. // these callback functions.
  305. //
  306. // int far DEL_CALLBACK)( int Func, unsigned long ulArg0, void far *pArg1,
  307. // void far *pArg2 )
  308. //
  309. // CB_DEL_FLGS 0x0001 // Passing back parsed delete flags
  310. // CB_DEL_ENVERR 0x0002 // Passing back non-fatal error
  311. // CB_DEL_SWITCH 0x0003 // Passing back unrecongized switch
  312. // CB_DEL_ERR_STR 0x0004 // Passing back error error string
  313. // CB_DEL_FOUND 0x0005 // File was found and ready to delete
  314. // CB_DEL_QDELALL 0x0006 // Query user if should delete *.*
  315. // CB_DEL_QDELALL 0x0006 // Query user if should delete *.*
  316. //
  317. //*********************************************************************
  318. #define DllDeleteFiles( szCmdLine, szEnv, CB_DelCallBack )\
  319. ((int)(*DllEntry)( DLL_DELETE, 3,\
  320. FSZPTR_TYPE + TRANS_SRC,\
  321. FSZPTR_TYPE + TRANS_SRC,\
  322. DWORD_TYPE + TRANS_NONE,\
  323. (char far *)szCmdLine,\
  324. (char far *)szEnv,\
  325. (int (far pascal *)())CB_DelCallBack ))
  326. //*********************************************************************
  327. // Main entry point for the file dir engine. Accepts a command line
  328. // and does an application callback the files meeting the specified
  329. // criteria.
  330. //
  331. // int DllDirFiles( char *szCmdLine, char *szEnvStr, DIR_CALLBACK DirCallBack )
  332. //
  333. // ARGUMENTS:
  334. // szCmdLine - Ptr to command line string, less command name
  335. // szEnvStr - Ptr to optional enviroment cmd string or NULL
  336. // DirCallBack - Ptr to dir callback function.
  337. // RETURNS:
  338. // int - OK if all files directoried successfull else error code
  339. // which is < 0 if a parse error and > 0 if a DOS
  340. // or C runtime error.
  341. //
  342. // szCmdLine is ptr to commandline string.
  343. //
  344. // "srcfiles [SrchCriteria] [/B] [/L] [/O] [/P] [/S] [/V] [/W] [/?]
  345. //
  346. // source Specifies the file or files to be directoried
  347. // and may be substituted with /F:filename
  348. // to use filespecs from a text file.
  349. //
  350. // SrchCriteria Any extended search criteria supported by
  351. // by the findfile engine.
  352. //
  353. // Switches: #defined value in DirFlgs
  354. //
  355. // /B Display a bare listing DIR_BARE 0x0001
  356. // /L Display in lower case DIR_LCASE 0x0002
  357. // /O Display in sorted order DIR_ORDERED 0x0004
  358. // /P Paged output DIR_PAGED 0x0008
  359. // /S Recurse subdirectories DIR_SUBDIRS 0X0010
  360. // /V Display verbose information DIR_VERBOSE 0x0020
  361. // /W Display wide listing DIR_WIDE 0x0040
  362. // /? Display help DIR_HELP 0x0080
  363. //
  364. //
  365. // DelCallBack is a ptr to a callback function which supports these
  366. // these callback functions.
  367. //
  368. // int far DIR_CALLBACK)( int Func, unsigned long ulArg0, void far *pArg1,
  369. // void far *pArg2 )
  370. //
  371. // CB_DIR_FLGS 0x0001 // Passing back parsed dir flags
  372. // CB_DIR_ENVERR 0x0002 // Passing back non-fatal error
  373. // CB_DIR_SWITCH 0x0003 // Passing a non-search switch
  374. // CB_DIR_ERR_STR 0x0004 // Passing back an error string
  375. // CB_DIR_FOUND 0x0005 // File was found and ready to delete
  376. // CB_DIR_ENTER 0x0006 // A search is starting on a new directory
  377. // CB_DIR_LEAVE 0x0007 // No more files on current directory
  378. // CB_DIR_NEWSEARCH 0x0008 // Starting a new srch with diff. filespec
  379. // CB_DIR_ENDPATH 0x0009 // End of current search path
  380. // CB_QUERY_ACCESS 0x000a // Query if access date is required.
  381. //
  382. //*********************************************************************
  383. #define DllDirFiles( szCmdLine, szEnv, CB_DirCallBack )\
  384. ((int)(*DllEntry)( DLL_DIR, 3,\
  385. FSZPTR_TYPE + TRANS_SRC,\
  386. FSZPTR_TYPE + TRANS_SRC,\
  387. DWORD_TYPE + TRANS_NONE,\
  388. (char far *)szCmdLine,\
  389. (char far *)szEnv,\
  390. (int (pascal far *)())CB_DirCallBack))
  391. //**********************************************************************
  392. // Returns disk free information for the specified drive.
  393. //
  394. // int DllGetDiskFree( int cDrvLetter, struct _diskfree_t *DrvInfo )
  395. //
  396. // ARGUMENTS:
  397. // DrvLetter - Drive letter to get disk free information about
  398. // pDrvInfo - Ptr to a drive information structure to fill in
  399. // RETURNS:
  400. // int - OK if no errors else errno from C runtime
  401. //
  402. //**********************************************************************
  403. #define DllGetDiskFree( DriveLetter, DiskFreeStruc )\
  404. ((int)(*DllEntry)( DLL_GET_DISK_FREE, 2,\
  405. WORD_TYPE + TRANS_NONE,\
  406. PTR_TYPE + TRANS_DEST,\
  407. sizeof( struct diskfree_t ),\
  408. DriveLetter,\
  409. (struct diskfree_t _far *)DiskFreeStruc ))
  410. //*********************************************************************
  411. // Main entry point for the file rename engine. Accepts a command line
  412. // and renames the files meeting the specified criteria.
  413. //
  414. // int DllRenameFiles( char *szCmdLine, char *szEnvStr, REN_CALLBACK RenCallBack )
  415. //
  416. // ARGUMENTS:
  417. // szCmdLine - Ptr to command line string, less command name
  418. // szEnvStr - Ptr to optional enviroment cmd string or NULL
  419. // DelCallBack - Ptr to rename callback function.
  420. // RETURNS:
  421. // int - OK if all files renamed successfull else error code
  422. // which is < 0 if a parse error and > 0 if a DOS
  423. // or C runtime error.
  424. //
  425. // szCmdLine is ptr to commandline string.
  426. //
  427. // "srcfiles [SrchCriteria] [/P] [/S]"
  428. //
  429. // source Specifies the file or files to be renamed
  430. // and may be substituted with /F:filename
  431. // to use filespecs from a text file.
  432. //
  433. // SrchCriteria Any extended search criteria supported by
  434. // by the findfile engine.
  435. //
  436. // /P Prompts for confirmation before copying each file
  437. // /S Rename files in specified path and all its subdirectories
  438. //
  439. //
  440. // DelCallBack is a ptr to a callback function which supports these
  441. // these callback functions.
  442. //
  443. // int far REN_CALLBACK)( int Func, unsigned long ulArg0, void far *pArg1,
  444. // void far *pArg2 )
  445. //
  446. // CB_REN_FLGS 0x0001 // Passing back parsed rename flags
  447. // CB_REN_ENVERR 0x0002 // Passing back non-fatal error
  448. // CB_REN_SWITCH 0x0003 // Passing back unrecongized switch
  449. // CB_REN_ERR_STR 0x0004 // Passing back error error string
  450. // CB_REN_FOUND 0x0005 // File was found and ready to rename
  451. //
  452. //*********************************************************************
  453. #define DllRenameFiles( szCmdLine, szEnv, CB_DelCallBack )\
  454. ((int)(*DllEntry)( DLL_RENAME, 3,\
  455. FSZPTR_TYPE + TRANS_SRC,\
  456. FSZPTR_TYPE + TRANS_SRC,\
  457. DWORD_TYPE + TRANS_NONE,\
  458. (char far *)szCmdLine,\
  459. (char far *)szEnv,\
  460. (int (far pascal *)())CB_DelCallBack ))
  461. //*********************************************************************
  462. // Loads a group of messages from the resource file in the specified
  463. // file into memory for latter retrieval by LoadStr(). In addition to
  464. // the requested messages the function will also load all error messages
  465. // in the ranges of 0-0xff and 0xff00 - 0xffff (-256 thru +255) on
  466. // the first call to the function. The resource table is built in
  467. // StrTable and then sorted, and then StrBuf is allocated and the
  468. // resource strings are read into the buffer.
  469. //
  470. // NOTE:
  471. // Currently this function may only be called once.
  472. //
  473. // int LoadMsgs( char *szFile, unsigned uStart, unsigned uEnd )
  474. //
  475. // ARGUMENTS:
  476. // szFile - Ptr to .EXE file containing the messages to load
  477. // uStart - Starting message number to load into memory
  478. // uEnd - Ending message number to be loaded into memory.
  479. // RETURNS:
  480. // int - OK if all messages (including normal preloaded messages)
  481. // are successfully loaded, else an error code.
  482. //
  483. //*********************************************************************
  484. #define DllLoadMsgs( szFile, uStart, uEnd )\
  485. ((int)(*DllEntry)( DLL_LOAD_MSGS, 3,\
  486. FSZPTR_TYPE + TRANS_SRC,\
  487. WORD_TYPE + TRANS_NONE,\
  488. WORD_TYPE + TRANS_NONE,\
  489. (char far *)szFile,\
  490. (unsigned)uStart,\
  491. (unsigned)uEnd ))
  492. //*********************************************************************
  493. // Windows emulatation function for accessing a string resource. Copies
  494. // the specified string resource into a caller supplied buffer and
  495. // appends a terminating zero to it. Because string groups are aligned
  496. // standard boundaries there is normally a lot of trailing zeros which
  497. // we strip off after reading in a group of strings.
  498. //
  499. // NOTE:
  500. // Currently this functions requires that the string resource was
  501. // previously loaded into memory by LoadMsgs() which should be called
  502. // once at the begining of the program to preload all required
  503. // messages.
  504. //
  505. // int DllLoadString( unsigned hInst, unsigned idResource, char far *szBuf,
  506. // int iBufLen )
  507. //
  508. // ARGUMENTS:
  509. // hInst - Instance of the calling program (should be zero)
  510. // idResource - The string ID as specified in the .RC file
  511. // szBuf - Buffer to copy the string to
  512. // iBufLen - Max characters to copy into the specified buffer
  513. // RETURNS:
  514. // int - The number of bytes copied. This number will be
  515. // 0 if the specified resource cannot be located in
  516. // StrTable[].
  517. //
  518. //*********************************************************************
  519. #define DllLoadString( hInst, idResource, szBuf, iBufLen )\
  520. ((int)(*DllEntry)( DLL_LOAD_STRING, 4,\
  521. WORD_TYPE + TRANS_NONE,\
  522. WORD_TYPE + TRANS_NONE,\
  523. FSZPTR_TYPE + TRANS_SRC,\
  524. WORD_TYPE + TRANS_NONE,\
  525. (unsigned)hInst,\
  526. (unsigned)idResource,\
  527. (char far *)szBuf,\
  528. (int)iBufLen ))
  529. //*********************************************************************
  530. // Extended file open function used DOS function 6ch to open a file
  531. // and return a file handle.
  532. //
  533. // unsigned DllDosExtOpen( char *szFile, unsigned uMode, unsigned uAttribs,
  534. // unsigned uCreat, unsigned *uFhandle )
  535. //
  536. // ARGUMENTS:
  537. // szFile - Ptr to buffer containing a fully qualified filespec string
  538. // uMode - Open mode for file access and sharing. (BX)
  539. // uAttribs - Attributes for file if being created. (CX)
  540. // uCreate - Create action flags. (DX)
  541. // uFhandle- Ptr to unsigned file handle
  542. // RETURNS:
  543. // unsigned - OK if no errors and open file handle stored in *uFhandle
  544. // ELSE DOS error code and errno set to C runtime erro code
  545. //
  546. //*********************************************************************
  547. #define DllDosExtOpen( szFile, uMode, uAttribs, uCreate, pHandle )\
  548. ((int)(*DllEntry)( DLL_EXT_OPEN_FILE, 5,\
  549. FSZPTR_TYPE + TRANS_SRC,\
  550. WORD_TYPE + TRANS_NONE,\
  551. WORD_TYPE + TRANS_NONE,\
  552. WORD_TYPE + TRANS_NONE,\
  553. FPTR_TYPE + TRANS_DEST,\
  554. sizeof( int ),\
  555. (char far *)szFile,\
  556. (unsigned)uMode,\
  557. (unsigned)uAttribs,\
  558. (unsigned)uCreate,\
  559. (int far *)pHandle ))
  560. //*********************************************************************
  561. // See C_RUNTIME _dos_open() for complete description.
  562. //*********************************************************************
  563. // unsigned DosOpenFile( char far *szFileSpec, unsigned uMode, int *pHandle );
  564. #define DllDosOpen( szFile, uMode, pHandle )\
  565. ((int)(*DllEntry)( DLL_OPEN_FILE, 3,\
  566. FSZPTR_TYPE + TRANS_SRC,\
  567. WORD_TYPE + TRANS_NONE,\
  568. FPTR_TYPE + TRANS_DEST,\
  569. sizeof( int ),\
  570. (char far *)szFile,\
  571. (unsigned)uMode,\
  572. (int far *)pHandle ))
  573. //*********************************************************************
  574. // See C_RUNTIME _dos_read() for complete description.
  575. //*********************************************************************
  576. // unsigned DosReadFile( int fHandle, char far *Buf, unsigned Bytes,
  577. // unsigned *puRead );
  578. #define DllDosRead( fHandle, pBuf, Bytes, pRead )\
  579. ((int)(*DllEntry)( DLL_READ_FILE, 4,\
  580. WORD_TYPE + TRANS_NONE,\
  581. FPTR_TYPE + TRANS_DEST,\
  582. Bytes,\
  583. WORD_TYPE + TRANS_NONE,\
  584. FPTR_TYPE + TRANS_DEST,\
  585. sizeof( int ),\
  586. (int)fHandle,\
  587. (void far *)pBuf,\
  588. (unsigned)Bytes,\
  589. (unsigned far *)pRead ))
  590. //*********************************************************************
  591. // See C_RUNTIME _dos_write() for complete description.
  592. //*********************************************************************
  593. // unsigned DosWriteFile( int fHandle, char far *Buf, unsigned Bytes,
  594. // unsigned *puWrite );
  595. #define DllDosWrite( fHandle, pBuf, Bytes, pWritten )\
  596. ((int)(*DllEntry)( DLL_WRITE_FILE, 4,\
  597. WORD_TYPE + TRANS_NONE,\
  598. FPTR_TYPE + TRANS_SRC,\
  599. Bytes,\
  600. WORD_TYPE + TRANS_NONE,\
  601. FPTR_TYPE + TRANS_DEST,\
  602. sizeof( int ),\
  603. (int)fHandle,\
  604. (void far *)pBuf,\
  605. (unsigned)Bytes,\
  606. (unsigned far *)pWritten ))
  607. //*********************************************************************
  608. // See C_RUNTIME _dos_close() for complete description.
  609. //*********************************************************************
  610. // unsigned DosCloseFile( int fHandle );
  611. #define DllDosClose( fHandle )\
  612. ((int)(*DllEntry)( DLL_CLOSE_FILE, 1,\
  613. WORD_TYPE + TRANS_NONE,\
  614. (int)fHandle ))
  615. //*********************************************************************
  616. // Seeks to a new position in an open file using DOS function 0x42.
  617. //
  618. // unsigned _dos_seek( int fHandle, long lOffset, int iOrgin, long *plCurPos );
  619. //
  620. // ARGUMENTS:
  621. // fHandle - Open DOS file handle
  622. // lOffset - Offset to seek to in the file
  623. // iOrigin - Origin to seek from can be:
  624. // SEEK_SET From begining of file
  625. // SEEK_CUR From current position if the file
  626. // SEEK_END From the end of the file
  627. // plCurPos - Ptr to dword value where absolute position in the file will
  628. // be stored after the seek
  629. // RETURNS:
  630. // unsigned - OK if no errors and open file handle stored in *uFhandle
  631. // ELSE DOS error code and errno set to C runtime erro code
  632. //
  633. //*********************************************************************
  634. // DllDosSeek( int fHandle, long 0L, int SEEK_SET, long *lPos )
  635. #define DllDosSeek( fHandle, lPos, Type, lpNewPos )\
  636. ((int)(*DllEntry)( DLL_SEEK_FILE, 4,\
  637. WORD_TYPE + TRANS_NONE,\
  638. DWORD_TYPE + TRANS_NONE,\
  639. WORD_TYPE + TRANS_NONE,\
  640. FPTR_TYPE + TRANS_DEST,\
  641. sizeof( long ),\
  642. (int)fHandle,\
  643. (long)lPos,\
  644. (int)Type,\
  645. (long far *)lpNewPos ))
  646. //**********************************************************************
  647. // Fills in a media ID information structure passed by the caller.
  648. //
  649. // NOTE: The _dos_getmedia_id call may return a volume id which does
  650. // not match that found with a _dos_findfirst() so we do the
  651. // _dos_findfirst() to be compatible with DOS 5.0 DIR cmd.
  652. //
  653. // int GetMediaId( int cDrvLetter, struct MEDIA_ID_INF *pMediaInf )
  654. //
  655. // ARGUMENTS:
  656. // cDrvLetter - Drive letter to get media information about
  657. // pMediaInf - Ptr to a media information structure to fill in
  658. // RETURNS:
  659. // int - OK if no errors else errno from C runtime
  660. //
  661. //**********************************************************************
  662. // DllGetMediaId( char DrvLetter, struct MEDIA_ID_INF *pMediaInf )
  663. #define DllGetMediaId( DrvLetter, pMediaInf )\
  664. ((int)(*DllEntry)( DLL_GET_MEDIA_ID, 2,\
  665. WORD_TYPE + TRANS_NONE,\
  666. FPTR_TYPE + TRANS_DEST,\
  667. sizeof( struct MEDIA_ID_INF ),\
  668. (char)DrvLetter,\
  669. (struct MEDIA_ID_INF far *)pMediaInf ))
  670. //**********************************************************************
  671. // Fills in a user supplied buffer with the current directory path string
  672. // for a specified drive. The path does not contain the drive letter or
  673. // root directory specifier, ie: "dos\user\bin". To get the current
  674. // directory on the current drive call the function with drive
  675. // specified as 0.
  676. //
  677. // int DllGetdCwd( int iDrive, char *szBuf )
  678. //
  679. // ARGUMENTS:
  680. // iDrive - Drive specifier (0=default,1=A:,2=B:,3=C:,...)
  681. // szBuf - Ptr to buffer to accept path string which should be 256
  682. // bytes in length.
  683. // RETURNS:
  684. // int - OK if specified drive C runtime error code
  685. //
  686. //**********************************************************************
  687. #define DllGetdCwd( iDrive, szBuf )\
  688. ((int)(*DllEntry)( DLL_GET_CWD_ID, 2,\
  689. WORD_TYPE + TRANS_NONE,\
  690. FSZPTR_TYPE + TRANS_DEST,\
  691. (int)iDrive,\
  692. (char far *)szBuf ))
  693. //**********************************************************************
  694. // Sets the working directory to that specified by a path string passed
  695. // by the caller. The path string may include a drive specifier and the
  696. // path may be relative to the current directory on the drive affected.
  697. //
  698. // int DllSetCwd( char *szBuf )
  699. //
  700. // ARGUMENTS:
  701. // szBuf - Ptr to string which specifies the directory to change to.
  702. // RETURNS:
  703. // int - OK if specified drive C runtime error code
  704. //
  705. //**********************************************************************
  706. #define DllSetCwd( szBuf )\
  707. ((int)(*DllEntry)( DLL_SET_CWD_ID, 1,\
  708. FSZPTR_TYPE + TRANS_SRC,\
  709. (char far *)szBuf ))
  710. //**********************************************************************
  711. // Gets the current drive using DOS function 0x19. The value obtained is
  712. // the based 1 drive (A:=1, B:=2, C:=3, ...)
  713. //
  714. // void DllGetDrive( unsigned *pDrive )
  715. //
  716. // ARGUMENTS:
  717. // pDrive - Pointer to unsigned value where the drive number will
  718. // be stored.
  719. // RETURNS:
  720. // void
  721. //
  722. //**********************************************************************
  723. #define DllGetDrive( pDrive )\
  724. ((void)(*DllEntry)( DLL_GET_DRV_ID, 1,\
  725. FPTR_TYPE + TRANS_DEST,\
  726. sizeof( unsigned ),\
  727. (unsigned far *)pDrive ))
  728. //**********************************************************************
  729. // Sets the current drive using DOS function 0x0e. The drive is specified
  730. // using base 1 so that A:=1, B:=2, C:=3, etc.
  731. //
  732. // void DllSetDrive( unsigned uDrive, unsigned *pNumDrvs )
  733. //
  734. // ARGUMENTS:
  735. // uDrive - Drive number to set as current drive.
  736. // pNumDrvs - Pointer to unsigned value where the total number of drives
  737. // in the system will be store. (This is the value of
  738. // lastdrive= in the config.sys).
  739. // RETURNS:
  740. // void - No return value is passed. Use DllGetDrive() to determine
  741. // if the call was successful.
  742. //
  743. //**********************************************************************
  744. #define DllSetDrive( uDrive, pNumDrvs )\
  745. ((void)(*DllEntry)( DLL_SET_DRV_ID, 2,\
  746. WORD_TYPE + TRANS_NONE,\
  747. FPTR_TYPE + TRANS_DEST,\
  748. sizeof( unsigned ),\
  749. (unsigned)(uDrive),\
  750. (unsigned far *)pNumDrvs ))
  751. //**********************************************************************
  752. // Creates a new directory with the specified name. The string specifying
  753. // the name may be a fully qualified path or relative to the current
  754. // drive and directory.
  755. //
  756. // int DllMakeDir( char *szDir )
  757. //
  758. // ARGUMENTS:
  759. // szDir - Ptr to path directory name string
  760. // RETURNS:
  761. // int - OK in successfull else C runtime error code of
  762. // EACCESS if directory already exists or conflicting
  763. // file name, or ENOENT if the path is invalid
  764. //
  765. //**********************************************************************
  766. #define DllMakeDir( szDir )\
  767. ((int)(*DllEntry)( DLL_MKDIR, 1,\
  768. FSZPTR_TYPE + TRANS_SRC,\
  769. (char far *)szDir ))
  770. //**********************************************************************
  771. // Deletes the directory with the specified name. The string specifying
  772. // the name may be a fully qualified path or relative to the current
  773. // drive and directory.
  774. //
  775. // int DllRemoveDir( char *szDir )
  776. //
  777. // ARGUMENTS:
  778. // szDir - Ptr to directory name string
  779. // RETURNS:
  780. // int - OK in successfull else C runtime error code of
  781. // EACCESS if name given is not a directory or the
  782. // directory is not empty or is the current or
  783. // root directory, or ENOENT if the path is invalid.
  784. //
  785. //**********************************************************************
  786. #define DllRemoveDir( szDir )\
  787. ((int)(*DllEntry)( DLL_RMDIR, 1,\
  788. FSZPTR_TYPE + TRANS_SRC,\
  789. (char far *)szDir ))
  790. //**********************************************************************
  791. // Creates a complete directory path from a caller supplied path string.
  792. // Any or all of the directories in the specified path may already
  793. // exist when the function is called. The path string may be drive or
  794. // UNC based and may include a trailing backslash.
  795. //
  796. // int DllCreateDirTree( char *szPath )
  797. //
  798. // ARGUMENTS:
  799. // szPath - Fully qualified path string.
  800. // RETURNS:
  801. // int - OK if successful else EACCES or ENOENT
  802. //
  803. //**********************************************************************
  804. #define DllCreateDirTree( szDir )\
  805. ((int)(*DllEntry)( DLL_MKDIR_TREE, 1,\
  806. FSZPTR_TYPE + TRANS_SRC,\
  807. (char far *)szDir ))
  808. //**********************************************************************
  809. // Main entry point for the find/grep engine. Accepts a command line and
  810. // emulates the DOS FIND command.
  811. //
  812. //
  813. // int FindFiles( char *szCmdLine, FIND_CALLBACK FindCallBack )
  814. //
  815. // szCmdLine is ptr to commandline string.
  816. //
  817. // "srcfiles [SrchCriteria] [/V] [/C] [/N] [/I]
  818. //
  819. // source Specifies the file or files to be finds
  820. // and may be substituted with /F:filename
  821. // to use filespecs from a text file.
  822. //
  823. // SrchCriteria Any extended search criteria supported by
  824. // by the findfile engine.
  825. //
  826. // /V Displays all lines NOT containing the specified string.
  827. // /C Displays only the count of lines containing the string.
  828. // /N Displays line numbers with the displayed lines.
  829. // /I Ignores the case of characters when searching for the string.
  830. //
  831. // FindCallBack is a ptr to a callback function which supports these
  832. // these callback functions.
  833. //
  834. // long (far pascal *FIND_CALLBACK)( int Func, unsigned uArg0,
  835. // void far *pArg1, void far *pArg2,
  836. // void far *pArg3 );
  837. //
  838. // CB_FIND_FLGS 0x0001 // Passing back parsed FIND flags
  839. // CB_FIND_ENVERR 0x0002 // Passing back non-fatal error
  840. // CB_FIND_SWITCH 0x0003 // Passing back unrecongized switch
  841. // CB_FIND_ERR_STR 0x0004 // Passing back error error string
  842. // CB_FIND_FOUND 0x0005 // File matching search criteria found
  843. // CB_FIND_MATCH 0x0006 // Passing back matching line from file
  844. // CB_FIND_COUNT 0x0007 // Passing back count of matching lines
  845. //
  846. //***********************************************************************
  847. #define DllFindFiles( szCmdLine, szEnv, CB_FindCallBack )\
  848. ((int)(*DllEntry)( DLL_FIND, 3,\
  849. FSZPTR_TYPE + TRANS_SRC,\
  850. FSZPTR_TYPE + TRANS_SRC,\
  851. DWORD_TYPE + TRANS_NONE,\
  852. (char far *)szCmdLine,\
  853. (char far *)szEnv,\
  854. (int (pascal far *)())CB_FindCallBack))
  855. //**********************************************************************
  856. // File touch engine entry function. Allows setting the time/date
  857. // stamp on files.
  858. //
  859. // int TouchFiles( char *szCmdLine, TOUCH_CALLBACK TouchCallBack )
  860. //
  861. // szCmdLine is ptr to commandline string.
  862. //
  863. // "srcfiles [SrchCriteria] [/TDM:mm-dd-yy[:hh:mm:ss]]
  864. // [/TTA:hh:mm:ss]
  865. // [/TDA:mm-dd-yy]
  866. //
  867. // source Specifies the file or files to be touches
  868. // and may be substituted with /F:filename
  869. // to use filespecs from a text file.
  870. //
  871. // SrchCriteria Any extended search criteria supported by
  872. // by the findfile engine.
  873. //
  874. // /TDM: Set last write date and optional time to specified value.
  875. // /TTM: Set last write time to specified value.
  876. // /TDA: Set last access date and optional time to specified value.
  877. // /TTA: Set last access time to specified value.
  878. //
  879. // TouchCallBack is a ptr to a callback function which supports these
  880. // these callback functions.
  881. //
  882. // long (far pascal *TOUCH_CALLBACK)( int Func, unsigned uArg0,
  883. // void far *pArg1, void far *pArg2,
  884. // void far *pArg3 );
  885. //
  886. // CB_TOUCH_FLGS 0x0001 // Passing back parsed TOUCH flags
  887. // CB_TOUCH_ENVERR 0x0002 // Passing back non-fatal error
  888. // CB_TOUCH_SWITCH 0x0003 // Passing back unrecongized switch
  889. // CB_TOUCH_ERR_STR 0x0004 // Passing back error error string
  890. // CB_TOUCH_FOUND 0x0005 // File matching search criteria found
  891. //
  892. //***********************************************************************
  893. #define DllTouchFiles( szCmdLine, szEnv, CB_TouchCallBack )\
  894. ((int)(*DllEntry)( DLL_TOUCH, 3,\
  895. FSZPTR_TYPE + TRANS_SRC,\
  896. FSZPTR_TYPE + TRANS_SRC,\
  897. DWORD_TYPE + TRANS_NONE,\
  898. (char far *)szCmdLine,\
  899. (char far *)szEnv,\
  900. (int (pascal far *)())CB_TouchCallBack))
  901. //**********************************************************************
  902. // File Attrib engine entry function. Allows setting access attributes
  903. // on files
  904. //
  905. // int AttribFiles( char *szCmdLine, char *szEnvStr,
  906. // ATTRIB_CALLBACK CB_AttrMain )
  907. //
  908. // szCmdLine is ptr to commandline string.
  909. //
  910. // "srcfiles [SrchCriteria] [{+|-}A] [{+|-}H] [{+|-}R] [{+|-}S]
  911. //
  912. // source Specifies the file or files to be attribs
  913. // and may be substituted with /F:filename
  914. // to use filespecs from a text file.
  915. //
  916. // SrchCriteria Any extended search criteria supported by
  917. // by the findfile engine.
  918. //
  919. // + Sets an attribute.
  920. // - Clears an attribute.
  921. // R Read-only file attribute.
  922. // A Archive file attribute.
  923. // S System file attribute.
  924. // H Hidden file attribute.
  925. // /S Processes files in all directories in the specified path.
  926. //
  927. //
  928. // AttribCallBack is a ptr to a callback function which supports these
  929. // these callback functions.
  930. //
  931. // long (far pascal *ATTRIB_CALLBACK)( int Func, unsigned uArg0,
  932. // void far *pArg1, void far *pArg2,
  933. // void far *pArg3 );
  934. //
  935. // CB_ATTRIB_FLGS 0x0001 // Passing back parsed ATTRIB flags
  936. // CB_ATTRIB_ENVERR 0x0002 // Passing back non-fatal error
  937. // CB_ATTRIB_SWITCH 0x0003 // Passing back unrecongized switch
  938. // CB_ATTRIB_ERR_STR 0x0004 // Passing back error error string
  939. // CB_ATTRIB_FOUND 0x0005 // File matching search criteria found
  940. //
  941. //***********************************************************************
  942. #define DllAttribFiles( szCmdLine, szEnv, CB_AttribCallBack )\
  943. ((int)(*DllEntry)( DLL_ATTRIB, 3,\
  944. FSZPTR_TYPE + TRANS_SRC,\
  945. FSZPTR_TYPE + TRANS_SRC,\
  946. DWORD_TYPE + TRANS_NONE,\
  947. (char far *)szCmdLine,\
  948. (char far *)szEnv,\
  949. (int (pascal far *)())CB_AttribCallBack))
  950. //**********************************************************************
  951. // Sets up the country specific information for the .DLL. The country
  952. // information is passed in a a buffer containg:
  953. //
  954. // Offset
  955. // 0 Case map table
  956. // 256 Collate table
  957. // 512 File name char table
  958. // 768 Extended country information structure
  959. // 808 END
  960. //
  961. // int DllSetCntryInfo( char far *pBuf )
  962. //
  963. // ARGUMENTS:
  964. // pBuf - Ptr to buffer described above
  965. // RETURNS:
  966. // void
  967. //
  968. //**********************************************************************
  969. #define DllSetCntryInfo( pBuf )\
  970. ((void)(*DllEntry)( DLL_SET_CNTRY_INF, 1,\
  971. FPTR_TYPE + TRANS_SRC,\
  972. (unsigned)(808),\
  973. (char far *)pBuf ))
  974. //**********************************************************************
  975. // Frees the instance data for the current instance of the DLL. Should
  976. // be the last call a Windows App makes to the DLL.
  977. //
  978. // int ReleaseDataSeg( void )
  979. //
  980. // ARGUMENTS:
  981. // NONE
  982. // RETURNS:
  983. // int - OK if successful else ERR_MEM_CORRUPT
  984. //
  985. //**********************************************************************
  986. #define DllReleaseInstance( )\
  987. ((int)(*DllEntry)( DLL_RELEASE, 0 ))