home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 2.ddi / INCLUDE.ZIP / DOS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  13.7 KB  |  438 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.     Copyright (c) Borland International 1987,1988,1990,1991
  7.     All Rights Reserved.
  8. */
  9. #ifndef __DOS_H
  10. #define __DOS_H
  11.  
  12. #ifdef __DLL__
  13. #define _FAR far
  14. #else
  15. #define _FAR
  16. #endif
  17.  
  18. #if __STDC__
  19. #define _Cdecl
  20. #else
  21. #define _Cdecl  cdecl
  22. #endif
  23.  
  24. #ifndef __PAS__
  25. #define _CType _Cdecl
  26. #else
  27. #define _CType pascal
  28. #endif
  29.  
  30. #ifndef __DLL__
  31.  
  32. /* Variables */
  33. extern  int const _Cdecl _8087;
  34. extern  int       _Cdecl _argc;
  35. extern  char    **_Cdecl _argv;
  36. extern  char    **_Cdecl  environ;
  37.  
  38. extern  int _Cdecl _doserrno;
  39.  
  40. extern  unsigned      _Cdecl _heaplen;
  41. extern  unsigned char _Cdecl _osmajor;
  42. extern  unsigned char _Cdecl _osminor;
  43. extern  unsigned      _Cdecl _psp;
  44. extern  unsigned      _Cdecl _stklen;
  45. extern  unsigned      _Cdecl _fpstklen;
  46. extern  unsigned      _Cdecl _version;
  47.  
  48. #endif  /* __DLL__*/
  49.  
  50.  
  51. #define FA_NORMAL   0x00        /* Normal file, no attributes */
  52. #define FA_RDONLY   0x01        /* Read only attribute */
  53. #define FA_HIDDEN   0x02        /* Hidden file */
  54. #define FA_SYSTEM   0x04        /* System file */
  55. #define FA_LABEL    0x08        /* Volume label */
  56. #define FA_DIREC    0x10        /* Directory */
  57. #define FA_ARCH     0x20        /* Archive */
  58.  
  59. #define NFDS    20          /* Maximum number of fds */
  60.  
  61. struct  fcb {
  62.     char    fcb_drive;      /* 0 = default, 1 = A, 2 = B */
  63.     char    fcb_name[8];    /* File name */
  64.     char    fcb_ext[3];     /* File extension */
  65.     short   fcb_curblk;     /* Current block number */
  66.     short   fcb_recsize;    /* Logical record size in bytes */
  67.     long    fcb_filsize;    /* File size in bytes */
  68.     short   fcb_date;       /* Date file was last written */
  69.     char    fcb_resv[10];   /* Reserved for DOS */
  70.     char    fcb_currec;     /* Current record in block */
  71.     long    fcb_random;     /* Random record number */
  72. };
  73.  
  74. struct  xfcb    {
  75.     char        xfcb_flag;  /* Contains 0xff to indicate xfcb */
  76.     char        xfcb_resv[5];/* Reserved for DOS */
  77.     char        xfcb_attr;  /* Search attribute */
  78.     struct  fcb xfcb_fcb;   /* The standard fcb */
  79. };
  80.  
  81. struct  COUNTRY {
  82.     int co_date;
  83.     char    co_curr[5];
  84.     char    co_thsep[2];
  85.     char    co_desep[2];
  86.     char    co_dtsep[2];
  87.     char    co_tmsep[2];
  88.     char    co_currstyle;
  89.     char    co_digits;
  90.     char    co_time;
  91.     long    co_case;
  92.     char    co_dasep[2];
  93.     char    co_fill[10];
  94. };
  95.  
  96. #if defined(__MSC) && !defined(__cplusplus)
  97. struct  DOSERROR {
  98.         int     exterror;
  99.         char    class;
  100.         char    action;
  101.         char    locus;
  102. };
  103. #else
  104. struct  DOSERROR {
  105.         int     de_exterror;
  106.         char    de_class;
  107.         char    de_action;
  108.         char    de_locus;
  109. };
  110. #endif    /* __MSC and not C++ */
  111.  
  112. struct  dfree   {
  113.     unsigned df_avail;
  114.     unsigned df_total;
  115.     unsigned df_bsec;
  116.     unsigned df_sclus;
  117. };
  118.  
  119. struct  fatinfo {
  120.     char    fi_sclus;
  121.     char    fi_fatid;
  122.     int fi_nclus;
  123.     int fi_bysec;
  124. };
  125.  
  126. struct  devhdr  {
  127.     long        dh_next;        /* Next device pointer */
  128.     short       dh_attr;        /* Attributes */
  129.     unsigned short  dh_strat;   /* Driver strategy routine */
  130.     unsigned short  dh_inter;   /* Driver interrupt routine */
  131.     char        dh_name[8];     /* Device name */
  132. };
  133.  
  134. struct  time    {
  135.     unsigned char   ti_min;     /* Minutes */
  136.     unsigned char   ti_hour;    /* Hours */
  137.     unsigned char   ti_hund;    /* Hundredths of seconds */
  138.     unsigned char   ti_sec;     /* Seconds */
  139. };
  140.  
  141. struct  date    {
  142.     int     da_year;        /* Year - 1980 */
  143.     char        da_day;     /* Day of the month */
  144.     char        da_mon;     /* Month (1 = Jan) */
  145. };
  146.  
  147. #ifndef _REG_DEFS
  148. #define _REG_DEFS
  149.  
  150. struct WORDREGS {
  151.     unsigned int    ax, bx, cx, dx, si, di, cflag, flags;
  152. };
  153.  
  154. struct BYTEREGS {
  155.     unsigned char   al, ah, bl, bh, cl, ch, dl, dh;
  156. };
  157.  
  158. union   REGS    {
  159.     struct  WORDREGS x;
  160.     struct  BYTEREGS h;
  161. };
  162.  
  163. struct  SREGS   {
  164.     unsigned int    es;
  165.     unsigned int    cs;
  166.     unsigned int    ss;
  167.     unsigned int    ds;
  168. };
  169.  
  170. struct  REGPACK {
  171.     unsigned    r_ax, r_bx, r_cx, r_dx;
  172.     unsigned    r_bp, r_si, r_di, r_ds, r_es, r_flags;
  173. };
  174.  
  175. #endif    /* _REG_DEFS */
  176.  
  177. typedef struct {
  178.     char    ds_drive;          /* do not change    */
  179.     char    ds_pattern [13];   /*  these fields,       */
  180.     char    ds_reserved [7];   /*   Microsoft reserved */
  181.     char    ds_attrib;
  182.     short   ds_time;
  183.     short   ds_date;
  184.     long    ds_size;
  185.     char    ds_nameZ [13];     /* result of the search, asciiz */
  186. }   dosSearchInfo;  /* used with DOS functions 4E, 4F   */
  187.  
  188.  
  189. #ifdef  __MSC
  190. #ifndef _FFBLK_DEF
  191. #define _FFBLK_DEF
  192. struct  ffblk   {
  193.     char        ff_reserved[21];
  194.     char        ff_attrib;
  195.     unsigned    ff_ftime;
  196.     unsigned    ff_fdate;
  197.     long        ff_fsize;
  198.     char        ff_name[13];
  199. };
  200. #endif    /* _FFBLK_DEF */
  201. #endif  /* __MSC */
  202.  
  203. #ifdef __cplusplus
  204. extern "C" {
  205. #endif
  206.  
  207. #if !defined( _Windows )
  208. int         _Cdecl absread( int __drive, int __nsects, long __lsect,
  209.                             void *__buffer );
  210. int         _Cdecl abswrite( int __drive, int __nsects, long __lsect,
  211.                              void *__buffer );
  212. int         _Cdecl allocmem( unsigned __size, unsigned _FAR *__segp );
  213. #endif
  214.  
  215. int         _CType bdos( int __dosfun, unsigned __dosdx, unsigned __dosal );
  216. int         _Cdecl bdosptr( int __dosfun, void _FAR *__argument,
  217.                             unsigned __dosal );
  218. struct COUNTRY _FAR *_Cdecl country( int __xcode, struct COUNTRY _FAR *__cp);
  219. void        _Cdecl ctrlbrk( int _Cdecl( *handler )( void ));
  220.  
  221. #if !defined( _Windows )
  222. void        _Cdecl delay( unsigned __milliseconds );
  223. #endif
  224.  
  225. void        _Cdecl disable( void );
  226. int         _Cdecl dosexterr( struct DOSERROR _FAR *__eblkp );
  227. long        _Cdecl dostounix( struct date _FAR *__d, struct time _FAR *__t );
  228. void            __emit__( );
  229. void        _Cdecl enable( void );
  230.  
  231. #if !defined( _Windows )
  232. int         _Cdecl freemem( unsigned __segx );
  233. #endif
  234.  
  235. int         _Cdecl getcbrk( void );
  236. void        _CType getdate( struct date _FAR *__datep );
  237. void        _Cdecl getdfree( unsigned char __drive,
  238.                              struct dfree _FAR *__dtable );
  239. void        _Cdecl getfat( unsigned char __drive,
  240.                            struct fatinfo _FAR *__dtable );
  241. void        _Cdecl getfatd( struct fatinfo _FAR *__dtable );
  242. unsigned    _Cdecl getpsp( void );
  243. int         _Cdecl getswitchar( void );
  244. void        _CType gettime( struct time _FAR *__timep );
  245. int         _Cdecl getverify( void );
  246.  
  247. #if !defined( _Windows )
  248. void        _Cdecl harderr( int _Cdecl( *handler )( ) );
  249. void        _Cdecl hardresume( int __axret );
  250. void        _Cdecl hardretn( int __retn );
  251. #endif
  252.  
  253. int         _Cdecl inport( int __portid );
  254. #ifndef _PORT_DEFS
  255. unsigned char _Cdecl inportb( int __portid );
  256. #endif
  257. int         _Cdecl int86( int __intno,
  258.                           union REGS _FAR *__inregs,
  259.                           union REGS _FAR *__outregs );
  260. int         _Cdecl int86x( int __intno,
  261.                            union REGS _FAR *__inregs,
  262.                            union REGS _FAR *__outregs,
  263.                            struct SREGS _FAR *__segregs );
  264. int         _Cdecl intdos( union REGS _FAR *__inregs,
  265.                            union REGS _FAR *__outregs );
  266. int         _Cdecl intdosx( union REGS _FAR *__inregs,
  267.                             union REGS _FAR *__outregs,
  268.                             struct SREGS _FAR *__segregs );
  269. void        _Cdecl intr( int __intno, struct REGPACK _FAR *__preg );
  270.  
  271. #if !defined( _Windows )
  272. void        _Cdecl keep( unsigned char __status, unsigned __size );
  273. void        _Cdecl nosound( void );
  274. #endif
  275.  
  276. void        _Cdecl outport( int __portid, int __value );
  277. #ifndef _PORT_DEFS
  278. void        _Cdecl outportb( int __portid, unsigned char __value );
  279. #endif
  280. char _FAR * _Cdecl parsfnm( const char _FAR *__cmdline,
  281.                             struct fcb _FAR *__fcb, int __opt );
  282. int         _Cdecl peek( unsigned __segment, unsigned __offset );
  283. char        _Cdecl peekb( unsigned __segment, unsigned __offset );
  284. void        _Cdecl poke( unsigned __segment, unsigned __offset, int __value);
  285. void        _Cdecl pokeb( unsigned __segment,
  286.                           unsigned __offset, char __value );
  287.  
  288. #if !defined( _Windows )
  289. int         _Cdecl randbrd( struct fcb _FAR *__fcb, int __rcnt );
  290. int         _Cdecl randbwr( struct fcb _FAR *__fcb, int __rcnt );
  291. #endif
  292.  
  293. void        _Cdecl segread( struct SREGS _FAR *__segp );
  294.  
  295. #if !defined( _Windows )
  296. int         _Cdecl setblock( unsigned __segx, unsigned __newsize );
  297. #endif
  298.  
  299. int         _Cdecl setcbrk( int __cbrkvalue );
  300. void        _Cdecl setdate( struct date _FAR *__datep );
  301. void        _Cdecl setswitchar( char __ch );
  302. void        _Cdecl settime( struct time _FAR *__timep );
  303. void        _Cdecl setverify( int __value );
  304.  
  305. #if !defined( _Windows )
  306. void        _Cdecl sleep( unsigned __seconds );
  307. void        _Cdecl sound( unsigned __frequency );
  308. #endif
  309.  
  310. void        _Cdecl unixtodos( long __time, struct date _FAR *__d,
  311.                               struct time _FAR *__t );
  312. int         _CType unlink( const char _FAR *__path );
  313.  
  314.     /* These are in-line functions.  These prototypes just clean up
  315.        some syntax checks and code generation.
  316.      */
  317.  
  318. void        _Cdecl          __cli__( void );
  319. void        _Cdecl          __sti__( void );
  320. void        _Cdecl          __int__( int __interruptnum );
  321.  
  322. #define disable( ) __emit__( (char )( 0xfa ) )
  323. #define enable( )  __emit__( (char )( 0xfb ) )
  324.  
  325. #define geninterrupt( i ) __int__( i )      /* Interrupt instruction */
  326.  
  327. #ifndef _PORT_DEFS
  328. #define _PORT_DEFS
  329.  
  330. unsigned char _Cdecl    __inportb__( int __portid );
  331. unsigned int _Cdecl     __inportw__( int __portid );
  332. void        _Cdecl      __outportb__( int __portid, unsigned char __value );
  333. void        _Cdecl      __outportw__( int __portid, unsigned int __value );
  334.  
  335. #define inportb         __inportb__
  336. #define inportw         __inportw__
  337. #define outportb        __outportb__
  338. #define outportw        __outportw__
  339.  
  340. /* some other compilers use inp, outp for inportb, outportb */
  341. #define inp( portid ) inportb( portid )
  342. #define outp( portid,v )  outportb( portid,v )
  343. #define inpw( portid ) inportw( portid )
  344. #define outpw( portid,v )  outportw( portid,v )
  345.  
  346. #endif    /* _PORT_DEFS */
  347.  
  348. #if !__STDC__
  349.  
  350. extern  unsigned    _Cdecl  _ovrbuffer;
  351. int cdecl far _OvrInitEms( unsigned __emsHandle, unsigned __emsFirst,
  352.                            unsigned __emsPages );
  353. int cdecl far _OvrInitExt( unsigned long __extStart,
  354.                            unsigned long __extLength );
  355.  
  356. char far *cdecl getdta( void );
  357. void      cdecl setdta( char far *__dta );
  358.  
  359. #define MK_FP( seg,ofs )( (void _seg * )( seg ) +( void near * )( ofs ))
  360. #define FP_SEG( fp )( (unsigned )( void _seg * )( void far * )( fp ))
  361. #define FP_OFF( fp )( (unsigned )( fp ))
  362.  
  363. #ifdef __cplusplus
  364. void    interrupt( far * _CType getvect( int __interruptno ))( ... );
  365. void        _CType setvect( int __interruptno,
  366.                             void interrupt( far *__isr )( ... ));
  367. int  inline _Cdecl peek( unsigned __segment, unsigned __offset )  
  368.                   { return( *( (int  far* )MK_FP( __segment, __offset )) ); }
  369. char inline _Cdecl peekb( unsigned __segment, unsigned __offset ) 
  370.                   { return( *( (char far* )MK_FP( __segment, __offset )) ); }
  371. void inline _Cdecl poke( unsigned __segment, unsigned __offset, int __value )  
  372.                {( *( (int  far* )MK_FP( __segment, __offset )) = __value ); }
  373. void inline _Cdecl pokeb( unsigned __segment, unsigned __offset, char __value )   
  374.                {( *( (char far* )MK_FP( __segment, __offset )) = __value ); }
  375. #else
  376. void    interrupt( far * _CType getvect( int __interruptno ))( );
  377. void        _CType setvect( int __interruptno,
  378.                             void interrupt( far *__isr )( ) );
  379. #define peek( a,b )( *( (int  far* )MK_FP( (a ),( b )) ))
  380. #define peekb( a,b )( *( (char far* )MK_FP( (a ),( b )) ))
  381. #define poke( a,b,c )( *( (int  far* )MK_FP( (a ),( b )) ) =( int )( c ))
  382. #define pokeb( a,b,c )( *( (char far* )MK_FP( (a ),( b )) ) =( char )( c ))
  383. #endif
  384.  
  385. #endif
  386.  
  387. #ifdef __MSC
  388.  
  389. /* Prototypes needed for MSC _dos_??? macros */
  390. int  _CType findfirst( const char _FAR *__path,
  391.                               struct ffblk _FAR *__ffblk, 
  392.                               int __attrib );
  393. int  _CType findnext( struct ffblk _FAR *__ffblk );
  394.  
  395. #endif    /* __MSC */
  396.  
  397. #ifdef __cplusplus
  398. }
  399. #endif
  400.  
  401. #ifdef __MSC
  402.  
  403. /* File attributes */
  404.  
  405. #define _A_NORMAL   0x00        /* Normal file, no attributes */
  406. #define _A_RDONLY   0x01        /* Read only attribute */
  407. #define _A_HIDDEN   0x02        /* Hidden file */
  408. #define _A_SYSTEM   0x04        /* System file */
  409. #define _A_VOLID    0x08        /* Volume label */
  410. #define _A_SUBDIR   0x10        /* Directory */
  411. #define _A_ARCH     0x20        /* Archive */
  412.  
  413. /* Structures */
  414.  
  415. struct find_t {
  416.     char     reserved[21];    /* Microsoft reserved - do not change */
  417.     char     attrib;        /* attribute byte for matched file */
  418.     unsigned wr_time;        /* time of last write to file */
  419.     unsigned wr_date;        /* date of last write to file */
  420.     long     size;        /* size of file */
  421.     char     name[13];        /* asciiz name of matched file */
  422. };
  423.  
  424. /* Variables */
  425.  
  426. #define _osversion _version
  427.  
  428. /* Macros for MSC functions */
  429.  
  430. #define _disable()        disable()
  431. #define _dos_findfirst(path,attrib,fileinfo) \
  432.   (unsigned)findfirst(path,(struct ffblk _FAR *)fileinfo,attrib)
  433. #define _dos_findnext(fileinfo) (unsigned)findnext((struct ffblk *)fileinfo)
  434. #define _enable()        enable()
  435. #endif    /* __MSC */
  436.  
  437. #endif
  438.