home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / famapi.zip / INCLUDE.ZIP / DOS.H < prev    next >
C/C++ Source or Header  |  1993-01-13  |  5KB  |  139 lines

  1. //
  2. //      **************************************************************
  3. //       JdeBP C++ Library Routines      General Public Licence v1.00
  4. //          Copyright (c) 1991,1992  Jonathan de Boyne Pollard
  5. //      **************************************************************
  6. //
  7. // DOS FUNCTIONS and SEGMENT:OFFSET MAIPULATIONS (MS-DOS)
  8. //
  9.  
  10. #if !defined(___STDDEF_H_INCLUDED)
  11. #include <_stddef.h>
  12. #endif
  13. #if !defined(___PORTINT_H_INCLUDED)
  14. #include <_portint.h>       // PORT and INTERRUPT FUNCTIONS
  15. #endif
  16. #if !defined(___ATTRIB_H_INCLUDED)
  17. #include <_attrib.h>        // File attribute constants
  18. #endif
  19.  
  20. #ifndef _DOS_H_INCLUDED
  21.  
  22. #define NULL    _NULL
  23.  
  24. #define MK_FP(s,o) _MK_FP(s,o)
  25. #define FP_SEG(fp) _FP_SEG(fp)
  26. #define FP_OFF(fp) _FP_OFF(fp)
  27.  
  28. struct DOSERROR {
  29.     int exterror;
  30.     char errclass;
  31.     char action;
  32.     char locus;
  33. };
  34.  
  35. struct find_t {
  36.     char        reserved[21];
  37.     char        attrib;
  38.     unsigned    wr_time;
  39.     unsigned    wr_date;
  40.     long        size;
  41.     char        name[13];
  42. };
  43.  
  44. struct dosdate_t {
  45.     unsigned char day;          /* 1-31 */
  46.     unsigned char month;        /* 1-12 */
  47.     unsigned int year;          /* 1980-2099 */
  48.     unsigned char dayofweek;    /* 0-6, 0=Sunday */
  49. };
  50. struct dostime_t {
  51.     unsigned char hour;     /* 0-23 */
  52.     unsigned char minute;   /* 0-59 */
  53.     unsigned char second;   /* 0-59 */
  54.     unsigned char hsecond;  /* 0-99 */
  55. };
  56.  
  57. struct diskfree_t {
  58.     unsigned total_clusters;
  59.     unsigned avail_clusters;
  60.     unsigned sectors_per_cluster;
  61.     unsigned bytes_per_sector;
  62. };
  63.  
  64. extern "C" {
  65.  
  66. //
  67. //  _dos calls only available under DOS
  68. //
  69. void        _CDECL  _dos_fullname(const char *, char *) ;
  70. void        _CDECL  _dos_keep   (unsigned, unsigned);
  71. unsigned    _CDECL  _dos_leadbytetable  (const void far * far * ) ;
  72. void        interrupt (_far * _CDECL getvect    (unsigned))();
  73. void        _CDECL  setvect (unsigned, void (interrupt _far *)());
  74.  
  75. #ifdef __MSC__
  76. void        _CDECL  _chain_intr (void (_CDECL _interrupt _far *)());
  77. void        interrupt (_far * _CDECL _dos_getvect(unsigned))();
  78. void        _CDECL  _dos_setvect    (unsigned, void (interrupt _far *)());
  79. #endif
  80.  
  81. //
  82. //  _dos calls available under OS/2
  83. //
  84. unsigned    _CDECL  _dos_allocmem(unsigned short, unsigned short *);
  85. unsigned    _CDECL  _dos_close  (int);
  86. unsigned    _CDECL  _dos_creat  (const char *, unsigned, int *);
  87. unsigned    _CDECL  _dos_creatnew   (const char *, unsigned, int *);
  88. unsigned    _CDECL  _dos_findfirst  (const char *, unsigned, struct find_t *);
  89. unsigned    _CDECL  _dos_findnext   (struct find_t *);
  90. unsigned    _CDECL  _dos_freemem    (unsigned);
  91. void        _CDECL  _dos_getdate    (struct dosdate_t *);
  92. void        _CDECL  _dos_getdrive   (unsigned *);
  93. unsigned    _CDECL  _dos_getdiskfree    (unsigned, struct diskfree_t *);
  94. unsigned    _CDECL  _dos_getfileattr    (const char *, unsigned *);
  95. unsigned    _CDECL  _dos_getftime   (int, unsigned *, unsigned *);
  96. void        _CDECL  _dos_gettime    (struct dostime_t *);
  97. unsigned    _CDECL  _dos_open   (const char *, unsigned, int *);
  98. unsigned    _CDECL  _dos_read   (int, void _far *, unsigned, unsigned *);
  99. unsigned    _CDECL  _dos_seek   (int, long, int, long *);
  100. unsigned    _CDECL  _dos_setblock   (unsigned, unsigned, unsigned *);
  101. unsigned    _CDECL  _dos_setdate    (struct dosdate_t *);
  102. void        _CDECL  _dos_setdrive   (unsigned, unsigned *);
  103. unsigned    _CDECL  _dos_setfileattr    (const char *, unsigned);
  104. unsigned    _CDECL  _dos_setftime   (int, unsigned, unsigned);
  105. unsigned    _CDECL  _dos_settime    (struct dostime_t *);
  106. unsigned    _CDECL  _dos_write  (int, const void _far *, unsigned, unsigned *);
  107. int         _CDECL  _dos_exterr (struct DOSERROR *);
  108.  
  109. //
  110. //  Global variables related to DOS
  111. //
  112. extern unsigned int     _CDECL _psp;            // Program Segment Prefix
  113. extern char far *       _CDECL _pspadr;         // PSP far pointer
  114. extern const char far * _CDECL _pgmptr;         // Pointer to prog name
  115. extern unsigned char    _CDECL _osmajor;        // DOS major version
  116. extern unsigned char    _CDECL _osminor;        // DOS minor version
  117. extern unsigned int     _CDECL _osversion;
  118.  
  119. }
  120.  
  121. //
  122. //  Windows compatible function call to perform int 21h services
  123. //
  124. //
  125. // This is for the DOS library only.  Windows exports a far pascal function
  126. // from KERNEL.EXE which (in 386 enhanced mode) performs faster processing
  127. // of int 21h than an actual int 21h instruction would, because of less
  128. // overhead with interrupt gates.  All of the other DOS...() functions call
  129. // Dos3Call to ensure future windows compatibility.
  130. //
  131. #ifdef __WINDOWS__
  132. extern "C"  void  _APICALL  Dos3Call    (void) ;
  133. #else
  134. #define Dos3Call()  { asm int 0x21; }
  135. #endif
  136.  
  137. #define _DOS_H_INCLUDED
  138. #endif
  139.