home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s038 / 10.ddi / 017.LIF / DOS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-02  |  7.9 KB  |  238 lines

  1. /* dos.h - This file defines data structures for DOS access.
  2.  * $Version: 1.2 $
  3.  * Copyright (c) 1988-91 Intel Corporation, ALL RIGHTS RESERVED.
  4.  */
  5.  
  6. #ifndef _dosh
  7. #define _dosh
  8. /*lint -library */
  9.  
  10. #include <i86.h>
  11.  
  12. #pragma fixedparams("_dos_allocmem",    "_dos_close",       "_dos_creat")
  13. #pragma fixedparams("_dos_creatnew",    "_dos_findfirst",   "_dos_findnext")
  14. #pragma fixedparams("_dos_freemem",     "_dos_getdate",     "_dos_getdiskfree")
  15. #pragma fixedparams("_dos_getdrive",    "_dos_getfileattr", "_dos_getftime")
  16. #pragma fixedparams("_dos_gettime",     "_dos_open",        "_dos_read")
  17. #pragma fixedparams("_dos_setblock",    "_dos_setdate",     "_dos_setdrive")
  18. #pragma fixedparams("_dos_setfileattr", "_dos_setftime",    "_dos_settime")
  19. #pragma fixedparams("_dos_write")
  20. #pragma fixedparams("bdos",     "_ctlcint", "dosexterr", "int86")
  21. #pragma fixedparams("int86x",   "intdos",   "intdosx",   "loadexec")
  22. #pragma fixedparams("ptrdiff",  "_quit",    "sysint",    "sysint21")
  23.  
  24. /*
  25.  * File attribute masks:
  26.  */
  27. #define _A_NORMAL        0x00           /* Normal file access, read/write OK */
  28. #define _A_RDONLY        0x01           /* File is read-only */
  29. #define _A_HIDDEN        0x02           /* File is hidden */
  30. #define _A_SYSTEM        0x04           /* File is a system file */
  31. #define _A_VOLID         0x08           /* File holds volume ID */
  32. #define _A_SUBDIR        0x10           /* File is a subdirectory */
  33. #define _A_ARCH          0x20           /* File needs to be archived */
  34.  
  35.  
  36. #ifndef _FAR
  37. #define _FAR far
  38. #define _NEAR near
  39. #endif
  40.  
  41. /* used by functions needing the DS register or seg. and off. of a pointer */
  42.  
  43. extern unsigned _dataseg;
  44.  
  45. #define DATASEG() _dataseg
  46.  
  47. #define FP_OFF(p) (((unsigned *)(&(p)))[0])
  48. #define FP_SEG(p) (((unsigned *)(&(p)))[1])
  49. #define _NP_OFF(p) ((unsigned)p)
  50. #define _NP_SEG(p) _dataseg
  51.  
  52. #if !_FAR_DATA_                         /* near data */
  53. #define P_SEG(p) _NP_SEG(p)
  54. #define P_OFF(p) _NP_OFF(p)
  55. #else                                   /* far or huge data */
  56. #define  P_SEG(p) FP_SEG(p)
  57. #define  P_OFF(p) FP_OFF(p)
  58. #endif
  59.  
  60. #define _doserrno ((_thread_ptr()->__doserrno)) /* DOS system error variable */
  61.  
  62. #pragma align (DOSERROR)
  63. struct DOSERROR {
  64.     int exterror;
  65.     char class, action, locus;
  66. };
  67.  
  68. /*
  69.  * Structure used by loadexec function:
  70.  */
  71. #pragma align (pblock)
  72. struct pblock {
  73.     unsigned env;                       /* segment address of environment */
  74.     char _FAR *com_line;                /* program command line */
  75.     char _FAR *fcb1;
  76.     char _FAR *fcb2;
  77. };
  78.  
  79. /*
  80.  * Used by sysint() and sysint21():
  81.  */
  82. #pragma align (regval)
  83. struct regval {
  84.     unsigned int  ax, bx, cx, dx, si, di, ds, es, bp;
  85. };
  86.  
  87. #ifndef _regs
  88. #pragma align (DWORDREGS)
  89. #pragma align (WORDREGS)
  90. #pragma align (BYTEREGS)
  91. union REGS {
  92.   struct DWORDREGS {unsigned  eax, ebx, ecx, edx, esi,
  93.                               edi, cflag, eflags, ebp;} w;
  94.  
  95.   struct WORDREGS  {unsigned  ax, bx, cx, dx, si,
  96.                               di, cflag, flags, bp;} x;
  97.  
  98. #if _ARCHITECTURE_ == 386 ||  _ARCHITECTURE_ == 486
  99.  
  100.   struct BYTEREGS  {unsigned  al:8, ah:8, :16, bl:8, bh:8, :16,
  101.                               cl:8, ch:8, :16, dl:8, dh:8, :16;} h;
  102. #else
  103.   struct BYTEREGS  {unsigned  al:8, ah:8, bl:8, bh:8,
  104.                               cl:8, ch:8, dl:8, dh:8;} h;
  105. #endif
  106.  
  107. };
  108.  
  109. #pragma align (SREGS)
  110. struct SREGS {
  111.     unsigned short es, cs, ss, ds, fs, gs;
  112. };
  113.  
  114. #define _regs
  115. #endif  /* _regs */
  116.  
  117. #ifndef _find_t
  118. /* structure used by _dos_findfirst */
  119. /*
  120.  * Structure used by _dos_findfirst:
  121.  */
  122. #pragma noalign (find_t)
  123. struct find_t {
  124.     char reserved[21];                  /* Reserved for DOS */
  125.     char attrib;                        /* Returned attribute */
  126.     unsigned short wr_time;             /* Time file last written */
  127.     unsigned short wr_date;             /* Date file last written */
  128.     long  size;                         /* Size of file */
  129.     char name[13];                      /* String containing the filename */
  130.     };
  131. #define _find_t
  132. #endif
  133.  
  134. /*
  135.  * Structure used by _dos_getdate and _dos_setdate:
  136.  */
  137. #pragma align (dosdate_t)
  138. struct dosdate_t {
  139.     unsigned char day;                    /* Range: 1-31 */
  140.     unsigned char month;                  /* Range: 1-12 */
  141.     unsigned short year;                  /* Range: 1980-2099 */
  142.     unsigned char dayofweek;              /* Range: 0-6 (0=Sun, 1=Mon, etc.) */
  143.     };
  144.  
  145. /*
  146.  * Structure used by _dos_gettime and _dos_settime:
  147.  */
  148. #pragma align (dostime_t)
  149. struct dostime_t {
  150.     unsigned char hour;                   /* Range: 0-23 */
  151.     unsigned char minute;                 /* Range: 0-59 */
  152.     unsigned char second;                 /* Range: 0-59 */
  153.     unsigned char hsecond;                /* Range: 0-99 */
  154.     };
  155.  
  156. /*
  157.  * Structure used by _dos_getdiskfree:
  158.  */
  159. #pragma align (diskfree_t)
  160. struct diskfree_t {
  161.     unsigned short total_clusters;
  162.     unsigned short avail_clusters;
  163.     unsigned short sectors_per_cluster;
  164.     unsigned short bytes_per_sector;
  165.     };
  166.  
  167. /*
  168.  * Function prototypes:
  169.  */
  170. int         bdos(int, unsigned int, unsigned int);
  171. void _FAR  _ctlcint(void);
  172. unsigned   _dos_allocmem(unsigned, unsigned *);
  173. unsigned   _dos_close(int);
  174. unsigned   _dos_creat(const char *, unsigned, int *);
  175. unsigned   _dos_creatnew(const char *, unsigned, int *);
  176. unsigned   _dos_findfirst(const char *, unsigned, struct find_t *);
  177. unsigned   _dos_findnext(struct find_t *);
  178. unsigned   _dos_freemem(unsigned);
  179. void       _dos_getdate(struct dosdate_t *);
  180. unsigned   _dos_getdiskfree(unsigned, struct diskfree_t *);
  181. void       _dos_getdrive(unsigned *);
  182. unsigned   _dos_getfileattr(const char *, unsigned *);
  183. unsigned   _dos_getftime(int, unsigned *, unsigned *);
  184. void       _dos_gettime(struct dostime_t *);
  185. unsigned   _dos_open(const char *, unsigned, int *);
  186. unsigned   _dos_read(int, void *, unsigned, unsigned *);
  187. unsigned   _dos_setblock(unsigned, unsigned, unsigned *);
  188. unsigned   _dos_setdate(struct dosdate_t *);
  189. void       _dos_setdrive(unsigned, unsigned *);
  190. unsigned   _dos_setfileattr(const char *, unsigned);
  191. unsigned   _dos_setftime(int, unsigned, unsigned);
  192. unsigned   _dos_settime(struct dostime_t *);
  193. unsigned   _dos_write(int, const void *, unsigned, unsigned *);
  194. int         dosexterr(struct DOSERROR *);
  195. int         int86(int, const union REGS *, union REGS *);
  196. int         int86x(int, const union REGS *, union REGS *, struct SREGS *);
  197. int         intdos(const union REGS *, union REGS *);
  198. int         intdosx(const union REGS *, union REGS *, struct SREGS *);
  199. int         loadexec(char _FAR *, struct pblock _FAR *, int);
  200. long        ptrdiff(void _FAR *, void _FAR *);
  201. void       _quit(int);
  202. int         sysint(unsigned, const struct regval *, struct regval *);
  203. int         sysint21(const struct regval *, struct regval *);
  204.  
  205.  
  206. /*
  207.  * Non-ANSI function also prototyped in stdlib.h
  208.  */
  209. #ifndef _stdlib_dos
  210. #define _stdlib_dos
  211. #pragma fixedparams("segread")
  212. void     segread(struct SREGS *);
  213. #endif
  214.  
  215. #ifndef _dosh_builtin
  216. #define _dosh_builtin
  217. /*
  218.  * Processor status flag values:
  219.  */
  220. #define _FLAG_CARRY      0x0001         /* Carry flag */
  221. #define _FLAG_PARITY     0x0004         /* Parity flag */
  222. #define _FLAG_AUXCARRY   0x0010         /* Auxillary carry flag */
  223. #define _FLAG_ZERO       0x0040         /* Zero flag */
  224. #define _FLAG_SIGN       0x0080         /* Sign flag */
  225. #define _FLAG_TRAP       0x0100         /* Trap flag */
  226. #define _FLAG_INTERRUPT  0x0200         /* Interrupt enable flag */
  227. #define _FLAG_DIRECTION  0x0400         /* Direction flag */
  228. #define _FLAG_OVERFLOW   0x0800         /* Overflow flag */
  229. #define _FLAG_IOPL       0x3000         /* IO privilege level mask */
  230. #define _FLAG_NESTED     0x4000         /* Nested task flag */
  231. #define _FLAG_RESUME    0x10000         /* Resume flag */
  232. #define _FLAG_VM        0x20000         /* Virtual 86 mode */
  233.  
  234. #endif /* _dosh_builtin */
  235.  
  236. #endif /* _dosh */
  237.  
  238.