ReactOS  0.4.12-dev-14-gd0c8636
evtmsggen.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS EventCreate Command
4  * FILE: base/applications/cmdutils/eventcreate/evtmsggen.c
5  * PURPOSE: Generator for the event message string templates file.
6  * Creates the message string file in the current directory.
7  * PROGRAMMER: Hermes Belusca-Maito
8  *
9  * You can compile this generator:
10  * with GCC : $ gcc -o evtmsggen.exe evtmsggen.c
11  * with MSVC: $ cl evtmsggen.c (or: $ cl /Fe"evtmsggen.exe" evtmsggen.c)
12  */
13 
14 #include <stdio.h>
15 
16 /*
17  * Enable/disable this option to use "English" for the message table language.
18  * The default behaviour when the option is disabled selects "Neutral" language.
19  */
20 // #define ENGLISH
21 
22 /* The default End-Of-Line control for the message file */
23 #define EOL "\r\n"
24 
25 
26 static void usage(char* name)
27 {
28  fprintf(stdout, "Usage: %s ID_min ID_max outfile.mc\n", name);
29 }
30 
31 int main(int argc, char* argv[])
32 {
33  FILE* outFile;
34  unsigned int id_min, id_max;
35  unsigned int i;
36 
37  /* Validate the arguments */
38  if (argc != 4)
39  {
40  usage(argv[0]);
41  return -1;
42  }
43 
44  id_min = (unsigned int)atoi(argv[1]);
45  id_max = (unsigned int)atoi(argv[2]);
46  if (id_min > id_max)
47  {
48  fprintf(stderr, "ERROR: Min ID %u cannot be strictly greater than Max ID %u !\n", id_min, id_max);
49  return -1;
50  }
51 
52  /* Open the file */
53  outFile = fopen(argv[3], "wb");
54  if (!outFile)
55  {
56  fprintf(stderr, "ERROR: Could not create output file '%s'.\n", argv[3]);
57  return -1;
58  }
59 
60  /* Generate the file */
61 
62  /* Write the header */
63  fprintf(outFile,
64  ";/*" EOL
65  "; * %s" EOL
66  "; * Contains event message string templates for the EventCreate Command." EOL
67  "; *" EOL
68  "; * This file is autogenerated, do not edit." EOL
69  "; * Generated with:" EOL
70  "; * %s %u %u %s" EOL
71  "; */" EOL
72  EOL
73 #ifdef ENGLISH
74  "LanguageNames=(English=0x409:MSG00409)" EOL
75 #else
76  "LanguageNames=(Neutral=0x0000:MSG00000)" EOL
77 #endif
78  "MessageIdTypedef=DWORD" EOL
79  EOL,
80  argv[3],
81  argv[0], id_min /* argv[1] */, id_max /* argv[2] */, argv[3]);
82 
83  /* Write the message string templates */
84  for (i = id_min; i <= id_max; ++i)
85  {
86  fprintf(outFile,
87  "MessageId=0x%X" EOL
88 #ifdef ENGLISH
89  "Language=English" EOL
90 #else
91  "Language=Neutral" EOL
92 #endif
93  "%%1" EOL
94  "." EOL
95  EOL,
96  i);
97  }
98 
99  /* Close the file */
100  fclose(outFile);
101 
102  return 0;
103 }
104 
105 /* EOF */
static int argc
Definition: ServiceArgs.c:12
#define EOL
Definition: evtmsggen.c:23
static void usage(char *name)
Definition: evtmsggen.c:26
static char ** argv
Definition: ServiceArgs.c:11
FILE * stdout
GLenum GLclampf GLint i
Definition: glfuncs.h:14
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
int main(int argc, char *argv[])
Definition: evtmsggen.c:31
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
Definition: name.c:36
FILE * stderr
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:29