home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c083 / 14.ddi / GENINC.PAK / DOS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-02  |  26.2 KB  |  744 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 6.0
  9.  *
  10.  *      Copyright (c) 1987, 1993 by Borland International
  11.  *      All Rights Reserved.
  12.  *
  13.  */
  14.  
  15. #ifndef __DOS_H
  16. #define __DOS_H
  17.  
  18. #if !defined(___DEFS_H)
  19. #include <_defs.h>
  20. #endif
  21.  
  22. #if !defined(__FLAT__)
  23.  
  24. #if !defined(_RTLDLL)
  25. extern  int _RTLENTRY  errno;
  26. extern  int _RTLENTRY  _doserrno;
  27. #else
  28.  
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. int far * far _RTLENTRY __getErrno(void);
  33. int far * far _RTLENTRY __getDOSErrno(void);
  34. #ifdef __cplusplus
  35. }
  36. #endif
  37.  
  38. #define errno (*__getErrno())
  39. #define _doserrno (*__getDOSErrno())
  40. #endif
  41.  
  42. /* Variables */
  43.  
  44. #ifndef __DLL__
  45. extern  int           _RTLENTRY _argc;
  46. extern  char        **_RTLENTRY _argv;
  47. extern  unsigned      _RTLENTRY _psp;
  48. #endif
  49.  
  50. #if !defined(__STDC__) /* obsolete */
  51. #define environ  _environ
  52. #endif
  53.  
  54. extern  int const     _RTLENTRY _8087;
  55. extern  char        **_RTLENTRY _environ;
  56.  
  57. extern  unsigned      _RTLENTRY _heaplen;
  58. extern  unsigned char _RTLENTRY _osmajor;
  59. extern  unsigned char _RTLENTRY _osminor;
  60. extern  unsigned      _RTLENTRY _stklen;
  61. extern  unsigned      _RTLENTRY _fpstklen;
  62. extern  unsigned      _RTLENTRY _version;
  63. extern  unsigned      _RTLENTRY _osversion;      /* MSC name for _version */
  64.  
  65.  
  66. #define FA_NORMAL   0x00        /* Normal file, no attributes */
  67. #define FA_RDONLY   0x01        /* Read only attribute */
  68. #define FA_HIDDEN   0x02        /* Hidden file */
  69. #define FA_SYSTEM   0x04        /* System file */
  70. #define FA_LABEL    0x08        /* Volume label */
  71. #define FA_DIREC    0x10        /* Directory */
  72. #define FA_ARCH     0x20        /* Archive */
  73.  
  74. /* MSC names for file attributes */
  75.  
  76. #define _A_NORMAL   0x00        /* Normal file, no attributes */
  77. #define _A_RDONLY   0x01        /* Read only attribute */
  78. #define _A_HIDDEN   0x02        /* Hidden file */
  79. #define _A_SYSTEM   0x04        /* System file */
  80. #define _A_VOLID    0x08        /* Volume label */
  81. #define _A_SUBDIR   0x10        /* Directory */
  82. #define _A_ARCH     0x20        /* Archive */
  83.  
  84. #define NFDS    20          /* Maximum number of fds */
  85.  
  86. struct  fcb {
  87.     char    fcb_drive;      /* 0 = default, 1 = A, 2 = B */
  88.     char    fcb_name[8];    /* File name */
  89.     char    fcb_ext[3];     /* File extension */
  90.     short   fcb_curblk;     /* Current block number */
  91.     short   fcb_recsize;    /* Logical record size in bytes */
  92.     long    fcb_filsize;    /* File size in bytes */
  93.     short   fcb_date;       /* Date file was last written */
  94.     char    fcb_resv[10];   /* Reserved for DOS */
  95.     char    fcb_currec;     /* Current record in block */
  96.     long    fcb_random;     /* Random record number */
  97. };
  98.  
  99. struct  xfcb    {
  100.     char        xfcb_flag;   /* Contains 0xff to indicate xfcb */
  101.     char        xfcb_resv[5];/* Reserved for DOS */
  102.     char        xfcb_attr;   /* Search attribute */
  103.     struct  fcb xfcb_fcb;   /* The standard fcb */
  104. };
  105.  
  106. struct  COUNTRY {
  107.     int co_date;
  108.     char    co_curr[5];
  109.     char    co_thsep[2];
  110.     char    co_desep[2];
  111.     char    co_dtsep[2];
  112.     char    co_tmsep[2];
  113.     char    co_currstyle;
  114.     char    co_digits;
  115.     char    co_time;
  116.     long    co_case;
  117.     char    co_dasep[2];
  118.     char    co_fill[10];
  119. };
  120.  
  121. #if defined(__MSC) && !defined(__cplusplus)
  122.  
  123. struct  DOSERROR {
  124.         int     exterror;
  125.         char    class;
  126.         char    action;
  127.         char    locus;
  128. };
  129. #else
  130. struct  DOSERROR {
  131.         int     de_exterror;
  132.         char    de_class;
  133.         char    de_action;
  134.         char    de_locus;
  135. };
  136. #endif  /* __MSC and not C++ */
  137.  
  138. struct  dfree   {
  139.     unsigned df_avail;
  140.     unsigned df_total;
  141.     unsigned df_bsec;
  142.     unsigned df_sclus;
  143. };
  144.  
  145. struct diskfree_t {
  146.     unsigned total_clusters;
  147.     unsigned avail_clusters;
  148.     unsigned sectors_per_cluster;
  149.     unsigned bytes_per_sector;
  150. };
  151.  
  152. struct fatinfo {
  153.     char     fi_sclus;
  154.     char     fi_fatid;
  155.     unsigned fi_nclus;
  156.     int      fi_bysec;
  157. };
  158.  
  159. struct  devhdr  {
  160.     long        dh_next;        /* Next device pointer */
  161.     short       dh_attr;        /* Attributes */
  162.     unsigned short  dh_strat;   /* Driver strategy routine */
  163.     unsigned short  dh_inter;   /* Driver interrupt routine */
  164.     char        dh_name[8];     /* Device name */
  165. };
  166.  
  167. struct  time    {
  168.     unsigned char   ti_min;     /* Minutes */
  169.     unsigned char   ti_hour;    /* Hours */
  170.     unsigned char   ti_hund;    /* Hundredths of seconds */
  171.     unsigned char   ti_sec;     /* Seconds */
  172. };
  173.  
  174. struct dostime_t {
  175.     unsigned char hour;         /* Hours */
  176.     unsigned char minute;       /* Minutes */
  177.     unsigned char second;       /* Seconds */
  178.     unsigned char hsecond;      /* Hundredths of seconds */
  179. };
  180.  
  181. struct  date    {
  182.     int     da_year;        /* Year - 1980 */
  183.     char        da_day;     /* Day of the month */
  184.     char        da_mon;     /* Month (1 = Jan) */
  185. };
  186.  
  187. struct  dosdate_t {
  188.     unsigned char day;      /* 1-31 */
  189.     unsigned char month;    /* 1-12 */
  190.     unsigned int  year;     /* 1980 - 2099 */
  191.     unsigned char dayofweek;/* 0 - 6 (0=Sunday) */
  192. };
  193.  
  194. #ifndef _REG_DEFS
  195. #define _REG_DEFS
  196.  
  197. struct WORDREGS {
  198.     unsigned int    ax, bx, cx, dx, si, di, cflag, flags;
  199. };
  200.  
  201. struct BYTEREGS {
  202.     unsigned char   al, ah, bl, bh, cl, ch, dl, dh;
  203. };
  204.  
  205. union  REGS    {
  206.     struct  WORDREGS x;
  207.     struct  BYTEREGS h;
  208. };
  209.  
  210. struct SREGS   {
  211.     unsigned int    es;
  212.     unsigned int    cs;
  213.     unsigned int    ss;
  214.     unsigned int    ds;
  215. };
  216.  
  217. struct REGPACK {
  218.     unsigned    r_ax, r_bx, r_cx, r_dx;
  219.     unsigned    r_bp, r_si, r_di, r_ds, r_es, r_flags;
  220. };
  221.  
  222. #endif  /* _REG_DEFS */
  223.  
  224. typedef struct {
  225.     char    ds_drive;          /* do not change    */
  226.     char    ds_pattern [13];   /*  these fields,       */
  227.     char    ds_reserved [7];   /*   Microsoft reserved */
  228.     char    ds_attrib;
  229.     short   ds_time;
  230.     short   ds_date;
  231.     long    ds_size;
  232.     char    ds_nameZ [13];     /* result of the search, asciiz */
  233. }   dosSearchInfo;  /* used with DOS functions 4E, 4F   */
  234.  
  235.  
  236. #ifndef _FFBLK_DEF
  237. #define _FFBLK_DEF
  238. struct  ffblk   {
  239.     char        ff_reserved[21];
  240.     char        ff_attrib;
  241.     unsigned    ff_ftime;
  242.     unsigned    ff_fdate;
  243.     long        ff_fsize;
  244.     char        ff_name[13];
  245. };
  246. #endif  /* _FFBLK_DEF */
  247.  
  248. /* The MSC find_t structure corresponds exactly to the ffblk structure */
  249. struct find_t {
  250.     char     reserved[21];      /* Microsoft reserved - do not change */
  251.     char     attrib;            /* attribute byte for matched file */
  252.     unsigned wr_time;           /* time of last write to file */
  253.     unsigned wr_date;           /* date of last write to file */
  254.     long     size;              /* size of file */
  255.     char     name[13];          /* asciiz name of matched file */
  256. };
  257.  
  258.  
  259. /* axret values for _hardresume() */
  260.  
  261. #define _HARDERR_IGNORE 0   /* ignore error */
  262. #define _HARDERR_RETRY  1   /* retry the operation */
  263. #define _HARDERR_ABORT  2   /* abort program */
  264. #define _HARDERR_FAIL   3   /* fail the operation */
  265.  
  266. #define SEEK_CUR    1
  267. #define SEEK_END    2
  268. #define SEEK_SET    0
  269.  
  270.  
  271. #ifdef __cplusplus
  272. extern "C" {
  273. #endif
  274.  
  275. #if !defined( _Windows )
  276. int         _RTLENTRY absread( int __drive, int __nsects, long __lsect,
  277.                             void _FAR *__buffer );
  278. int         _RTLENTRY abswrite( int __drive, int __nsects, long __lsect,
  279.                              void _FAR *__buffer );
  280. int         _RTLENTRY allocmem( unsigned __size, unsigned _FAR *__segp );
  281. void        _RTLENTRYF delay( unsigned __milliseconds );
  282. unsigned    _RTLENTRY _dos_allocmem( unsigned __size, unsigned _FAR *__segp );
  283. unsigned    _RTLENTRY _dos_freemem( unsigned __segx );
  284. void        _RTLENTRY _dos_keep(unsigned char __status, unsigned __size);
  285. unsigned    _RTLENTRY _dos_setblock( unsigned __size, unsigned __segx,
  286.                    unsigned _FAR *__maxp );
  287. int         _RTLENTRY freemem( unsigned __segx );
  288. void        _RTLENTRY keep( unsigned char __status, unsigned __size );
  289. void        _RTLENTRY nosound( void );
  290. int         _RTLENTRY randbrd( struct fcb _FAR *__fcb, int __rcnt );
  291. int         _RTLENTRY randbwr( struct fcb _FAR *__fcb, int __rcnt );
  292. int         _RTLENTRY setblock( unsigned __segx, unsigned __newsize );
  293. void        _RTLENTRY sleep( unsigned __seconds );
  294. void        _RTLENTRY sound( unsigned __frequency );
  295.  
  296. #endif
  297.  
  298. int         _RTLENTRYF _FARFUNC bdos( int __dosfun, unsigned __dosdx, unsigned __dosal );
  299. int         _RTLENTRYF bdosptr( int __dosfun, void _FAR *__argument,
  300.                                  unsigned __dosal );
  301. struct COUNTRY _FAR *_RTLENTRY country( int __xcode, struct COUNTRY _FAR *__cp);
  302. void        _RTLENTRY ctrlbrk( int _RTLENTRY( *handler )( void ));
  303.  
  304. void        _RTLENTRY _FARFUNC disable( void );
  305. int         _RTLENTRY _FARFUNC dosexterr( struct DOSERROR _FAR *__eblkp );
  306. long        _RTLENTRY _FARFUNC dostounix( struct date _FAR *__d, struct time _FAR *__t );
  307.  
  308. unsigned    _RTLENTRY _dos_close ( int __fd );
  309. unsigned    _RTLENTRY _dos_commit( int __fd );
  310. unsigned    _RTLENTRY _dos_creat( const char _FAR *__pathP, unsigned __attr,
  311.                 int _FAR *__fd );
  312. unsigned    _RTLENTRY _dos_creatnew( const char _FAR *__pathP, unsigned __attr,
  313.                    int _FAR *__fd );
  314. unsigned    _RTLENTRY _dos_findfirst( const char _FAR *__path,
  315.                   unsigned __attrib,
  316.                   struct find_t _FAR *__finfo );
  317. unsigned    _RTLENTRY _dos_findnext( struct find_t _FAR *__finfo );
  318. void        _RTLENTRY _dos_getdate( struct dosdate_t _FAR *__datep );
  319. unsigned    _RTLENTRY _dos_getdiskfree( unsigned __drive,
  320.                       struct diskfree_t _FAR *__dtable);
  321. void        _RTLENTRY _dos_getdrive( unsigned _FAR *__drive );
  322. unsigned    _RTLENTRY _dos_getfileattr( const char _FAR *__filename,
  323.                       unsigned _FAR *__attrib );
  324. unsigned    _RTLENTRY _dos_getftime( int __fd, unsigned _FAR *__date,
  325.                    unsigned _FAR *__time );
  326. void        _RTLENTRY _dos_gettime( struct dostime_t _FAR *__timep );
  327. unsigned    _RTLENTRY _dos_open( const char _FAR *__pathP, unsigned __oflag,
  328.                    int _FAR *__fd );
  329. unsigned    _RTLENTRY _dos_read( int __fd, void __far *__buf, unsigned __len,
  330.                    unsigned _FAR *__nread );
  331. unsigned    _RTLENTRY _dos_setdate( struct dosdate_t _FAR *__datep );
  332. void        _RTLENTRY _dos_setdrive( unsigned __drive, unsigned _FAR *__ndrives );
  333. unsigned    _RTLENTRY _dos_setfileattr( const char _FAR *__filename,
  334.                       unsigned _FAR __attrib);
  335. unsigned    _RTLENTRY _dos_setftime( int __fd, unsigned __date, unsigned __time );
  336. unsigned    _RTLENTRY _dos_settime( struct dostime_t _FAR *__timep );
  337. unsigned    _RTLENTRY _dos_write( int __fd, const void __far *__buf, unsigned __len,
  338.                 unsigned _FAR *__nread );
  339.  
  340. void        __emit__( unsigned char __byte, ...);
  341. void        _RTLENTRY _FARFUNC enable( void );
  342.  
  343. int         _RTLENTRY getcbrk( void );
  344. void        _RTLENTRYF getdate( struct date _FAR *__datep );
  345. void        _RTLENTRY getdfree( unsigned char __drive,
  346.                  struct dfree _FAR *__dtable );
  347. int         _RTLENTRY getdrive( void );
  348. void        _RTLENTRY getfat( unsigned char __drive,
  349.                           struct fatinfo _FAR *__dtable );
  350. void        _RTLENTRY getfatd( struct fatinfo _FAR *__dtable );
  351. unsigned    _RTLENTRY getpsp( void );
  352. void        _RTLENTRYF gettime( struct time _FAR *__timep );
  353. int         _RTLENTRY getverify( void );
  354.  
  355. #if !defined( _Windows )
  356. #ifdef __cplusplus
  357. void        _RTLENTRY _harderr( void _RTLENTRY (__far *__fptr)( unsigned __deverr,
  358.                              unsigned __doserr, unsigned __far *__hdr) );
  359. #else
  360. void        _RTLENTRY _harderr( void _RTLENTRY (__far *__fptr)( ) );
  361. #endif
  362. void        _RTLENTRY _hardresume( int __axret );
  363. void        _RTLENTRY _hardretn( int __retn );
  364.  
  365. #ifdef __cplusplus
  366. void        _RTLENTRYF harderr( int _RTLENTRY( *__handler )( int __errval, int __ax,
  367.                                 int __bp, int __si) );
  368. #else
  369. void        _RTLENTRYF harderr( int _RTLENTRY( *__handler )( ) );
  370. #endif
  371. void        _RTLENTRYF hardresume( int __axret );
  372. void        _RTLENTRYF hardretn( int __retn );
  373. #endif
  374.  
  375. #ifndef _PORT_DEFS
  376. unsigned        _RTLENTRY inport ( unsigned __portid );
  377. unsigned char   _RTLENTRY inportb( unsigned __portid );
  378. unsigned        _RTLENTRY inpw   ( unsigned __portid );
  379. int             _RTLENTRY inp    ( unsigned __portid );
  380. #endif
  381.  
  382. int         _RTLENTRY int86( int __intno,
  383.                          union REGS _FAR *__inregs,
  384.                          union REGS _FAR *__outregs );
  385. int         _RTLENTRY int86x( int __intno,
  386.                           union REGS _FAR *__inregs,
  387.                           union REGS _FAR *__outregs,
  388.                           struct SREGS _FAR *__segregs );
  389. int         _RTLENTRY intdos( union REGS _FAR *__inregs,
  390.                           union REGS _FAR *__outregs );
  391. int         _RTLENTRY intdosx( union REGS _FAR *__inregs,
  392.                                     union REGS _FAR *__outregs,
  393.                                     struct SREGS _FAR *__segregs );
  394. void        _RTLENTRY intr( int __intno, struct REGPACK _FAR *__preg );
  395.  
  396.  
  397. #ifndef _PORT_DEFS
  398. void        _RTLENTRY outport ( unsigned __portid, unsigned __value );
  399. void        _RTLENTRY outportb( unsigned __portid, unsigned char __value );
  400. unsigned    _RTLENTRY outpw   ( unsigned __portid, unsigned __value );
  401. int         _RTLENTRY outp    ( unsigned __portid, int __value );
  402. #endif
  403.  
  404. char _FAR * _RTLENTRY parsfnm( const char _FAR *__cmdline,
  405.                       struct fcb _FAR *__fcb, int __opt );
  406. int         _RTLENTRY peek( unsigned __segment, unsigned __offset );
  407. char        _RTLENTRY peekb( unsigned __segment, unsigned __offset );
  408. void        _RTLENTRY poke( unsigned __segment, unsigned __offset, int __value);
  409. void        _RTLENTRY pokeb( unsigned __segment,
  410.                           unsigned __offset, char __value );
  411.  
  412. void        _RTLENTRY segread( struct SREGS _FAR *__segp );
  413.  
  414. int         _RTLENTRY setcbrk( int __cbrkvalue );
  415. void        _RTLENTRY setdate( struct date _FAR *__datep );
  416. void        _RTLENTRY settime( struct time _FAR *__timep );
  417. void        _RTLENTRY setverify( int __value );
  418.  
  419. void        _RTLENTRY _FARFUNC unixtodos( long __time, struct date _FAR *__d,
  420.                               struct time _FAR *__t );
  421. int         _RTLENTRYF unlink( const char _FAR *__path );
  422.  
  423.     /* These are in-line functions.  These prototypes just clean up
  424.        some syntax checks and code generation.
  425.      */
  426.  
  427. void        _RTLENTRY          __cli__( void );
  428. void        _RTLENTRY          __sti__( void );
  429. void        _RTLENTRY          __int__( int __interruptnum );
  430.  
  431. #define disable( ) __emit__( (char )( 0xfa ) ) /* MSC name */
  432. #define enable( )  __emit__( (char )( 0xfb ) ) /* MSC name */
  433. #define _disable( ) __emit__( (char )( 0xfa ) ) /* MSC name */
  434. #define _enable( )  __emit__( (char )( 0xfb ) ) /* MSC name */
  435. #define geninterrupt( i ) __int__( i )      /* Interrupt instruction */
  436.  
  437. #ifndef _PORT_DEFS
  438. #define _PORT_DEFS
  439.  
  440. unsigned char   _RTLENTRY    __inportb__ ( unsigned __portid );
  441. unsigned        _RTLENTRY    __inportw__ ( unsigned __portid );
  442. unsigned char   _RTLENTRY    __outportb__( unsigned __portid, unsigned char __value );
  443. unsigned        _RTLENTRY    __outportw__( unsigned __portid, unsigned __value );
  444.  
  445. #define inportb(__portid)           __inportb__(__portid)
  446. #define outportb(__portid, __value) ((void) __outportb__(__portid, __value))
  447. #define inport(__portid)            __inportw__(__portid)
  448. #define outport(__portid, __value)  ((void) __outportw__(__portid, __value))
  449.  
  450. /* MSC-compatible macros for port I/O */
  451. #define inp(__portid)               __inportb__ (__portid)
  452. #define outp(__portid, __value)     __outportb__(__portid, (unsigned char)(__value))
  453. #define inpw(__portid)              __inportw__ (__portid)
  454. #define outpw(__portid, __value)    __outportw__(__portid, __value)
  455.  
  456. #endif  /* _PORT_DEFS */
  457.  
  458. #if !__STDC__
  459.  
  460. #if !defined(_Windows)
  461.  
  462. extern  unsigned    _RTLENTRY  _ovrbuffer;
  463. int cdecl far _OvrInitEms( unsigned __emsHandle, unsigned __emsFirst,
  464.                            unsigned __emsPages );
  465. int cdecl far _OvrInitExt( unsigned long __extStart,
  466.                            unsigned long __extLength );
  467.  
  468. #endif /* _Windows  */
  469.  
  470. char far *cdecl getdta( void );
  471. void      cdecl setdta( char far *__dta );
  472.  
  473. #define MK_FP( seg,ofs )( (void _seg * )( seg ) +( void near * )( ofs ))
  474. #define FP_SEG( fp )( (unsigned )( void _seg * )( void far * )( fp ))
  475. #define FP_OFF( fp )( (unsigned )( fp ))
  476.  
  477. #ifdef __cplusplus
  478. void        _RTLENTRY _chain_intr ( void interrupt (far *__target)( ... ));
  479. void interrupt( far * _RTLENTRY _dos_getvect( unsigned __interruptno ))( ... );
  480. void interrupt( far * _RTLENTRYF getvect( int __interruptno ))( ... );
  481. void        _RTLENTRY _dos_setvect( unsigned __interruptno,
  482.                                  void interrupt( far *__isr )( ... ));
  483. void        _RTLENTRYF setvect( int __interruptno,
  484.                             void interrupt( far *__isr )( ... ));
  485. int  inline _RTLENTRY peek( unsigned __segment, unsigned __offset )
  486.                   { return( *( (int  far* )MK_FP( __segment, __offset )) ); }
  487. char inline _RTLENTRY peekb( unsigned __segment, unsigned __offset )
  488.                   { return( *( (char far* )MK_FP( __segment, __offset )) ); }
  489. void inline _RTLENTRY poke( unsigned __segment, unsigned __offset, int __value )
  490.                {( *( (int  far* )MK_FP( __segment, __offset )) = __value ); }
  491. void inline _RTLENTRY pokeb( unsigned __segment, unsigned __offset, char __value )
  492.                {( *( (char far* )MK_FP( __segment, __offset )) = __value ); }
  493. #else
  494. void        _RTLENTRY _chain_intr ( void interrupt (far *__target)( ));
  495. void interrupt( far * _RTLENTRY _dos_getvect( unsigned __interruptno ))( );
  496. void interrupt( far * _RTLENTRYF getvect( int __interruptno ))( );
  497. void        _RTLENTRY _dos_setvect( unsigned __interruptno,
  498.                 void interrupt( far *__isr )( ));
  499. void        _RTLENTRYF setvect( int __interruptno,
  500.                 void interrupt( far *__isr )( ) );
  501. #define peek( a,b )( *( (int  far* )MK_FP( (a ),( b )) ))
  502. #define peekb( a,b )( *( (char far* )MK_FP( (a ),( b )) ))
  503. #define poke( a,b,c )( *( (int  far* )MK_FP( (a ),( b )) ) =( int )( c ))
  504. #define pokeb( a,b,c )( *( (char far* )MK_FP( (a ),( b )) ) =( char )( c ))
  505. #endif  /* __cplusplus */
  506.  
  507. #endif  /* !__STDC__ */
  508.  
  509. #ifdef __cplusplus
  510. }
  511. #endif
  512.  
  513.  
  514. #else  /* defined __FLAT__ */
  515.  
  516. #pragma option -a-
  517.  
  518. #ifdef _MT
  519.  
  520. #ifdef __cplusplus
  521. extern "C" {
  522. #endif
  523. extern  int * _RTLENTRY _EXPFUNC __errno(void);
  524. extern  int * _RTLENTRY _EXPFUNC __doserrno(void);
  525. #ifdef  __cplusplus
  526. }
  527. #endif
  528. #define errno (*__errno())
  529. #define _doserrno (*__doserrno())
  530.  
  531. #else
  532.  
  533. extern  int _RTLENTRY _EXPDATA errno;
  534. extern  int _RTLENTRY _EXPDATA _doserrno;
  535.  
  536. #endif
  537.  
  538. #if !defined(__STDC__)
  539. #define environ  _environ
  540. #endif
  541.  
  542. /* Variables */
  543. extern  int const _RTLENTRY _EXPDATA _8087;
  544. extern  int       _RTLENTRY _EXPDATA _argc;
  545. extern  char    **_RTLENTRY _EXPDATA _argv;
  546. extern  char    **_RTLENTRY _EXPDATA _environ;
  547.  
  548. extern  unsigned char _RTLENTRY _EXPDATA _osmajor;
  549. extern  unsigned char _RTLENTRY _EXPDATA _osminor;
  550. extern  unsigned      _RTLENTRY _EXPDATA _osversion;
  551. extern  unsigned      _RTLENTRY _EXPDATA _version;
  552.  
  553.  
  554. #define FA_NORMAL   0x00        /* Normal file, no attributes */
  555. #define FA_RDONLY   0x01        /* Read only attribute */
  556. #define FA_HIDDEN   0x02        /* Hidden file */
  557. #define FA_SYSTEM   0x04        /* System file */
  558. #define FA_LABEL    0x08        /* Volume label */
  559. #define FA_DIREC    0x10        /* Directory */
  560. #define FA_ARCH     0x20        /* Archive */
  561.  
  562. /* MSC names for file attributes */
  563.  
  564. #define _A_NORMAL   0x00        /* Normal file, no attributes */
  565. #define _A_RDONLY   0x01        /* Read only attribute */
  566. #define _A_HIDDEN   0x02        /* Hidden file */
  567. #define _A_SYSTEM   0x04        /* System file */
  568. #define _A_VOLID    0x08        /* Volume label */
  569. #define _A_SUBDIR   0x10        /* Directory */
  570. #define _A_ARCH     0x20        /* Archive */
  571.  
  572. struct COUNTRY {
  573.     int co_date;
  574.     char    co_curr[5];
  575.     char    co_thsep[2];
  576.     char    co_desep[2];
  577.     char    co_dtsep[2];
  578.     char    co_tmsep[2];
  579.     char    co_currstyle;
  580.     char    co_digits;
  581.     char    co_time;
  582.     long    co_case;
  583.     char    co_dasep[2];
  584.     char    co_fill[10];
  585. };
  586.  
  587. struct  dfree   {
  588.     unsigned df_avail;
  589.     unsigned df_total;
  590.     unsigned df_bsec;
  591.     unsigned df_sclus;
  592. };
  593.  
  594. struct  diskfree_t {
  595.     unsigned total_clusters;
  596.     unsigned avail_clusters;
  597.     unsigned sectors_per_cluster;
  598.     unsigned bytes_per_sector;
  599. };
  600.  
  601. struct  time    {
  602.     unsigned char   ti_min;     /* Minutes */
  603.     unsigned char   ti_hour;    /* Hours */
  604.     unsigned char   ti_hund;    /* Hundredths of seconds */
  605.     unsigned char   ti_sec;     /* Seconds */
  606. };
  607.  
  608. struct  dostime_t {
  609.     unsigned char hour;         /* Hours */
  610.     unsigned char minute;       /* Minutes */
  611.     unsigned char second;       /* Seconds */
  612.     unsigned char hsecond;      /* Hundredths of seconds */
  613. };
  614.  
  615. struct  date    {
  616.     int         da_year;    /* Year - 1980 */
  617.     char        da_day;     /* Day of the month */
  618.     char        da_mon;     /* Month (1 = Jan) */
  619. };
  620.  
  621. struct  dosdate_t {
  622.     unsigned char day;      /* 1-31 */
  623.     unsigned char month;    /* 1-12 */
  624.     unsigned int  year;     /* 1980 - 2099 */
  625.     unsigned char dayofweek;/* 0 - 6 (0=Sunday) */
  626. };
  627.  
  628. #ifndef _FFBLK_DEF
  629. #define _FFBLK_DEF
  630. struct  ffblk   {
  631.     long            ff_reserved;
  632.     long            ff_fsize;
  633.     unsigned long   ff_attrib;
  634.     unsigned short  ff_ftime;
  635.     unsigned short  ff_fdate;
  636.     char            ff_name[256];
  637. };
  638. #endif  /* __FFBLK_DEF */
  639.  
  640. /* The MSC find_t structure corresponds exactly to the ffblk structure */
  641. struct  find_t {
  642.     long            reserved;
  643.     long            size;              /* size of file */
  644.     unsigned long   attrib;            /* attribute byte for matched file */
  645.     unsigned short  wr_time;           /* time of last write to file */
  646.     unsigned short  wr_date;           /* date of last write to file */
  647.     char            name[256];         /* asciiz name of matched file */
  648. };
  649.  
  650.  
  651. #define SEEK_CUR    1
  652. #define SEEK_END    2
  653. #define SEEK_SET    0
  654.  
  655.  
  656. #ifdef __cplusplus
  657. extern "C" {
  658. #endif
  659.  
  660. struct COUNTRY * _RTLENTRY _EXPFUNC country( int __xcode, struct COUNTRY *__cp);
  661. long        _RTLENTRY _EXPFUNC dostounix( struct date *__d, struct time *__t );
  662.  
  663. unsigned    _RTLENTRY _EXPFUNC _dos_close( int __fd );
  664. unsigned    _RTLENTRY _EXPFUNC _dos_creat( const char * __pathP, unsigned __attr, int * __fd );
  665. unsigned    _RTLENTRY _EXPFUNC _dos_creatnew( const char * __pathP, unsigned __attr, int * __fd );
  666. unsigned    _RTLENTRY _EXPFUNC _dos_findfirst( const char * __path, unsigned __attrib, struct find_t *__finfo );
  667. unsigned    _RTLENTRY _EXPFUNC _dos_findnext( struct find_t *__finfo );
  668. void        _RTLENTRY _EXPFUNC _dos_getdate( struct dosdate_t *__datep );
  669. unsigned    _RTLENTRY _EXPFUNC _dos_getdiskfree( unsigned __drive, struct diskfree_t *__dtable );
  670. void        _RTLENTRY _EXPFUNC _dos_getdrive( unsigned *__drive );
  671. unsigned    _RTLENTRY _EXPFUNC _dos_getfileattr( const char * __filename, unsigned *__attrib );
  672. unsigned    _RTLENTRY _EXPFUNC _dos_getftime( int __fd, unsigned *__date, unsigned *__time );
  673. void        _RTLENTRY _EXPFUNC _dos_gettime( struct dostime_t *__timep );
  674. unsigned    _RTLENTRY _EXPFUNC _dos_open( const char * __pathP, unsigned __oflag, int * __fd );
  675. unsigned    _RTLENTRY _EXPFUNC _dos_read( int __fd, void * __buf, unsigned __len, unsigned *__nread );
  676. unsigned    _RTLENTRY _EXPFUNC _dos_setdate( struct dosdate_t *__datep );
  677. void        _RTLENTRY _EXPFUNC _dos_setdrive( unsigned __drive, unsigned *__ndrives );
  678. unsigned    _RTLENTRY _EXPFUNC _dos_setfileattr( const char * __filename, unsigned __attrib );
  679. unsigned    _RTLENTRY _EXPFUNC _dos_setftime( int __fd, unsigned __date, unsigned __time );
  680. unsigned    _RTLENTRY _EXPFUNC _dos_settime( struct dostime_t *__timep );
  681. unsigned    _RTLENTRY _EXPFUNC _dos_write( int __fd, void * __buf, unsigned __len, unsigned *__nread );
  682.  
  683. /*  Only valid for DOS */
  684. #pragma obsolete _dos_close
  685. #pragma obsolete _dos_creat
  686. #pragma obsolete _dos_creatnew
  687. #pragma obsolete _dos_findfirst
  688. #pragma obsolete _dos_findnext
  689. #pragma obsolete _dos_getdate
  690. #pragma obsolete _dos_getdiskfree
  691. #pragma obsolete _dos_getdrive
  692. #pragma obsolete _dos_getfileattr
  693. #pragma obsolete _dos_getftime
  694. #pragma obsolete _dos_gettime
  695. #pragma obsolete _dos_open
  696. #pragma obsolete _dos_read
  697. #pragma obsolete _dos_setdate
  698. #pragma obsolete _dos_setdrive
  699. #pragma obsolete _dos_setfileattr
  700. #pragma obsolete _dos_setftime
  701. #pragma obsolete _dos_settime
  702. #pragma obsolete _dos_write
  703.  
  704. void        _RTLENTRYF _EXPFUNC getdate( struct date *__datep );
  705. void        _RTLENTRY _EXPFUNC getdfree( unsigned char __drive,
  706.                  struct dfree*__dtable );
  707. int         _RTLENTRY _EXPFUNC _getdrive( void );
  708. void        _RTLENTRYF _EXPFUNC gettime( struct time *__timep );
  709. int         _RTLENTRY _EXPFUNC getverify( void );
  710.  
  711. void        _RTLENTRY _EXPFUNC setdate( struct date *__datep );
  712. void        _RTLENTRY _EXPFUNC settime( struct time *__timep );
  713. void        _RTLENTRY _EXPFUNC setverify( int __value );
  714.  
  715. void        _RTLENTRY _EXPFUNC _sleep( unsigned __seconds );
  716.  
  717. void        _RTLENTRY _EXPFUNC unixtodos( long __time, struct date *__d,
  718.                               struct time *__t );
  719. int         _RTLENTRYF _EXPFUNC unlink( const char * __path );
  720.  
  721. #define sleep(unsigned) _sleep(unsigned)
  722.  
  723. /* Inline functions.
  724.  */
  725. void                 __int__( int __interruptnum );
  726.  
  727. #define disable( ) __emit__( (unsigned char )( 0xfa ) ) /* MSC name */
  728. #define enable( )  __emit__( (unsigned char )( 0xfb ) ) /* MSC name */
  729. #define _disable( ) __emit__( (unsigned char )( 0xfa ) ) /* MSC name */
  730. #define _enable( )  __emit__( (unsigned char )( 0xfb ) ) /* MSC name */
  731.  
  732. #define geninterrupt( i ) __int__( i )      /* Interrupt instruction */
  733.  
  734. #ifdef __cplusplus
  735. }
  736. #endif
  737.  
  738. #pragma option -a. /* restore default packing */
  739.  
  740. #endif  /* __FLAT__ */
  741.  
  742.  
  743. #endif  /* __DOS_H */
  744.