9a5517ac7fbfa2a8d52cc658b4c9374dde99173d
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
9 /* INCLUDES *******************************************************************/
13 /* GLOBALS ********************************************************************/
15 /* Internal tool data */
17 ULONG gSubVersion
= 40;
23 /* Command-line parameters */
24 BOOLEAN UnicodeFile
, Verbose
, NoLogo
, FallbackDriver
, SanityCheck
, SourceOnly
;
27 /* FUNCTIONS ******************************************************************/
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",
34 gVersion
, gSubVersion
);
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");
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");
57 printf("should not be here");
64 ULONG i
, ErrorCode
, FailureCode
;
67 CHAR BuildOptions
[16] = {0};
69 /* Loop for parameter */
70 for (i
= 1; i
< argc
; ++i
)
72 if (argv
[i
][0] != '/' && argv
[i
][0] != '-')
75 if (argv
[i
][1] && !argv
[i
][2])
80 /* Check supported options */
107 /* Fallback driver */
150 /* If you got here, the options are invalid or missing */
156 /* Do we have no options? */
157 if (i
== argc
) PrintUsage();
159 /* Should we announce ourselves? */
162 /* This is who we are */
163 printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n",
164 gVersion
, gSubVersion
);
167 /* Save the file name */
168 gpszFileName
= argv
[i
];
170 /* Open either as binary or text */
172 if (!UnicodeFile
) OpenFlags
= "rt";
174 /* Open a handle to the file */
175 gfpInput
= fopen(gpszFileName
, OpenFlags
);
178 /* Couldn't open it */
179 printf("Unable to open '%s' for read.\n", gpszFileName
);
183 /* Should we print out what we're doing? */
186 /* Are we only building the source files? */
189 /* Then there's no target architecture */
190 strcpy(BuildOptions
, "source files");
194 /* Take a look at the target architecture*/
197 /* Print the appropriate message depending on what was chosen */
199 strcpy(BuildOptions
, "i386/x86");
202 strcpy(BuildOptions
, "ia64");
205 strcpy(BuildOptions
, "amd64/x64");
208 strcpy(BuildOptions
, "wow64");
211 strcpy(BuildOptions
, "unknown purpose");
216 /* Now inform the user */
217 printf("Compiling layout information from '%s' for %s.\n", gpszFileName
, BuildOptions
);
220 /* Now parse the keywords */
221 FailureCode
= DoParsing();
223 /* Should we build? */
224 if (!(SourceOnly
) && !(FallbackDriver
)) ErrorCode
= 0;//DoBuild();
226 /* Did everything work? */
227 if (FailureCode
== 0)
229 /* Tell the user, if he cares */
230 if (!NoLogo
) printf("All tasks completed successfully.\n");
234 /* Print the failure code */
235 printf("\n %13d\n", FailureCode
);
238 /* Return the error code */