Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
6.6 KiB

  1. // globals.c - global variables/needed across modules
  2. //
  3. // Copyright (c) 1988-1990, Microsoft Corporation. All rights reserved.
  4. //
  5. // Purpose:
  6. // This is the routine in which global variables reside.
  7. //
  8. // HackAlert:
  9. // The functionality explained in the Notes below work only because of the way
  10. // Microsoft Compiler's upto C6.0A allocate initialized data ... in the order
  11. // in which it is specified. All variables between startOfSave and endOfSave
  12. // have to be initialized. According to ChuckG this functionality is not
  13. // guaranteed in C7.0 and so these should be moved to a struct.
  14. //
  15. // Notes:
  16. // This module was created for an interesting reason. NMAKE handles recursive
  17. // calls by saving its global variables somewhere in memory. It handles this by
  18. // allocating all global variables which have value changes in each recursive
  19. // in adjacent memory. The routine called recursively is doMake() and before it
  20. // is called the address of this chunk of memory is stored. When the recursive
  21. // call returns the memory is restored using the stored address. startOfSave and
  22. // endOfSave give the location of this chunk. The reason this method was opted
  23. // for is that spawning of NMAKE would consume a lot of memory under DOS. This
  24. // might not be very efficient under OS/2 because the code gets shared.
  25. //
  26. // Revision History:
  27. // 15-Nov-1993 JR Major speed improvements
  28. // 04-Apr-1990 SB Add fHeapChk
  29. // 01-Dec-1989 SB Made some variables near and pushed some into saveArea
  30. // 19-Oct-1989 SB variable fOptionK added (ifdef SLASHK)
  31. // 02-Oct-1989 SB add dynamic inline file handling support
  32. // 18-May-1989 SB Support of H and NOLOGO in MAKEFLAGS
  33. // 24-Apr-1989 SB Added ext_size, filename_size, filenameext_size &
  34. // resultbuf_size for OS/2 1.2 support
  35. // 05-Apr-1989 SB made revList, delList, scriptFileList NEAR
  36. // 22-Mar-1989 SB removed tmpFileStack and related variables
  37. // 16-Feb-1989 SB added delList to have scriptfile deletes at end of make
  38. // 21-Dec-1988 SB Added scriptFileList to handle multiple script files
  39. // removed tmpScriptFile and fKeep (not reqd anymore)
  40. // 19-Dec-1988 SB Added fKeep to handle KEEP/NOKEEP
  41. // 14-Dec-1988 SB Added tmpScriptFile to handle 'z' option
  42. // 30-Nov-1988 SB Added revList to handle 'z' option
  43. // 23-Nov-1988 SB Added CmdLine[] to handle extmake syntax
  44. // made pCmdLineCopy Global in build.c
  45. // 21-Oct-1988 SB Added fInheritUserEnv to inherit macros
  46. // 15-Sep-1988 RB Move some def's here for completeness.
  47. // 17-Aug-1988 RB Declare everything near.
  48. // 06-Jul-1988 rj Ditched shell and argVector globals.
  49. #include "precomp.h"
  50. #pragma hdrstop
  51. #if defined(STATISTICS)
  52. unsigned long CntfindMacro;
  53. unsigned long CntmacroChains;
  54. unsigned long CntinsertMacro;
  55. unsigned long CntfindTarget;
  56. unsigned long CnttargetChains;
  57. unsigned long CntStriCmp;
  58. unsigned long CntunQuotes;
  59. unsigned long CntFreeStrList;
  60. unsigned long CntAllocStrList;
  61. #endif
  62. BOOL fOptionK; // TRUE if user specifies /K
  63. BOOL fDescRebuildOrder; // TRUE if user specifies /O
  64. BOOL fSlashKStatus = TRUE; // no error when slash K specified
  65. // Used by action.c & nmake.c
  66. //
  67. // Required to make NMAKE inherit user modified changes to the environment. To
  68. // be set to true before defineMacro() is called so that user defined changes
  69. // in environment variables are reflected in the environment. If set to false
  70. // then these changes are made only in NMAKE tables and the environment remains
  71. // unchanged
  72. BOOL fInheritUserEnv;
  73. BOOL fRebuildOnTie; // TRUE if /b specified, Rebuild on tie
  74. // Used by action.c and nmake.c
  75. //
  76. // delList is the list of delete commands for deleting inline files which are
  77. // not required anymore (have a NOKEEP action specified.
  78. STRINGLIST * delList;
  79. // Complete list of generated inline files. Required to avoid duplicate names
  80. // NOTNEEDED
  81. STRINGLIST * inlineFileList;
  82. // from NMAKE.C
  83. // No of blanks is same as no of Allowed options in NMAKE; currently 14
  84. // L = nologo, H = help
  85. // corr to ABCDEHIKLNPQRSTUY?
  86. char makeflags[] = "MAKEFLAGS= ";
  87. BOOL firstToken; // to initialize parser
  88. BOOL bannerDisplayed;
  89. UCHAR flags; // holds -d -s -n -i -u
  90. UCHAR gFlags; // "global" -- all targets
  91. FILE * file;
  92. STRINGLIST * makeTargets; // list of targets to make
  93. STRINGLIST * makeFiles; // user can specify > 1
  94. BOOL fDebug;
  95. MACRODEF * pMacros;
  96. STRINGLIST * pValues;
  97. // from LEXER.C
  98. BOOL colZero = TRUE; // global flag set if at column zero of a makefile/tools.ini
  99. unsigned line;
  100. char * fName;
  101. char * string;
  102. INCLUDEINFO incStack[MAXINCLUDE]; //Assume this is initialized to null
  103. int incTop;
  104. // Inline file list -- Gets created in lexer.c and is used by action.c to
  105. // produce a delete command when 'NOKEEP' or Z option is set
  106. //
  107. SCRIPTLIST * scriptFileList;
  108. // from PARSER.C
  109. BOOL init; // global boolean value to indicate if tools.ini is being parsed
  110. UCHAR stack[STACKSIZE];
  111. int top = -1; // gets pre-incremented before use
  112. unsigned currentLine; // used for all error messages
  113. // from ACTION.C
  114. MACRODEF * macroTable[MAXMACRO];
  115. MAKEOBJECT * targetTable[MAXTARGET];
  116. STRINGLIST * macros;
  117. STRINGLIST * dotSuffixList;
  118. STRINGLIST * dotPreciousList;
  119. RULELIST * rules;
  120. STRINGLIST * list;
  121. char * name;
  122. BUILDBLOCK * block;
  123. UCHAR currentFlags;
  124. UCHAR actionFlags;
  125. // from BUILD.C
  126. unsigned errorLevel;
  127. unsigned numCommands;
  128. char * shellName;
  129. char * pCmdLineCopy;
  130. char CmdLine[MAXCMDLINELENGTH];
  131. // from IFEXPR.C
  132. UCHAR ifStack[IFSTACKSIZE];
  133. int ifTop = -1; // pre-incremented
  134. char * lbufPtr; // ptr to alloced buf
  135. char * prevDirPtr; // ptr to directive
  136. unsigned lbufSize; // initial size
  137. int chBuf = -1;
  138. // from UTIL.C
  139. char * dollarDollarAt;
  140. char * dollarLessThan;
  141. char * dollarStar;
  142. char * dollarAt;
  143. STRINGLIST * dollarQuestion;
  144. STRINGLIST * dollarStarStar;
  145. // from parser.c
  146. char buf[MAXBUF];
  147. // from action.c
  148. const char suffixes[] = ".SUFFIXES";
  149. const char ignore[] = ".IGNORE";
  150. const char silent[] = ".SILENT";
  151. const char precious[] = ".PRECIOUS";