home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c031 / 4.ddi / INCLUDE / DOS.H$ / DOS
Encoding:
Text File  |  1991-11-06  |  7.5 KB  |  318 lines

  1. /***
  2. *dos.h - definitions for MS-DOS interface routines
  3. *
  4. *    Copyright (c) 1985-1992, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. *    Defines the structs and unions used for the direct DOS interface
  8. *    routines; includes macros to access the segment and offset
  9. *    values of far pointers, so that they may be used by the routines; and
  10. *    provides function prototypes for direct DOS interface functions.
  11. *
  12. ****/
  13.  
  14. #ifndef _INC_DOS
  15.  
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif
  19.  
  20. #if (_MSC_VER <= 600)
  21. #define __cdecl     _cdecl
  22. #define __far       _far
  23. #define __interrupt _interrupt
  24. #define __near      _near
  25. #endif
  26.  
  27. #ifndef _REGS_DEFINED
  28.  
  29. /* word registers */
  30.  
  31. struct _WORDREGS {
  32.     unsigned int ax;
  33.     unsigned int bx;
  34.     unsigned int cx;
  35.     unsigned int dx;
  36.     unsigned int si;
  37.     unsigned int di;
  38.     unsigned int cflag;
  39.     };
  40.  
  41. /* byte registers */
  42.  
  43. struct _BYTEREGS {
  44.     unsigned char al, ah;
  45.     unsigned char bl, bh;
  46.     unsigned char cl, ch;
  47.     unsigned char dl, dh;
  48.     };
  49.  
  50. /* general purpose registers union -
  51.  *  overlays the corresponding word and byte registers.
  52.  */
  53.  
  54. union _REGS {
  55.     struct _WORDREGS x;
  56.     struct _BYTEREGS h;
  57.     };
  58.  
  59. /* segment registers */
  60.  
  61. struct _SREGS {
  62.     unsigned int es;
  63.     unsigned int cs;
  64.     unsigned int ss;
  65.     unsigned int ds;
  66.     };
  67.  
  68. #ifndef __STDC__
  69. /* Non-ANSI names for compatibility */
  70.  
  71. struct WORDREGS {
  72.     unsigned int ax;
  73.     unsigned int bx;
  74.     unsigned int cx;
  75.     unsigned int dx;
  76.     unsigned int si;
  77.     unsigned int di;
  78.     unsigned int cflag;
  79.     };
  80.  
  81. struct BYTEREGS {
  82.     unsigned char al, ah;
  83.     unsigned char bl, bh;
  84.     unsigned char cl, ch;
  85.     unsigned char dl, dh;
  86.     };
  87.  
  88. union REGS {
  89.     struct WORDREGS x;
  90.     struct BYTEREGS h;
  91.     };
  92.  
  93. struct SREGS {
  94.     unsigned int es;
  95.     unsigned int cs;
  96.     unsigned int ss;
  97.     unsigned int ds;
  98.     };
  99.  
  100. #endif    /* __STDC__ */
  101.  
  102. #define _REGS_DEFINED
  103. #endif /* _REGS_DEFINED */
  104.  
  105.  
  106. /* dosexterror structure */
  107.  
  108. #ifndef _DOSERROR_DEFINED
  109. #pragma pack(2)
  110.  
  111. struct _DOSERROR {
  112.     int exterror;
  113.     char errclass;
  114.     char action;
  115.     char locus;
  116.     };
  117.  
  118. #if ((!defined(__STDC__)) && (!defined(__cplusplus)))
  119. /* Non-ANSI name for compatibility */
  120. struct DOSERROR {
  121.     int exterror;
  122.     char class;
  123.     char action;
  124.     char locus;
  125.     };
  126. #endif
  127.  
  128. #pragma pack()
  129. #define _DOSERROR_DEFINED
  130. #endif
  131.  
  132.  
  133. /* _dos_findfirst structure */
  134.  
  135. #ifndef _FIND_T_DEFINED
  136. #pragma pack(2)
  137.  
  138. struct _find_t {
  139.     char reserved[21];
  140.     char attrib;
  141.     unsigned wr_time;
  142.     unsigned wr_date;
  143.     long size;
  144.     char name[13];
  145.     };
  146.  
  147. #ifndef __STDC__
  148. /* Non-ANSI name for compatibility */
  149. #define find_t _find_t
  150. #endif
  151.  
  152. #pragma pack()
  153. #define _FIND_T_DEFINED
  154. #endif
  155.  
  156.  
  157. /* _dos_getdate/_dossetdate and _dos_gettime/_dos_settime structures */
  158.  
  159. #ifndef _DATETIME_T_DEFINED
  160. #pragma pack(2)
  161.  
  162. struct _dosdate_t {
  163.     unsigned char day;        /* 1-31 */
  164.     unsigned char month;        /* 1-12 */
  165.     unsigned int year;        /* 1980-2099 */
  166.     unsigned char dayofweek;    /* 0-6, 0=Sunday */
  167.     };
  168.  
  169. struct _dostime_t {
  170.     unsigned char hour;    /* 0-23 */
  171.     unsigned char minute;    /* 0-59 */
  172.     unsigned char second;    /* 0-59 */
  173.     unsigned char hsecond;    /* 0-99 */
  174.     };
  175.  
  176. #ifndef __STDC__
  177. /* Non-ANSI names for compatibility */
  178. #define dosdate_t _dosdate_t
  179. #define dostime_t _dostime_t
  180. #endif
  181.  
  182. #pragma pack()
  183. #define _DATETIME_T_DEFINED
  184. #endif
  185.  
  186.  
  187. /* _dos_getdiskfree structure */
  188.  
  189. #ifndef _DISKFREE_T_DEFINED
  190.  
  191. struct _diskfree_t {
  192.     unsigned total_clusters;
  193.     unsigned avail_clusters;
  194.     unsigned sectors_per_cluster;
  195.     unsigned bytes_per_sector;
  196.     };
  197.  
  198. #ifndef __STDC__
  199. /* Non-ANSI name for compatibility */
  200. #define diskfree_t _diskfree_t
  201. #endif
  202.  
  203. #define _DISKFREE_T_DEFINED
  204. #endif
  205.  
  206.  
  207. /* manifest constants for _hardresume result parameter */
  208.  
  209. #define _HARDERR_IGNORE     0    /* Ignore the error */
  210. #define _HARDERR_RETRY        1    /* Retry the operation */
  211. #define _HARDERR_ABORT        2    /* Abort program issuing Interrupt 23h */
  212. #define _HARDERR_FAIL        3    /* Fail the system call in progress */
  213.                     /* _HARDERR_FAIL is not supported on DOS 2.x */
  214.  
  215. /* File attribute constants */
  216.  
  217. #define _A_NORMAL    0x00    /* Normal file - No read/write restrictions */
  218. #define _A_RDONLY    0x01    /* Read only file */
  219. #define _A_HIDDEN    0x02    /* Hidden file */
  220. #define _A_SYSTEM    0x04    /* System file */
  221. #define _A_VOLID    0x08    /* Volume ID file */
  222. #define _A_SUBDIR    0x10    /* Subdirectory */
  223. #define _A_ARCH     0x20    /* Archive file */
  224.  
  225. /* macros to break C "far" pointers into their segment and offset components
  226.  */
  227.  
  228. #define _FP_SEG(fp) (*((unsigned __far *)&(fp)+1))
  229. #define _FP_OFF(fp) (*((unsigned __far *)&(fp)))
  230.  
  231.  
  232. /* external variable declarations */
  233.  
  234. extern unsigned int __near __cdecl _osversion;
  235.  
  236.  
  237. /* function prototypes */
  238.  
  239. int __cdecl _bdos(int, unsigned int, unsigned int);
  240. #ifndef _WINDOWS
  241. void __cdecl _chain_intr(void (__cdecl __interrupt __far *)());
  242. #endif
  243. void __cdecl _disable(void);
  244. #ifndef _WINDOWS
  245. unsigned __cdecl _dos_allocmem(unsigned, unsigned *);
  246. #endif
  247. unsigned __cdecl _dos_close(int);
  248. unsigned __cdecl _dos_commit(int);
  249. unsigned __cdecl _dos_creat(const char *, unsigned, int *);
  250. unsigned __cdecl _dos_creatnew(const char *, unsigned, int *);
  251. unsigned __cdecl _dos_findfirst(const char *, unsigned, struct _find_t *);
  252. unsigned __cdecl _dos_findnext(struct _find_t *);
  253. #ifndef _WINDOWS
  254. unsigned __cdecl _dos_freemem(unsigned);
  255. #endif
  256. void __cdecl _dos_getdate(struct _dosdate_t *);
  257. void __cdecl _dos_getdrive(unsigned *);
  258. unsigned __cdecl _dos_getdiskfree(unsigned, struct _diskfree_t *);
  259. unsigned __cdecl _dos_getfileattr(const char *, unsigned *);
  260. unsigned __cdecl _dos_getftime(int, unsigned *, unsigned *);
  261. void __cdecl _dos_gettime(struct _dostime_t *);
  262. void (__cdecl __interrupt __far * __cdecl _dos_getvect(unsigned))();
  263. #ifndef _WINDOWS
  264. void __cdecl _dos_keep(unsigned, unsigned);
  265. #endif
  266. unsigned __cdecl _dos_open(const char *, unsigned, int *);
  267. unsigned __cdecl _dos_read(int, void __far *, unsigned, unsigned *);
  268. #ifndef _WINDOWS
  269. unsigned __cdecl _dos_setblock(unsigned, unsigned, unsigned *);
  270. #endif
  271. unsigned __cdecl _dos_setdate(struct _dosdate_t *);
  272. void __cdecl _dos_setdrive(unsigned, unsigned *);
  273. unsigned __cdecl _dos_setfileattr(const char *, unsigned);
  274. unsigned __cdecl _dos_setftime(int, unsigned, unsigned);
  275. unsigned __cdecl _dos_settime(struct _dostime_t *);
  276. #ifndef _WINDOWS
  277. void __cdecl _dos_setvect(unsigned, void (__cdecl __interrupt __far *)());
  278. #endif
  279. unsigned __cdecl _dos_write(int, const void __far *, unsigned, unsigned *);
  280. int __cdecl _dosexterr(struct _DOSERROR *);
  281. void __cdecl _enable(void);
  282. #ifndef _WINDOWS
  283. void __cdecl _harderr(void (__far __cdecl *)());
  284. void __cdecl _hardresume(int);
  285. void __cdecl _hardretn(int);
  286. #endif
  287. int __cdecl _intdos(union _REGS *, union _REGS *);
  288. int __cdecl _intdosx(union _REGS *, union _REGS *, struct _SREGS *);
  289. int __cdecl _int86(int, union _REGS *, union _REGS *);
  290. int __cdecl _int86x(int, union _REGS *, union _REGS *, struct _SREGS *);
  291.  
  292. void __cdecl _segread(struct _SREGS *);
  293.  
  294. #ifndef __STDC__
  295. /* Non-ANSI names for compatibility */
  296.  
  297. #define FP_SEG       _FP_SEG
  298. #define FP_OFF       _FP_OFF
  299.  
  300. int __cdecl bdos(int, unsigned int, unsigned int);
  301. int __cdecl intdos(union REGS *, union REGS *);
  302. int __cdecl intdosx(union REGS *, union REGS *, struct SREGS *);
  303. int __cdecl int86(int, union REGS *, union REGS *);
  304. int __cdecl int86x(int, union REGS *, union REGS *, struct SREGS *);
  305. #ifndef __cplusplus
  306. int __cdecl dosexterr(struct DOSERROR *);
  307. #endif
  308. void __cdecl segread(struct SREGS *);
  309.  
  310. #endif    /* __STDC__ */
  311.  
  312. #ifdef __cplusplus
  313. }
  314. #endif
  315.  
  316. #define _INC_DOS
  317. #endif    /* _INC_DOS */
  318.