home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c034 / 7.ddi / INCLUDE / BSEDOS.H$ / BSEDOS.bin
Encoding:
Text File  |  1990-01-05  |  47.2 KB  |  1,522 lines

  1. /***************************************************************************\
  2. *
  3. * Module Name: BSEDOS.H
  4. *
  5. * OS/2 Base Include File
  6. *
  7. * Copyright (c) 1987-1990, Microsoft Corporation.  All rights reserved.
  8. *
  9. * =======================================================================
  10. *
  11. * Subcomponents marked with "+" are partially included by default
  12. *
  13. *   #define:        To include:
  14. *
  15. * + INCL_DOSPROCESS    Process and thread support
  16. *   INCL_DOSINFOSEG    InfoSeg support
  17. * + INCL_DOSFILEMGR    File Management
  18. * + INCL_DOSMEMMGR    Memory Management
  19. * + INCL_DOSSEMAPHORES    Semaphore support
  20. * + INCL_DOSDATETIME    Date/Time and Timer support
  21. *   INCL_DOSMODULEMGR    Module manager
  22. * + INCL_DOSRESOURCES    Resource support
  23. *   INCL_DOSNLS     National Language Support
  24. *   INCL_DOSSIGNALS    Signals
  25. *   INCL_DOSMISC    Miscellaneous
  26. *   INCL_DOSMONITORS    Monitors
  27. *   INCL_DOSQUEUES    Queues
  28. *   INCL_DOSSESMGR    Session Manager Support
  29. *   INCL_DOSDEVICES    Device specific, ring 2 support
  30. *   INCL_DOSNMPIPES    Named Pipes Support
  31. *   INCL_DOSTRACE    Trace support
  32. *
  33. \***************************************************************************/
  34.  
  35. #define INCL_DOSINCLUDED
  36.  
  37. #ifdef INCL_DOS
  38.  
  39. #define INCL_DOSPROCESS
  40. #define INCL_DOSINFOSEG
  41. #define INCL_DOSFILEMGR
  42. #define INCL_DOSMEMMGR
  43. #define INCL_DOSSEMAPHORES
  44. #define INCL_DOSDATETIME
  45. #define INCL_DOSMODULEMGR
  46. #define INCL_DOSRESOURCES
  47. #define INCL_DOSNLS
  48. #define INCL_DOSSIGNALS
  49. #define INCL_DOSMISC
  50. #define INCL_DOSMONITORS
  51. #define INCL_DOSQUEUES
  52. #define INCL_DOSSESMGR
  53. #define INCL_DOSDEVICES
  54. #define INCL_DOSNMPIPES
  55. #define INCL_DOSTRACE
  56.  
  57. #endif /* INCL_DOS */
  58.  
  59. #ifdef INCL_ERRORS
  60. #define INCL_DOSERRORS
  61. #endif /* INCL_ERRORS */
  62.  
  63. #if (defined(INCL_DOSPROCESS) || !defined(INCL_NOCOMMON))
  64.  
  65. /*** General services */
  66.  
  67. USHORT APIENTRY DosBeep(USHORT usFrequency, USHORT usDuration);
  68.  
  69. /*** Process and Thread support */
  70.  
  71. VOID APIENTRY DosExit(USHORT fTerminate, USHORT usExitCode);
  72.  
  73. /* DosExit fTerminate */
  74. #define EXIT_THREAD        0
  75. #define EXIT_PROCESS        1
  76.  
  77. #endif /* common INCL_DOSPROCESS definitions */
  78.  
  79. #if (defined(INCL_DOSPROCESS) && !defined(INCL_DOSPROCESS_INCLUDED))
  80. #define INCL_DOSPROCESS_INCLUDED
  81.  
  82. typedef struct _PIDINFO {    /* pidi */
  83.     PID pid;
  84.     TID tid;
  85.     PID pidParent;
  86. } PIDINFO;
  87. typedef PIDINFO FAR *PPIDINFO;
  88.  
  89. typedef VOID (FAR *PFNTHREAD)(VOID);
  90.  
  91. USHORT APIENTRY DosCreateThread(PFNTHREAD pfnFun, PTID pTid, PBYTE pbStack);
  92. USHORT APIENTRY DosResumeThread(TID tid);
  93. USHORT APIENTRY DosSuspendThread(TID tid);
  94.  
  95. /* DosCwait fScope */
  96. #define DCWA_PROCESS        0
  97. #define DCWA_PROCESSTREE    1
  98.  
  99. /* DosCwait ffWait */
  100. #define DCWW_WAIT        0
  101. #define DCWW_NOWAIT        1
  102.  
  103. typedef struct _RESULTCODES {    /* resc */
  104.     USHORT codeTerminate;
  105.     USHORT codeResult;
  106. } RESULTCODES;
  107. typedef RESULTCODES FAR *PRESULTCODES;
  108.  
  109. USHORT APIENTRY DosCwait(USHORT fScope, USHORT fWait, PRESULTCODES prescResults,
  110.              PPID ppidProcess, PID pidWaitProcess);
  111. USHORT APIENTRY DosSleep(ULONG ulTime);
  112.  
  113. /* codeTerminate values (also passed to ExitList routines) */
  114. #define TC_EXIT     0
  115. #define TC_HARDERROR    1
  116. #define TC_TRAP     2
  117. #define TC_KILLPROCESS    3
  118.  
  119. typedef VOID (PASCAL FAR *PFNEXITLIST)(USHORT);
  120.  
  121. USHORT APIENTRY DosEnterCritSec(VOID);
  122. USHORT APIENTRY DosExitCritSec(VOID);
  123. USHORT APIENTRY DosExitList(USHORT fFnCode, PFNEXITLIST pfnFunction);
  124.  
  125. /* DosExitList fFnCode    */
  126. #define EXLST_ADD    1
  127. #define EXLST_REMOVE    2
  128. #define EXLST_EXIT    3
  129.  
  130. USHORT APIENTRY DosExecPgm(PCHAR pchFailName, SHORT cbFailName,
  131.                USHORT fExecFlags, PSZ pszArgs, PSZ pszEnv,
  132.                PRESULTCODES prescResults, PSZ pszPgmName);
  133.  
  134. /* DosExecPgm fExecFlags */
  135. #define EXEC_SYNC        0
  136. #define EXEC_ASYNC        1
  137. #define EXEC_ASYNCRESULT    2
  138. #define EXEC_TRACE        3
  139. #define EXEC_BACKGROUND     4
  140.  
  141. USHORT APIENTRY DosGetPID(PPIDINFO ppidInfo);
  142. USHORT APIENTRY DosGetPPID(USHORT pidChild, PUSHORT ppidParent);
  143.  
  144. USHORT APIENTRY DosGetPrty(USHORT usScope, PUSHORT pusPriority, USHORT pid);
  145. USHORT APIENTRY DosSetPrty(USHORT usScope, USHORT fPrtyClass, SHORT sChange,
  146.                USHORT id);
  147.  
  148. /* DosGetPrty/DosSetPrty usScope */
  149. #define PRTYS_PROCESS        0
  150. #define PRTYS_PROCESSTREE    1
  151. #define PRTYS_THREAD        2
  152.  
  153. /* DosGetPrty/DosSetPrty priority classes */
  154. #define PRTYC_NOCHANGE        0
  155. #define PRTYC_IDLETIME        1
  156. #define PRTYC_REGULAR        2
  157. #define PRTYC_TIMECRITICAL    3
  158. #define PRTYC_FOREGROUNDSERVER    4
  159.  
  160. /* DosSetPrty priority deltas (sChange) */
  161. #define PRTYD_MINIMUM        (-31)
  162. #define PRTYD_MAXIMUM        31
  163.  
  164. USHORT APIENTRY DosKillProcess(USHORT usScope, PID pidProcess);
  165.  
  166. /* DosKillProcess usScope */
  167. #define DKP_PROCESSTREE     0
  168. #define DKP_PROCESS        1
  169.  
  170. #endif /* INCL_DOSPROCESS */
  171.  
  172.  
  173. /*** InfoSeg support */
  174.  
  175. #if (defined(INCL_DOSINFOSEG) && !defined(INCL_DOSINFOSEG_INCLUDED))
  176. #define INCL_DOSINFOSEG_INCLUDED
  177.  
  178. /* Global Information Segment */
  179.  
  180. typedef struct _GINFOSEG {    /* gis */
  181.     ULONG    time;
  182.     ULONG    msecs;
  183.     UCHAR    hour;
  184.     UCHAR    minutes;
  185.     UCHAR    seconds;
  186.     UCHAR    hundredths;
  187.     USHORT    timezone;
  188.     USHORT    cusecTimerInterval;
  189.     UCHAR    day;
  190.     UCHAR    month;
  191.     USHORT    year;
  192.     UCHAR    weekday;
  193.     UCHAR    uchMajorVersion;
  194.     UCHAR    uchMinorVersion;
  195.     UCHAR    chRevisionLetter;
  196.     UCHAR    sgCurrent;
  197.     UCHAR    sgMax;
  198.     UCHAR    cHugeShift;
  199.     UCHAR    fProtectModeOnly;
  200.     USHORT    pidForeground;
  201.     UCHAR    fDynamicSched;
  202.     UCHAR    csecMaxWait;
  203.     USHORT    cmsecMinSlice;
  204.     USHORT    cmsecMaxSlice;
  205.     USHORT    bootdrive;
  206.     UCHAR    amecRAS[32];
  207.     UCHAR    csgWindowableVioMax;
  208.     UCHAR    csgPMMax;
  209. } GINFOSEG;
  210. typedef GINFOSEG FAR *PGINFOSEG;
  211.  
  212. /* Local Information Segment */
  213.  
  214. typedef struct _LINFOSEG {    /* lis */
  215.     PID    pidCurrent;
  216.     PID    pidParent;
  217.     USHORT    prtyCurrent;
  218.     TID    tidCurrent;
  219.     USHORT    sgCurrent;
  220.     UCHAR    rfProcStatus;
  221.     UCHAR    dummy1;
  222.     BOOL    fForeground;
  223.     UCHAR    typeProcess;
  224.     UCHAR    dummy2;
  225.     SEL    selEnvironment;
  226.     USHORT    offCmdLine;
  227.     USHORT    cbDataSegment;
  228.     USHORT    cbStack;
  229.     USHORT    cbHeap;
  230.     HMODULE hmod;
  231.     SEL    selDS;
  232. } LINFOSEG;
  233. typedef LINFOSEG FAR *PLINFOSEG;
  234.  
  235. /* Process Type codes (local information segment typeProcess field)    */
  236.  
  237. #define PT_FULLSCREEN        0 /* Full screen application        */
  238. #define PT_REALMODE        1 /* Real mode process            */
  239. #define PT_WINDOWABLEVIO    2 /* VIO windowable application     */
  240. #define PT_PM            3 /* Presentation Manager application    */
  241. #define PT_DETACHED        4 /* Detached application        */
  242.  
  243. /* Process Status Flag definitions (local info seg rfProcStatus field)    */
  244.  
  245. #define PS_EXITLIST        1 /* Thread is in exitlist routine    */
  246.  
  247.  
  248. USHORT APIENTRY DosGetInfoSeg(PSEL pselGlobal, PSEL pselLocal);
  249.  
  250. /* Helper macros used to convert selector to PINFOSEG or LINFOSEG    */
  251.  
  252. #define MAKEPGINFOSEG(sel)  ((PGINFOSEG)MAKEP(sel, 0))
  253. #define MAKEPLINFOSEG(sel)  ((PLINFOSEG)MAKEP(sel, 0))
  254.  
  255. #endif /* INCL_DOSINFOSEG */
  256.  
  257. #ifndef INCL_SAADEFS
  258.  
  259. /*
  260.  * CCHMAXPATH is the maximum fully qualified path name length including
  261.  * the drive letter, colon, backslashes and terminating NULL.
  262.  */
  263. #define CCHMAXPATH    260
  264.  
  265. /*
  266.  * CCHMAXPATHCOMP is the maximum individual path component name length
  267.  * including a terminating NULL.
  268.  */
  269. #define CCHMAXPATHCOMP    256
  270.  
  271. #endif  /* !INCL_SAADEFS */
  272.  
  273. #if ((defined(INCL_DOSFILEMGR) || !defined(INCL_NOCOMMON)) && !defined(INCL_DOSFILEMGR_INCLUDED))
  274. #define INCL_DOSFILEMGR_INCLUDED
  275.  
  276. /*** File manager */
  277.  
  278. /* DosChgFilePtr() file position codes */
  279.  
  280. #define FILE_BEGIN        0x0000 /* relative to beginning of file    */
  281. #define FILE_CURRENT        0x0001 /* relative to current fptr position*/
  282. #define FILE_END        0x0002 /* relative to end of file       */
  283.  
  284. /* DosFindFirst/Next Directory handle types */
  285.  
  286. #define HDIR_SYSTEM        0x0001    /* Use system handle (1)       */
  287. #define HDIR_CREATE        0xFFFF    /* Allocate a new, unused handle   */
  288.  
  289. /* DosCopy control bits - may be or'ed together */
  290. #define DCPY_EXISTING        0x00001 /* Copy even if target exists       */
  291. #define DCPY_APPEND        0x00002 /* Append to existing file, don't replace*/
  292.  
  293. /* Dosopen/DosQFHandState/DosQueryFileInfo et al file attributes; also        */
  294. /* known as Dso File Mode bits...                                             */
  295. #define FILE_NORMAL        0x0000
  296. #define FILE_READONLY        0x0001
  297. #define FILE_HIDDEN        0x0002
  298. #define FILE_SYSTEM        0x0004
  299. #define FILE_DIRECTORY        0x0010
  300. #define FILE_ARCHIVED        0x0020
  301.  
  302. /* DosOpen() actions */
  303. #define FILE_EXISTED        0x0001
  304. #define FILE_CREATED        0x0002
  305. #define FILE_TRUNCATED        0x0003
  306.  
  307. /* DosOpen() open flags */
  308. #define FILE_OPEN        0x0001
  309. #define FILE_TRUNCATE        0x0002
  310. #define FILE_CREATE        0x0010
  311.  
  312. /* applies if file already exists */
  313.  
  314. #define OPEN_ACTION_FAIL_IF_EXISTS     0x0000  /* ---- ---- ---- 0000    */
  315. #define OPEN_ACTION_OPEN_IF_EXISTS     0x0001  /* ---- ---- ---- 0001    */
  316. #define OPEN_ACTION_REPLACE_IF_EXISTS  0x0002  /* ---- ---- ---- 0010    */
  317.  
  318. /* applies if file does not exist */
  319.  
  320. #define OPEN_ACTION_FAIL_IF_NEW        0x0000  /* ---- ---- 0000 ----    */
  321. #define OPEN_ACTION_CREATE_IF_NEW      0x0010  /* ---- ---- 0001 ----    */
  322.  
  323. /* DosOpen/DosSetFHandState flags */
  324.  
  325. #define OPEN_ACCESS_READONLY        0x0000    /* ---- ---- ---- -000    */
  326. #define OPEN_ACCESS_WRITEONLY        0x0001    /* ---- ---- ---- -001    */
  327. #define OPEN_ACCESS_READWRITE        0x0002    /* ---- ---- ---- -010    */
  328. #define OPEN_SHARE_DENYREADWRITE    0x0010    /* ---- ---- -001 ----    */
  329. #define OPEN_SHARE_DENYWRITE        0x0020    /* ---- ---- -010 ----    */
  330. #define OPEN_SHARE_DENYREAD        0x0030    /* ---- ---- -011 ----    */
  331. #define OPEN_SHARE_DENYNONE        0x0040    /* ---- ---- -100 ----    */
  332. #define OPEN_FLAGS_NOINHERIT        0x0080    /* ---- ---- 1--- ----    */
  333. #define OPEN_FLAGS_NO_LOCALITY        0x0000    /* ---- -000 ---- ----    */
  334. #define OPEN_FLAGS_SEQUENTIAL        0x0100    /* ---- -001 ---- ----    */
  335. #define OPEN_FLAGS_RANDOM        0x0200    /* ---- -010 ---- ----    */
  336. #define OPEN_FLAGS_RANDOMSEQUENTIAL    0x0300    /* ---- -011 ---- ----    */
  337. #define OPEN_FLAGS_NO_CACHE        0x1000    /* ---1 ---- ---- ----    */
  338. #define OPEN_FLAGS_FAIL_ON_ERROR    0x2000    /* --1- ---- ---- ----    */
  339. #define OPEN_FLAGS_WRITE_THROUGH    0x4000    /* -1-- ---- ---- ----    */
  340. #define OPEN_FLAGS_DASD         0x8000    /* 1--- ---- ---- ----    */
  341.  
  342.  
  343. /* DosSearchPath() constants from 1.1 (backword compatability) */
  344.  
  345. #define SEARCH_PATH        0x0000
  346. #define SEARCH_CUR_DIRECTORY    0x0001
  347. #define SEARCH_ENVIRONMENT    0x0002
  348. #define SEARCH_IGNORENETERRS    0x0004
  349.  
  350. /* DosSearchPath() constants for 1.2 and later */
  351. #define DSP_PATH        0 /* path is specified in parameter    */
  352. #define DSP_CUR_DIRECTORY    1 /* current dir will be searched first */
  353. #define DSP_ENVIRONMENT     2 /* from envirnoment variable        */
  354. #define DSP_IGNORENETERR    4 /* ignore net errs & continue search    */
  355.  
  356. USHORT APIENTRY DosSearchPath(USHORT fsSearch, PSZ pszPath, PSZ pszFName,
  357.                   PBYTE pBuf, USHORT cbBuf);
  358.  
  359. /*
  360.  * DosFileIO
  361.  */
  362. /* File IO command words */
  363. #define FIO_LOCK        0    /* Lock Files            */
  364. #define FIO_UNLOCK        1    /* Unlock Files         */
  365. #define FIO_SEEK        2    /* Seek (set file ptr)        */
  366. #define FIO_READ        3    /* File Read            */
  367. #define FIO_WRITE        4    /* File Write            */
  368.  
  369. /* Lock Sharing Modes */
  370. #define FIO_NOSHARE        0    /* None             */
  371. #define FIO_SHAREREAD        1    /* Read-Only            */
  372.  
  373. typedef struct    _FIOLOCKCMD {    /* FLC    FileLockCmd prefix    */
  374.     USHORT    usCmd;        /* Cmd = FIO_LOCK        */
  375.     USHORT    cLockCnt;    /* Lock records that follow    */
  376.     ULONG    cTimeOut;    /* in Msec            */
  377. } FIOLOCKCMD;
  378. typedef FIOLOCKCMD FAR *PFIOLOCKCMD;
  379.  
  380. typedef struct    _FIOLOCKREC {    /* FLR FileLockRecord           */
  381.     USHORT fShare;        /* FIO_NOSHARE or FIO_SHAREREAD    */
  382.     ULONG  cbStart;     /* Starting offset for lock region */
  383.     ULONG  cbLength;    /* Length of lock region       */
  384. } FIOLOCKREC;
  385. typedef FIOLOCKREC FAR *PFIOLOCKREC;
  386.  
  387. typedef struct    _FIOUNLOCKCMD { /* FUC FileUnlockCmd prefix    */
  388.     USHORT    usCmd;        /* Cmd = FIO_UNLOCK        */
  389.     USHORT    cUnlockCnt;    /* Unlock records that follow    */
  390. } FIOUNLOCKCMD;
  391. typedef FIOUNLOCKCMD FAR *PFIOUNLOCKCMD;
  392.  
  393. typedef struct    _FIOUNLOCKREC { /* FUR FileUnlockRecord          */
  394.     ULONG    cbStart;    /* Starting offset for unlock region */
  395.     ULONG    cbLength;    /* Length of unlock region         */
  396. } FIOUNLOCKREC;
  397. typedef FIOUNLOCKREC FAR *PFIOUNLOCKREC;
  398.  
  399. typedef struct    _FIOSEEKCMD {    /* FSC Seek command structure          */
  400.     USHORT    usCmd;        /* Cmd = FIO_SEEK              */
  401.     USHORT    fsMethod;    /* One of&gml FPM_BEGINNING, FPM_CURRENT, */
  402.                 /* or FPM_END                  */
  403.     ULONG    cbDistance;    /* Byte offset for seek           */
  404.     ULONG    cbNewPosition;    /* Bytes from start of file after seek      */
  405. } FIOSEEKCMD;
  406. typedef FIOSEEKCMD FAR *PFIOSEEKCMD;
  407.  
  408. typedef struct    _FIOREADWRITE { /* FRWC Read&Write command structure     */
  409.     USHORT    usCmd;        /* Cmd = FIO_READ or FIO_WRITE        */
  410.     PVOID    pbBuffer;    /* Pointer to data buffer        */
  411.     USHORT    cbBufferLen;    /* Bytes in buffer or max size        */
  412.     USHORT    cbActualLen;    /* Bytes actually read/written        */
  413. } FIOREADWRITE;
  414. typedef FIOREADWRITE FAR *PFIOREADWRITE;
  415.  
  416. /***
  417.  * EA Info Levels & Find First/Next
  418.  * API's: DosFindFirst, DosQueryFileInfo, DosQueryPathInfo, DosSetFileInfo,
  419.  *      DosSetPathInfo
  420.  */
  421.  
  422. /* File info levels : All listed API's */
  423. #define FIL_STANDARD        1   /* Info level 1, standard file info */
  424. #define FIL_QUERYEASIZE     2   /* Level 2, return Full EA size    */
  425. #define FIL_QUERYEASFROMLIST    3   /* Level 3, return requested EA's   */
  426.  
  427. /* File info levels: Dos...PathInfo only */
  428. #define FIL_QUERYFULLNAME    5   /* Level 5, return fully qualified    */
  429.                     /*     name of file            */
  430. #define FIL_NAMEISVALID     6   /* Level 6, check validity of    */
  431.                     /* file/path name for this FSD    */
  432.  
  433. /* DosFindNotifyFirst() */
  434. #define FNOTIL_STANDARD     1   /* Find-Notify Info level 1&gml Return */
  435.                     /* standard directory change info       */
  436.  
  437. /* DosFsAttach() */
  438. /* Attact or detach */
  439. #define FSATTACH        0    /* Attach file server    */
  440. #define FSDETACH        1    /* Detach file server    */
  441.  
  442. /* DosFsCtl() */
  443. /* Routing type */
  444. #define FSCTL_HANDLE        1    /* File Handle directs req routing */
  445. #define FSCTL_PATHNAME        2    /* Path Name directs req routing   */
  446. #define FSCTL_FSDNAME        3    /* FSD Name directs req routing    */
  447.  
  448. /* DosQueryFSAttach() */
  449. /* Information level types (defines method of query) */
  450. #define FSAIL_QUERYNAME     1    /* Return data for a Drive or Device */
  451. #define FSAIL_DEVNUMBER     2    /* Return data for Ordinal Device #  */
  452. #define FSAIL_DRVNUMBER     3    /* Return data for Ordinal Drive #   */
  453.  
  454. /* Item types (from data structure item "iType") */
  455. #define FSAT_CHARDEV        1    /* Resident character device    */
  456. #define FSAT_PSEUDODEV        2    /* Pusedu-character device    */
  457. #define FSAT_LOCALDRV        3    /* Local drive            */
  458. #define FSAT_REMOTEDRV        4    /* Remote drive attached to FSD */
  459.  
  460. /* Data structure for QFSAttach       */
  461. typedef struct    _FSQBUFFER {    /* fsqbf */
  462.     USHORT    iType;        /* Item type                  */
  463.     USHORT    cbName;     /* Length of item name, sans NULL     */
  464.     UCHAR    szName[1];    /* ASCIIZ item name              */
  465.     USHORT    cbFSDName;    /* Length of FSD name, sans NULL      */
  466.     UCHAR    szFSDName[1];    /* ASCIIZ FSD name              */
  467.     USHORT    cbFSAData;    /* Length of FSD Attach data returned */
  468.     UCHAR    rgFSAData[1];    /* FSD Attach data from FSD          */
  469. } FSQBUFFER;
  470. typedef FSQBUFFER FAR *PFSQBUFFER;
  471.  
  472. /*
  473.  * File System Drive Information&gml DosQFSInfo DosSetFSInfo
  474.  */
  475.  
  476. /* FS Drive Info Levels                         */
  477. #define FSIL_ALLOC        1 /* Drive allocation info (Query only) */
  478. #define FSIL_VOLSER        2 /* Drive Volume/Serial information    */
  479.  
  480. /* HANDTYPE values */
  481.  
  482. #define HANDTYPE_FILE        0x0000
  483. #define HANDTYPE_DEVICE     0x0001
  484. #define HANDTYPE_PIPE        0x0002
  485. #define HANDTYPE_NETWORK    0x8000
  486.  
  487. /* DosQHandType() */
  488. /* Handle classes (low 8 bits of Handle Type)                */
  489. #define FHT_DISKFILE        0x0000    /* Disk file handle        */
  490. #define FHT_CHRDEV        0x0001    /* Character device handle    */
  491. #define FHT_PIPE        0x0002    /* Pipe handle            */
  492.  
  493. /* Handle bits (high 8 bits of Handle Type)                */
  494. #define FHB_DSKREMOTE        0x8000    /* Remote disk            */
  495. #define FHB_CHRDEVREMOTE    0x8001    /* Remote character device    */
  496. #define FHB_PIPEREMOTE        0x8002    /* Remote pipe            */
  497.  
  498.  
  499. #ifndef INCL_SAADEFS
  500.  
  501. /* File time and date types */
  502.  
  503. typedef struct _FTIME {     /* ftime */
  504.     unsigned twosecs : 5;
  505.     unsigned minutes : 6;
  506.     unsigned hours     : 5;
  507. } FTIME;
  508. typedef FTIME FAR *PFTIME;
  509.  
  510. typedef struct _FDATE {     /* fdate */
  511.     unsigned day     : 5;
  512.     unsigned month     : 4;
  513.     unsigned year     : 7;
  514. } FDATE;
  515. typedef FDATE FAR *PFDATE;
  516.  
  517. typedef struct _FILEFINDBUF {    /* findbuf */
  518.     FDATE    fdateCreation;
  519.     FTIME    ftimeCreation;
  520.     FDATE    fdateLastAccess;
  521.     FTIME    ftimeLastAccess;
  522.     FDATE    fdateLastWrite;
  523.     FTIME    ftimeLastWrite;
  524.     ULONG    cbFile;
  525.     ULONG    cbFileAlloc;
  526.     USHORT    attrFile;
  527.     UCHAR    cchName;
  528.     CHAR    achName[CCHMAXPATHCOMP];
  529. } FILEFINDBUF;
  530. typedef FILEFINDBUF FAR *PFILEFINDBUF;
  531.  
  532. typedef struct _FILEFINDBUF2 {    /* findbuf2 */
  533.     FDATE    fdateCreation;
  534.     FTIME    ftimeCreation;
  535.     FDATE    fdateLastAccess;
  536.     FTIME    ftimeLastAccess;
  537.     FDATE    fdateLastWrite;
  538.     FTIME    ftimeLastWrite;
  539.     ULONG    cbFile;
  540.     ULONG    cbFileAlloc;
  541.     USHORT    attrFile;
  542.     ULONG    cbList;
  543.     UCHAR    cchName;
  544.     CHAR    achName[CCHMAXPATHCOMP];
  545. } FILEFINDBUF2;
  546. typedef FILEFINDBUF2 FAR *PFILEFINDBUF2;
  547.  
  548. /* extended attribute structures */
  549. typedef struct _GEA {        /* gea */
  550.     BYTE    cbName;     /* name length not including NULL */
  551.     CHAR    szName[1];    /* attribute name          */
  552. } GEA;
  553. typedef GEA far *PGEA;
  554.  
  555. typedef struct _GEALIST {    /* geal */
  556.     ULONG  cbList;        /* total bytes of structure inc full list */
  557.     GEA    list[1];     /* variable length GEA structures      */
  558. } GEALIST;
  559. typedef GEALIST far * PGEALIST;
  560.  
  561. typedef struct _FEA {        /* fea */
  562.     BYTE    fEA;        /* flags                */
  563.     BYTE    cbName;     /* name length not including NULL    */
  564.     USHORT    cbValue;    /* value length             */
  565. } FEA;
  566. typedef FEA far *PFEA;
  567.  
  568. /* flags for _FEA.fEA */
  569.  
  570. #define FEA_NEEDEA 0x80     /* need EA bit */
  571.  
  572. typedef struct _FEALIST {    /* feal */
  573.     ULONG  cbList;        /* total bytes of structure inc full list */
  574.     FEA    list[1];     /* variable length FEA structures      */
  575. } FEALIST;
  576. typedef FEALIST far * PFEALIST;
  577.  
  578. typedef struct _EAOP {        /* eaop */
  579.     PGEALIST fpGEAList;    /* general EA list */
  580.     PFEALIST fpFEAList;    /* full EA list    */
  581.     ULONG     oError;
  582. } EAOP;
  583. typedef EAOP far * PEAOP;
  584.  
  585.  
  586. /*
  587.  * Equates for EA types
  588.  *
  589.  * Values 0xFFFE thru 0x8000 are reserved.
  590.  * Values 0x0000 thru 0x7fff are user definable.
  591.  * Value  0xFFFC is not used
  592.  */
  593.  
  594. #define EAT_BINARY    0xFFFE /* length preceeded binary       */
  595. #define EAT_ASCII    0xFFFD /* length preceeded ASCII       */
  596. #define EAT_BITMAP    0xFFFB /* length preceeded bitmap       */
  597. #define EAT_METAFILE    0xFFFA /* length preceeded metafile       */
  598. #define EAT_ICON    0xFFF9 /* length preceeded icon        */
  599. #define EAT_EA        0xFFEE /* length preceeded ASCII extended attribute */
  600.                    /* name of associated data (#include)*/
  601. #define EAT_MVMT    0xFFDF /* multi-valued, multi-typed field  */
  602. #define EAT_MVST    0xFFDE /* multi-valued, single-typed field */
  603. #define EAT_ASN1    0xFFDD /* ASN.1 field               */
  604.  
  605.  
  606. #endif  /* !INCL_SAADEFS */
  607.  
  608. USHORT APIENTRY DosOpen(PSZ pszFname, PHFILE phfOpen, PUSHORT pusAction,
  609.             ULONG ulFSize, USHORT usAttr, USHORT fsOpenFlags,
  610.             USHORT fsOpenMode, ULONG ulReserved);
  611. USHORT APIENTRY DosOpen2(PSZ pszFname, PHFILE phf, PUSHORT pusAction,
  612.              ULONG ulFSize, USHORT usAttr, USHORT usOpenFlags,
  613.              ULONG usOpenMode, PEAOP pvEABuf, ULONG ulReserved);
  614. USHORT APIENTRY DosClose(HFILE hf);
  615. USHORT APIENTRY DosRead(HFILE hf, PVOID pBuf, USHORT cbBuf,
  616.             PUSHORT pcbBytesRead);
  617. USHORT APIENTRY DosWrite(HFILE hf, PVOID bBuf, USHORT cbBuf,
  618.              PUSHORT pcbBytesWritten);
  619. USHORT APIENTRY DosOplockRelease(ULONG cookie, USHORT procBlkKey);
  620. USHORT APIENTRY DosOplockWait(PULONG pcookie, PULONG procBlkKey);
  621.  
  622. /* File system shutdown */
  623.  
  624. USHORT APIENTRY DosShutdown(ULONG ulReserved);
  625.  
  626. /* File time and date types */
  627.  
  628. typedef struct _FILESTATUS {    /* fsts */
  629.     FDATE    fdateCreation;
  630.     FTIME    ftimeCreation;
  631.     FDATE    fdateLastAccess;
  632.     FTIME    ftimeLastAccess;
  633.     FDATE    fdateLastWrite;
  634.     FTIME    ftimeLastWrite;
  635.     ULONG    cbFile;
  636.     ULONG    cbFileAlloc;
  637.     USHORT    attrFile;
  638. } FILESTATUS;
  639. typedef FILESTATUS FAR *PFILESTATUS;
  640.  
  641. typedef struct _FILESTATUS2 {     /* fsts2 */
  642.     FDATE    fdateCreation;
  643.     FTIME    ftimeCreation;
  644.     FDATE    fdateLastAccess;
  645.     FTIME    ftimeLastAccess;
  646.     FDATE    fdateLastWrite;
  647.     FTIME    ftimeLastWrite;
  648.     ULONG    cbFile;
  649.     ULONG    cbFileAlloc;
  650.     USHORT    attrFile;
  651.     ULONG    cbList;
  652. } FILESTATUS2;
  653. typedef FILESTATUS2 FAR *PFILESTATUS2;
  654.  
  655. typedef struct _FSALLOCATE {    /* fsalloc */
  656.     ULONG    ulReserved;
  657.     ULONG    cSectorUnit;
  658.     ULONG    cUnit;
  659.     ULONG    cUnitAvail;
  660.     USHORT    cbSector;
  661. } FSALLOCATE;
  662. typedef FSALLOCATE FAR *PFSALLOCATE;
  663.  
  664. typedef struct _VOLUMELABEL {    /* vol */
  665.     BYTE    cch;
  666.     CHAR    szVolLabel[12];
  667. } VOLUMELABEL;
  668. typedef VOLUMELABEL FAR *PVOLUMELABEL;
  669.  
  670. typedef struct _FSINFO {    /* fsinf */
  671.     ULONG ulVSN;
  672.     VOLUMELABEL vol;
  673. } FSINFO;
  674. typedef FSINFO FAR *PFSINFO;
  675.  
  676. typedef struct _FILELOCK {    /* flock */
  677.     LONG    lOffset;
  678.     LONG    lRange;
  679. } FILELOCK;
  680. typedef FILELOCK FAR *PFILELOCK;
  681.  
  682. typedef SHANDLE HDIR;        /* hdir */
  683. typedef HDIR FAR *PHDIR;
  684.  
  685. USHORT APIENTRY DosDelete(PSZ pszFName, ULONG ulReserverd);
  686. USHORT APIENTRY DosDupHandle(HFILE hfOld, PHFILE phfNew);
  687.  
  688. USHORT APIENTRY DosQFHandState(HFILE hf, PUSHORT pfsOpenMode);
  689. USHORT APIENTRY DosSetFHandState(HFILE hf, USHORT fsState);
  690. USHORT APIENTRY DosQHandType(HFILE hf, PUSHORT pfsType, PUSHORT pusDevAttr);
  691.  
  692. USHORT APIENTRY DosReadAsync (HFILE hf, PULONG hsemRam, PUSHORT pusErrCode,
  693.                   PVOID pBuf, USHORT cbBuf, PUSHORT pcbBytesRead);
  694. USHORT APIENTRY DosWriteAsync(HFILE hf, PULONG hsemRam, PUSHORT pusErrCode,
  695.                   PVOID pBuf, USHORT cbBuf, PUSHORT pcbBytesWritten);
  696.  
  697. USHORT APIENTRY DosFindFirst(PSZ pszFSpec, PHDIR phdir, USHORT usAttr,
  698.                  PFILEFINDBUF pffb, USHORT cbBuf, PUSHORT pcSearch,
  699.                  ULONG ulReserved);
  700. USHORT APIENTRY DosFindFirst2(PSZ pszFSpec, PHDIR phdir, USHORT usAttr,
  701.                   PVOID pBuf, USHORT cbBuf, PUSHORT pcSearch,
  702.                   USHORT usInfoLevel, ULONG ulReserved);
  703. USHORT APIENTRY DosFindNext(HDIR hdir, PFILEFINDBUF pffb, USHORT cbBuf,
  704.                 PUSHORT pcSearch);
  705. USHORT APIENTRY DosFindClose(HDIR hdir);
  706.  
  707. USHORT APIENTRY DosFSAttach(PSZ pszDevName, PSZ pszFSD, PBYTE pData,
  708.                 USHORT cbData, USHORT fsOp, ULONG ulReserved);
  709. USHORT APIENTRY DosQFSAttach(PSZ pszDev, USHORT usOrdinal, USHORT usInfoLevel,
  710.                  PBYTE pFSAttBuf, PUSHORT cbBuf, ULONG ulReserved);
  711. USHORT APIENTRY DosFSCtl(PBYTE pData, USHORT cbData, PUSHORT pcbData,
  712.              PBYTE pParms, USHORT cbParms, PUSHORT pcbParms,
  713.              USHORT usFunCode, PSZ pszRoute, HFILE hf,
  714.              USHORT usRouteMethod, ULONG ulReserved);
  715.  
  716. USHORT APIENTRY DosNewSize(HFILE hf, ULONG ulNewSize);
  717. USHORT APIENTRY DosBufReset(HFILE hf);
  718.  
  719. USHORT APIENTRY DosChgFilePtr(HFILE hf, LONG lOffset, USHORT fsMethod,
  720.                   PULONG pulNewOffset);
  721.  
  722. USHORT APIENTRY DosSetFilePtr(HFILE hf, LONG lOffset, USHORT fsMethod,
  723.                   PULONG pulNewOffset);
  724.  
  725. USHORT APIENTRY DosFileLocks(HFILE hf, PLONG pUnlock, PLONG pLock);
  726.  
  727. USHORT APIENTRY DosMove(PSZ pszOld, PSZ pszNew, ULONG ulReserved);
  728. USHORT APIENTRY DosCopy(PSZ pszSrc, PSZ pszDst, USHORT usOpt, ULONG ulReserved);
  729. USHORT APIENTRY DosEditName(USHORT usEditLevel, PSZ pszSrc, PSZ pszEdit,
  730.                 PBYTE pszDst, USHORT cbDst);
  731.  
  732. USHORT APIENTRY DosFileIO(HFILE hf, PBYTE pbCmd, USHORT cbCmd, PUSHORT pulErr);
  733. USHORT APIENTRY DosMkDir(PSZ pszDirName, ULONG usReserved);
  734. USHORT APIENTRY DosMkDir2(PSZ pszDir, PEAOP pBuf, ULONG ulReserved);
  735. USHORT APIENTRY DosRmDir(PSZ pszDir, ULONG ulReserved);
  736. USHORT APIENTRY DosSelectDisk(USHORT usDrvNum);
  737. USHORT APIENTRY DosQCurDisk(PUSHORT pusDrvNum, PULONG pulLogDrvMap);
  738.  
  739. USHORT APIENTRY DosChDir(PSZ pszDir, ULONG ulReserved);
  740. USHORT APIENTRY DosQCurDir(USHORT usDrvNum, PBYTE pszPathBuf,
  741.                PUSHORT pcbPathBuf);
  742.  
  743. USHORT APIENTRY DosQFSInfo(USHORT usDrvNum, USHORT usInfoLevel, PBYTE pbInfo,
  744.                USHORT cbInfo);
  745. USHORT APIENTRY DosSetFSInfo(USHORT usDrvNum, USHORT usInfoLevel, PBYTE pBuf,
  746.                  USHORT cbBuf);
  747. USHORT APIENTRY DosQVerify(PBOOL pfVerifyOn);
  748. USHORT APIENTRY DosSetVerify(USHORT fVerify);
  749. USHORT APIENTRY DosSetMaxFH(USHORT usHandles);
  750.  
  751. USHORT APIENTRY DosQFileInfo(HFILE hf, USHORT usInfoLevel, PVOID pInfoBuf,
  752.                  USHORT cbInfoBuf);
  753. USHORT APIENTRY DosSetFileInfo(HFILE hf, USHORT usInfoLevel, PBYTE pInfoBuf,
  754.                    USHORT cbInfoBuf);
  755. USHORT APIENTRY DosQPathInfo(PSZ pszPath, USHORT usInfoLevel, PBYTE pInfoBuf,
  756.                  USHORT cbInfoBuf, ULONG ulReserved);
  757. USHORT APIENTRY DosSetPathInfo(PSZ pszPath, USHORT usInfoLevel, PBYTE pInfoBuf,
  758.                    USHORT cbInfoBuf, USHORT usFlags,
  759.                    ULONG ulReserved);
  760.  
  761. /* defines for DosSetPathInfo -fsOptions flag */
  762. #define DSPI_WRTTHRU    0x10    /* write through */
  763.  
  764. USHORT APIENTRY DosQFileMode(PSZ pszFName, PUSHORT pusAttr, ULONG ulReserved);
  765. USHORT APIENTRY DosSetFileMode(PSZ pszFName, USHORT usAttr, ULONG ulReserved);
  766.  
  767. /* constants for DosEnumAttribute() */
  768. #define ENUMEA_REFTYPE_FHANDLE 0
  769. #define ENUMEA_REFTYPE_PATH    1
  770. #define ENUMEA_LEVEL_NO_VALUE  1L
  771.  
  772. USHORT APIENTRY DosEnumAttribute(USHORT, PVOID, ULONG, PVOID, ULONG, PULONG,
  773.                  ULONG, ULONG);
  774. /* ENUMEA_LEVEL_NO_VALUE info returned from DosEnumAttribute */
  775. typedef struct _DENA1 {    /* dena */
  776.     UCHAR    reserved;  /* 0                       */
  777.     UCHAR    cbName;    /* length of name exculding NULL          */
  778.     USHORT    cbValue;   /* length of value                  */
  779.     UCHAR    szName[1]; /* variable length asciiz name          */
  780. } DENA1;
  781. typedef DENA1 FAR *PDENA1;
  782.  
  783. #endif /* common INCL_DOSFILEMGR */
  784.  
  785. #if (defined(INCL_DOSMEMMGR) || !defined(INCL_NOCOMMON))
  786. /*** Memory management */
  787.  
  788. USHORT APIENTRY DosAllocSeg(USHORT cbSize, PSEL pSel, USHORT fsAlloc);
  789. USHORT APIENTRY DosReallocSeg(USHORT cbNewSize, SEL sel);
  790. USHORT APIENTRY DosFreeSeg(SEL sel);
  791. USHORT APIENTRY DosGiveSeg(SEL sel, PID pid, PSEL pSelRecipient);
  792. USHORT APIENTRY DosGetSeg(SEL sel);
  793. USHORT APIENTRY DosSizeSeg(SEL sel, PULONG pcbSize);
  794.  
  795. /* Segment attribute flags (used with DosAllocSeg) */
  796.  
  797. #define SEG_NONSHARED        0x0000
  798. #define SEG_GIVEABLE        0x0001
  799. #define SEG_GETTABLE        0x0002
  800. #define SEG_DISCARDABLE     0x0004
  801. #define SEG_SIZEABLE        0x0008
  802.  
  803. #endif /* common INCL_DOSMEMMGR */
  804.  
  805. #if (defined(INCL_DOSMEMMGR) && !defined(INCL_DOSMEMMGR_INCLUDED))
  806. #define INCL_DOSMEMMGR_INCLUDED
  807.  
  808. USHORT APIENTRY DosAllocHuge(USHORT cSegs, USHORT cbPartialSeg, PSEL psel,
  809.                  USHORT cMaxSegs, USHORT fsAlloc);
  810. USHORT APIENTRY DosReallocHuge(USHORT cSegs, USHORT cbPartialSeg, SEL sel);
  811. USHORT APIENTRY DosGetHugeShift(PUSHORT pusShiftCount);
  812.  
  813. USHORT APIENTRY DosAllocShrSeg(USHORT cbSeg, PSZ pszSegName, PSEL psel);
  814.  
  815. USHORT APIENTRY DosLockSeg(SEL sel);
  816. USHORT APIENTRY DosUnlockSeg(SEL sel);
  817.  
  818. USHORT APIENTRY DosGetShrSeg(PSZ pszSegName, PSEL psel);
  819.  
  820. USHORT APIENTRY DosMemAvail(PULONG pcbFree);
  821. USHORT APIENTRY DosCreateCSAlias(SEL selDS, PSEL pselCS);
  822.  
  823. USHORT APIENTRY DosSubAlloc(SEL sel, PUSHORT pusOffset, USHORT cb);
  824. USHORT APIENTRY DosSubFree(SEL sel, USHORT offBlock, USHORT cb);
  825. USHORT APIENTRY DosSubSet(SEL sel, USHORT fFlags, USHORT cbNew);
  826.  
  827. #endif /* INCL_DOSMEMMGR */
  828.  
  829. #if (defined(INCL_DOSSEMAPHORES) || !defined(INCL_NOCOMMON))
  830.  
  831. /*** Semaphore support */
  832.  
  833. #define SEM_INDEFINITE_WAIT    (-1L)
  834. #define SEM_IMMEDIATE_RETURN    0L
  835.  
  836. USHORT APIENTRY DosSemClear(HSEM hsem);
  837. USHORT APIENTRY DosSemSet(HSEM hsem);
  838. USHORT APIENTRY DosSemWait(HSEM hsem, LONG lTimeOut);
  839. USHORT APIENTRY DosSemSetWait(HSEM hsem, LONG lTimeOut);
  840. USHORT APIENTRY DosSemRequest(HSEM hsem, LONG lTimeOut);
  841.  
  842. #endif /* common INCL_DOSSEMAPHORES */
  843.  
  844. #if (defined(INCL_DOSSEMAPHORES) && !defined(INCL_DOSSEMAPHORES_INCLUDED))
  845. #define INCL_DOSSEMAPHORES_INCLUDED
  846.  
  847. typedef LHANDLE HSYSSEM;    /* hssm */
  848. typedef HSYSSEM FAR *PHSYSSEM;
  849.  
  850. USHORT APIENTRY DosCreateSem(USHORT fExclusive, PHSYSSEM phsem, PSZ pszSemName);
  851.  
  852. #define CSEM_PRIVATE        0
  853. #define CSEM_PUBLIC        1
  854.  
  855. USHORT APIENTRY DosOpenSem(PHSEM phsem, PSZ pszSemName);
  856. USHORT APIENTRY DosCloseSem(HSEM hsem);
  857.  
  858. typedef struct _MUXSEM {    /* mxs */
  859.     USHORT    zero;
  860.     HSEM    hsem;
  861. } MUXSEM;
  862. typedef MUXSEM FAR *PMUXSEM;
  863.  
  864. typedef struct _MUXSEMLIST {    /* mxsl */
  865.     USHORT    cmxs;
  866.     MUXSEM    amxs[16];
  867. } MUXSEMLIST;
  868. typedef MUXSEMLIST FAR *PMUXSEMLIST;
  869.  
  870. /*
  871.  * Since a MUXSEMLIST structure is actually a variable length
  872.  * structure, the following macro may be used to define a MUXSEMLIST
  873.  * structure having size elements, named "name".
  874.  */
  875. #define DEFINEMUXSEMLIST(name, size) \
  876.     struct {                 \
  877.     USHORT cmxs;             \
  878.     MUXSEM amxs[size];         \
  879.     } name;
  880.  
  881. /*
  882.  * This function actually takes a far pointer to a MUXSEMLIST structure
  883.  * as its second parameter, but in order to allow its use with the
  884.  * DEFINEMUXSEMLIST macro, it is declared here as PVOID.
  885.  */
  886. USHORT APIENTRY DosMuxSemWait(PUSHORT pisemCleared, PVOID pmsxl, LONG lTimeOut);
  887.  
  888.  
  889. /*** Fast safe ram semaphores */
  890.  
  891. typedef struct _DOSFSRSEM {    /* dosfsrs */
  892.     USHORT    cb;
  893.     PID    pid;
  894.     TID    tid;
  895.     USHORT    cUsage;
  896.     USHORT    client;
  897.     ULONG    sem;
  898. } DOSFSRSEM;
  899. typedef DOSFSRSEM FAR *PDOSFSRSEM;
  900.  
  901. USHORT APIENTRY DosFSRamSemRequest(PDOSFSRSEM pdosfsrs, LONG lTimeOut);
  902. USHORT APIENTRY DosFSRamSemClear(PDOSFSRSEM pdosfsrs);
  903.  
  904. #endif /* INCL_DOSSEMAPHORES */
  905.  
  906. #if ((defined(INCL_DOSDATETIME) || !defined(INCL_NOCOMMON)) && !defined(INCL_DOSDATETIME_INCLUDED))
  907.  
  908. /*** Time support */
  909.  
  910. typedef struct _DATETIME {    /* date */
  911.     UCHAR    hours;
  912.     UCHAR    minutes;
  913.     UCHAR    seconds;
  914.     UCHAR    hundredths;
  915.     UCHAR    day;
  916.     UCHAR    month;
  917.     USHORT    year;
  918.     SHORT    timezone;
  919.     UCHAR    weekday;
  920. } DATETIME;
  921. typedef DATETIME FAR *PDATETIME;
  922.  
  923. USHORT APIENTRY DosGetDateTime(PDATETIME pdatetime);
  924. USHORT APIENTRY DosSetDateTime(PDATETIME pdatetime);
  925.  
  926. #endif /* common INCL_DOSDATETIME */
  927.  
  928. #if (defined(INCL_DOSDATETIME) && !defined(INCL_DOSDATETIME_INCLUDED))
  929. #define INCL_DOSDATETIME_INCLUDED
  930.  
  931. typedef SHANDLE HTIMER;
  932. typedef HTIMER FAR *PHTIMER;
  933.  
  934. USHORT APIENTRY DosTimerAsync(ULONG ulTime, HSEM hsem, PHTIMER phtimer);
  935. USHORT APIENTRY DosTimerStart(ULONG ulTime, HSEM hsem, PHTIMER phtimer);
  936. USHORT APIENTRY DosTimerStop(HTIMER htimer);
  937.  
  938. #endif /* INCL_DOSDATETIME */
  939.  
  940.  
  941. /*** Module manager */
  942.  
  943. #if (defined(INCL_DOSMODULEMGR) && !defined(INCL_DOSMODULEMGR_INCLUDED))
  944. #define INCL_DOSMODULEMGR_INCLUDED
  945.  
  946. USHORT APIENTRY DosLoadModule(PSZ pszFailName, USHORT cbFileName,
  947.                               PSZ pszModName, PHMODULE phmod);
  948. USHORT APIENTRY DosFreeModule(HMODULE hmod);
  949. USHORT APIENTRY DosGetProcAddr(HMODULE hmod, PSZ pszProcName,
  950.                    PPFN ppfnProcAddr);
  951. USHORT APIENTRY DosGetModHandle(PSZ pszModName, PHMODULE phMod);
  952. USHORT APIENTRY DosGetModName(HMODULE hmod, USHORT cbBuf, PCHAR pchBuf);
  953.  
  954. #endif /* INCL_DOSMODULEMGR */
  955.  
  956. #if (defined(INCL_DOSRESOURCES) || !defined(INCL_NOCOMMON))
  957.  
  958. /*** Resource support */
  959.  
  960. /* Predefined resource types */
  961.  
  962. #define RT_POINTER        1   /* mouse pointer shape        */
  963. #define RT_BITMAP        2   /* bitmap                */
  964. #define RT_MENU         3   /* menu template            */
  965. #define RT_DIALOG        4   /* dialog template            */
  966. #define RT_STRING        5   /* string tables            */
  967. #define RT_FONTDIR        6   /* font directory            */
  968. #define RT_FONT         7   /* font                */
  969. #define RT_ACCELTABLE        8   /* accelerator tables        */
  970. #define RT_RCDATA        9   /* binary data            */
  971. #define RT_MESSAGE        10  /* error mesage tables        */
  972. #define RT_DLGINCLUDE        11  /* dialog include file name     */
  973. #define RT_VKEYTBL        12  /* key to vkey tables        */
  974. #define RT_KEYTBL        13  /* key to UGL tables        */
  975. #define RT_CHARTBL        14
  976. #define RT_DISPLAYINFO        15  /* screen display information    */
  977.  
  978. #define RT_FKASHORT        16  /* function key area short form    */
  979. #define RT_FKALONG        17  /* function key area long form    */
  980.  
  981. #define RT_HELPTABLE        18
  982. #define RT_HELPSUBTABLE     19
  983.  
  984. #define RT_FDDIR        20
  985. #define RT_FD            21
  986.  
  987. #define RT_MAX            22  /* 1st unused Resource Type     */
  988.  
  989.  
  990. #endif /* common INCL_DOSRESOURCES */
  991.  
  992. #if (defined(INCL_DOSRESOURCES) && !defined(INCL_DOSRESOURCES_INCLUDED))
  993. #define INCL_DOSRESOURCES_INCLUDED
  994.  
  995. USHORT APIENTRY DosGetResource(HMODULE hmod, USHORT idType, USHORT idName,
  996.                    PSEL psel);
  997. USHORT APIENTRY DosGetResource2(HMODULE hmod, USHORT idType, USHORT idName,
  998.                 PVOID FAR * ppData);
  999. USHORT APIENTRY DosFreeResource(PVOID pData);
  1000.  
  1001. #endif /* INCL_DOSRESOURCES */
  1002.  
  1003.  
  1004. /*** NLS Support */
  1005.  
  1006. #if (defined(INCL_DOSNLS) && !defined(INCL_DOSNLS_INCLUDED))
  1007. #define INCL_DOSNLS_INCLUDED
  1008.  
  1009. typedef struct _COUNTRYCODE {    /* ctryc */
  1010.     USHORT    country;
  1011.     USHORT    codepage;
  1012. } COUNTRYCODE;
  1013. typedef COUNTRYCODE FAR *PCOUNTRYCODE;
  1014.  
  1015. /* fsDateFmt */
  1016.  
  1017. #define DATEFMT_MM_DD_YY  0x0000
  1018. #define DATEFMT_DD_MM_YY  0x0001
  1019. #define DATEFMT_YY_MM_DD  0x0002
  1020.  
  1021. /* fsCurrencyFmt */
  1022.  
  1023. #define CURRENCY_FOLLOW   0x0001
  1024. #define CURRENCY_SPACE    0x0002
  1025. #define CURRENCY_DECIMAL  0x0004
  1026.  
  1027. typedef struct _COUNTRYINFO {    /* ctryi */
  1028.     USHORT    country;
  1029.     USHORT    codepage;
  1030.     USHORT    fsDateFmt;
  1031.     CHAR    szCurrency[5];
  1032.     CHAR    szThousandsSeparator[2];
  1033.     CHAR    szDecimal[2];
  1034.     CHAR    szDateSeparator[2];
  1035.     CHAR    szTimeSeparator[2];
  1036.     UCHAR    fsCurrencyFmt;
  1037.     UCHAR    cDecimalPlace;
  1038.     UCHAR    fsTimeFmt;
  1039.     USHORT    abReserved1[2];
  1040.     CHAR    szDataSeparator[2];
  1041.     USHORT    abReserved2[5];
  1042. } COUNTRYINFO;
  1043. typedef COUNTRYINFO FAR *PCOUNTRYINFO;
  1044.  
  1045. USHORT APIENTRY DosGetCtryInfo(USHORT cbBuf, PCOUNTRYCODE pctryc,
  1046.                    PCOUNTRYINFO pctryi, PUSHORT pcbCtryInfo);
  1047. USHORT APIENTRY DosGetDBCSEv(USHORT cbBuf, PCOUNTRYCODE pctryc, PCHAR pchBuf);
  1048. USHORT APIENTRY DosCaseMap(USHORT usLen, PCOUNTRYCODE pctryc, PCHAR pchStr);
  1049. USHORT APIENTRY DosGetCollate(USHORT cbBuf, PCOUNTRYCODE pctryc, PCHAR pchBuf,
  1050.                   PUSHORT pcbTable);
  1051. USHORT APIENTRY DosGetCp(USHORT cbBuf, PUSHORT pBuf, PUSHORT pcbCodePgLst);
  1052. USHORT APIENTRY DosSetCp(USHORT usCodePage, USHORT usReserved);
  1053. USHORT APIENTRY DosSetProcCp(USHORT usCodePage, USHORT usReserved);
  1054.  
  1055. #endif /* INCL_DOSNLS */
  1056.  
  1057.  
  1058. /*** Signal support */
  1059.  
  1060. #if (defined(INCL_DOSSIGNALS) && !defined(INCL_DOSSIGNALS_INCLUDED))
  1061. #define INCL_DOSSIGNALS_INCLUDED
  1062.  
  1063. /* Signal Numbers for DosSetSigHandler  */
  1064.  
  1065. #define SIG_CTRLC        1    /* Control C              */
  1066. /*    (UNDEFINED)        2       reserved for future use    */
  1067. #define SIG_KILLPROCESS     3    /* Program Termination          */
  1068. #define SIG_CTRLBREAK        4    /* Control Break          */
  1069. #define SIG_PFLG_A        5    /* Process Flag A          */
  1070. #define SIG_PFLG_B        6    /* Process Flag B          */
  1071. #define SIG_PFLG_C        7    /* Process Flag C          */
  1072. #define SIG_CSIGNALS        8    /* number of signals plus one */
  1073.  
  1074. /* Flag Numbers for DosFlagProcess */
  1075.  
  1076. #define PFLG_A            0    /* Process Flag A          */
  1077. #define PFLG_B            1    /* Process Flag B          */
  1078. #define PFLG_C            2    /* Process Flag C          */
  1079.  
  1080. /* Signal actions */
  1081.  
  1082. #define SIGA_KILL        0
  1083. #define SIGA_IGNORE        1
  1084. #define SIGA_ACCEPT        2
  1085. #define SIGA_ERROR        3
  1086. #define SIGA_ACKNOWLEDGE    4
  1087.  
  1088. /* DosHoldSignal constants */
  1089.  
  1090. #define HLDSIG_ENABLE        0
  1091. #define HLDSIG_DISABLE        1
  1092.  
  1093. /* DosFlagProcess codes */
  1094.  
  1095. #define FLGP_SUBTREE        0
  1096. #define FLGP_PID        1
  1097.  
  1098. typedef VOID (PASCAL FAR *PFNSIGHANDLER)(USHORT, USHORT);
  1099.  
  1100. USHORT APIENTRY DosSetSigHandler(PFNSIGHANDLER pfnSigHandler,
  1101.                  PFNSIGHANDLER FAR * ppfnPrev, PUSHORT pfAction,
  1102.                  USHORT fAction, USHORT usSigNum);
  1103. USHORT APIENTRY DosFlagProcess(PID pid, USHORT fScope, USHORT usFlagNum,
  1104.                    USHORT usFlagArg);
  1105. USHORT APIENTRY DosHoldSignal(USHORT fDisable);
  1106. USHORT APIENTRY DosSendSignal(USHORT idProcess, USHORT usSigNumber);
  1107.  
  1108. #endif /* INCL_DOSSIGNALS */
  1109.  
  1110.  
  1111. /*** Monitor support */
  1112.  
  1113. #if (defined(INCL_DOSMONITORS) && !defined(INCL_DOSMONITORS_INCLUDED))
  1114. #define INCL_DOSMONITORS_INCLUDED
  1115.  
  1116. #define MONITOR_DEFAULT 0x0000
  1117. #define MONITOR_BEGIN   0x0001
  1118. #define MONITOR_END     0x0002
  1119.  
  1120. typedef SHANDLE HMONITOR;    /* hmon */
  1121. typedef HMONITOR FAR *PHMONITOR;
  1122.  
  1123. typedef struct _MONIN {     /* mnin */
  1124.     USHORT cb;
  1125.     BYTE abReserved[18];
  1126.     BYTE abBuffer[108];
  1127. } MONIN;
  1128. typedef MONIN FAR *PMONIN;
  1129.  
  1130. typedef struct _MONOUT {    /* mnout */
  1131.     USHORT cb;
  1132.     UCHAR buffer[18];
  1133.     BYTE abBuf[108];
  1134. } MONOUT;
  1135. typedef MONOUT FAR *PMONOUT;
  1136.  
  1137. USHORT APIENTRY DosMonOpen(PSZ pszDevName, PHMONITOR phmon);
  1138. USHORT APIENTRY DosMonClose(HMONITOR hmon);
  1139. USHORT APIENTRY DosMonReg(HMONITOR hmon, PBYTE pbInBuf, PBYTE pbOutBuf,
  1140.               USHORT fPosition, USHORT usIndex);
  1141. USHORT APIENTRY DosMonRead(PBYTE pbInBuf, USHORT fWait, PBYTE pbDataBuf,
  1142.                PUSHORT pcbData);
  1143. USHORT APIENTRY DosMonWrite(PBYTE pbOutBuf, PBYTE pbDataBuf, USHORT cbData);
  1144.  
  1145. #endif /* INCL_DOSMONITORS */
  1146.  
  1147.  
  1148. /*** Pipe and queue support */
  1149.  
  1150. #if (defined(INCL_DOSQUEUES) && !defined(INCL_DOSQUEUES_INCLUDED))
  1151. #define INCL_DOSQUEUES_INCLUDED
  1152.  
  1153. /* DosCreateQueue() priority */
  1154.  
  1155. #define QUE_FIFO       0x0000
  1156. #define QUE_LIFO       0x0001
  1157. #define QUE_PRIORITY   0x0002
  1158.  
  1159. typedef SHANDLE HQUEUE;     /* hq */
  1160. typedef HQUEUE FAR *PHQUEUE;
  1161.  
  1162. typedef struct _QUEUERESULT {    /* qresc */
  1163.     PID pidProcess;
  1164.     USHORT usEventCode;
  1165. } QUEUERESULT;
  1166. typedef QUEUERESULT FAR *PQUEUERESULT;
  1167.  
  1168. USHORT APIENTRY DosMakePipe(PHFILE phfRead, PHFILE phfWrite, USHORT cb);
  1169. USHORT APIENTRY DosCloseQueue(HQUEUE hqueue);
  1170. USHORT APIENTRY DosCreateQueue(PHQUEUE phqueue, USHORT fQueueOrder,
  1171.                    PSZ pszQueueName);
  1172. USHORT APIENTRY DosOpenQueue(PUSHORT ppidOwner, PHQUEUE phqueue,
  1173.                  PSZ pszQueueName);
  1174. USHORT APIENTRY DosPeekQueue(HQUEUE hqueue, PQUEUERESULT pqresc,
  1175.                  PUSHORT pcbElement, PULONG ppBuf,
  1176.                  PUSHORT pElemCode, UCHAR fWait,
  1177.                  PBYTE pbElemPrty, ULONG hsem);
  1178. USHORT APIENTRY DosPurgeQueue(HQUEUE hqueue);
  1179. USHORT APIENTRY DosQueryQueue(HQUEUE hqueue, PUSHORT pcElem);
  1180. USHORT APIENTRY DosReadQueue(HQUEUE hqueue, PQUEUERESULT pqresc,
  1181.                  PUSHORT pcbElem, PVOID FAR *ppv, USHORT usElem,
  1182.                  UCHAR fWait, PBYTE pbElemPrty, HSEM hsem);
  1183. USHORT APIENTRY DosWriteQueue(HQUEUE hqueue, USHORT usRequest, USHORT cbBuf,
  1184.                   PBYTE pBuf, UCHAR fPriority);
  1185.  
  1186. #endif /* INCL_DOSQUEUES */
  1187.  
  1188. #if (defined(INCL_DOSMISC) && !defined(INCL_DOSMISC_INCLUDED))
  1189. #define INCL_DOSMISC_INCLUDED
  1190.  
  1191. /* DosQSysInfo index */
  1192. #define Q_MAX_PATH_LENGTH    0 /* index for query max path length  */
  1193.  
  1194. /* DosError() error-handling types */
  1195.  
  1196. #define HARDERROR_ENABLE    0x0001
  1197. #define HARDERROR_DISABLE    0x0000
  1198. #define EXCEPTION_ENABLE    0x0000
  1199. #define EXCEPTION_DISABLE    0x0002
  1200.  
  1201. /* DosSetVec vectors */
  1202.  
  1203. #define VECTOR_DIVIDE_BY_ZERO    0x0000
  1204. #define VECTOR_OVERFLOW     0x0004
  1205. #define VECTOR_OUTOFBOUNDS    0x0005
  1206. #define VECTOR_INVALIDOPCODE    0x0006
  1207. #define VECTOR_NO_EXTENSION    0x0007
  1208. #define VECTOR_EXTENSION_ERROR    0x0010
  1209.  
  1210. /* DosGetMachineMode() machine modes */
  1211.  
  1212. #define MODE_REAL    0x0000
  1213. #define MODE_PROTECTED    0x0001
  1214.  
  1215. USHORT APIENTRY DosError(USHORT fEnable);
  1216. USHORT APIENTRY DosSetVec(USHORT usVecNum, PFN pfnFun, PPFN ppfnPrev);
  1217. USHORT APIENTRY DosGetMessage(PCHAR FAR * ppchVTable, USHORT usVCount,
  1218.                   PCHAR pchBuf, USHORT cbBuf, USHORT usMsgNum,
  1219.                   PSZ pszFileName, PUSHORT pcbMsg);
  1220. USHORT APIENTRY DosErrClass(USHORT usErrCode, PUSHORT pusClass,
  1221.                 PUSHORT pfsAction, PUSHORT pusLocus);
  1222. USHORT APIENTRY DosInsMessage(PCHAR FAR * ppchVTable, USHORT usVCount,
  1223.                   PSZ pszMsg, USHORT cbMsg, PCHAR pchBuf,
  1224.                   USHORT cbBuf, PUSHORT pcbMsg);
  1225. USHORT APIENTRY DosPutMessage(HFILE hf, USHORT cbMsg, PCHAR pchMsg);
  1226. USHORT APIENTRY DosQSysInfo(USHORT index, PBYTE pBuf, USHORT cbBuf);
  1227. USHORT APIENTRY DosGetEnv(PUSHORT pselEnv, PUSHORT pOffsetCmd);
  1228. USHORT APIENTRY DosScanEnv(PSZ pszVarName, PSZ    FAR * ppszResult);
  1229. USHORT APIENTRY DosGetVersion(PUSHORT pVer);
  1230. USHORT APIENTRY DosGetMachineMode(PBYTE pMachMode);
  1231.  
  1232. #endif /* INCL_DOSMISC */
  1233.  
  1234.  
  1235. /*** Session manager support */
  1236.  
  1237. #if (defined(INCL_DOSSESMGR) && !defined(INCL_DOSSESMGR_INCLUDED))
  1238. #define INCL_DOSSESMGR_INCLUDED
  1239.  
  1240. /* DosQAppType() application types */
  1241.  
  1242. #define NOTSPECIFIED    0x0000
  1243. #define NOTWINDOCOMPAT    0x0001
  1244. #define WINDOWCOMPAT    0x0002
  1245. #define WINDOWAPI    0x0003
  1246. #define BOUND        0x0008
  1247. #define DYNAMICLINK    0x0010
  1248. #define DOSFORMAT    0x0020
  1249.  
  1250. typedef struct _STARTDATA {    /* stdata */
  1251.     USHORT    Length;
  1252.     USHORT    Related;
  1253.     USHORT    FgBg;
  1254.     USHORT    TraceOpt;
  1255.     PSZ    PgmTitle;
  1256.     PSZ    PgmName;
  1257.     PBYTE    PgmInputs;
  1258.     PBYTE    TermQ;
  1259.     PBYTE    Environment;
  1260.     USHORT    InheritOpt;
  1261.     USHORT    SessionType;
  1262.     PSZ    IconFile;
  1263.     ULONG    PgmHandle;
  1264.     USHORT    PgmControl;
  1265.     USHORT    InitXPos;
  1266.     USHORT    InitYPos;
  1267.     USHORT    InitXSize;
  1268.     USHORT    InitYSize;
  1269. } STARTDATA;
  1270. typedef STARTDATA FAR *PSTARTDATA;
  1271.  
  1272. /* STATUSDATA.SelectInd constants */
  1273.  
  1274. #define TARGET_UNCHANGED       0x0000
  1275. #define TARGET_SELECTABLE      0x0001
  1276. #define TARGET_NOT_SELECTABLE  0x0002
  1277.  
  1278. /* STATUSDATA.BondInd constants */
  1279.  
  1280. #define BOND_UNCHANGED  0x0000
  1281. #define BOND_CHILD      0x0001
  1282. #define BOND_NONE       0x0002
  1283.  
  1284. typedef struct _STATUSDATA {    /* stsdata */
  1285.     USHORT    Length;
  1286.     USHORT    SelectInd;
  1287.     USHORT    BondInd;
  1288. } STATUSDATA;
  1289. typedef STATUSDATA FAR *PSTATUSDATA;
  1290.  
  1291. USHORT APIENTRY DosStartSession(PSTARTDATA pstdata, PUSHORT pidSession,
  1292.                 PUSHORT ppid);
  1293. USHORT APIENTRY DosSetSession(USHORT idSession, PSTATUSDATA pstsdata);
  1294. USHORT APIENTRY DosSelectSession(USHORT idSession, ULONG ulReserved);
  1295. USHORT APIENTRY DosStopSession(USHORT fScope, USHORT idSession,
  1296.                    ULONG ulReserved);
  1297. USHORT APIENTRY DosQAppType(PSZ pszPrgName, PUSHORT pusType);
  1298.  
  1299. #endif /* INCL_DOSSESMGR */
  1300.  
  1301.  
  1302. /*** Device support */
  1303.  
  1304. #if (defined(INCL_DOSDEVICES) && !defined(INCL_DOSDEVICES_INCLUDED))
  1305. #define INCL_DOSDEVICES_INCLUDED
  1306.  
  1307. /* DosPhysicalDisk() physical disk information */
  1308.  
  1309. #define INFO_COUNT_PARTITIONABLE_DISKS    0x0001
  1310. #define INFO_GETIOCTLHANDLE        0x0002
  1311. #define INFO_FREEIOCTLHANDLE        0x0003
  1312.  
  1313. /* DosDevConfig information requests */
  1314.  
  1315. #define DEVINFO_PRINTER      0x0000
  1316. #define DEVINFO_RS232        0x0001
  1317. #define DEVINFO_FLOPPY       0x0002
  1318. #define DEVINFO_COPROCESSOR  0x0003
  1319. #define DEVINFO_SUBMODEL     0x0004
  1320. #define DEVINFO_MODEL        0x0005
  1321. #define DEVINFO_ADAPTER      0x0006
  1322.  
  1323. USHORT APIENTRY DosDevConfig(PVOID pDevInfo, USHORT usItem, USHORT usReserved);
  1324. USHORT APIENTRY DosDevIOCtl(PVOID pData, PVOID pParms, USHORT usFun,
  1325.                 USHORT usCategory, HFILE hDev);
  1326. USHORT APIENTRY DosDevIOCtl2(PVOID pData, USHORT cbData, PVOID pParm,
  1327.                  USHORT cbParm, USHORT usFun, USHORT usCategory,
  1328.                  HFILE hDev);
  1329.  
  1330. USHORT APIENTRY DosCLIAccess(VOID);
  1331. USHORT APIENTRY DosPortAccess(USHORT usReserved, USHORT fRelease,
  1332.                   USHORT usFirstPort, USHORT usLastPort);
  1333. USHORT APIENTRY DosPhysicalDisk(USHORT usFun, PBYTE pOut, USHORT cbOut,
  1334.                 PBYTE pParm, USHORT cbParm);
  1335.  
  1336. USHORT APIENTRY DosR2StackRealloc(USHORT cbStack);
  1337. VOID   APIENTRY DosCallback(PFN pfn);
  1338.  
  1339. #endif /* INCL_DOSDEVICES */
  1340.  
  1341.  
  1342. /*** DosNamedPipes API Support */
  1343.  
  1344. #if (defined(INCL_DOSNMPIPES) && !defined(INCL_DOSNMPIPES_INCLUDED))
  1345. #define INCL_DOSNMPIPES_INCLUDED
  1346.  
  1347. typedef SHANDLE HPIPE;        /* hp */
  1348. typedef HPIPE FAR *PHPIPE;
  1349.  
  1350. /*** Data structures and equates used with named pipes ***/
  1351.  
  1352. typedef struct _PIPEINFO { /* nmpinf */
  1353.     USHORT cbOut;
  1354.     USHORT cbIn;
  1355.     BYTE   cbMaxInst;
  1356.     BYTE   cbCurInst;
  1357.     BYTE   cbName;
  1358.     CHAR   szName[1];
  1359. } PIPEINFO;
  1360. typedef PIPEINFO FAR *PPIPEINFO;
  1361.  
  1362. /* The following structure for backward compatability to nmpipe.h */
  1363.  
  1364. struct    npi_data1 {    /* PipeInfo data block (returned, level 1) */
  1365.     unsigned short    npi_obuflen;    /* length of outgoing I/O buffer */
  1366.     unsigned short    npi_ibuflen;    /* length of incoming I/O buffer */
  1367.     unsigned char    npi_maxicnt;    /* maximum number of instances     */
  1368.     unsigned char    npi_curicnt;    /* current number of instances     */
  1369.     unsigned char    npi_namlen;    /* length of pipe name         */
  1370.     char    npi_name[1];        /* start of name         */
  1371. };    /* npi_data1 */
  1372.  
  1373. typedef struct _PIPESEMSTATE {    /* nmpsmst */
  1374.     BYTE   fStatus;
  1375.     BYTE   fFlag;
  1376.     USHORT usKey;
  1377.     USHORT usAvail;
  1378. } PIPESEMSTATE;
  1379. typedef PIPESEMSTATE FAR *PPIPESEMSTATE;
  1380.  
  1381. /* The following structure for backward compatability to nmpipe.h */
  1382.  
  1383. struct  npss    {       /* QNmPipeSemState information record */
  1384.     unsigned char    npss_status; /* type of record, 0 = EOI, 1 = read ok, */
  1385.                                      /*   2 = write ok, 3 = pipe closed       */
  1386.     unsigned char    npss_flag;   /* additional info, 01 = waiting thread  */
  1387.     unsigned short    npss_key;    /* user's key value                      */
  1388.     unsigned short    npss_avail;  /* available data/space if status = 1/2  */
  1389. };    /* npss */
  1390.  
  1391. /* values in npss_status */
  1392. #define NPSS_EOI        0 /* End Of Information    */
  1393. #define NPSS_RDATA        1 /* read data available   */
  1394. #define NPSS_WSPACE        2 /* write space available */
  1395. #define NPSS_CLOSE        3 /* pipe in CLOSING state */
  1396.  
  1397. /* values in npss_flag */
  1398. #define NPSS_WAIT        0x01  /* waiting thread on end of pipe */
  1399.  
  1400. /* defined bits in pipe mode */
  1401. #define NP_NBLK         0x8000 /* non-blocking read/write */
  1402. #define NP_SERVER        0x4000 /* set if server end      */
  1403. #define NP_WMESG        0x0400 /* write messages      */
  1404. #define NP_RMESG        0x0100 /* read as messages      */
  1405. #define NP_ICOUNT        0x00FF /* instance count field      */
  1406.  
  1407.  
  1408. /*    Named pipes may be in one of several states depending on the actions
  1409.  *    that have been taken on it by the server end and client end.  The
  1410.  *    following state/action table summarizes the valid state transitions:
  1411.  *
  1412.  *    Current state        Action            Next state
  1413.  *
  1414.  *     <none>         server DosMakeNmPipe    DISCONNECTED
  1415.  *     DISCONNECTED        server connect        LISTENING
  1416.  *     LISTENING        client open         CONNECTED
  1417.  *     CONNECTED        server disconn        DISCONNECTED
  1418.  *     CONNECTED        client close        CLOSING
  1419.  *     CLOSING        server disconn        DISCONNECTED
  1420.  *     CONNECTED        server close        CLOSING
  1421.  *     <any other>        server close        <pipe deallocated>
  1422.  *
  1423.  *    If a server disconnects his end of the pipe, the client end will enter a
  1424.  *    special state in which any future operations (except close) on the file
  1425.  *    descriptor associated with the pipe will return an error.
  1426.  */
  1427.  
  1428. /*
  1429.  *    Values for named pipe state
  1430.  */
  1431.  
  1432. #define NP_DISCONNECTED     1 /* after pipe creation or Disconnect */
  1433. #define NP_LISTENING        2 /* after DosNmPipeConnect           */
  1434. #define NP_CONNECTED        3 /* after Client open               */
  1435. #define NP_CLOSING        4 /* after Client or Server close      */
  1436.  
  1437. /* DosMakeNmPipe open modes */
  1438.  
  1439. #define NP_ACCESS_INBOUND    0x0000
  1440. #define NP_ACCESS_OUTBOUND    0x0001
  1441. #define NP_ACCESS_DUPLEX    0x0002
  1442. #define NP_INHERIT        0x0000
  1443. #define NP_NOINHERIT        0x0080
  1444. #define NP_WRITEBEHIND        0x0000
  1445. #define NP_NOWRITEBEHIND    0x4000
  1446.  
  1447. /* DosMakeNmPipe and DosQNmPHandState state */
  1448.  
  1449. #define NP_READMODE_BYTE    0x0000
  1450. #define NP_READMODE_MESSAGE    0x0100
  1451. #define NP_TYPE_BYTE        0x0000
  1452. #define NP_TYPE_MESSAGE     0x0400
  1453. #define NP_END_CLIENT        0x0000
  1454. #define NP_END_SERVER        0x4000
  1455. #define NP_WAIT         0x0000
  1456. #define NP_NOWAIT        0x8000
  1457. #define NP_UNLIMITED_INSTANCES    0x00FF
  1458.  
  1459. typedef struct _AVAILDATA   {    /* PeekNMPipe Bytes Available record */
  1460.     USHORT    cbpipe;     /* bytes left in the pipe         */
  1461.     USHORT    cbmessage;    /* bytes left in current message     */
  1462. } AVAILDATA;
  1463. typedef AVAILDATA FAR *PAVAILDATA;
  1464.  
  1465. USHORT APIENTRY DosCallNmPipe(PSZ pszName, PBYTE pInBuf, USHORT cbInBuf,
  1466.                   PBYTE pbOutBuf, USHORT cbOutBuf, PUSHORT pcbRead,
  1467.                   ULONG ulTimeOut);
  1468. USHORT APIENTRY DosConnectNmPipe(HPIPE hp);
  1469. USHORT APIENTRY DosDisConnectNmPipe(HPIPE hp);
  1470. USHORT APIENTRY DosMakeNmPipe(PSZ pszName, PHPIPE php, USHORT fsOpenMode,
  1471.                   USHORT fsPipeMode, USHORT cbOutBuf,
  1472.                   USHORT cbInBuf, ULONG ulTimeOut);
  1473. USHORT APIENTRY DosPeekNmPipe(HPIPE hp, PBYTE pBuf, USHORT cbBuf,
  1474.                   PUSHORT pcbRead, PAVAILDATA pAvail,
  1475.                   PUSHORT pfsState);
  1476. USHORT APIENTRY DosQNmPHandState(HPIPE hp, PUSHORT pfsState);
  1477. USHORT APIENTRY DosQNmPipeInfo(HPIPE hp, USHORT usInfoLevel, PBYTE pBuf,
  1478.                    USHORT cb);
  1479. USHORT APIENTRY DosQNmPipeSemState(HSEM hsem, PPIPESEMSTATE pnmpsmst, USHORT cb);
  1480. USHORT APIENTRY DosSetNmPHandState(HPIPE hp, USHORT fsState);
  1481. USHORT APIENTRY DosSetNmPipeSem(HPIPE hp, HSEM hsem, USHORT usKeyVal);
  1482. USHORT APIENTRY DosTransactNmPipe(HPIPE hp, PBYTE bOutBuf, USHORT cbOut,
  1483.                   PBYTE pInBuf, USHORT cbIn, PUSHORT pcbRead);
  1484. USHORT APIENTRY DosWaitNmPipe(PSZ pszName, ULONG ulTimeOut);
  1485.  
  1486. #endif /* INCL_DOSNMPIPES */
  1487.  
  1488.  
  1489. /*** Trace support */
  1490.  
  1491. #if (defined(INCL_DOSTRACE) && !defined(INCL_DOSTRACE_INCLUDED))
  1492. #define INCL_DOSTRACE_INCLUDED
  1493.  
  1494. typedef struct PTRACEBUF {    /* ptrcbf */
  1495.     PID    pid;
  1496.     TID    tid;
  1497.     USHORT cmd;
  1498.     USHORT value;
  1499.     USHORT offv;
  1500.     USHORT segv;
  1501.     USHORT mte;
  1502.     USHORT rAX;
  1503.     USHORT rBX;
  1504.     USHORT rCX;
  1505.     USHORT rDX;
  1506.     USHORT rSI;
  1507.     USHORT rDI;
  1508.     USHORT rBP;
  1509.     USHORT rDS;
  1510.     USHORT rES;
  1511.     USHORT rIP;
  1512.     USHORT rCS;
  1513.     USHORT rF;
  1514.     USHORT rSP;
  1515.     USHORT rSS;
  1516. } PTRACEBUF;
  1517. typedef PTRACEBUF FAR *PPTRACEBUF;
  1518.  
  1519. USHORT APIENTRY DosPTrace(PBYTE pPtraceBuf);
  1520.  
  1521. #endif /* INCL_DOSTRACE */
  1522.