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