home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / C-FDC / RECOV.C < prev    next >
Text File  |  1986-05-06  |  1KB  |  50 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <dos.h>
  4. #include "fdc.h"
  5.  
  6. int main()
  7. {
  8.  
  9.     int i, j, k, drive, head, track, start_sect, max_sect, type;
  10.     int zflag;
  11.     char buf[BUFSIZ * 9 + 1];
  12.     char buf1[BUFSIZ * 9 + 1];
  13.     FILE *fp;
  14.  
  15.  
  16.     if((fp = fopen("recov.dat", "wb")) == (FILE *)NULL) {
  17.         fprintf(stderr, "Can't open the output file!\n");
  18.         exit(1);
  19.     }
  20.     drive = 0;                /* set drive to A */
  21.     type = 2;                /* set 320/360K disk in 1.2 M drive */
  22.     start_sect = 1;
  23.     max_sect = 9;
  24.     if(setdasd(drive, type)) {
  25.         fprintf(stderr, "Can't set the dasd for drive A!\n");
  26.         fclose(fp);
  27.         exit(1);
  28.     }
  29.     
  30.     for(track = 0; track < 40; track++) 
  31.         for(head = 0; head < 2; head++)
  32.             for(i = 0; i < 3; i++) {
  33.                 if(rdtrack(drive, head, track, start_sect, max_sect, buf) == 0) {
  34.                     for(j = 0, k = 0; j < BUFSIZ * 9; ++j) 
  35.                         if(buf[j] != 0xf6 && buf[j] != 0x1a && buf[j]) 
  36.                             buf1[k++] = buf[j];
  37.                     fwrite(buf1, sizeof(char), k, fp);
  38.                     break;
  39.                 } else {
  40.                     fprintf(stderr, "failure %d on head %d, track %d\n", i, head,
  41.                     track);
  42.                 }
  43.             }
  44.     fclose(fp);
  45.     printf("done\n");
  46.     exit(0);
  47.  
  48. }
  49.                     
  50.