home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 110_01 / undelete.c < prev    next >
Text File  |  1984-03-03  |  2KB  |  85 lines

  1. /* MOVER.C v0.1 */
  2.  
  3. #include <undelete.h>
  4.  
  5.  
  6. main(argc,argv)
  7. int argc; char *argv[];
  8. {
  9.     int x; 
  10.     char foo[40], current, extent, diag, temp, orig, Unum, Debug;
  11.     char Moving;
  12.     if(argc < 2)
  13.     {
  14.         printf(
  15.          "\nUsage:undelete <filename> <filename>[-d][-U<num>][-M].....");
  16.         exit();
  17.     }
  18.  
  19.     Debug = Dump = Unum = 0;
  20.     for(x=1;x<argc;x++)
  21.         if(argv[x][0] == '-')
  22.         {
  23.             switch(toupper(argv[x][1])){
  24.             case 'D': Dump = 1;
  25.                 argv[x][0] = '\0'; /* remove entry */
  26.                 break;
  27.             case 'U': _mvx(argv[x]); 
  28.                 if(Debug) printf("\nString became '%s'",argv[x]);
  29.                 Unum = (atoi(argv[x]) & 0x1f);
  30.                 argv[x][0] = '\0';
  31.                 printf("\nRestoring to user #%d",Unum);
  32.                 break;
  33.             case 'M':Moving = 1;
  34.                 argv[x][0] = '\0';
  35.                 printf("\nUndeleted entries will be moved.");
  36.                 break;
  37.  
  38.             case 'X':argv[x][0] = '\0';
  39.                 Debug = 1;
  40.             }
  41.         }
  42.  
  43.  
  44.  
  45.     orig = bdos(0x19);
  46.     current = orig;
  47.     fillarray(current);
  48.     for(x=1;x<argc;x++)
  49.     {
  50.         if(argv[x][0] == '\0') continue; /* Skip null ones */
  51.         if(argv[x][1] == ':')
  52.         {
  53.             temp = toupper(argv[x][0]) - 'A';
  54.             if(temp != current)
  55.                 fillarray(current=temp);
  56.             _mvx(argv[x]);
  57.         }
  58.         else if(orig != current) fillarray(current=orig);
  59.  
  60.  
  61.         extent = 0;
  62.         do 
  63.         {
  64.             setfcb(foo,argv[x]);
  65.             foo[12] = extent++;
  66.             if((!(diag = findfcb(foo))) ||
  67.              ((marker.ptr->user != 0xe5) && !Moving))
  68.             {
  69.                 if(!diag)
  70.                     printf("\n%s not found in directory.",argv[x]);
  71.                 else
  72.                     printf("\n%s was not a deleted entry.",argv[x]);
  73.                 break;
  74.             }
  75.             sector[marker.sec].dir[marker.entry].user = Unum;
  76.             bios(SETDMA,sector[marker.sec].dir);
  77.             bios(SETTRK,DTRACK+(marker.sec / NSECS));
  78.             bios(SETSEC,translate(marker.sec % NSECS));
  79.             bios(DWRITE);
  80.         } while(marker.ptr->ext == 128);
  81.     }
  82. }
  83.  
  84.  
  85.  ent