home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / mc / mc.h < prev    next >
C/C++ Source or Header  |  1997-10-05  |  5KB  |  299 lines

  1. /*++
  2.  
  3. Copyright (c) 1991-1997 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     mc.h
  8.  
  9. Abstract:
  10.  
  11.     This is the main include file for the Win32 Message Compiler (MC)
  12.  
  13. Author:
  14.  
  15.     Steve Wood (stevewo) 21-Aug-1991
  16.  
  17. Revision History:
  18.  
  19. --*/
  20.  
  21. #if 0
  22. #include <nt.h>
  23. #include <ntrtl.h>
  24. #include <nturtl.h>
  25. #endif
  26.  
  27. #include <process.h>
  28. #include <stdio.h>
  29. #include <stddef.h>
  30. #include <stdlib.h>
  31. #include <stdarg.h>
  32. #include <limits.h>
  33. #include <malloc.h>
  34. #include <errno.h>
  35. #include <ctype.h>
  36. #include <signal.h>
  37. #include <string.h>
  38. #include <time.h>
  39. #include <io.h>
  40. #include <fcntl.h>
  41. #include <conio.h>
  42. #include <sys\types.h>
  43. #include <sys\stat.h>
  44.  
  45. #ifdef TOOL
  46.  
  47. #define MAX_PATH 265
  48.  
  49. #else
  50.  
  51. #include <windows.h>
  52.  
  53. #endif
  54.  
  55. //
  56. // Global constants
  57. //
  58.  
  59. #define MCCHAR_END_OF_LINE_COMMENT    ';'
  60.  
  61. #define MCTOK_END_OF_FILE             0x00
  62.  
  63. #define MCTOK_NUMBER                  0x01
  64. #define MCTOK_NAME                    0x02
  65. #define MCTOK_EQUAL                   0x03
  66. #define MCTOK_LEFT_PAREN              0x04
  67. #define MCTOK_RIGHT_PAREN             0x05
  68. #define MCTOK_COLON                   0x06
  69. #define MCTOK_PLUS                    0x07
  70. #define MCTOK_END_OF_LINE_COMMENT     0x08
  71.  
  72. #define MCTOK_MSGIDTYPE_KEYWORD       0x11
  73. #define MCTOK_SEVNAMES_KEYWORD        0x12
  74. #define MCTOK_FACILITYNAMES_KEYWORD   0x13
  75. #define MCTOK_LANGNAMES_KEYWORD       0x14
  76. #define MCTOK_MESSAGEID_KEYWORD       0x15
  77. #define MCTOK_SEVERITY_KEYWORD        0x16
  78. #define MCTOK_FACILITY_KEYWORD        0x17
  79. #define MCTOK_SYMBOLNAME_KEYWORD      0x18
  80. #define MCTOK_LANGUAGE_KEYWORD        0x19
  81.  
  82.  
  83. //
  84. // Global data types
  85. //
  86.  
  87. typedef struct _LANGUAGE_INFO {
  88.     struct _LANGUAGE_INFO *Next;
  89.     ULONG Id;
  90.     ULONG Length;
  91.     PCHAR Text;
  92. } LANGUAGE_INFO, *PLANGUAGE_INFO;
  93.  
  94. typedef struct _MESSAGE_INFO {
  95.     struct _MESSAGE_INFO *Next;
  96.     ULONG Id;
  97.     ULONG Method;
  98.     PCHAR SymbolicName;
  99.     PCHAR EndOfLineComment;
  100.     PLANGUAGE_INFO MessageText;
  101. } MESSAGE_INFO, *PMESSAGE_INFO;
  102.  
  103. #define MSG_PLUS_ONE 0
  104. #define MSG_PLUS_VALUE 1
  105. #define MSG_ABSOLUTE 2
  106.  
  107. typedef struct _MESSAGE_BLOCK {
  108.     struct _MESSAGE_BLOCK *Next;
  109.     ULONG LowId;
  110.     ULONG HighId;
  111.     ULONG InfoLength;
  112.     PMESSAGE_INFO LowInfo;
  113. } MESSAGE_BLOCK, *PMESSAGE_BLOCK;
  114.  
  115. typedef struct _NAME_INFO {
  116.     struct _NAME_INFO *Next;
  117.     ULONG LastId;
  118.     ULONG Id;
  119.     PVOID Value;
  120.     BOOLEAN Used;
  121.     char Name[ 1 ];
  122. } NAME_INFO, *PNAME_INFO;
  123.  
  124.  
  125. //
  126. // Global variables
  127. //
  128.  
  129. int VerboseOutput;
  130. int WarnOs2Compatible;
  131. int InsertSymbolicName;
  132. int GenerateDecimalValues;
  133. int ResultCode;
  134. ULONG CustomerMsgIdBit;
  135.  
  136. FILE *MessageFile;
  137. char MessageFileName[ MAX_PATH ];
  138. unsigned int MessageFileLineNumber;
  139. unsigned int Token;
  140. char TokenCharValue[ 256 ];
  141. ULONG TokenNumericValue;
  142. PNAME_INFO TokenKeyword;
  143.  
  144. FILE *HeaderFile;
  145. char HeaderFileName[ MAX_PATH ];
  146. FILE *RcInclFile;
  147. char RcInclFileName[ MAX_PATH ];
  148. FILE *BinaryMessageFile;
  149. char BinaryMessageFileName[ MAX_PATH ];
  150.  
  151. char *MessageIdTypeName;
  152.  
  153. PNAME_INFO FacilityNames;
  154. PNAME_INFO CurrentFacilityName;
  155. PNAME_INFO SeverityNames;
  156. PNAME_INFO CurrentSeverityName;
  157. PNAME_INFO LanguageNames;
  158. PNAME_INFO CurrentLanguageName;
  159.  
  160. PMESSAGE_INFO Messages;
  161. PMESSAGE_INFO CurrentMessage;
  162.  
  163. //
  164. // Functions defined in mc.c
  165. //
  166.  
  167. void
  168. McPrintUsage( void );
  169.  
  170.  
  171. //
  172. // Functions defined in mcparse.c
  173. //
  174.  
  175. BOOLEAN
  176. McParseFile( void );
  177.  
  178. BOOLEAN
  179. McParseMessageDefinition( void );
  180.  
  181. BOOLEAN
  182. McParseMessageText(
  183.     PMESSAGE_INFO MessageInfo
  184.     );
  185.  
  186. BOOLEAN
  187. McParseNameList(
  188.     PNAME_INFO *NameListHead,
  189.     BOOLEAN ValueRequired,
  190.     ULONG MaximumValue
  191.     );
  192.  
  193. BOOLEAN
  194. McParseName(
  195.     PNAME_INFO NameListHead,
  196.     PNAME_INFO *Result
  197.     );
  198.  
  199.  
  200. //
  201. // Functions defined in mcout.c
  202. //
  203.  
  204. BOOLEAN
  205. McBlockMessages( void );
  206.  
  207.  
  208. BOOLEAN
  209. McWriteBinaryFiles( void );
  210.  
  211.  
  212.  
  213. //
  214. // Functions defined in mclex.c
  215. //
  216.  
  217. BOOLEAN
  218. McInitLexer( void );
  219.  
  220. BOOLEAN
  221. McOpenInputFile( void );
  222.  
  223. void
  224. McFlushComments( void );
  225.  
  226. void
  227. McCloseInputFile( void );
  228.  
  229. void
  230. McCloseOutputFiles( void );
  231.  
  232. void
  233. McInputError(
  234.     char *Message,
  235.     BOOLEAN Error,
  236.     PVOID Argument
  237.     );
  238.  
  239. char *
  240. McGetLine( void );
  241.  
  242. void
  243. McSkipLine( void );
  244.  
  245. char
  246. McGetChar(
  247.     BOOLEAN SkipWhiteSpace
  248.     );
  249.  
  250. void
  251. McUnGetChar(
  252.     char c
  253.     );
  254.  
  255. unsigned int
  256. McGetToken(
  257.     BOOLEAN KeywordExpected
  258.     );
  259.  
  260. void
  261. McUnGetToken( void );
  262.  
  263. char *
  264. McSkipWhiteSpace(
  265.     char *s
  266.     );
  267.  
  268. //
  269. // Functions defined in mcutil.c
  270. //
  271.  
  272. PNAME_INFO
  273. McAddName(
  274.     PNAME_INFO *NameListHead,
  275.     char *Name,
  276.     ULONG Id,
  277.     PVOID Value
  278.     );
  279.  
  280.  
  281. PNAME_INFO
  282. McFindName(
  283.     PNAME_INFO NameListHead,
  284.     char *Name
  285.     );
  286.  
  287.  
  288. BOOLEAN
  289. McCharToInteger(
  290.     PCHAR String,
  291.     int Base,
  292.     PULONG Value
  293.     );
  294.  
  295. char *
  296. McMakeString(
  297.     char *String
  298.     );
  299.