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