home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / bbs / opus / to_opus.c < prev   
Encoding:
C/C++ Source or Header  |  1992-05-04  |  2.1 KB  |  126 lines

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