Begin implementing Keyboard Layout Compiler Tool, as requested by KJK::Hyperion....
[reactos.git] / reactos / tools / kbdtool / main.c
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 <string.h>
12 #include <stdarg.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include "getopt.h"
16 #include <host/typedefs.h>
17
18 /* GLOBALS ********************************************************************/
19
20 ULONG gVersion = 3;
21 ULONG gSubVersion = 40;
22 BOOLEAN UnicodeFile, Verbose, NoLogo, FallbackDriver, SanityCheck, SourceOnly;
23 ULONG BuildType;
24
25 /* FUNCTIONS ******************************************************************/
26
27 void
28 usage()
29 {
30 /* This is who we are */
31 printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n",
32 gVersion, gSubVersion);
33
34 /* This is what we do */
35 printf("Usage: KbdTool [-v] [-n] [-w] [-k] [-n] [-u|a] [-i|x|m|o|s] FILE\n\n");
36 printf("\t[-?] display this message\n");
37 printf("\t[-n] no logo or normal build information displayed\n\n");
38 printf("\t[-a] Uses non-Unicode source files (default)\n");
39 printf("\t[-u] Uses Unicode source files\n\n");
40 printf("\t[-v] Verbose diagnostics (and warnings, with -w)\n");
41 printf("\t[-w] display extended Warnings\n\n");
42 printf("\t[-x] Builds for x86 (default)\n");
43 printf("\t[-i] Builds for IA64\n");
44 printf("\t[-m] Builds for AMD64\n");
45 printf("\t[-o] Builds for WOW64\n");
46 printf("\t[-s] Generate Source files (no build)\n\n");
47 printf("\tFILE The source keyboard file (required)\n\n");
48
49 /* Extra hints */
50 printf("\t-u/-a are mutually exclusive; kbdutool will use the last one if you specify more than one.\n");
51 printf("\t-i/-x/-m/-o-s will exhibit the same behavior when than one of them is specified.\n\n");
52
53 /* Quit */
54 _exit(1);
55 printf("should not be here");
56 }
57
58 int
59 main(int argc,
60 char** argv)
61 {
62 CHAR Option;
63
64 /* Loop for parameter */
65 while (TRUE)
66 {
67 /* Get the options */
68 Option = getopt(argc, argv, "aAeEiIkKmMnNOosSuUvVwWxX?");
69 if (Option != -1)
70 {
71 /* Check supported options */
72 switch (Option)
73 {
74 /* ASCII File */
75 case 'A':
76 case 'a':
77 UnicodeFile = 0;
78 continue;
79
80 /* UNICODE File */
81 case 'U':
82 case 'u':
83 UnicodeFile = 1;
84 continue;
85
86 /* Verbose */
87 case 'V':
88 case 'v':
89 Verbose = 1;
90 continue;
91
92 /* No logo */
93 case 'N':
94 case 'n':
95 NoLogo = 1;
96 continue;
97
98 /* Fallback driver */
99 case 'K':
100 case 'k':
101 FallbackDriver = 1;
102 continue;
103
104 /* Sanity Check */
105 case 'W':
106 case 'w':
107 SanityCheck = 1;
108 continue;
109
110 /* Itanium */
111 case 'I':
112 case 'i':
113 BuildType = 1;
114 continue;
115
116 /* X86 */
117 case 'X':
118 case 'x':
119 BuildType = 0;
120 continue;
121
122 /* AMD64 */
123 case 'M':
124 case 'm':
125 BuildType = 2;
126 continue;
127
128 /* WOW64 */
129 case 'O':
130 case 'o':
131 BuildType = 3;
132 continue;
133
134 /* Source only */
135 case 'S':
136 case 's':
137 SourceOnly = 1;
138 continue;
139 default:
140 break;
141 }
142
143 /* If you got here, the options are invalid or missing */
144 usage();
145 }
146 break;
147 }
148
149 /* Do we have no options? */
150 if (optind == argc) usage();
151
152 /* Should we announce ourselves? */
153 if (!NoLogo)
154 {
155 /* This is who we are */
156 printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n",
157 gVersion, gSubVersion);
158 }
159
160 /* Otherwise... do something */
161 printf("Zoom zoom...\n");
162 }
163
164 /* EOF */