home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 19.ddi / INCLUDE / DOS.H_ / DOS.H
Encoding:
C/C++ Source or Header  |  1993-02-08  |  8.1 KB  |  331 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 
  101.  
  102. #define _REGS_DEFINED
  103. #endif 
  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. /* macro to construct a far pointer from segment and offset values
  232.  */
  233.  
  234. #define _MK_FP(seg, offset) (void __far *)(((unsigned long)seg << 16) \
  235.     + (unsigned long)(unsigned)offset)
  236.  
  237. /* external variable declarations */
  238.  
  239. extern unsigned int __near __cdecl _osversion;
  240.  
  241.  
  242. /* function prototypes */
  243.  
  244. #ifndef _MT
  245. int __cdecl _bdos(int, unsigned int, unsigned int);
  246. #ifndef _WINDOWS
  247. void __cdecl _chain_intr(void (__cdecl __interrupt __far *)());
  248. #endif 
  249. void __cdecl _disable(void);
  250. #ifndef _WINDOWS
  251. unsigned __cdecl _dos_allocmem(unsigned, unsigned *);
  252. #endif 
  253. unsigned __cdecl _dos_close(int);
  254. unsigned __cdecl _dos_commit(int);
  255. unsigned __cdecl _dos_creat(const char *, unsigned, int *);
  256. unsigned __cdecl _dos_creatnew(const char *, unsigned, int *);
  257. unsigned __cdecl _dos_findfirst(const char *, unsigned, struct _find_t *);
  258. unsigned __cdecl _dos_findnext(struct _find_t *);
  259. #ifndef _WINDOWS
  260. unsigned __cdecl _dos_freemem(unsigned);
  261. #endif 
  262. void __cdecl _dos_getdate(struct _dosdate_t *);
  263. void __cdecl _dos_getdrive(unsigned *);
  264. unsigned __cdecl _dos_getdiskfree(unsigned, struct _diskfree_t *);
  265. unsigned __cdecl _dos_getfileattr(const char *, unsigned *);
  266. unsigned __cdecl _dos_getftime(int, unsigned *, unsigned *);
  267. void __cdecl _dos_gettime(struct _dostime_t *);
  268. void (__cdecl __interrupt __far * __cdecl _dos_getvect(unsigned))();
  269. #ifndef _WINDOWS
  270. void __cdecl _dos_keep(unsigned, unsigned);
  271. #endif 
  272. unsigned __cdecl _dos_lock(int, int, unsigned long, unsigned long);
  273. unsigned __cdecl _dos_open(const char *, unsigned, int *);
  274. unsigned __cdecl _dos_read(int, void __far *, unsigned, unsigned *);
  275. unsigned long __cdecl _dos_seek(int, unsigned long, int);
  276. #ifndef _WINDOWS
  277. unsigned __cdecl _dos_setblock(unsigned, unsigned, unsigned *);
  278. #endif 
  279. unsigned __cdecl _dos_setdate(struct _dosdate_t *);
  280. void __cdecl _dos_setdrive(unsigned, unsigned *);
  281. unsigned __cdecl _dos_setfileattr(const char *, unsigned);
  282. unsigned __cdecl _dos_setftime(int, unsigned, unsigned);
  283. unsigned __cdecl _dos_settime(struct _dostime_t *);
  284. #ifndef _WINDOWS
  285. void __cdecl _dos_setvect(unsigned, void (__cdecl __interrupt __far *)());
  286. #endif 
  287. unsigned __cdecl _dos_write(int, const void __far *, unsigned, unsigned *);
  288. int __cdecl _dosexterr(struct _DOSERROR *);
  289. void __cdecl _enable(void);
  290. #ifndef _WINDOWS
  291. void __cdecl _harderr(void (__far __cdecl *)(unsigned, unsigned,
  292.     unsigned __far *));
  293. void __cdecl _hardresume(int);
  294. void __cdecl _hardretn(int);
  295. #endif 
  296. int __cdecl _intdos(union _REGS *, union _REGS *);
  297. int __cdecl _intdosx(union _REGS *, union _REGS *, struct _SREGS *);
  298. int __cdecl _int86(int, union _REGS *, union _REGS *);
  299. int __cdecl _int86x(int, union _REGS *, union _REGS *, struct _SREGS *);
  300. #endif 
  301.  
  302. void __cdecl _segread(struct _SREGS *);
  303.  
  304. #ifndef __STDC__
  305. /* Non-ANSI names for compatibility */
  306.  
  307. #define FP_SEG     _FP_SEG
  308. #define FP_OFF     _FP_OFF
  309. #define MK_FP      _MK_FP
  310.  
  311. #ifndef _MT
  312. int __cdecl bdos(int, unsigned int, unsigned int);
  313. int __cdecl intdos(union REGS *, union REGS *);
  314. int __cdecl intdosx(union REGS *, union REGS *, struct SREGS *);
  315. int __cdecl int86(int, union REGS *, union REGS *);
  316. int __cdecl int86x(int, union REGS *, union REGS *, struct SREGS *);
  317. #ifndef __cplusplus
  318. int __cdecl dosexterr(struct DOSERROR *);
  319. #endif 
  320. #endif 
  321. void __cdecl segread(struct SREGS *);
  322.  
  323. #endif 
  324.  
  325. #ifdef __cplusplus
  326. }
  327. #endif 
  328.  
  329. #define _INC_DOS
  330. #endif 
  331.