home *** CD-ROM | disk | FTP | other *** search
/ Oldies but Goodies / OldiesButGoodiesROMMANTechnologies1993.disc1of1.iso / adventur / advent0.c < prev    next >
Text File  |  1984-05-19  |  4KB  |  150 lines

  1.  
  2. /*    program ADVENT0.C                    *\
  3. \*    execution will read the four adventure text files    *\
  4. \*    files; "advent1.txt", "advent2.txt", "advent3.txt" &    *\
  5. \*    "advent4.txt".  it will create the file "advtext.h"    *\
  6. \*    which is an Index Sequential Access Method (ISAM)    *\
  7. \*    header to be #included into "advent.c" before the    *\
  8. \*    header "advdef.h" is #included.                */
  9.  
  10.  
  11. #include    "stdio.h"    /* drv = 1.1st file 2.def 3.A    */
  12. #include    "advent.h"
  13.  
  14. extern    int    fclose();
  15. extern    char    *fgets();
  16. extern    FILE    *fopen();
  17. extern    int    fprintf();
  18. extern    int    fputs();
  19. extern    long    ftell();
  20. extern    int    printf();
  21.  
  22.  
  23. main(argc, argv)
  24. int    argc;
  25. char    **argv;
  26. {
  27.  
  28.     FILE    *isam, *fd1, *fd2, *fd3, *fd4;
  29.     char    itxt[255], otxt[80], lstr[12];
  30.     int    cnt, llen;
  31.  
  32.     isam = fopen("advtext.h", "w");
  33.     if (!isam) {
  34.         printf("Sorry, I can't open advtext.h...\n");
  35.         exit();
  36.     }
  37.     fd1 = fopen("advent1.txt", "r");
  38.     if (!fd1) {
  39.         printf("Sorry, I can't open advent1.txt...\n");
  40.         exit();
  41.     }
  42.     fd2 = fopen("advent2.txt", "r");
  43.     if (!fd2) {
  44.         printf("Sorry, I can't open advent2.txt...\n");
  45.         exit();
  46.     }
  47.     fd3 = fopen("advent3.txt", "r");
  48.     if (!fd3) {
  49.         printf("Sorry, I can't open advent3.txt...\n");
  50.         exit();
  51.     }
  52.     fd4 = fopen("advent4.txt", "r");
  53.     if (!fd4) {
  54.         printf("Sorry, I can't open advent4.txt...\n");
  55.         exit();
  56.     }
  57.  
  58.     fprintf(isam, "\n/");
  59.     fprintf(isam, "*\theader: ADVTEXT.H\t\t\t\t\t*/\n\n\n");
  60.  
  61.  
  62.     cnt = -1;
  63.     lstr[0] = '\0';
  64.     fprintf(isam, "long\tidx1[MAXLOC] = {\n\t");
  65.     while (fgets(itxt, 255, fd1)) {
  66.         printf("%s", itxt);
  67.         if (itxt[0] == '#') {
  68.             if (lstr[0])
  69.                 fprintf(isam, "%s,", lstr);
  70.             llen = ltoa(ftell(fd1), lstr);
  71.             if (!llen) {
  72.                 printf("ltoa err in advent1.txt\n");
  73.                 exit();
  74.             }            /* if (!llen)    */
  75.             if (++cnt == 5) {
  76.                 fprintf(isam, "\n\t");
  77.                 cnt = 0;
  78.             }            /* if (cnt)    */
  79.         }                /* if (itxt[0])    */
  80.     }                    /* while fgets    */
  81.     fprintf(isam, "%s\n\t};\n\n", lstr);
  82.  
  83.     cnt = -1;
  84.     lstr[0] = '\0';
  85.     fprintf(isam, "long\tidx2[MAXLOC] = {\n\t");
  86.     while (fgets(itxt, 255, fd2)) {
  87.         printf("%s", itxt);
  88.         if (itxt[0] == '#') {
  89.             if (lstr[0])
  90.                 fprintf(isam, "%s,", lstr);
  91.             llen = ltoa(ftell(fd2), lstr);
  92.             if (!llen) {
  93.                 printf("ltoa err in advent2.txt\n");
  94.                 exit();
  95.             }            /* if (!llen)    */
  96.             if (++cnt == 5) {
  97.                 fprintf(isam, "\n\t");
  98.                 cnt = 0;
  99.             }            /* if (cnt)    */
  100.         }                /* if (itxt[0])    */
  101.     }                    /* while fgets    */
  102.     fprintf(isam, "%s\n\t};\n\n", lstr);
  103.  
  104.     cnt = -1;
  105.     lstr[0] = '\0';
  106.     fprintf(isam, "long\tidx3[MAXOBJ] = {\n\t");
  107.     while (fgets(itxt, 255, fd3)) {
  108.         printf("%s", itxt);
  109.         if (itxt[0] == '#') {
  110.             if (lstr[0])
  111.                 fprintf(isam, "%s,", lstr);
  112.             llen = ltoa(ftell(fd3), lstr);
  113.             if (!llen) {
  114.                 printf("ltoa err in advent3.txt\n");
  115.                 exit();
  116.             }            /* if (!llen)    */
  117.             if (++cnt == 5) {
  118.                 fprintf(isam, "\n\t");
  119.                 cnt = 0;
  120.             }            /* if (cnt)    */
  121.         }                /* if (itxt[0])    */
  122.     }                    /* while fgets    */
  123.     fprintf(isam, "%s\n\t};\n\n", lstr);
  124.  
  125.     cnt = -1;
  126.     lstr[0] = '\0';
  127.     fprintf(isam, "long\tidx4[MAXMSG] = {\n\t");
  128.     while (fgets(itxt, 255, fd4)) {
  129.         printf("%s", itxt);
  130.         if (itxt[0] == '#') {
  131.             if (lstr[0])
  132.                 fprintf(isam, "%s,", lstr);
  133.             llen = ltoa(ftell(fd4), lstr);
  134.             if (!llen) {
  135.                 printf("ltoa err in advent4.txt\n");
  136.                 exit();
  137.             }            /* if (!llen)    */
  138.             if (++cnt == 5) {
  139.                 fprintf(isam, "\n\t");
  140.                 cnt = 0;
  141.             }            /* if (cnt)    */
  142.         }                /* if (itxt[0])    */
  143.     }                    /* while fgets    */
  144.     fprintf(isam, "%s\n\t};\n\n", lstr);
  145.  
  146.  
  147. }                        /* main        */
  148.  
  149.  
  150.