home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / c4 / pro11 / movable.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-05-05  |  977 b   |  43 lines

  1. /*
  2.  * ====================================================================
  3.  *  MOVABLE.C - function to test device by number:  0=current, 1=A, 2=B,...
  4.  *  Returns:  int 0: removable, int 1: fixed
  5.  * ====================================================================
  6.  */
  7. #include <dos.h>
  8. #include <stdio.h>
  9. #include <ctype.h>
  10. #define DEBUG 0
  11. #if DEBUG
  12. #include <string.h>
  13. #endif
  14. #if DEBUG
  15. int main (int argc, char * argv[])
  16. #else
  17. int movable (int drv)    /* value:  1-26 */
  18. #endif
  19. { int rc; int carry =0 ;
  20.   #if DEBUG
  21.   int drv;
  22.   char st[10] = "removable";
  23.   drv = toupper(argv[1][0]) - 'A'+1;
  24.   #endif
  25.   asm push ds ;
  26.   asm push dx ;
  27.   asm mov ah,44h ;
  28.   asm mov al,08h ;
  29.   asm mov bl,drv ;
  30.   asm int 21h ;
  31.   asm jnc OK ;
  32.   asm mov carry,80h ;
  33.   OK:
  34.   asm mov rc,ax ;
  35.   asm pop dx ;
  36.   asm pop ds ;
  37.   #if DEBUG
  38.   if (rc) strcpy(st,"fixed");
  39.   printf("MOVABLE reports device %d is %s\n",drv,st);
  40.   #endif
  41.   rc |= carry;
  42.   return rc;
  43. }