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.

339 lines
5.7 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. mc.h
  5. Abstract:
  6. This is the main include file for the Win32 Message Compiler (MC)
  7. Author:
  8. Steve Wood (stevewo) 21-Aug-1991
  9. Revision History:
  10. --*/
  11. #include <process.h>
  12. #include <stdio.h>
  13. #include <stddef.h>
  14. #include <stdlib.h>
  15. #include <stdarg.h>
  16. #include <limits.h>
  17. #include <malloc.h>
  18. #include <errno.h>
  19. #include <ctype.h>
  20. #include <signal.h>
  21. #include <string.h>
  22. #include <time.h>
  23. #include <io.h>
  24. #include <fcntl.h>
  25. #include <conio.h>
  26. #include <sys\types.h>
  27. #include <sys\stat.h>
  28. #include <wchar.h>
  29. #include <assert.h>
  30. #include <locale.h>
  31. #include <windows.h>
  32. //
  33. // Global constants
  34. //
  35. #define MCCHAR_END_OF_LINE_COMMENT L';'
  36. #define MCTOK_END_OF_FILE 0x0000
  37. #define MCTOK_NUMBER 0x0001
  38. #define MCTOK_NAME 0x0002
  39. #define MCTOK_EQUAL 0x0003
  40. #define MCTOK_LEFT_PAREN 0x0004
  41. #define MCTOK_RIGHT_PAREN 0x0005
  42. #define MCTOK_COLON 0x0006
  43. #define MCTOK_PLUS 0x0007
  44. #define MCTOK_END_OF_LINE_COMMENT 0x0008
  45. #define MCTOK_MSGIDTYPE_KEYWORD 0x0011
  46. #define MCTOK_SEVNAMES_KEYWORD 0x0012
  47. #define MCTOK_FACILITYNAMES_KEYWORD 0x0013
  48. #define MCTOK_LANGNAMES_KEYWORD 0x0014
  49. #define MCTOK_MESSAGEID_KEYWORD 0x0015
  50. #define MCTOK_SEVERITY_KEYWORD 0x0016
  51. #define MCTOK_FACILITY_KEYWORD 0x0017
  52. #define MCTOK_SYMBOLNAME_KEYWORD 0x0018
  53. #define MCTOK_LANGUAGE_KEYWORD 0x0019
  54. #define MCTOK_OUTBASE_KEYWORD 0x001A
  55. #define MCTOK_MSGTYPEDEF_KEYWORD 0x001B
  56. //
  57. // Global data types
  58. //
  59. typedef struct _LANGUAGE_INFO {
  60. struct _LANGUAGE_INFO *Next;
  61. ULONG Id;
  62. ULONG Length;
  63. WCHAR *Text;
  64. } LANGUAGE_INFO, *PLANGUAGE_INFO;
  65. typedef struct _MESSAGE_INFO {
  66. struct _MESSAGE_INFO *Next;
  67. ULONG Id;
  68. ULONG Method;
  69. WCHAR *SymbolicName;
  70. WCHAR *EndOfLineComment;
  71. PLANGUAGE_INFO MessageText;
  72. } MESSAGE_INFO, *PMESSAGE_INFO;
  73. #define MSG_PLUS_ONE 0
  74. #define MSG_PLUS_VALUE 1
  75. #define MSG_ABSOLUTE 2
  76. typedef struct _MESSAGE_BLOCK {
  77. struct _MESSAGE_BLOCK *Next;
  78. ULONG LowId;
  79. ULONG HighId;
  80. ULONG InfoLength;
  81. PMESSAGE_INFO LowInfo;
  82. } MESSAGE_BLOCK, *PMESSAGE_BLOCK;
  83. typedef struct _NAME_INFO {
  84. struct _NAME_INFO *Next;
  85. ULONG LastId;
  86. ULONG Id;
  87. PVOID Value;
  88. BOOL Used;
  89. UINT CodePage;
  90. WCHAR Name[ 1 ];
  91. } NAME_INFO, *PNAME_INFO;
  92. //
  93. // Global variables
  94. //
  95. int VerboseOutput;
  96. int WarnOs2Compatible;
  97. int InsertSymbolicName;
  98. int MaxMessageLength;
  99. int GenerateDecimalSevAndFacValues;
  100. int GenerateDecimalMessageValues;
  101. int ResultCode;
  102. ULONG InputErrorCount;
  103. int NULLTerminate;
  104. int OleOutput;
  105. int UnicodeInput;
  106. int UnicodeOutput;
  107. ULONG CustomerMsgIdBit;
  108. FILE *MessageFile;
  109. char MessageFileName[ MAX_PATH ];
  110. char *MessageFileNameNoExt;
  111. unsigned int MessageFileLineNumber;
  112. unsigned int Token;
  113. WCHAR TokenCharValue[ 256 ];
  114. ULONG TokenNumericValue;
  115. PNAME_INFO TokenKeyword;
  116. FILE *HeaderFile;
  117. char HeaderFileName[ MAX_PATH ];
  118. char HeaderFileExt[ MAX_PATH ];
  119. FILE *RcInclFile;
  120. char RcInclFileName[ MAX_PATH ];
  121. FILE *BinaryMessageFile;
  122. char BinaryMessageFileName[ MAX_PATH ];
  123. int GenerateDebugFile;
  124. FILE *DebugFile;
  125. char DebugFileName[ MAX_PATH ];
  126. WCHAR *MessageIdTypeName;
  127. WCHAR *MessageIdTypeMacro;
  128. PNAME_INFO FacilityNames;
  129. PNAME_INFO CurrentFacilityName;
  130. PNAME_INFO SeverityNames;
  131. PNAME_INFO CurrentSeverityName;
  132. PNAME_INFO LanguageNames;
  133. PNAME_INFO CurrentLanguageName;
  134. CPINFO CPInfo;
  135. PMESSAGE_INFO Messages;
  136. PMESSAGE_INFO CurrentMessage;
  137. BOOL fUniqueBinName;
  138. CHAR FNameMsgFileName[_MAX_FNAME];
  139. //
  140. // c-runtime macros
  141. //
  142. #define iswcsymf(_c) (iswalpha(_c) || ((_c) == L'_'))
  143. #define iswcsym(_c) (iswalnum(_c) || ((_c) == L'_'))
  144. //
  145. // Functions defined in mc.c
  146. //
  147. void
  148. McPrintUsage( void );
  149. //
  150. // Functions defined in mcparse.c
  151. //
  152. BOOL
  153. McParseFile( void );
  154. BOOL
  155. McParseMessageDefinition( void );
  156. BOOL
  157. McParseMessageText(
  158. PMESSAGE_INFO MessageInfo
  159. );
  160. BOOL
  161. McParseNameList(
  162. PNAME_INFO *NameListHead,
  163. BOOL ValueRequired,
  164. ULONG MaximumValue
  165. );
  166. BOOL
  167. McParseName(
  168. PNAME_INFO NameListHead,
  169. PNAME_INFO *Result
  170. );
  171. //
  172. // Functions defined in mcout.c
  173. //
  174. BOOL
  175. McBlockMessages( void );
  176. BOOL
  177. McWriteBinaryFilesA( void );
  178. BOOL
  179. McWriteBinaryFilesW( void );
  180. VOID
  181. McClearArchiveBit( LPSTR Name );
  182. //
  183. // Functions defined in mclex.c
  184. //
  185. BOOL
  186. McInitLexer( void );
  187. BOOL
  188. McOpenInputFile( void );
  189. void
  190. McFlushComments( void );
  191. void
  192. McCloseInputFile( void );
  193. void
  194. McCloseOutputFiles( BOOL );
  195. void
  196. McInputErrorA(
  197. char *Message,
  198. BOOL Error,
  199. PVOID Argument
  200. );
  201. void
  202. McInputErrorW(
  203. WCHAR *Message,
  204. BOOL Error,
  205. PVOID Argument
  206. );
  207. WCHAR *
  208. McGetLine( void );
  209. void
  210. McSkipLine( void );
  211. WCHAR
  212. McGetChar(
  213. BOOL SkipWhiteSpace
  214. );
  215. void
  216. McUnGetChar(
  217. WCHAR c
  218. );
  219. unsigned int
  220. McGetToken(
  221. BOOL KeywordExpected
  222. );
  223. void
  224. McUnGetToken( void );
  225. WCHAR *
  226. McSkipWhiteSpace(
  227. WCHAR *s
  228. );
  229. //
  230. // Functions defined in mcutil.c
  231. //
  232. PNAME_INFO
  233. McAddName(
  234. PNAME_INFO *NameListHead,
  235. WCHAR *Name,
  236. ULONG Id,
  237. PVOID Value
  238. );
  239. PNAME_INFO
  240. McFindName(
  241. PNAME_INFO NameListHead,
  242. WCHAR *Name
  243. );
  244. BOOL
  245. McCharToInteger(
  246. WCHAR * String,
  247. int Base,
  248. PULONG Value
  249. );
  250. WCHAR *
  251. McMakeString(
  252. WCHAR *String
  253. );
  254. BOOL
  255. IsFileUnicode(
  256. char * fName
  257. );
  258. WCHAR *
  259. fgetsW(
  260. WCHAR * string,
  261. long count,
  262. FILE * fp
  263. );