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.

140 lines
4.5 KiB

  1. /******************************************************************************
  2. Source File: Parser.C
  3. This is an NT Build hack. It includes all of the "C" files used for the
  4. GPD parser, because Build can't handle directories beyond ..
  5. This file also contains some of the code used to access parts of the parser.
  6. It is put here so that there will be no need to grovel around to find the
  7. appropriate include files needed to call the parser.
  8. Copyright (c) 1997 by Microsoft Corporation. All Rights Reserved
  9. A Pretty Penny Enterprises Production
  10. Change History:
  11. 06-20-1997 Bob_Kjelgaard@Prodigy.Net Did the dirty deed
  12. 07-18-1998 ekevans@acsgroup.com Added first parser access routines
  13. ******************************************************************************/
  14. #define UNICODE
  15. #define _UNICODE
  16. #undef WINVER // Undo the MFC weirdness
  17. #define WINVER 0x0500
  18. #define _DEBUG_H_
  19. #include "lib.h"
  20. extern void _cdecl DebugPrint(PCSTR, ...);
  21. #define ERR(x) DebugPrint x
  22. #define WARNING(x) DebugPrint x
  23. #define VERBOSE(x)
  24. #define ASSERT(x)
  25. #define RIP(x)
  26. // Parser files
  27. #if defined(WIN32)
  28. #include "..\..\..\parsers\gpd\preproc1.c"
  29. #include "..\..\..\parsers\gpd\command.c"
  30. #include "..\..\..\parsers\gpd\constrnt.c"
  31. #include "..\..\..\parsers\gpd\helper1.c"
  32. #include "..\..\..\parsers\gpd\installb.c"
  33. #include "..\..\..\parsers\gpd\macros1.c"
  34. #include "..\..\..\parsers\gpd\postproc.c"
  35. #include "..\..\..\parsers\gpd\semanchk.c"
  36. #include "..\..\..\parsers\gpd\shortcut.c"
  37. #include "..\..\..\parsers\gpd\snapshot.c"
  38. #include "..\..\..\parsers\gpd\snaptbl.c"
  39. #include "..\..\..\parsers\gpd\state1.c"
  40. #include "..\..\..\parsers\gpd\state2.c"
  41. #include "..\..\..\parsers\gpd\token1.c"
  42. #include "..\..\..\parsers\gpd\value1.c"
  43. #include "..\..\..\parsers\gpd\treewalk.c"
  44. #include "..\..\..\parsers\gpd\framwrk1.c"
  45. #else
  46. #include "..\..\parsers\gpd\preproc1.c"
  47. #include "..\..\parsers\gpd\command.c"
  48. #include "..\..\parsers\gpd\constrnt.c"
  49. #include "..\..\parsers\gpd\helper1.c"
  50. #include "..\..\parsers\gpd\installb.c"
  51. #include "..\..\parsers\gpd\macros1.c"
  52. #include "..\..\parsers\gpd\postproc.c"
  53. #include "..\..\parsers\gpd\semanchk.c"
  54. #include "..\..\parsers\gpd\shortcut.c"
  55. #include "..\..\parsers\gpd\snapshot.c"
  56. #include "..\..\parsers\gpd\snaptbl.c"
  57. #include "..\..\parsers\gpd\state1.c"
  58. #include "..\..\parsers\gpd\state2.c"
  59. #include "..\..\parsers\gpd\token1.c"
  60. #include "..\..\parsers\gpd\value1.c"
  61. #include "..\..\parsers\gpd\treewalk.c"
  62. #include "..\..\parsers\gpd\framwrk1.c"
  63. #endif
  64. BOOL bKeywordInitDone = FALSE ; // TRUE iff the keyword table has been initialized
  65. int nKeywordTableSize = -1 ; // The number of valid entries in the keyword table
  66. /******************************************************************************
  67. InitGPDKeywordTable()
  68. Call the part of the GPD parser that is needed to initialize the GPD keyword
  69. table. This must be done before GPD keyword string pointers can be returned
  70. by GetGPDKeywordStr().
  71. If all goes well, a flag is set, the size of the table is saved, and the size
  72. of the table is returned. If something fails, return -1.
  73. ******************************************************************************/
  74. int InitGPDKeywordTable(PGLOBL pglobl)
  75. {
  76. PRANGE prng ; // Used to reference the table section ranges
  77. // Initialize the GPD parser
  78. VinitGlobals(0, pglobl) ;
  79. if (!BpreAllocateObjects(pglobl) || !BinitPreAllocatedObjects(pglobl))
  80. return -1 ;
  81. bKeywordInitDone = TRUE ;
  82. // Save the size of the table
  83. prng = (PRANGE)(gMasterTable[MTI_RNGDICTIONARY].pubStruct) ;
  84. nKeywordTableSize = (int) (prng[END_ATTR - 1].dwEnd) ;
  85. // Return the size of the table
  86. return nKeywordTableSize ;
  87. }
  88. /******************************************************************************
  89. GetGPDKeywordStr()
  90. Return a pointer to the specified (numbered) GPD keyword string. The pointer
  91. might be NULL. Always return a NULL pointer if the GPD keyword table has not
  92. been initialized or a request for a string passed the end of the table is
  93. requested.
  94. ******************************************************************************/
  95. PSTR GetGPDKeywordStr(int nkeyidx, PGLOBL pglobl)
  96. {
  97. // Nothing can be done if the GPD parser could not be initialized or the
  98. // key index is too big.
  99. if (!bKeywordInitDone || nkeyidx > nKeywordTableSize)
  100. return NULL ;
  101. // Return the requested keyword string pointer.
  102. return (mMainKeywordTable[nkeyidx].pstrKeyword) ;
  103. }