home *** CD-ROM | disk | FTP | other *** search
/ CICA 1993 August / CICA.cdr / _bbs / maxtool / max.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-30  |  3.7 KB  |  141 lines

  1. /*
  2.   
  3.     Maximus CDROM Mount :
  4.   
  5.     Creates FILES.BBS files and CDAREAS.CTL from indexfile on 
  6.     CD-ROM from Walnut Creek CD-ROM.
  7.   
  8.     Usage :
  9.   
  10.     MAX <CD-ROMdrive> <Directory for FILES.BBS files>
  11.   
  12.     Example :
  13.   
  14.     MAX G: C:\MAX\CDAREAS
  15.   
  16. */
  17.  
  18.  
  19. #include <ctype.h>
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <string.h>
  23.  
  24. void 
  25. main(int argc, char **argv) {
  26.     FILE *dosindex;
  27.     FILE *areasfile;
  28.     FILE *filesbbsfile = NULL;
  29.  
  30.     char name[255];
  31.  
  32.     char indexfname[80];
  33.     char filesbbsname[80];
  34.     char dirname[80];
  35.     char areadesc[80];
  36.     char areaname[15];
  37.  
  38.     char buf[512];
  39.     char tmps[512];
  40.  
  41.     long totdirs = 0;
  42.  
  43.     char *p, *r;
  44.  
  45.     printf("╔═════════════════════════════════════════════════════════════════╕\n");
  46.     printf("║                                                                 │\n");
  47.     printf("║                   ««« Maximus CDROM Mount »»»                  │\n");
  48.     printf("║                                                                 │\n");
  49.     printf("║ Creates Files.Bbs files and Hcdareas.Ctl from indexfiles on the │\n");
  50.     printf("║ CD-ROM from Walnut Creek CD-ROM.                                │\n");
  51.     printf("║                                                                 │\n");
  52.     printf("║ (C) Copyright 1993 Koos van den Hout /                          │\n");
  53.     printf("║                            Van den Hout Creative Communications │\n");
  54.     printf("║ (C) copy right 1993 Walnut Creek CDROM                          │\n");
  55.     printf("║ This program is Freeware. Feel free to share the executable /   │\n");
  56.     printf("║ source with anyone. Read MaxHmnt.Doc for license.               │\n");
  57.     printf("║                                                                 │\n");
  58.     printf("╙─────────────────────────────────────────────────────────────────┘\n\n");
  59.  
  60.     if (argc < 3) {
  61.         printf("Usage :\n\n");
  62.         printf("MAX <CD-ROMdrive> <Directory for FILES.BBS files>\n\n");
  63.         printf("Example:\n");
  64.         printf("MAX G: C:\\MAX\\CDAREAS\n\n");
  65.         printf("Read MAXHMNT.DOC for more info.\n");
  66.         exit(1);
  67.     }
  68.     strupr(argv[1]);
  69.     strupr(argv[2]);
  70.  
  71.     strcpy(indexfname, argv[1]);
  72.     strcat(indexfname, "\\dirs.txt");
  73.  
  74.     if ((dosindex = fopen(indexfname, "rt")) == NULL) {
  75.         printf("Can't open index file %s\n", indexfname);
  76.         exit(1);
  77.     }
  78.     if ((areasfile = fopen("HCDAREAS.CTL", "wt")) == NULL) {
  79.         printf("Can't write area file\n");
  80.         exit(1);
  81.     }
  82.     
  83.     fprintf(areasfile, "% Areas file of Walnut Creek CDROM.\n");
  84.     fprintf(areasfile, "% Created by Max\n\n");
  85.     while (NULL != fgets(buf, 512, dosindex)) {
  86.  
  87.         buf[strlen(buf) - 1] = 0;
  88.  
  89.         if (0 == strlen(buf))
  90.             continue;
  91.         
  92.         if (0 == strncmp(buf, "---", 3))
  93.             break;
  94.  
  95.         p = strchr(buf, ' ');
  96.         r = strchr(buf, '\t');
  97.         if (r && r < p)
  98.             p = r;
  99.         *p = 0;
  100.         strcpy(dirname, buf);
  101.         *p = ' ';
  102.         while (isspace(*p))
  103.             ++p;
  104.  
  105.         /* p now at description */
  106.                 
  107.         ++totdirs;
  108.  
  109.         strcpy(areadesc, p);
  110.  
  111.         sprintf(areaname, "HC%03li", totdirs);
  112.         strupr(areaname);
  113.  
  114.         printf("[%03li] %s%s >> %s\n",
  115.                   totdirs, argv[1], dirname, areadesc);
  116.  
  117.         strcpy(filesbbsname, argv[2]);
  118.  
  119.         if (filesbbsname[strlen(filesbbsname) - 1] != '\\')
  120.             strcat(filesbbsname, "\\");
  121.         
  122.         sprintf(tmps, "HC%03li.BBS", totdirs);
  123.         strcat(filesbbsname, tmps);
  124.  
  125.         sprintf(buf, "copy %s\\files.bbs %s", dirname, filesbbsname);
  126.  
  127.         system(buf);
  128.  
  129.         fprintf(areasfile, "Area %s\n", areaname);
  130.         fprintf(areasfile, "        Access           Disgrace/S\n");
  131.         fprintf(areasfile, "        FileInfo         %s\n", areadesc);
  132.         fprintf(areasfile, "        Download         %s%s\n", argv[1], dirname);
  133.         fprintf(areasfile, "        FileList         %s\n", filesbbsname);
  134.         fprintf(areasfile, "End Area\n\n");
  135.     }
  136.  
  137.     fclose(filesbbsfile);
  138.     fclose(areasfile);
  139.     fclose(dosindex);
  140. }
  141.