home *** CD-ROM | disk | FTP | other *** search
/ CICA 1992 July / Cica_July92.cdr / bbs / opus / to_max.c < prev   
C/C++ Source or Header  |  1992-06-29  |  3KB  |  146 lines

  1. /*
  2.  * from simtel20 and CICA format to:
  3.  * Remote Access / Maximus / TubFile / Opus / QuickBbs / SuperBbs
  4.  */
  5.  
  6. #if 0
  7. 1234567890123456789012345678901 [Simtel]
  8. 4DOSANN.ZIP   B    6864  910819  4DOS runs on DOS 5.0 and Norton DOS info
  9. 1234567890123456789012345678901 [CICA]
  10. diskindx.txt    901031    Cumulative Index of the WRK Disks (below)
  11. diskroot.zip    920610    Windows Resource Kit 4/3/92
  12. ---------->
  13. AD-FEBBS.ZIP Great Demo for Febbs made by OUNO-Soft.
  14. #endif
  15.  
  16. #include <ctype.h>
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20.  
  21. #define CICA
  22.  
  23. struct data {
  24.     char filename[15];
  25.     long filesize;
  26.     int year;
  27.     int month;
  28.     int day;
  29.     char description[900];
  30. };
  31.  
  32. int pastheader = 0;
  33. struct data line;
  34.  
  35. void
  36. readline(void) {
  37.     char buf[1000];
  38.     char workbuf[1000];
  39.     static char datebuf[5] = "12";
  40.     char *r;
  41.     
  42.     if (NULL == gets(buf))
  43.         exit(0);
  44.     
  45.     /* wait for header */
  46.     if (! pastheader) {
  47. #ifdef CICA        
  48.         if (0 == strlen(buf))
  49.             ++pastheader;
  50. #else        
  51.         if (strstr(buf, "================"))
  52.             ++pastheader;
  53. #endif        
  54.         return;
  55.     }
  56.     
  57.     line.filename[0] = 0;
  58.     line.description[0] = 0;
  59.     
  60.     if (strlen(buf) == 0) {
  61.         fprintf(stderr, "zero length line\n");
  62.         return;
  63.     }
  64.     
  65.     if (strlen(buf) < 31) {
  66.         fprintf(stderr, "warning: line too short:\n%s\n", buf);
  67.     }
  68.     
  69.     strcpy(workbuf, buf);
  70.     
  71.     r = strtok(buf, "\r\n\t ");
  72.     if (! r) {
  73.         fprintf(stderr, "unknown line:\n%s\n", buf);
  74.         return;
  75.     }
  76.     strcpy(line.filename, r);
  77.     
  78.     r += strlen(r) + 1;        /* skip name */
  79.     while (isspace(*r))        /* skip white */
  80.         ++r;
  81.     
  82. #ifndef CICA    
  83.     ++r;                    /* skip file type */
  84.     
  85.     while (isspace(*r))        /* skip white */
  86.         ++r;
  87.     
  88.     r = strtok(r, "\r\n\t ");
  89.     if (! r) {
  90.         fprintf(stderr, "unknown line:\n%s\n", buf);
  91.         line.filename[0] = 0;
  92.         return;
  93.     }
  94.     line.filesize = atol(r);
  95.     r += strlen(r) + 1;
  96.     
  97.     while (isspace(*r))        /* skip white */
  98.         ++r;
  99. #endif    
  100.     
  101.     datebuf[0] = *r;
  102.     ++r;
  103.     datebuf[1] = *r;
  104.     ++r;
  105.     line.year = atoi(datebuf);
  106.     
  107.     datebuf[0] = *r;
  108.     ++r;
  109.     datebuf[1] = *r;
  110.     ++r;
  111.     line.month = atoi(datebuf);
  112.     datebuf[0] = *r;
  113.     ++r;
  114.     datebuf[1] = *r;
  115.     ++r;
  116.     line.day = atoi(datebuf);
  117.     
  118.     while (isspace(*r))        /* skip white */
  119.         ++r;
  120.     
  121.     if (*r)    
  122.         strcpy(line.description, r);
  123. }
  124.  
  125. void
  126. writeline(void) {
  127.  
  128.     if (! line.filename[0])
  129.         return;
  130.  
  131. #if 0    
  132. 9600TEXT.ZIP  A pair of US Robotics text files about HST modems.
  133. #endif
  134.  
  135.     printf("%s %s\n", line.filename, line.description);
  136. }
  137.  
  138. void _Cdecl
  139. main(void) {
  140.     
  141.     while (1) {
  142.         readline();
  143.         writeline();
  144.     }
  145. }
  146.