home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / DMAKE38A.ZIP / IMACS.C < prev    next >
C/C++ Source or Header  |  1992-01-23  |  6KB  |  173 lines

  1. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/RCS/imacs.c,v 1.1 1992/01/24 03:29:55 dvadura Exp $
  2. -- SYNOPSIS -- define default internal macros.
  3. -- 
  4. -- DESCRIPTION
  5. --    This file adds to the internal macro tables the set of default
  6. --    internal macros, and for those that are accessible internally via
  7. --    variables creates these variables, and initializes them to point
  8. --    at the default values of these macros.
  9. --
  10. -- AUTHOR
  11. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  12. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  13. --
  14. -- COPYRIGHT
  15. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  16. -- 
  17. --      This program is free software; you can redistribute it and/or
  18. --      modify it under the terms of the GNU General Public License
  19. --      (version 1), as published by the Free Software Foundation, and
  20. --      found in the file 'LICENSE' included with this distribution.
  21. -- 
  22. --      This program is distributed in the hope that it will be useful,
  23. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  24. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  25. --      GNU General Public License for more details.
  26. -- 
  27. --      You should have received a copy of the GNU General Public License
  28. --      along with this program;  if not, write to the Free Software
  29. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  30. --
  31. -- LOG
  32. --     $Log: imacs.c,v $
  33.  * Revision 1.1  1992/01/24  03:29:55  dvadura
  34.  * dmake Version 3.8, Initial revision
  35.  *
  36. */
  37.  
  38. #include "extern.h"
  39.  
  40. static    void    _set_int_var ANSI((char *, char *, int, int *));
  41. static    void    _set_string_var ANSI((char *, char *, int, char **));
  42. static    void    _set_bit_var ANSI((char *, char *, int));
  43.  
  44. /*
  45. ** Arrange to parse the strings stored in Rules[]
  46. */
  47. PUBLIC void
  48. Make_rules()
  49. {
  50.    Parse(NIL(FILE));
  51. }
  52.  
  53.  
  54. #define M_FLAG   M_DEFAULT | M_EXPANDED
  55.  
  56. /*
  57. ** Add to the macro table all of the internal macro variables plus
  58. ** create secondary variables which will give access to their values
  59. ** easily, both when needed and when the macro value is modified.
  60. ** The latter is accomplished by providing a flag in the macro and a field
  61. ** which gives a pointer to the value if it is a char or string macro value
  62. ** and a mask representing the bit of the global flag register that is affected
  63. ** by this macro's value.
  64. */
  65. PUBLIC void
  66. Create_macro_vars()
  67. {
  68.    static char* switchar;
  69.    char   swchar[2];
  70.  
  71.    swchar[0] = Get_switch_char(), swchar[1] = '\0';
  72.    _set_string_var("SWITCHAR", swchar, M_PRECIOUS, &switchar);
  73.    _set_string_var("DIRSEPSTR", (*swchar=='/')?"\\":"/",M_PRECIOUS,&DirSepStr);
  74.    _set_string_var("DIRBRKSTR", DirBrkStr, M_PRECIOUS, &DirBrkStr);
  75.    swchar[0] = DEF_ESCAPE_CHAR, swchar[1] = '\0';
  76.    _set_string_var(".ESCAPE_PREFIX", swchar, M_FLAG, &Escape_char);
  77.  
  78.    _set_bit_var(".SILENT",   "", A_SILENT  );
  79.    _set_bit_var(".IGNORE",   "", A_IGNORE  );
  80.    _set_bit_var(".PRECIOUS", "", A_PRECIOUS);
  81.    _set_bit_var(".EPILOG",   "", A_EPILOG  );
  82.    _set_bit_var(".PROLOG",   "", A_PROLOG  );
  83.    _set_bit_var(".NOINFER",  "", A_NOINFER );
  84.    _set_bit_var(".SEQUENTIAL","",A_SEQ     );
  85.    _set_bit_var(".USESHELL", "", A_SHELL   );
  86.    _set_bit_var(".SWAP",     "", A_SWAP    );
  87.    _set_bit_var(".MKSARGS",  "", A_MKSARGS );
  88.  
  89.    Glob_attr = A_DEFAULT;        /* set all flags to NULL   */
  90.  
  91.    _set_string_var("SHELL",        "",  M_DEFAULT, &Shell       );
  92.    _set_string_var("SHELLFLAGS",   " ", M_DEFAULT, &Shell_flags );
  93.    _set_string_var("GROUPSHELL",   "",  M_DEFAULT, &GShell      );
  94.    _set_string_var("GROUPFLAGS",   " ", M_DEFAULT, &GShell_flags);
  95.    _set_string_var("SHELLMETAS",   "",  M_DEFAULT, &Shell_metas );
  96.    _set_string_var("GROUPSUFFIX",  "",  M_DEFAULT, &Grp_suff    );
  97.    _set_string_var("PREP",         "0", M_DEFAULT, &Prep        );
  98.    _set_string_var("AUGMAKE",NIL(char), M_DEFAULT, &Augmake     );
  99.    _set_string_var(".KEEP_STATE",  "",  M_DEFAULT, &Keep_state  );
  100.    _set_string_var(".NOTABS",      "",  M_MULTI,   &Notabs      );
  101.  
  102.    _set_string_var(".SETDIR", "", M_DEFAULT|M_NOEXPORT, &Start_dir );
  103.    _set_string_var("MAKEDIR",Get_current_dir(),M_PRECIOUS|M_NOEXPORT,&Makedir);
  104.    _set_string_var("PWD",  Makedir,  M_DEFAULT|M_NOEXPORT, &Pwd);
  105.    _set_string_var("TMD",  "",       M_DEFAULT|M_NOEXPORT, &Tmd);
  106.  
  107.    Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
  108.  
  109.    _set_int_var( "MAXLINELENGTH", "0", M_DEFAULT|M_NOEXPORT, &Buffer_size );
  110.    (void) Def_macro("MAXLINELENGTH", "0", M_FLAG | M_DEFAULT);
  111.  
  112.    /* set MAXPROCESSLIMIT high initially so that it allows MAXPROCESS to
  113.     * change from command line. */
  114.    _set_int_var( "MAXPROCESSLIMIT", "100", M_DEFAULT|M_NOEXPORT, &Max_proclmt );
  115.    _set_int_var( "MAXPROCESS", "1", M_DEFAULT|M_NOEXPORT, &Max_proc );
  116. }
  117.  
  118.  
  119. /*
  120. ** Define an integer variable value, and set up the macro.
  121. */
  122. static void
  123. _set_int_var(name, val, flag, var)
  124. char *name;
  125. char *val;
  126. int  flag;
  127. int  *var;
  128. {
  129.    HASHPTR hp;
  130.  
  131.    hp = Def_macro(name, val, M_FLAG | flag);
  132.    hp->ht_flag |= M_VAR_INT | M_MULTI;
  133.    hp->MV_IVAR  = var;
  134.    *var         = atoi(val);
  135. }
  136.  
  137.  
  138. /*
  139. ** Define a string variables value, and set up the macro.
  140. */
  141. static void
  142. _set_string_var(name, val, flag, var)
  143. char *name;
  144. char *val;
  145. int  flag;
  146. char **var;
  147. {
  148.    HASHPTR hp;
  149.  
  150.    hp = Def_macro(name, val, M_FLAG | flag);
  151.    hp->ht_flag |= M_VAR_STRING | M_MULTI;
  152.    hp->MV_SVAR  = var;
  153.    *var         = hp->ht_value;
  154. }
  155.  
  156.  
  157. /*
  158. ** Define a bit variable value, and set up the macro.
  159. */
  160. static void
  161. _set_bit_var(name, val, mask)
  162. char *name;
  163. char *val;
  164. int  mask;
  165. {
  166.    HASHPTR hp;
  167.  
  168.    hp           = Def_macro(name, val, M_FLAG);
  169.    hp->ht_flag |= M_VAR_BIT | M_MULTI;
  170.    hp->MV_MASK  = mask;
  171.    hp->MV_BVAR  = &Glob_attr;
  172. }
  173.