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.

126 lines
4.2 KiB

  1. /************************************************************************/
  2. /* */
  3. /* RCPP - Resource Compiler Pre-Processor for NT system */
  4. /* */
  5. /* P0DEFS.H - Defintions for PreProcessor parsing code */
  6. /* */
  7. /* 06-Dec-90 w-BrianM Update for NT from PM SDK RCPP */
  8. /* */
  9. /************************************************************************/
  10. struct s_defn {
  11. pdefn_t defn_next; /* pointer to next ident */
  12. PUCHAR defn_ident; /* pointer to name */
  13. ptext_t defn_text; /* definition substitution string */
  14. char defn_nformals;/*number of formal arguments - can be <0*/
  15. char defn_expanding; /* are we already expanding this one? */
  16. };
  17. #define DEFN_IDENT(P) ((P)->defn_ident)
  18. #define DEFN_NAME(P) (DEFN_IDENT(P))
  19. #define DEFN_NEXT(P) ((P)->defn_next)
  20. #define DEFN_TEXT(P) ((P)->defn_text)
  21. #define DEFN_NFORMALS(P) ((P)->defn_nformals)
  22. #define DEFN_EXPANDING(P) ((P)->defn_expanding)
  23. #define FILE_EOS 0x01
  24. #define ACTUAL_EOS 0x02
  25. #define DEFINITION_EOS 0x04
  26. #define RESCAN_EOS 0x08
  27. #define BACKSLASH_EOS 0x10
  28. #define ANY_EOS ( FILE_EOS | ACTUAL_EOS | DEFINITION_EOS\
  29. | RESCAN_EOS | BACKSLASH_EOS )
  30. /*
  31. ** arbitrarily chosen characters that get special treatment when found
  32. ** after EOS in handle_eos()
  33. */
  34. #define EOS_ACTUAL 'A'
  35. #define EOS_DEFINITION 'D'
  36. #define EOS_RESCAN 'R'
  37. #define EOS_PAD 'P'
  38. #define FROM_COMMAND -2
  39. #define PRE_DEFINED(P) (DEFN_NFORMALS(P) < FROM_COMMAND)
  40. typedef struct s_expstr {
  41. ptext_t exp_string; /* ptr to next character in stream aft macro */
  42. char *exp_actuals; /* ptr to start of actuals linked list */
  43. ptext_t exp_text; /* ptr to expanded text for this macro */
  44. pdefn_t exp_macro; /* ptr to macro defn */
  45. UCHAR exp_nactuals; /* number of actuals */
  46. UCHAR exp_nactsexpanded;/* number of expanded actuals for handle_eos*/
  47. } expansion_t;
  48. /*
  49. ** note that CURRENT_STRING usually points into an area in the macro
  50. ** expansion buffer, but the first item used (Macro_depth equals 1) points
  51. ** to text read from a file. In some versions, the heap is reshuffled
  52. ** and this pointer must be updated for the first item.
  53. */
  54. #define CURRENT_STRING Macro_expansion[Macro_depth].exp_string
  55. #define CURRENT_ACTUALS Macro_expansion[Macro_depth].exp_actuals
  56. #define CURRENT_TEXT Macro_expansion[Macro_depth].exp_text
  57. #define CURRENT_MACRO Macro_expansion[Macro_depth].exp_macro
  58. #define CURRENT_NACTUALS Macro_expansion[Macro_depth].exp_nactuals
  59. #define CURRENT_NACTSEXPANDED Macro_expansion[Macro_depth].exp_nactsexpanded
  60. /*
  61. ** finds address after last element in an array. Used to check for
  62. ** buffer overflows.
  63. */
  64. #define LIMIT(a) &(a)[sizeof(a)]
  65. #define IS_CHAR(c,uc) (toupper(c) == (uc))
  66. #define IS_B(c) IS_CHAR(c, 'B')
  67. #define IS_D(c) IS_CHAR(c, 'D')
  68. #define IS_E(c) IS_CHAR(c, 'E')
  69. #define IS_F(c) IS_CHAR(c, 'F')
  70. #define IS_H(c) IS_CHAR(c, 'H')
  71. #define IS_EL(c) IS_CHAR(c, 'L')
  72. #define IS_O(c) IS_CHAR(c, 'O')
  73. #define IS_Q(c) IS_CHAR(c, 'Q')
  74. #define IS_U(c) IS_CHAR(c, 'U')
  75. #define IS_X(c) IS_CHAR(c, 'X')
  76. #define IS_DOT(c) (c == '.')
  77. #define IS_SIGN(c) ((c == '+') || (c =='-'))
  78. #define P0_IF 0
  79. #define P0_ELIF 1
  80. #define P0_ELSE 2
  81. #define P0_ENDIF 3
  82. #define P0_IFDEF 4
  83. #define P0_IFNDEF 5
  84. #define P0_DEFINE 6
  85. #define P0_INCLUDE 7
  86. #define P0_PRAGMA 8
  87. #define P0_UNDEF 9
  88. #define P0_LINE 10
  89. #define P0_NOTOKEN 11
  90. #define P0_ERROR 12
  91. #define P0_IDENT 13
  92. #define HLN_NAME(s) ((s).hln_name)
  93. #define HLN_HASH(s) ((s).hln_hash)
  94. #define HLN_LENGTH(s) ((s).hln_length)
  95. #define HLN_IDENT_HASH(p) (HLN_HASH(*(p)))
  96. #define HLN_IDENT_LENGTH(p) (HLN_LENGTH(*(p)))
  97. #define HLN_IDENTP_NAME(p) (HLN_NAME(*(p)))
  98. #define HLN_TO_NAME(S) ((PUCHAR)pstrndup(HLN_IDENTP_NAME(S),HLN_IDENT_LENGTH(S)))
  99. #define HASH_MASK 0x5f
  100. #define LIMIT_ID_LENGTH 31
  101. #define LIMIT_NESTED_INCLUDES 10
  102. #define LIMIT_MACRO_DEPTH 64
  103. #define LIMIT_STRING_LENGTH 2043
  104. #define LEVEL_0 0xff
  105. #define MUST_OPEN 1
  106. #define MAY_OPEN 0
  107. /*** The following are defined to use on the Token Table ***/
  108. #define TS_STR(idx) (Tokstrings[idx-L_NOTOKEN].k_text)
  109. #define TS_VALUE(idx) (Tokstrings[idx-L_NOTOKEN].k_token)