home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dmake40.zip / imacs.c < prev    next >
C/C++ Source or Header  |  1994-10-23  |  6KB  |  179 lines

  1. /* RCS      -- $Header: /u5/dvadura/src/public/dmake/src/RCS/imacs.c,v 1.1 1994/10/06 17:42:40 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) 1992,1994 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  1994/10/06  17:42:40  dvadura
  34.  * dmake Release Version 4.0, 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.    char   buf[20];
  71.  
  72.    swchar[0] = Get_switch_char(), swchar[1] = '\0';
  73.    _set_string_var("SWITCHAR", swchar, M_PRECIOUS, &switchar);
  74.    _set_string_var("DIRSEPSTR", (*swchar=='/')?"\\":"/",M_DEFAULT,&DirSepStr);
  75.    _set_string_var("DIRBRKSTR", DirBrkStr, M_DEFAULT, &DirBrkStr);
  76.    swchar[0] = DEF_ESCAPE_CHAR, swchar[1] = '\0';
  77.    _set_string_var(".ESCAPE_PREFIX", swchar, M_FLAG, &Escape_char);
  78.  
  79.    _set_bit_var(".SILENT",   "", A_SILENT  );
  80.    _set_bit_var(".IGNORE",   "", A_IGNORE  );
  81.    _set_bit_var(".PRECIOUS", "", A_PRECIOUS);
  82.    _set_bit_var(".EPILOG",   "", A_EPILOG  );
  83.    _set_bit_var(".PROLOG",   "", A_PROLOG  );
  84.    _set_bit_var(".NOINFER",  "", A_NOINFER );
  85.    _set_bit_var(".SEQUENTIAL","",A_SEQ     );
  86.    _set_bit_var(".USESHELL", "", A_SHELL   );
  87.    _set_bit_var(".SWAP",     "", A_SWAP    );
  88.    _set_bit_var(".MKSARGS",  "", A_MKSARGS );
  89.    _set_bit_var(".IGNOREGROUP","",A_IGNOREGROUP);
  90.  
  91.    Glob_attr = A_DEFAULT;        /* set all flags to NULL   */
  92.  
  93.    _set_string_var("SHELL",        "",  M_DEFAULT, &Shell       );
  94.    _set_string_var("SHELLFLAGS",   " ", M_DEFAULT, &Shell_flags );
  95.    _set_string_var("GROUPSHELL",   "",  M_DEFAULT, &GShell      );
  96.    _set_string_var("GROUPFLAGS",   " ", M_DEFAULT, &GShell_flags);
  97.    _set_string_var("SHELLMETAS",   "",  M_DEFAULT, &Shell_metas );
  98.    _set_string_var("GROUPSUFFIX",  "",  M_DEFAULT, &Grp_suff    );
  99.    _set_string_var("AUGMAKE",NIL(char), M_DEFAULT, &Augmake     );
  100.    _set_string_var(".KEEP_STATE",  "",  M_DEFAULT, &Keep_state  );
  101.    _set_string_var(".NOTABS",      "",  M_MULTI,   &Notabs      );
  102.    _set_string_var(".DIRCACHE",    "y", M_DEFAULT, &UseDirCache );
  103.  
  104.    _set_string_var("MAKEDIR",Get_current_dir(),M_PRECIOUS|M_NOEXPORT,&Makedir);
  105.    _set_string_var("PWD",  Makedir,  M_DEFAULT|M_NOEXPORT, &Pwd);
  106.    _set_string_var("TMD",  "",       M_DEFAULT|M_NOEXPORT, &Tmd);
  107.  
  108.    Def_macro("NULL", "", M_PRECIOUS|M_NOEXPORT|M_FLAG);
  109.  
  110.    _set_int_var( "MAXLINELENGTH", "0", M_DEFAULT|M_NOEXPORT, &Buffer_size );
  111.    _set_int_var( "PREP",          "0", M_DEFAULT, &Prep );
  112.    (void) Def_macro("MAXLINELENGTH", "1024", M_FLAG | M_DEFAULT);
  113.  
  114.    /* set MAXPROCESSLIMIT high initially so that it allows MAXPROCESS to
  115.     * change from command line. */
  116.    _set_int_var( "MAXPROCESSLIMIT", "100", M_DEFAULT|M_NOEXPORT,&Max_proclmt );
  117.    _set_int_var( "MAXPROCESS", "1", M_DEFAULT|M_NOEXPORT, &Max_proc );
  118.    _set_int_var( "DYNAMICNESTINGLEVEL", "100", M_DEFAULT|M_NOEXPORT,
  119.          &DynamicNestLevel);
  120.    sprintf(buf,"%d",NAME_MAX);
  121.    _set_int_var( "NAMEMAX", buf, M_DEFAULT|M_NOEXPORT, &NameMax);
  122. }
  123.  
  124.  
  125. /*
  126. ** Define an integer variable value, and set up the macro.
  127. */
  128. static void
  129. _set_int_var(name, val, flag, var)
  130. char *name;
  131. char *val;
  132. int  flag;
  133. int  *var;
  134. {
  135.    HASHPTR hp;
  136.  
  137.    hp = Def_macro(name, val, M_FLAG | flag);
  138.    hp->ht_flag |= M_VAR_INT | M_MULTI;
  139.    hp->MV_IVAR  = var;
  140.    *var         = atoi(val);
  141. }
  142.  
  143.  
  144. /*
  145. ** Define a string variables value, and set up the macro.
  146. */
  147. static void
  148. _set_string_var(name, val, flag, var)
  149. char *name;
  150. char *val;
  151. int  flag;
  152. char **var;
  153. {
  154.    HASHPTR hp;
  155.  
  156.    hp = Def_macro(name, val, M_FLAG | flag);
  157.    hp->ht_flag |= M_VAR_STRING | M_MULTI;
  158.    hp->MV_SVAR  = var;
  159.    *var         = hp->ht_value;
  160. }
  161.  
  162.  
  163. /*
  164. ** Define a bit variable value, and set up the macro.
  165. */
  166. static void
  167. _set_bit_var(name, val, mask)
  168. char *name;
  169. char *val;
  170. int  mask;
  171. {
  172.    HASHPTR hp;
  173.  
  174.    hp           = Def_macro(name, val, M_FLAG);
  175.    hp->ht_flag |= M_VAR_BIT | M_MULTI;
  176.    hp->MV_MASK  = mask;
  177.    hp->MV_BVAR  = &Glob_attr;
  178. }
  179.