home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / doc_net / simcvt_c.arc / SIMCVT.C < prev    next >
C/C++ Source or Header  |  1990-01-21  |  3KB  |  73 lines

  1. /******************************************************************************
  2.  
  3. Written by reynolds@sun.com                                     01/21/90
  4.  
  5. This SIMCVT.C filter should convert Simtel-20's "SIMIBM.IDX" file into a
  6. readable "SIMIBM.LST" that is compatible with the other convert programs,
  7. except for the run-date at the top of the output file.
  8.  
  9. This program, written in "C" should compile on both 4.3BSD Unix machines,
  10. as well as IBM/pc compatible machines.  It works on both VAXen, and Suns.
  11.  
  12. To Compile on Unix, type "cc SIMCVT.C", and this should create "a.out"
  13. To Compile on IBM/pcs, see your C manual that came with the compiler, and
  14. change the first "c = getchar()" statement depending upon the EOL character.
  15.  
  16. To run on Unix machines, type    "cat SIMIBM.IDX | a.out > SIMIBM.LST"
  17. To run on IBM/pcs machines, type "type SIMIBM.IDX | simcvt > SIMIBM.LST"
  18.  
  19. ******************************************************************************/
  20.  
  21. #include <stdio.h>
  22.  
  23. main()
  24.  
  25. {
  26. char  fs[10],dir[20],name[15],descr[60]; /* input variables */
  27. int   rev,bits;                          /* input variables */
  28. float length,date;                       /* input variables */
  29. char  lfs[10],ldir[20];                  /* stores last filesystem/directory */
  30. char  type;                              /* output variable for 'A' or 'B' */
  31. char  c;                                 /* picks off EOF,",linefeed */
  32.  
  33. printf("WSMR-SIMTEL20.ARMY.MIL PUBLIC DOMAIN LISTING\n\n");
  34. printf("NOTE: Type B is Binary; Type A is ASCII\n");
  35.  
  36. while (c != EOF)  {
  37.  
  38.    scanf("\"%[^\"]\",\"%[^\"]\",\"%[^\"]\",%i,%f,%i,%f,\"%[^\"]\"",
  39.             fs, dir, name, &rev, &length, &bits, &date, descr);
  40.  
  41.    /* c = getchar();  remove the linefeed - ONLY NEEDED IN UNIX */ 
  42.    c = getchar(); /* remove the ^M from the input line, and trap EOF */
  43.  
  44.    if (c != EOF) {
  45.  
  46.       type = 'B';                        /* Binary 8-bit */
  47.       if (bits == 7) type = 'A';         /* ASCII  7-bit */
  48.  
  49.       if (strcmp(ldir,dir) || strcmp(lfs,fs)) {  /* New Directory */
  50.          printf("\nDirectory %s%s\n",fs,dir);
  51.          printf(" Filename   Type Length   Date    Description\n");
  52.          printf("==============================================\n");
  53.          strcpy(ldir, dir);          /* Remember last directory with ldir  */
  54.          strcpy(lfs,fs);             /* Remember last file system with lfs */
  55.          }                           /* End of the New Directory routine   */
  56.  
  57.       strcat(name, "            ");  /* fill out the filename to 12 spaces */
  58.  
  59.       printf("%12.12s  %c %7.0f  %6.0f  %s\n",name,type,length,date,descr);
  60.       }
  61.    }
  62. } /* end of main() program by Ray */
  63.  
  64. /*****************************************************************************
  65.  
  66.    This filter takes data in the following format:
  67. "PD1:","<MSDOS.ADA>","ADA-LRM2.ARC",1,320086,8,890411,"The Ada Language Reference Manual reader (2/4)"
  68.  
  69.    And converts it to the following format:
  70. ADA-LRM1.ARC  B  231947  890411  The Ada Language Reference Manual reader (1/4)
  71.  
  72. *****************************************************************************/
  73.