home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / d / dshar116.zip / DOSFN.C < prev    next >
C/C++ Source or Header  |  1993-03-08  |  2KB  |  118 lines

  1.  /* for old MS-C who lacks _dos_xxxx() */
  2. #include <dos.h>
  3. #include "common.h"
  4.  
  5. #define NULL    0
  6.  
  7. static    char    myDTA[DTASIZE];
  8. static    char    far    *myDTAp = myDTA;
  9.  
  10. unsigned _dos_getfileattr(s, ap)
  11. char    *s;
  12. unsigned *ap;
  13. {
  14.     char    far    *fars = s;
  15.     union    REGS    in, out;
  16.     struct    SREGS    segreg;
  17.  
  18.     in . x . ax = 0x4300;
  19.     in . x . dx = (unsigned int)s;
  20.     segreg . ds = FP_SEG(fars);
  21.     intdosx(&in, &out, &segreg);
  22.     return(out . x . cflag ? out . x . ax : ((*ap = out . x . cx), 0));
  23. }
  24.  
  25. #if 0 /* Not used */
  26. unsigned _dos_setfileattr(s, a)
  27. char    *s;
  28. unsigned a;
  29. {
  30.     char    far    *fars = s;
  31.     union    REGS    in, out;
  32.     struct    SREGS    segreg;
  33.  
  34.     in . x . ax = 0x4301;
  35.     in . x . cx = a;
  36.     in . x . dx = (unsigned int)s;
  37.     segreg . ds = FP_SEG(fars);
  38.     intdosx(&in, &out, &segreg);
  39.     return(out . x . cflag ? out . x . ax : 0);
  40. }
  41. #endif
  42.  
  43. unsigned _dos_getftime(f, p, q)
  44. int    f;
  45. unsigned *p, *q;
  46. {
  47.     union    REGS    in, out;
  48.  
  49.     in . x . ax = 0x5700;
  50.     in . x . bx = f;
  51.     intdos(&in, &out);    
  52.     return(out . x . cflag ? out . x . ax :
  53.                 (*p = out . x . dx, *q = out . x . cx, 0));
  54. }
  55.  
  56. #if 0 /* Not used */
  57. unsigned _dos_setftime(f, d, t)
  58. int    f;
  59. unsigned d, t;
  60. {
  61.     union    REGS    in, out;
  62.  
  63.     in . x . ax = 0x5701;
  64.     in . x . bx = f;
  65.     in . x . cx = t;
  66.     in . x . dx = d;
  67.     intdos(&in, &out);    
  68.     return(out . x . cflag ? out . x . ax : 0);
  69. }
  70. #endif
  71.  
  72. unsigned _dos_findfirst(s, i, p)
  73. char    *s; /* findnext when s == NULL */
  74. unsigned i;
  75. struct    find_t    *p;
  76. {
  77.     char    far    *fars = s;
  78.     union    REGS    in, out;
  79.     struct    SREGS    segreg;
  80.  
  81.     in . h . ah = 0x1a;
  82.     in . x . dx = (unsigned int)myDTA;
  83.     segreg . ds = FP_SEG(myDTAp);
  84.     intdosx(&in, &out, &segreg);
  85.  
  86.     if(s == NULL){
  87.         memcpy(myDTA, (char *)p, sizeof(struct find_t));
  88.         in . h . ah = 0x4f;
  89.     } else {
  90.         in . h . ah = 0x4e;
  91.         in . x . cx = i;
  92.         in . x . dx = (unsigned int)s;
  93.         segreg . ds = FP_SEG(fars);
  94.     }
  95.     intdosx(&in, &out, &segreg);
  96.     return(out . x . cflag ? out . x . ax :
  97.         (memcpy((char *)p, myDTA, sizeof(struct find_t)), 0));
  98. }
  99.  
  100. unsigned _dos_findnext(p)
  101. struct    find_t    *p;
  102. {
  103.     return _dos_findfirst(NULL, 0, p);
  104. }
  105.  
  106. #ifdef MSC4
  107. isatty(fd) /* MSC4 has buggy isatty() */
  108. register int    fd;
  109. {
  110.     union    REGS    in, out;
  111.  
  112.     in . x . ax = 0x4400;
  113.     in . x . bx = fd;
  114.     intdos(&in, &out);
  115.     return(!out . x . cflag && (out . x . ax & 0x80));
  116. }
  117. #endif
  118.