home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / dos.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  12.3 KB  |  404 lines

  1. /*  dos.h
  2.  
  3.     Defines structs, unions, macros, and functions for dealing
  4.     with MSDOS and the Intel iAPX86 microprocessor family.
  5.  
  6. */
  7. /*
  8.  *      C/C++ Run Time Library - Version 10.0
  9.  *
  10.  *      Copyright (c) 1987, 2000 by Inprise Corporation
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. /* $Revision:   9.18  $ */
  16.  
  17. #ifndef __DOS_H
  18. #define __DOS_H
  19.  
  20. #ifndef ___STDDEF_H
  21. #include <_stddef.h>
  22. #endif
  23.  
  24. #ifndef __ERRNO_H
  25. #include <errno.h>
  26. #endif
  27.  
  28. #if !defined(RC_INVOKED)
  29.  
  30. #if defined(__STDC__)
  31. #pragma warn -nak
  32. #endif
  33.  
  34. #pragma pack(push, 1)
  35.  
  36. #endif  /* !RC_INVOKED */
  37.  
  38. /* Define intrinsic outside of any namespace */
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. void     _RTLENTRY             __int__(int __interruptnum);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46.  
  47. #ifdef __cplusplus
  48. namespace std {
  49. #endif /* __cplusplus */
  50.  
  51.  
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55.  
  56.  
  57. #ifndef FA_NORMAL
  58. #define FA_NORMAL   0x00        /* Normal file, no attributes */
  59. #define FA_RDONLY   0x01        /* Read only attribute */
  60. #define FA_HIDDEN   0x02        /* Hidden file */
  61. #define FA_SYSTEM   0x04        /* System file */
  62. #define FA_LABEL    0x08        /* Volume label */
  63. #define FA_DIREC    0x10        /* Directory */
  64. #define FA_ARCH     0x20        /* Archive */
  65. #endif /* FA_NORMAL */
  66.  
  67. #ifndef _A_NORMAL
  68. /* MSC names for file attributes */
  69. #define _A_NORMAL   0x00        /* Normal file, no attributes */
  70. #define _A_RDONLY   0x01        /* Read only attribute */
  71. #define _A_HIDDEN   0x02        /* Hidden file */
  72. #define _A_SYSTEM   0x04        /* System file */
  73. #define _A_VOLID    0x08        /* Volume label */
  74. #define _A_SUBDIR   0x10        /* Directory */
  75. #define _A_ARCH     0x20        /* Archive */
  76. #endif /* _A_NORMAL */
  77.  
  78. #ifndef SEEK_CUR
  79. #define SEEK_CUR    1
  80. #define SEEK_END    2
  81. #define SEEK_SET    0
  82. #endif /* SEEK_CUR */
  83.  
  84. #if !defined(__STDC__)
  85. #define environ  _environ
  86. #endif
  87.  
  88.  
  89. struct  dfree
  90. {
  91.     unsigned df_avail;
  92.     unsigned df_total;
  93.     unsigned df_bsec;
  94.     unsigned df_sclus;
  95. };
  96.  
  97. struct diskfree_t
  98. {
  99.     unsigned total_clusters;
  100.     unsigned avail_clusters;
  101.     unsigned sectors_per_cluster;
  102.     unsigned bytes_per_sector;
  103. };
  104.  
  105. struct time
  106. {
  107.     unsigned char   ti_min;     /* Minutes */
  108.     unsigned char   ti_hour;    /* Hours */
  109.     unsigned char   ti_hund;    /* Hundredths of seconds */
  110.     unsigned char   ti_sec;     /* Seconds */
  111. };
  112.  
  113. struct dostime_t
  114. {
  115.     unsigned char hour;         /* Hours */
  116.     unsigned char minute;       /* Minutes */
  117.     unsigned char second;       /* Seconds */
  118.     unsigned char hsecond;      /* Hundredths of seconds */
  119. };
  120.  
  121. struct date
  122. {
  123.     int     da_year;        /* Year - 1980 */
  124.     char    da_day;     /* Day of the month */
  125.     char    da_mon;     /* Month (1 = Jan) */
  126. };
  127.  
  128. struct dosdate_t
  129. {
  130.     unsigned char day;      /* 1-31 */
  131.     unsigned char month;    /* 1-12 */
  132.     unsigned int  year;     /* 1980 - 2099 */
  133.     unsigned char dayofweek;/* 0 - 6 (0=Sunday) */
  134. };
  135.  
  136. #ifndef MAXPATH
  137. #define MAXPATH   260
  138. #define MAXDIR    256
  139. #define MAXFILE   256
  140. #define MAXEXT    256
  141. #define MAXDRIVE    3
  142. #endif
  143.  
  144. #ifndef _FFBLK_DEF
  145. #define _FFBLK_DEF
  146. struct  ffblk   {
  147.     long            ff_reserved;
  148.     long            ff_fsize;
  149.     unsigned long   ff_attrib;
  150.     unsigned short  ff_ftime;
  151.     unsigned short  ff_fdate;
  152.     char            ff_name[MAXPATH];
  153. };
  154. struct  _wffblk {
  155.     long            ff_reserved;
  156.     long            ff_fsize;
  157.     unsigned long   ff_attrib;
  158.     unsigned short  ff_ftime;
  159.     unsigned short  ff_fdate;
  160.     wchar_t         ff_name[MAXPATH];
  161. };
  162.  
  163. #endif  /* __FFBLK_DEF */
  164.  
  165. struct find_t
  166. {
  167.     long            reserved;
  168.     long            size;              /* size of file */
  169.     unsigned long   attrib;            /* attribute byte for matched file */
  170.     unsigned short  wr_time;           /* time of last write to file */
  171.     unsigned short  wr_date;           /* date of last write to file */
  172.     char            name[MAXPATH];     /* asciiz name of matched file */
  173. };
  174.  
  175. /*
  176.    The prototype for __emit__ has been removed from DOS.H.  __emit__ is
  177.    still supported, but is now automatically recognized by the compiler and
  178.    provides some new features, now that it's un-prototyped:
  179.  
  180.    __emit__ usually works with constant numbers of size char, short, long,
  181.    and __int64, however, there are three special additions here:
  182.  
  183.      int x;
  184.      __emit__(&x);
  185.  
  186.    This will emit the address of the variable x in the correct little-endian
  187.    form to be used in assembly operations.
  188.  
  189.      __emit__(1.234F);
  190.      __emit__(1.234);
  191.      __emit__(1.234L);
  192.  
  193.    These emit the 4, 8, or 10 byte pattern that represents the constant
  194.    float, double, or long double values of 1.23.
  195.  
  196.      __emit__("Hello There");
  197.  
  198.    This will create a constant string (just like the compiler does with
  199.    any constant string in C or C++) and emits the 4-byte address of this
  200.    string.
  201.  
  202.    There is a special byte-saving optimization made if a signed
  203.    int constant number is specified: the fewest number of bytes required
  204.    to represent that number will be emitted.  If the same value is cast
  205.    or suffixed to be unsigned int instead, the full size is emitted.  Keep
  206.    in mind that all integral literals are, by definition, signed integers
  207.    (unless an alternate suffix is applied):
  208.  
  209.      __emit__(0);            // yields an 8-bit 00h not a 32-bit 00000000h
  210.                                 use __emit__(0u) to get 32-bits.
  211.  
  212.      __emit__(0x64);         // yields an 8-bit 64h
  213.      __emit__(100u);         // yields a 32-bit 00000064h
  214.      __emit__(0x64u);        // yields a 32-bit 00000064h
  215.  
  216.      __emit__((char) 50);    // yields an 8-bit 32h
  217.      __emit__((short) 500);  // yields a 16-bit 01F4h
  218.  
  219.      __emit__(2ui64);        // yields a 64-bit 0000000000000002h
  220.      __emit__(20i64);        // yields a 64-bit 0000000000000014h
  221.  
  222.    Multiple parameters can be passed to __emit__ and they will be generated
  223.    from left to right (similar to the pascal calling convention).  The left
  224.    most parameter will be emitted to a lower address in memory than the
  225.    right most parameter.
  226.  
  227.     __emit__(0,1,2,3,4);              // yields 5 bytes: 0001020304
  228.     __emit__(L'\x8C\x1F', 0, 300i64); // yields 11 bytes:8C1F001201000000000000
  229.  
  230. */
  231.  
  232. unsigned _RTLENTRY _EXPFUNC _dos_close(int __fd);
  233. unsigned _RTLENTRY _EXPFUNC _dos_creat(const char _FAR *__pathP, unsigned __attr,
  234.                                 int _FAR *__fd);
  235. unsigned _RTLENTRY _EXPFUNC _dos_creatnew(const char _FAR *__pathP, unsigned __attr,
  236.                                 int _FAR *__fd);
  237. unsigned _RTLENTRY _EXPFUNC _dos_findfirst(const char _FAR *__path,
  238.                                 unsigned __attrib,
  239.                                 struct find_t _FAR *__finfo);
  240. unsigned _RTLENTRY _EXPFUNC _dos_findnext(struct find_t _FAR *__finfo);
  241. void     _RTLENTRY _EXPFUNC _dos_getdate(struct dosdate_t _FAR *__datep);
  242. unsigned _RTLENTRY _EXPFUNC _dos_getdiskfree(unsigned __drive,
  243.                                 struct diskfree_t _FAR *__dtable);
  244. void     _RTLENTRY _EXPFUNC _dos_getdrive(unsigned _FAR *__drive);
  245. unsigned _RTLENTRY _EXPFUNC _dos_getfileattr(const char _FAR *__filename,
  246.                                 unsigned _FAR *__attrib);
  247. unsigned _RTLENTRY _EXPFUNC _dos_getftime(int __fd, unsigned _FAR *__date,
  248.                                 unsigned _FAR *__time);
  249. void     _RTLENTRY _EXPFUNC _dos_gettime(struct dostime_t _FAR *__timep);
  250. unsigned _RTLENTRY _EXPFUNC _dos_open(const char _FAR *__pathP, unsigned __oflag,
  251.                                 int _FAR *__fd);
  252. unsigned _RTLENTRY _EXPFUNC _dos_setdate(struct dosdate_t _FAR *__datep);
  253. void     _RTLENTRY _EXPFUNC _dos_setdrive(unsigned __drive, unsigned _FAR *__ndrives);
  254. unsigned _RTLENTRY _EXPFUNC _dos_setfileattr(const char _FAR *__filename,
  255.                                 unsigned _FAR __attrib);
  256. unsigned _RTLENTRY _EXPFUNC _dos_setftime(int __fd, unsigned __date, unsigned __time);
  257. unsigned _RTLENTRY _EXPFUNC _dos_settime(struct dostime_t _FAR *__timep);
  258. long     _RTLENTRY _EXPFUNC dostounix(struct date _FAR *__d, struct time _FAR *__t);
  259. void     _RTLENTRY _EXPFUNC getdate(struct date _FAR *__datep);
  260. void     _RTLENTRY _EXPFUNC getdfree(unsigned char __drive,
  261.                                 struct dfree _FAR *__dtable);
  262. int      _RTLENTRY _EXPFUNC _getdrive(void);
  263. void     _RTLENTRY _EXPFUNC gettime(struct time _FAR *__timep);
  264. void     _RTLENTRY _EXPFUNC setdate(struct date _FAR *__datep);
  265. void     _RTLENTRY _EXPFUNC settime( struct time _FAR *__timep);
  266. void     _RTLENTRY _EXPFUNC unixtodos(long __time, struct date _FAR *__d,
  267.                                 struct time _FAR *__t);
  268. int      _RTLENTRY _EXPFUNC unlink(const char _FAR *__path);
  269. unsigned _RTLENTRY _EXPFUNC _dos_read(int __fd, void *__buf, unsigned __len,
  270.                                 unsigned *__nread);
  271. unsigned _RTLENTRY _EXPFUNC _dos_write(int __fd, const void *__buf, unsigned __len,
  272.                                 unsigned *__nread );
  273.  
  274. __inline void _disable(void) { __emit__((unsigned char)(0xfa)); }
  275. __inline void _enable(void)  { __emit__((unsigned char)(0xfb)); }
  276.  
  277. #define geninterrupt(i) __int__(i)      /* Interrupt instruction */
  278.  
  279. /* Variables */
  280. #if !defined(__ARGV_DEFINED)
  281. #define __ARGV_DEFINED
  282.     extern int           _RTLENTRY _EXPDATA _argc;
  283.     extern char **       _RTLENTRY _EXPDATA _argv;
  284. #   define __argc        _argc  /* MSC Version */
  285. #   define __argv        _argv  /* MSC Version */
  286. #endif /* __ARGV_DEFINED */
  287.  
  288. extern int const     _RTLENTRY _EXPDATA _8087;
  289. extern char **       _RTLENTRY _EXPDATA _environ;
  290.  
  291. extern unsigned char _RTLENTRY _EXPDATA _osmajor;
  292. extern unsigned char _RTLENTRY _EXPDATA _osminor;
  293. extern unsigned      _RTLENTRY _EXPDATA _osversion;
  294. extern unsigned      _RTLENTRY _EXPDATA _version;
  295.  
  296. void _RTLENTRY _EXPFUNC _sleep(unsigned __seconds);
  297. void _RTLENTRY _EXPFUNC sleep(unsigned __seconds);
  298.  
  299. #ifdef __MFC_COMPAT__
  300. #define _getdiskfree _dos_getdiskfree
  301. #define _diskfree_t diskfree_t
  302. #else
  303. #pragma obsolete _dos_getdiskfree
  304. #endif
  305.  
  306. #if !defined(RC_INVOKED)
  307. #pragma obsolete _dos_close
  308. #pragma obsolete _dos_creat
  309. #pragma obsolete _dos_creatnew
  310. #pragma obsolete _dos_findfirst
  311. #pragma obsolete _dos_findnext
  312. #pragma obsolete _dos_getdate
  313. #pragma obsolete _dos_getdrive
  314. #pragma obsolete _dos_getfileattr
  315. #pragma obsolete _dos_getftime
  316. #pragma obsolete _dos_gettime
  317. #pragma obsolete _dos_open
  318. #pragma obsolete _dos_read
  319. #pragma obsolete _dos_setdate
  320. #pragma obsolete _dos_setdrive
  321. #pragma obsolete _dos_setfileattr
  322. #pragma obsolete _dos_setftime
  323. #pragma obsolete _dos_settime
  324. #pragma obsolete _dos_write
  325. #pragma obsolete sleep
  326. #endif
  327.  
  328. #ifdef __cplusplus
  329. }
  330. #endif
  331.  
  332.  
  333. #if !defined(RC_INVOKED)
  334.  
  335. /* restore default packing */
  336. #pragma pack(pop)
  337.  
  338. #if defined(__STDC__)
  339. #pragma warn .nak
  340. #endif
  341.  
  342. #endif  /* !RC_INVOKED */
  343.  
  344. #ifdef __cplusplus
  345. } // std
  346. #endif /* __cplusplus */
  347.  
  348. #endif  /* __DOS_H */
  349.  
  350. #if defined(__cplusplus) && !defined(__USING_CNAME__) && !defined(__DOS_H_USING_LIST)
  351. #define __DOS_H_USING_LIST
  352.  
  353.     using std::dfree;
  354.     using std::diskfree_t;
  355.     using std::time;
  356.     using std::dostime_t;
  357.     using std::date;
  358.     using std::dosdate_t;
  359.     using std::ffblk;
  360.     using std::_wffblk;
  361.     using std::find_t;
  362.     using std::_dos_close;
  363.     using std::_dos_creat;
  364.     using std::_dos_creatnew;
  365.     using std::_dos_findfirst;
  366.     using std::_dos_findnext;
  367.     using std::_dos_getdate;
  368.     using std::_dos_getdiskfree;
  369.     using std::_dos_getdrive;
  370.     using std::_dos_getfileattr;
  371.     using std::_dos_getftime;
  372.     using std::_dos_gettime;
  373.     using std::_dos_open;
  374.     using std::_dos_setdate;
  375.     using std::_dos_setdrive;
  376.     using std::_dos_setfileattr;
  377.     using std::_dos_setftime;
  378.     using std::_dos_settime;
  379.     using std::_disable;
  380.     using std::dostounix;
  381.     using std::_enable;
  382.     using std::getdate;
  383.     using std::getdfree;
  384.     using std::_getdrive;
  385.     using std::gettime;
  386.     using std::setdate;
  387.     using std::settime;
  388.     using std::unixtodos;
  389.     using std::unlink;
  390.     using std::_dos_read;
  391.     using std::_dos_write;
  392.     using std::_argc;
  393.     using std::_argv;
  394.     using std::_8087;
  395.     using std::_environ;
  396.     using std::_osmajor;
  397.     using std::_osminor;
  398.     using std::_osversion;
  399.     using std::_version;
  400.     using std::_sleep;
  401.     using std::sleep;
  402. #endif /* __USING_CNAME__ */
  403.  
  404.