home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / a-kwic / examples / fishrec.c < prev    next >
C/C++ Source or Header  |  1994-01-26  |  1KB  |  61 lines

  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5.  
  6. /*
  7.  * fishrec.c - Reads "fishcon" formatted fish disk contents reports, and
  8.  * produces input for loaddb.
  9.  */
  10.  
  11. static char RCS_ID[] =
  12. {
  13.     " $Id: fishrec.c,v 2.2 1994/01/15 11:15:58 D_Lowrey Exp $ "};
  14.  
  15. int disk_num;
  16. char line[90], *line_ptr, title[90];
  17.  
  18. main()
  19. {
  20.  
  21.     disk_num = 0;
  22.  
  23.     while (gets(line) != NULL)
  24.     {
  25. /*
  26.  * Throw away any leading title pages
  27.  */
  28.         if (!strncmp(line, "======", 6))
  29.             continue;
  30.  
  31.         if (!strncmp(line, "Below is a listing", 18))
  32.             continue;
  33.  
  34.         if (!strncmp(line, "PAGE ", 5))
  35.             continue;
  36.  
  37.         if (line[0] == NULL)
  38.             continue;
  39.  
  40.         if (isalnum(line[0]))
  41.         {
  42.             if (!strncmp(line, "This is disk ", 13))
  43.             {
  44.                 disk_num = atoi(&line[13]);
  45.                 continue;
  46.             }
  47.             else
  48.             {
  49.                 sscanf(line, "%s", title);
  50.                 printf("#R\n");
  51.                 printf("#H %s (Disk %03d)\n", title, disk_num);
  52.                 printf("#K disk/%03d\n", disk_num);
  53.                 printf("#K pgm/%s\n", title);
  54.                 printf("%s\n", line);
  55.             }
  56.         }
  57.         else
  58.             printf("%s\n", line);
  59.     }
  60. }
  61.