home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MAKEMAKE.ZIP / MAK_CFG.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-02-21  |  2.1 KB  |  83 lines

  1. /*
  2.     mak_cfg.c --     get configuration information
  3.                         for the makemak program
  4. */
  5.  
  6. /*    Last revised : Sun February 21, 1988 at 1:14:57 pm*/
  7. /* Loran W. Richardson */
  8.  
  9. #include    <stdio.h>
  10. #include    <stdlib.h>
  11. #include    <string.h>
  12. #include    "makemak.h"
  13.  
  14. char defaults[LIBS + 1][SLEN];
  15. char mak_defs[LIBS + 1][FNAMELEN];
  16.  
  17. int mak_cfg(char *pname)
  18. {
  19.     char line[SLEN];
  20.     char temp[SLEN];
  21.     char path[_MAX_PATH];
  22.     char *s;
  23.     FILE *fp;
  24.     FLAGS i;
  25.  
  26. /* set up header strings */
  27.     strcpy(mak_defs[TARGET], "target");
  28.     strcpy(mak_defs[CC], "cc");
  29.     strcpy(mak_defs[C_OPTS], "c_opts");
  30.     strcpy(mak_defs[CDEFS] ,"cdefs");
  31.     strcpy(mak_defs[MC], "mc");
  32.     strcpy(mak_defs[M_OPTS], "m_opts");
  33.     strcpy(mak_defs[MDEFS], "mdefs");
  34.     strcpy(mak_defs[LINK], "link");
  35.     strcpy(mak_defs[L_OPTS], "l_opts");
  36.     strcpy(mak_defs[LMAP], "lmap");
  37.     strcpy(mak_defs[LIBS], "libs");
  38.  
  39. /* set up the defaults */
  40.  
  41.     strcpy(defaults[CC],    "cl");
  42.     strcpy(defaults[C_OPTS], "/Zi /Od /c");
  43.     strcpy(defaults[CDEFS],    "");
  44.     strcpy(defaults[MC],    "masm");
  45.     strcpy(defaults[M_OPTS], "/Zi");
  46.     strcpy(defaults[MDEFS],    "");
  47.     strcpy(defaults[LINK], "link");
  48.     strcpy(defaults[L_OPTS], "/CO");
  49.     strcpy(defaults[LMAP], "NUL");
  50.     strcpy(defaults[LIBS], "");
  51.  
  52.  
  53.  
  54.  
  55. /* get the environment settings */
  56.     if ((s = getenv("CL")) != NULL)
  57.         strcpy(defaults[C_OPTS], s);
  58.  
  59.     if ((s = getenv("MASM")) != NULL)
  60.         strcpy(defaults[M_OPTS], s);
  61.  
  62.     if ((s = getenv("LINK")) != NULL)
  63.         strcpy(defaults[L_OPTS], s);
  64.  
  65. /* get the configuration file values */
  66.     _searchenv("makemak.cfg", "CONFIG", path);    /* find the configuration file */
  67.     if (path[0] != '\0')
  68.         if ((fp = fopen(path, "r")) != NULL)
  69.             while ((s = fgets(line, SLEN, fp)) != NULL) /* read in a line */
  70.                 {
  71.                 strcpy(temp, strtok(line, " \t\n="));    /* get the first word */
  72.                 for (i = CC; i <= LIBS; ++i)    /* loop through the options */
  73.                     if (strcmpi(temp, mak_defs[i]) == 0) /* word matches option ? */
  74.                         {
  75.                         strcpy(defaults[i], strtok(NULL, "\n")); /* copy the rest of the line */
  76.                         if (defaults[i][0] == '=')                      /* into the defaults */
  77.                             strcpy(defaults[i], (defaults[i]) + 1);
  78.                         break;
  79.                         }
  80.                 }
  81.     return(0);
  82. }
  83.