home *** CD-ROM | disk | FTP | other *** search
/ CD-X 1 / cdx_01.iso / shareuti / secdev13 / source / logout.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-02  |  2.4 KB  |  79 lines

  1. /* This file is a part of SecureDevice 1.3
  2.    Copyright (C) 1994 by Max Loewenthal and Arthur Helwig
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.  
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17.  
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <bios.h>
  21. #include <dos.h>
  22. #include <string.h>
  23. #include <ctype.h>
  24. #include "globals.h"
  25.  
  26. #define MinorName "LOGOUT"
  27. #define MinorVer "1.01"
  28.  
  29. void main(int argc,char *argv[])
  30. { unsigned char SubUnit;
  31.   int i,nofdrivers;
  32.   char DriveOK=0;
  33.   unsigned char Driveletter;
  34.   union REGS regs;
  35.   struct SREGS segregs;
  36.  
  37.   printf("%s %s's %s %s\n",MajorName,MajorVer,MinorName,MinorVer);
  38.   printf("Written by %s\n",AuthorName);
  39.  
  40.   if(argc<2)
  41.     { printf("Usage: LOGOUT <driveletter>|ALL\n");
  42.       exit(0);
  43.     }
  44.  
  45.   regs.x.ax = 0xE209;
  46.   regs.x.dx = 0;
  47.   int86x(0x2F, ®s, ®s, &segregs);
  48.   if(regs.x.ax != 0x1DEA)
  49.     { printf("SECDEV.SYS not loaded\n");
  50.       exit(1);
  51.     }
  52.   nofdrivers=regs.x.dx;
  53.  
  54.   if(!strcmpi(argv[1],"ALL"))
  55.     { printf("Logging out all drives...\n");
  56.       regs.h.dl = 0xFF;              /* Select all drives */
  57.     } else
  58.     { Driveletter=toupper(*argv[1]);
  59.       for(i=0;i<nofdrivers && !DriveOK;i++)
  60.         { regs.x.ax = 0xE201;            /* Get information */
  61.           regs.x.dx = i;
  62.           int86x(0x2F, ®s, ®s, &segregs);
  63.  
  64.           DriveOK = ((Driveletter-'A') >= regs.h.dl) &&
  65.                     ((Driveletter-'A') < regs.h.dl+regs.h.al);
  66.         }
  67.       if(!DriveOK)
  68.         { printf("Drive %c: is not an encrypted drive\n",Driveletter);
  69.           exit(1);
  70.         }
  71.       printf("Logging out drive %c:\n",Driveletter);
  72.       regs.h.dl = Driveletter-'A';
  73.     }
  74.   regs.x.ax = 0xE203;               /* Log out */
  75.   int86x(0x2F, ®s, ®s, &segregs);
  76.   printf("Done\n");
  77. }
  78.  
  79.