home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 163_01 / doscall.c < prev    next >
Text File  |  1988-01-31  |  2KB  |  105 lines

  1. /*
  2. ** include doscall.c -- functions to invoke DOS
  3. */
  4. #include <doscall.h>
  5.  
  6.  
  7. /*
  8. ** variables for communicating with #asm code
  9. */
  10.  
  11. static char
  12.   AH, AL;
  13. static int
  14.   CX, DX;
  15.  
  16.  
  17. /*
  18. ** determine if a character is a legal DOS file name character
  19. */
  20.  
  21. _doschar(ch) char ch; {
  22.   char *ptr;
  23.   if((ch >= 'a') & (ch <= 'z')) return 1;
  24.   if((ch >= 'A') & (ch <= 'Z')) return 1;
  25.   if((ch >= '0') & (ch <= '9')) return 1;
  26.   ptr = "$&#@!%'()-{}_^~`";
  27.   while(*ptr) if(ch == *ptr++) return 1;
  28.   return 0;
  29.   }
  30.  
  31.  
  32. /*
  33. ** perform a DOS function call
  34. */
  35.  
  36. _dosfcall(function, dreg) int function, dreg; {
  37.   AH = function;
  38.   DX = dreg;
  39. #asm
  40.        MOV AH,QAH      ; get the function code
  41.        MOV DX,QDX
  42.        INT 021H        ; call DOS
  43.        MOV QAL,AL
  44. #endasm
  45.   return AL;
  46.   }
  47.  
  48.  
  49. /*
  50. ** perform a DOS function call using CX
  51. */
  52.  
  53. _dosfxcall(function, dreg, cin, cout) int function, dreg, cin, *cout; {
  54.   AH = function;
  55.   CX = cin;
  56.   DX = dreg;
  57. #asm
  58.        MOV AH,QAH      ; get the function code
  59.        MOV CX,QCX
  60.        MOV DX,QDX
  61.        INT 021H        ; call DOS
  62.        MOV QAL,AL
  63.        MOV QCX,CX
  64. #endasm
  65.   *cout = CX;
  66.   return AL;
  67.   }
  68.  
  69.  
  70. /*
  71. ** get date from DOS
  72. */
  73.  
  74. _dosdate(year, month, day) int *year, *month, *day; {
  75. #asm
  76.        MOV AH,02AH
  77.        INT 021H
  78.        MOV QCX,CX
  79.        MOV QDX,DX
  80. #endasm
  81.   *year = CX;
  82.   *month = (DX >> 8) & 255;
  83.   *day = DX & 255;
  84.   }
  85.  
  86.  
  87. /*
  88. ** get time from DOS
  89. */
  90.  
  91. _dostime(hours, minutes, seconds, hundreths)
  92.     int *hours, *minutes, *seconds, *hundreths; {
  93. #asm
  94.        MOV AH,02CH
  95.        INT 021H
  96.        MOV QCX,CX
  97.        MOV QDX,DX
  98. #endasm
  99.   *hours = (CX >> 8) & 255;
  100.   *minutes = CX & 255;
  101.   *seconds = (DX >> 8) & 255;
  102.   *hundreths = DX & 255;
  103.   }
  104.  
  105.