Source code of Windows XP (NT5)
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.

142 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 1997-2000 Microsoft Corporation
  3. Module Name:
  4. EzParse.h
  5. Abstract:
  6. Poor man C/C++/any file parser declaration.
  7. Author:
  8. Gor Nishanov (gorn) 03-Apr-1999
  9. Revision History:
  10. Gor Nishanov (gorn) 03-Apr-1999 -- hacked together to prove that this can work
  11. ToDo:
  12. Clean it up
  13. --*/
  14. typedef struct _STR_PAIR
  15. {
  16. LPCSTR beg;
  17. LPCSTR end;
  18. bool empty() const { return beg == end; }
  19. } STR_PAIR, *PSTR_PAIR;
  20. typedef struct _EZPARSE_CONTEXT {
  21. LPCSTR start;
  22. LPCSTR currentStart;
  23. LPCSTR currentEnd;
  24. LPCSTR filename;
  25. LPCSTR lastScanned;
  26. UINT scannedLineCount;
  27. LPCSTR macroEnd;
  28. BOOL doubleParent;
  29. struct _EZPARSE_CONTEXT * previousContext;
  30. DWORD Options;
  31. } EZPARSE_CONTEXT, *PEZPARSE_CONTEXT;
  32. void ExParsePrintErrorPrefix(FILE* f, char* funcname);
  33. extern DWORD ErrorCount;
  34. #define ReportError ExParsePrintErrorPrefix(stdout, __FUNCTION__);printf
  35. typedef
  36. DWORD (*EZPARSE_CALLBACK) (PSTR_PAIR, INT, PVOID, PEZPARSE_CONTEXT);
  37. typedef
  38. DWORD (*PROCESSFILE_CALLBACK) (
  39. LPCSTR, LPCSTR, EZPARSE_CALLBACK,PVOID,PEZPARSE_CONTEXT);
  40. DWORD
  41. EzGetLineNo(
  42. IN LPCSTR Ptr,
  43. IN PEZPARSE_CONTEXT
  44. );
  45. DWORD
  46. EzParse(
  47. IN LPCSTR filename,
  48. IN EZPARSE_CALLBACK Callback,
  49. IN PVOID Context);
  50. DWORD
  51. EzParseWithOptions(
  52. IN LPCSTR filename,
  53. IN EZPARSE_CALLBACK Callback,
  54. IN PVOID Context,
  55. IN DWORD Options
  56. );
  57. DWORD
  58. EzParseEx(
  59. IN LPCSTR filename,
  60. IN PROCESSFILE_CALLBACK ProcessData,
  61. IN EZPARSE_CALLBACK Callback,
  62. IN PVOID Context,
  63. IN DWORD Options);
  64. DWORD
  65. EzParseResourceEx(
  66. IN LPCSTR ResName,
  67. IN PROCESSFILE_CALLBACK ProcessData,
  68. IN EZPARSE_CALLBACK Callback,
  69. IN PVOID Context);
  70. DWORD
  71. SmartScan(
  72. IN LPCSTR begin,
  73. IN LPCSTR end,
  74. IN EZPARSE_CALLBACK Callback,
  75. IN PVOID Context,
  76. IN OUT PEZPARSE_CONTEXT ParseContext
  77. );
  78. DWORD
  79. ScanForFunctionCalls(
  80. IN LPCSTR begin,
  81. IN LPCSTR end,
  82. IN EZPARSE_CALLBACK Callback,
  83. IN PVOID Context,
  84. IN OUT PEZPARSE_CONTEXT ParseContext
  85. );
  86. enum {
  87. NO_SEMICOLON = 0x01,
  88. IGNORE_CPP_COMMENT = 0x02,
  89. IGNORE_POUND_COMMENT = 0x04,
  90. IGNORE_COMMENT = IGNORE_CPP_COMMENT | IGNORE_POUND_COMMENT,
  91. };
  92. DWORD
  93. ScanForFunctionCallsEx(
  94. IN LPCSTR begin,
  95. IN LPCSTR end,
  96. IN EZPARSE_CALLBACK Callback,
  97. IN PVOID Context,
  98. IN OUT PEZPARSE_CONTEXT ParseContext,
  99. IN DWORD Options
  100. );
  101. __declspec(selectany) int DbgLevel = 0;
  102. enum DBG_LEVELS {
  103. DBG_UNUSUAL = 1,
  104. DBG_NOISE = 2,
  105. DBG_FLOOD = 3,
  106. };
  107. #define Always printf
  108. #define Flood (DbgLevel < DBG_FLOOD)?0:printf
  109. #define Noise (DbgLevel < DBG_NOISE)?0:printf
  110. #define Unusual (DbgLevel < DBG_UNUSUAL)?0:printf