home *** CD-ROM | disk | FTP | other *** search
/ PC Extra Super CD 1998 January / PCPLUS131.iso / DJGPP / V2 / DJDEV201.ZIP / include / dos.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-12  |  7.0 KB  |  268 lines

  1. /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
  2. #ifndef __dj_include_dos_h_
  3. #define __dj_include_dos_h_
  4.  
  5. #ifndef __dj_ENFORCE_ANSI_FREESTANDING
  6.  
  7. #ifndef __STRICT_ANSI__
  8.  
  9. #ifndef _POSIX_SOURCE
  10.  
  11. #include <pc.h>
  12.  
  13. struct DWORDREGS {
  14.   unsigned long edi;
  15.   unsigned long esi;
  16.   unsigned long ebp;
  17.   unsigned long cflag;
  18.   unsigned long ebx;
  19.   unsigned long edx;
  20.   unsigned long ecx;
  21.   unsigned long eax;
  22.   unsigned short eflags;
  23. };
  24.  
  25. struct DWORDREGS_W {
  26.   unsigned long di;
  27.   unsigned long si;
  28.   unsigned long bp;
  29.   unsigned long cflag;
  30.   unsigned long bx;
  31.   unsigned long dx;
  32.   unsigned long cx;
  33.   unsigned long ax;
  34.   unsigned short flags;
  35. };
  36.  
  37. struct WORDREGS {
  38.   unsigned short di, _upper_di;
  39.   unsigned short si, _upper_si;
  40.   unsigned short bp, _upper_bp;
  41.   unsigned short cflag, _upper_cflag;
  42.   unsigned short bx, _upper_bx;
  43.   unsigned short dx, _upper_dx;
  44.   unsigned short cx, _upper_cx;
  45.   unsigned short ax, _upper_ax;
  46.   unsigned short flags;
  47. };
  48.  
  49. struct BYTEREGS {
  50.   unsigned short di, _upper_di;
  51.   unsigned short si, _upper_si;
  52.   unsigned short bp, _upper_bp;
  53.   unsigned long cflag;
  54.   unsigned char bl;
  55.   unsigned char bh;
  56.   unsigned short _upper_bx;
  57.   unsigned char dl;
  58.   unsigned char dh;
  59.   unsigned short _upper_dx;
  60.   unsigned char cl;
  61.   unsigned char ch;
  62.   unsigned short _upper_cx;
  63.   unsigned char al;
  64.   unsigned char ah;
  65.   unsigned short _upper_ax;
  66.   unsigned short flags;
  67. };
  68.  
  69. union REGS {        /* Compatible with DPMI structure, except cflag */
  70.   struct DWORDREGS d;
  71. #ifdef _NAIVE_DOS_REGS
  72.   struct WORDREGS x;
  73. #else
  74. #if _BORLAND_DOS_REGS
  75.   struct DWORDREGS x;
  76. #else
  77.   struct DWORDREGS_W x;
  78. #endif
  79. #endif
  80.   struct WORDREGS w;
  81.   struct BYTEREGS h;
  82. };
  83.  
  84. struct SREGS {
  85.   unsigned short es;
  86.   unsigned short ds;
  87.   unsigned short fs;
  88.   unsigned short gs;
  89.   unsigned short cs;
  90.   unsigned short ss;
  91. };
  92.  
  93. struct ftime {
  94.   unsigned ft_tsec:5;    /* 0-29, double to get real seconds */
  95.   unsigned ft_min:6;    /* 0-59 */
  96.   unsigned ft_hour:5;    /* 0-23 */
  97.   unsigned ft_day:5;    /* 1-31 */
  98.   unsigned ft_month:4;    /* 1-12 */
  99.   unsigned ft_year:7;    /* since 1980 */
  100. };
  101.  
  102. struct date {
  103.   short da_year;
  104.   char  da_day;
  105.   char  da_mon;
  106. };
  107.  
  108. struct time {
  109.   unsigned char ti_min;
  110.   unsigned char ti_hour;
  111.   unsigned char ti_hund;
  112.   unsigned char ti_sec;
  113. };
  114.  
  115. struct dfree {
  116.   unsigned df_avail;
  117.   unsigned df_total;
  118.   unsigned df_bsec;
  119.   unsigned df_sclus;
  120. };
  121.  
  122. #ifdef __cplusplus
  123. extern "C" {
  124. #endif
  125.  
  126. extern unsigned short   _osmajor, _osminor;
  127. extern const    char  * _os_flavor;
  128.  
  129. unsigned short _get_dos_version(int);
  130.  
  131.  
  132. int int86(int ivec, union REGS *in, union REGS *out);
  133. int int86x(int ivec, union REGS *in, union REGS *out, struct SREGS *seg);
  134. int intdos(union REGS *in, union REGS *out);
  135. int intdosx(union REGS *in, union REGS *out, struct SREGS *seg);
  136. int bdos(int func, unsigned dx, unsigned al);
  137. int bdosptr(int func, void *dx, unsigned al);
  138.  
  139. #define bdosptr(a, b, c) bdos(a, (unsigned)(b), c)
  140. #define intdos(a, b) int86(0x21, a, b)
  141. #define intdosx(a, b, c) int86x(0x21, a, b, c)
  142.  
  143. int enable(void);
  144. int disable(void);
  145.  
  146. int getftime(int handle, struct ftime *ftimep);
  147. int setftime(int handle, struct ftime *ftimep);
  148.  
  149. int getcbrk(void);
  150. int setcbrk(int new_value);
  151.  
  152. void getdate(struct date *);
  153. void gettime(struct time *);
  154. void setdate(struct date *);
  155. void settime(struct time *);
  156.  
  157. void getdfree(unsigned char drive, struct dfree *ptr);
  158.  
  159. void delay(unsigned msec);
  160. /* int _get_default_drive(void);
  161. void _fixpath(const char *, char *); */
  162.  
  163.  
  164. /*
  165.  *  For compatibility with other DOS C compilers.
  166.  */
  167.  
  168. #define _A_NORMAL   0x00    /* Normal file - No read/write restrictions */
  169. #define _A_RDONLY   0x01    /* Read only file */
  170. #define _A_HIDDEN   0x02    /* Hidden file */
  171. #define _A_SYSTEM   0x04    /* System file */
  172. #define _A_VOLID    0x08    /* Volume ID file */
  173. #define _A_SUBDIR   0x10    /* Subdirectory */
  174. #define _A_ARCH     0x20    /* Archive file */
  175.  
  176. #define _enable   enable
  177. #define _disable  disable
  178.  
  179. struct _dosdate_t {
  180.   unsigned char  day;       /* 1-31 */
  181.   unsigned char  month;     /* 1-12 */
  182.   unsigned short year;      /* 1980-2099 */
  183.   unsigned char  dayofweek; /* 0-6, 0=Sunday */
  184. };
  185. #define dosdate_t _dosdate_t
  186.  
  187. struct _dostime_t {
  188.   unsigned char hour;     /* 0-23 */
  189.   unsigned char minute;   /* 0-59 */
  190.   unsigned char second;   /* 0-59 */
  191.   unsigned char hsecond;  /* 0-99 */
  192. };
  193. #define dostime_t _dostime_t
  194.  
  195. struct _find_t {
  196.   char reserved[21] __attribute__((packed));
  197.   unsigned char attrib __attribute__((packed));
  198.   unsigned short wr_time __attribute__((packed));
  199.   unsigned short wr_date __attribute__((packed));
  200.   unsigned long size __attribute__((packed));
  201.   char name[256] __attribute__((packed));
  202. };
  203. #define find_t _find_t
  204.  
  205. struct _diskfree_t {
  206.   unsigned short total_clusters;
  207.   unsigned short avail_clusters;
  208.   unsigned short sectors_per_cluster;
  209.   unsigned short bytes_per_sector;
  210. };
  211. #define diskfree_t _diskfree_t
  212.  
  213. struct _DOSERROR {
  214.   int  exterror;
  215.   #ifdef __cplusplus
  216.   char errclass;
  217.   #else
  218.   char class;
  219.   #endif
  220.   char action;
  221.   char locus;
  222. };
  223. #define DOSERROR _DOSERROR
  224.  
  225. unsigned int   _dos_creat(const char *_filename, unsigned int _attr, int *_handle);
  226. unsigned int   _dos_creatnew(const char *_filename, unsigned int _attr, int *_handle);
  227. unsigned int   _dos_open(const char *_filename, unsigned int _mode, int *_handle);
  228. unsigned int   _dos_write(int _handle, const void *_buffer, unsigned int _count, unsigned int *_result);
  229. unsigned int   _dos_read(int _handle, void *_buffer, unsigned int _count, unsigned int *_result);
  230. unsigned int   _dos_close(int _handle);
  231. unsigned int   _dos_commit(int _handle);
  232.  
  233. unsigned int   _dos_findfirst(char *_name, unsigned int _attr, struct _find_t *_result);
  234. unsigned int   _dos_findnext(struct _find_t *_result);
  235.  
  236. void           _dos_getdate(struct _dosdate_t *_date);
  237. unsigned int   _dos_setdate(struct _dosdate_t *_date);
  238. void           _dos_gettime(struct _dostime_t *_time);
  239. unsigned int   _dos_settime(struct _dostime_t *_time);
  240.  
  241. unsigned int   _dos_getftime(int _handle, unsigned int *_p_date, unsigned int *_p_time);
  242. unsigned int   _dos_setftime(int _handle, unsigned int _date, unsigned int _time);
  243. unsigned int   _dos_getfileattr(const char *_filename, unsigned int *_p_attr);
  244. unsigned int   _dos_setfileattr(const char *_filename, unsigned int _attr);
  245.  
  246. void           _dos_getdrive(unsigned int *_p_drive);
  247. void           _dos_setdrive(unsigned int _drive, unsigned int *_p_drives);
  248. unsigned int   _dos_getdiskfree(unsigned int _drive, struct _diskfree_t *_diskspace);
  249.  
  250. int            _dosexterr(struct _DOSERROR *_p_error);
  251. #define dosexterr(_ep) _dosexterr(_ep)
  252.  
  253. #define int386(_i, _ir, _or)         int86(_i, _ir, _or)
  254. #define int386x(_i, _ir, _or, _sr)   int86x(_i, _ir, _or, _sr)
  255.  
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259.  
  260. #endif /* !_POSIX_SOURCE */
  261. #endif /* !__STRICT_ANSI__ */
  262. #endif /* !__dj_ENFORCE_ANSI_FREESTANDING */
  263.  
  264. #ifndef __dj_ENFORCE_FUNCTION_CALLS
  265. #endif /* !__dj_ENFORCE_FUNCTION_CALLS */
  266.  
  267. #endif /* !__dj_include_dos_h_ */
  268.