home *** CD-ROM | disk | FTP | other *** search
/ The Best of Mecomp Multimedia 1 / Mecomp-CD.iso / amiga / tools / cd / indexcd / bin / sources.lha / sources / SetConfig.c < prev    next >
C/C++ Source or Header  |  1980-01-04  |  4KB  |  177 lines

  1.  
  2. char *Titolo = "$VER: SetConfig v1.1 (07-05-1996) © di Claudio Buraglio";
  3.  
  4. #include    <stdio.h>
  5. #include <string.h>
  6.  
  7. char destdir [80];    // Configuration data
  8. char clha    [80];
  9. char ctext   [80];
  10. char cpic    [80];
  11. char cmod    [80];
  12. char cdms    [80];
  13. char destdms [80];
  14. char csample [80];
  15.  
  16. char path[128];
  17. char line[128];
  18. char comm[128];
  19. char    buf[225];
  20.  
  21. char *ptr;
  22. FILE *fp;
  23.  
  24. char *Config    =    "S:EARSAN.configurazione";
  25.  
  26. main(int argc, char **argv)
  27. {
  28.     printf("\n%s\n\n",Titolo+6);
  29.     strcpy(line, argv[1]);
  30.     LoadConfiguration();
  31.  
  32.     if (strstr(line, "destdir") != 0)
  33.     {
  34.         strcpy(buf, destdir);
  35.         SplittaCampo();
  36.         sprintf(line, "c:RequestFile >T:File.temp TITLE \"Directory destinazione...\" %s\n", path);
  37.     }
  38.     if (strstr(line, "clha") != 0)
  39.     {
  40.         strcpy(buf, clha);
  41.         SplittaCampo();
  42.         sprintf(line, "c:RequestFile >T:File.temp TITLE \"Percorso comando LHA...\" DRAWER %s FILE %s\n", path, comm);
  43.         LoadSelected();
  44.         strcpy(clha, buf);
  45.     }
  46.     if (strstr(line, "ctext") != 0)
  47.     {
  48.         strcpy(buf, ctext);
  49.         SplittaCampo();
  50.         sprintf(line, "c:RequestFile >T:File.temp TITLE \"Visualizzatore di testi...\" DRAWER %s FILE %s\n", path, comm);
  51.     }
  52.     if (strstr(line, "cpic") != 0)
  53.     {
  54.         strcpy(buf, cpic);
  55.         SplittaCampo();
  56.         sprintf(line, "c:RequestFile >T:File.temp TITLE \"Visualizzatore grafica...\" DRAWER %s FILE %s\n", path, comm);
  57.     }
  58.     if (strstr(line, "cmod") != 0)
  59.     {
  60.         strcpy(buf, cmod);
  61.         SplittaCampo();
  62.         sprintf(line, "c:RequestFile >T:File.temp TITLE \"Player moduli audio...\" DRAWER %s FILE %s\n", path, comm);
  63.     }
  64.     if (strstr(line, "cdms") != 0)
  65.     {
  66.         strcpy(buf, cdms);
  67.         SplittaCampo();
  68.         sprintf(line, "c:RequestFile >T:File.temp TITLE \"Percorso e comando DMS...\" DRAWER %s FILE %s\n", path, comm);
  69.     }
  70.     if (strstr(line, "destdms") != 0)
  71.     {
  72.         strcpy(buf, destdir);
  73.         SplittaCampo();
  74.         sprintf(line, "c:RequestFile >T:File.temp TITLE \"Disco destinazione DMS...\" %s\n", path);
  75.     }
  76.  
  77.     system(line);
  78.  
  79.     return(0);
  80. }
  81.  
  82. SplittaCampo()
  83. {
  84.     strcpy(path, buf);
  85.     strcpy(comm, buf);
  86.     if((ptr = strrchr(path, '/')) != NULL || (ptr = strrchr(path, ':')) != NULL)
  87.     {
  88.         *ptr++;
  89.         strcpy(comm, ptr);
  90.         *ptr = 0;
  91.     }
  92. }
  93.  
  94. LoadSelected()
  95. {
  96.     if (fp = fopen("T:File.temp", "r"))
  97.     {
  98.         fgets(buf, sizeof(buf)-1, fp);
  99.         fclose(fp);
  100.     }
  101. }
  102.  
  103.  
  104. LoadConfiguration()
  105. {
  106.     char *coda;
  107.  
  108.     strcpy(destdir, "RAM:");
  109.     strcpy(   clha, "LHA");
  110.     strcpy(  ctext, "MultiView");
  111.     strcpy(   cpic, "VT");
  112.     strcpy(   cmod, "HIP");
  113.     strcpy(   cdms, "DMS");
  114.     strcpy(destdms, "DF0:");
  115.  
  116.     if (fp = fopen(Config, "r"))
  117.     {
  118.        while (fgets(buf, sizeof(buf)-1, fp))
  119.         {
  120.             if ((ptr = strstr(buf, "destdir=")) != NULL)
  121.             {
  122.                 ptr = strchr(buf, '=');
  123.                 ptr++;
  124.                 coda = stpcpy(destdir, ptr);
  125.                 *--coda = 0;
  126.             }
  127.             if ((ptr = strstr(buf, "lha=")) != NULL)
  128.             {
  129.                 ptr = strchr(buf, '=');
  130.                 ptr++;
  131.                 coda = stpcpy(clha, ptr);
  132.                 *--coda = 0;
  133.             }
  134.             if ((ptr = strstr(buf, "text=")) != NULL)
  135.             {
  136.                 ptr = strchr(buf, '=');
  137.                 ptr++;
  138.                 coda = stpcpy(ctext, ptr);
  139.                 *--coda = 0;
  140.             }
  141.             if ((ptr = strstr(buf, "pic=")) != NULL)
  142.             {
  143.                 ptr = strchr(buf, '=');
  144.                 ptr++;
  145.                 coda = stpcpy(cpic, ptr);
  146.                 *--coda = 0;
  147.             }
  148.             if ((ptr = strstr(buf, "mod=")) != NULL)
  149.             {
  150.                 ptr = strchr(buf, '=');
  151.                 ptr++;
  152.                 coda = stpcpy(cmod, ptr);
  153.                 *--coda = 0;
  154.             }
  155.             if ((ptr = strstr(buf, "sample=")) != NULL)
  156.             {
  157.                 ptr = strchr(buf, '=');
  158.                 ptr++;
  159.                 coda = stpcpy(csample, ptr);
  160.                 *--coda = 0;
  161.             }
  162.         }
  163.         fclose(fp);
  164.  
  165.         int i = 0;                    // cmod in Uppercase
  166.         while (cmod[i] != 0)
  167.         {
  168.             if ((cmod[i] >= 0x61 && path[i] <= 0x7A) != NULL )
  169.             {
  170.                 cmod[i] = toupper(cmod[i]);
  171.             }
  172.             i++;
  173.         }
  174.     }
  175. }
  176.  
  177.