ReactOS 0.4.16-dev-297-gc569aee
main.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Build Tools [Keyboard Layout Compiler]
3 * LICENSE: BSD - See COPYING.BSD in the top level directory
4 * FILE: tools/kbdtool/main.c
5 * PURPOSE: Main Logic Loop
6 * PROGRAMMERS: ReactOS Foundation
7 */
8
9/* INCLUDES *******************************************************************/
10
11#include "kbdtool.h"
12
13/* GLOBALS ********************************************************************/
14
15/* Internal tool data */
18
19/* Input file */
22
23/* Command-line parameters */
26
27/* FUNCTIONS ******************************************************************/
28
29VOID
31{
32 /* This is who we are */
33 printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n",
35
36 /* This is what we do */
37 printf("Usage: KbdTool [-v] [-n] [-w] [-k] [-n] [-u|a] [-i|x|m|o|s] FILE\n\n");
38 printf("\t[-?] display this message\n");
39 printf("\t[-n] no logo or normal build information displayed\n\n");
40 printf("\t[-a] Uses non-Unicode source files (default)\n");
41 printf("\t[-u] Uses Unicode source files\n\n");
42 printf("\t[-v] Verbose diagnostics (and warnings, with -w)\n");
43 printf("\t[-w] display extended Warnings\n\n");
44 printf("\t[-x] Builds for x86 (default)\n");
45 printf("\t[-i] Builds for IA64\n");
46 printf("\t[-m] Builds for AMD64\n");
47 printf("\t[-o] Builds for WOW64\n");
48 printf("\t[-s] Generate Source files (no build)\n\n");
49 printf("\tFILE The source keyboard file (required)\n\n");
50
51 /* Extra hints */
52 printf("\t-u/-a are mutually exclusive; kbdutool will use the last one if you specify more than one.\n");
53 printf("\t-i/-x/-m/-o-s will exhibit the same behavior when than one of them is specified.\n\n");
54
55 /* Quit */
56 exit(1);
57 printf("should not be here");
58}
59
60INT
62 PCHAR* argv)
63{
64 int i;
65 ULONG ErrorCode, FailureCode;
66 CHAR Option;
67 PCHAR OpenFlags;
68 CHAR BuildOptions[16] = {0};
69
70 /* Loop for parameter */
71 for (i = 1; i < argc; ++i)
72 {
73 if (argv[i][0] != '/' && argv[i][0] != '-')
74 break;
75
76 if (argv[i][1] && !argv[i][2])
77 Option = argv[i][1];
78 else
79 Option = 0;
80
81 /* Check supported options */
82 switch (Option)
83 {
84 /* ASCII File */
85 case 'A':
86 case 'a':
87 UnicodeFile = 0;
88 break;
89
90 /* UNICODE File */
91 case 'U':
92 case 'u':
93 UnicodeFile = 1;
94 break;
95
96 /* Verbose */
97 case 'V':
98 case 'v':
99 Verbose = 1;
100 break;
101
102 /* No logo */
103 case 'N':
104 case 'n':
105 NoLogo = 1;
106 break;
107
108 /* Fallback driver */
109 case 'K':
110 case 'k':
111 FallbackDriver = 1;
112 break;
113
114 /* Sanity Check */
115 case 'W':
116 case 'w':
117 SanityCheck = 1;
118 break;
119
120 /* Itanium */
121 case 'I':
122 case 'i':
123 BuildType = 1;
124 break;
125
126 /* X86 */
127 case 'X':
128 case 'x':
129 BuildType = 0;
130 break;
131
132 /* AMD64 */
133 case 'M':
134 case 'm':
135 BuildType = 2;
136 break;
137
138 /* WOW64 */
139 case 'O':
140 case 'o':
141 BuildType = 3;
142 break;
143
144 /* Source only */
145 case 'S':
146 case 's':
147 SourceOnly = 1;
148 break;
149
150 default:
151 /* If you got here, the options are invalid or missing */
152 PrintUsage();
153 break;
154 }
155 }
156
157 /* Do we have no options? */
158 if (i == argc) PrintUsage();
159
160 /* Should we announce ourselves? */
161 if (!NoLogo)
162 {
163 /* This is who we are */
164 printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n",
166 }
167
168 /* Save the file name */
170
171 /* Open either as binary or text */
172 OpenFlags = "rb";
173 if (!UnicodeFile) OpenFlags = "rt";
174
175 /* Open a handle to the file */
176 gfpInput = fopen(gpszFileName, OpenFlags);
177 if (!gfpInput)
178 {
179 /* Couldn't open it */
180 printf("Unable to open '%s' for read.\n", gpszFileName);
181 exit(1);
182 }
183
184 /* Should we print out what we're doing? */
185 if (!NoLogo)
186 {
187 /* Are we only building the source files? */
188 if (SourceOnly)
189 {
190 /* Then there's no target architecture */
191 strcpy(BuildOptions, "source files");
192 }
193 else
194 {
195 /* Take a look at the target architecture*/
196 switch (BuildType)
197 {
198 /* Print the appropriate message depending on what was chosen */
199 case 0:
200 strcpy(BuildOptions, "i386/x86");
201 break;
202 case 1:
203 strcpy(BuildOptions, "ia64");
204 break;
205 case 2:
206 strcpy(BuildOptions, "amd64/x64");
207 break;
208 case 3:
209 strcpy(BuildOptions, "wow64");
210 break;
211 default:
212 strcpy(BuildOptions, "unknown purpose");
213 break;
214 }
215 }
216
217 /* Now inform the user */
218 printf("Compiling layout information from '%s' for %s.\n", gpszFileName, BuildOptions);
219 }
220
221 /* Now parse the keywords */
222 FailureCode = DoParsing();
223
224 /* Should we build? */
225 if (!(SourceOnly) && !(FallbackDriver)) ErrorCode = 0;//DoBuild();
226
227 /* Did everything work? */
228 if (FailureCode == 0)
229 {
230 /* Tell the user, if he cares */
231 if (!NoLogo) printf("All tasks completed successfully.\n");
232 }
233 else
234 {
235 /* Print the failure code */
236 printf("\n %13d\n", FailureCode);
237 }
238
239 /* Return the error code */
240 return ErrorCode;
241}
242
243/* EOF */
unsigned char BOOLEAN
static int argc
Definition: ServiceArgs.c:12
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int main()
Definition: test.c:6
#define printf
Definition: freeldr.h:97
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
ULONG DoParsing(VOID)
Definition: parser.c:972
char gVersion[]
Definition: main.c:57
#define argv
Definition: mplay32.c:18
_In_ NDIS_ERROR_CODE ErrorCode
Definition: ndis.h:4436
void PrintUsage()
Definition: nslookup.c:68
#define exit(n)
Definition: config.h:202
FILE * gfpInput
Definition: main.c:21
BOOLEAN SanityCheck
Definition: main.c:24
BOOLEAN SourceOnly
Definition: main.c:24
ULONG BuildType
Definition: main.c:25
BOOLEAN NoLogo
Definition: main.c:24
BOOLEAN Verbose
Definition: main.c:24
BOOLEAN FallbackDriver
Definition: main.c:24
ULONG gSubVersion
Definition: main.c:17
PCHAR gpszFileName
Definition: main.c:20
BOOLEAN UnicodeFile
Definition: main.c:24
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
char CHAR
Definition: xmlstorage.h:175