[KBDTOOL]: Whitespace fixes.

svn path=/trunk/; revision=65995
This commit is contained in:
Hermès Bélusca-Maïto 2015-01-07 18:24:14 +00:00
parent 3f427653d8
commit c67fcc673a
3 changed files with 334 additions and 334 deletions

View file

@ -26,13 +26,13 @@ ULONG BuildType;
/* FUNCTIONS ******************************************************************/ /* FUNCTIONS ******************************************************************/
VOID VOID
PrintUsage(VOID) PrintUsage(VOID)
{ {
/* This is who we are */ /* This is who we are */
printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n", printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n",
gVersion, gSubVersion); gVersion, gSubVersion);
/* This is what we do */ /* This is what we do */
printf("Usage: KbdTool [-v] [-n] [-w] [-k] [-n] [-u|a] [-i|x|m|o|s] FILE\n\n"); printf("Usage: KbdTool [-v] [-n] [-w] [-k] [-n] [-u|a] [-i|x|m|o|s] FILE\n\n");
printf("\t[-?] display this message\n"); printf("\t[-?] display this message\n");
@ -47,11 +47,11 @@ PrintUsage(VOID)
printf("\t[-o] Builds for WOW64\n"); printf("\t[-o] Builds for WOW64\n");
printf("\t[-s] Generate Source files (no build)\n\n"); printf("\t[-s] Generate Source files (no build)\n\n");
printf("\tFILE The source keyboard file (required)\n\n"); printf("\tFILE The source keyboard file (required)\n\n");
/* Extra hints */ /* Extra hints */
printf("\t-u/-a are mutually exclusive; kbdutool will use the last one if you specify more than one.\n"); printf("\t-u/-a are mutually exclusive; kbdutool will use the last one if you specify more than one.\n");
printf("\t-i/-x/-m/-o-s will exhibit the same behavior when than one of them is specified.\n\n"); printf("\t-i/-x/-m/-o-s will exhibit the same behavior when than one of them is specified.\n\n");
/* Quit */ /* Quit */
exit(1); exit(1);
printf("should not be here"); printf("should not be here");
@ -65,18 +65,18 @@ main(INT argc,
CHAR Option; CHAR Option;
PCHAR OpenFlags; PCHAR OpenFlags;
CHAR BuildOptions[16] = {0}; CHAR BuildOptions[16] = {0};
/* Loop for parameter */ /* Loop for parameter */
for (i = 1; i < argc; ++i) for (i = 1; i < argc; ++i)
{ {
if (argv[i][0] != '/' && argv[i][0] != '-') if (argv[i][0] != '/' && argv[i][0] != '-')
break; break;
if (argv[i][1] && !argv[i][2]) if (argv[i][1] && !argv[i][2])
Option = argv[i][1]; Option = argv[i][1];
else else
Option = 0; Option = 0;
/* Check supported options */ /* Check supported options */
switch (Option) switch (Option)
{ {
@ -85,74 +85,74 @@ main(INT argc,
case 'a': case 'a':
UnicodeFile = 0; UnicodeFile = 0;
break; break;
/* UNICODE File */ /* UNICODE File */
case 'U': case 'U':
case 'u': case 'u':
UnicodeFile = 1; UnicodeFile = 1;
break; break;
/* Verbose */ /* Verbose */
case 'V': case 'V':
case 'v': case 'v':
Verbose = 1; Verbose = 1;
break; break;
/* No logo */ /* No logo */
case 'N': case 'N':
case 'n': case 'n':
NoLogo = 1; NoLogo = 1;
break; break;
/* Fallback driver */ /* Fallback driver */
case 'K': case 'K':
case 'k': case 'k':
FallbackDriver = 1; FallbackDriver = 1;
break; break;
/* Sanity Check */ /* Sanity Check */
case 'W': case 'W':
case 'w': case 'w':
SanityCheck = 1; SanityCheck = 1;
break; break;
/* Itanium */ /* Itanium */
case 'I': case 'I':
case 'i': case 'i':
BuildType = 1; BuildType = 1;
break; break;
/* X86 */ /* X86 */
case 'X': case 'X':
case 'x': case 'x':
BuildType = 0; BuildType = 0;
break; break;
/* AMD64 */ /* AMD64 */
case 'M': case 'M':
case 'm': case 'm':
BuildType = 2; BuildType = 2;
break; break;
/* WOW64 */ /* WOW64 */
case 'O': case 'O':
case 'o': case 'o':
BuildType = 3; BuildType = 3;
break; break;
/* Source only */ /* Source only */
case 'S': case 'S':
case 's': case 's':
SourceOnly = 1; SourceOnly = 1;
break; break;
default: default:
/* If you got here, the options are invalid or missing */ /* If you got here, the options are invalid or missing */
PrintUsage(); PrintUsage();
break; break;
} }
} }
/* Do we have no options? */ /* Do we have no options? */
if (i == argc) PrintUsage(); if (i == argc) PrintUsage();
@ -163,14 +163,14 @@ main(INT argc,
printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n", printf("\nKbdTool v%d.%02d - convert keyboard text file to C file or a keyboard layout DLL\n\n",
gVersion, gSubVersion); gVersion, gSubVersion);
} }
/* Save the file name */ /* Save the file name */
gpszFileName = argv[i]; gpszFileName = argv[i];
/* Open either as binary or text */ /* Open either as binary or text */
OpenFlags = "rb"; OpenFlags = "rb";
if (!UnicodeFile) OpenFlags = "rt"; if (!UnicodeFile) OpenFlags = "rt";
/* Open a handle to the file */ /* Open a handle to the file */
gfpInput = fopen(gpszFileName, OpenFlags); gfpInput = fopen(gpszFileName, OpenFlags);
if (!gfpInput) if (!gfpInput)
@ -179,7 +179,7 @@ main(INT argc,
printf("Unable to open '%s' for read.\n", gpszFileName); printf("Unable to open '%s' for read.\n", gpszFileName);
exit(1); exit(1);
} }
/* Should we print out what we're doing? */ /* Should we print out what we're doing? */
if (!NoLogo) if (!NoLogo)
{ {
@ -197,7 +197,7 @@ main(INT argc,
/* Print the appropriate message depending on what was chosen */ /* Print the appropriate message depending on what was chosen */
case 0: case 0:
strcpy(BuildOptions, "i386/x86"); strcpy(BuildOptions, "i386/x86");
break; break;
case 1: case 1:
strcpy(BuildOptions, "ia64"); strcpy(BuildOptions, "ia64");
break; break;
@ -212,17 +212,17 @@ main(INT argc,
break; break;
} }
} }
/* Now inform the user */ /* Now inform the user */
printf("Compiling layout information from '%s' for %s.\n", gpszFileName, BuildOptions); printf("Compiling layout information from '%s' for %s.\n", gpszFileName, BuildOptions);
} }
/* Now parse the keywords */ /* Now parse the keywords */
FailureCode = DoParsing(); FailureCode = DoParsing();
/* Should we build? */ /* Should we build? */
if (!(SourceOnly) && !(FallbackDriver)) ErrorCode = 0;//DoBuild(); if (!(SourceOnly) && !(FallbackDriver)) ErrorCode = 0;//DoBuild();
/* Did everything work? */ /* Did everything work? */
if (FailureCode == 0) if (FailureCode == 0)
{ {
@ -234,7 +234,7 @@ main(INT argc,
/* Print the failure code */ /* Print the failure code */
printf("\n %13d\n", FailureCode); printf("\n %13d\n", FailureCode);
} }
/* Return the error code */ /* Return the error code */
return ErrorCode; return ErrorCode;
} }

View file

@ -26,7 +26,7 @@ WChName(IN ULONG Char,
IN BOOLEAN AddZero) IN BOOLEAN AddZero)
{ {
PCHAR p; PCHAR p;
/* Check for invalid character */ /* Check for invalid character */
if (Char == -1) if (Char == -1)
{ {
@ -37,19 +37,19 @@ WChName(IN ULONG Char,
{ {
/* Use our global buffer */ /* Use our global buffer */
p = gCharName; p = gCharName;
/* Add the first quote unless this was a zero-string */ /* Add the first quote unless this was a zero-string */
if (!AddZero) *p++ = '\''; if (!AddZero) *p++ = '\'';
/* Now replace any other quote or comment character with a slash */ /* Now replace any other quote or comment character with a slash */
if ((Char == '\"') || (Char == '\'') || (Char == '\\')) *p++ = '\\'; if ((Char == '\"') || (Char == '\'') || (Char == '\\')) *p++ = '\\';
/* Now plug in the character */ /* Now plug in the character */
*p++ = Char; *p++ = Char;
/* And add the terminating quote, unless this was a zero-string */ /* And add the terminating quote, unless this was a zero-string */
if (!AddZero) *p++ = '\''; if (!AddZero) *p++ = '\'';
/* Terminate the buffer */ /* Terminate the buffer */
*p = '\0'; *p = '\0';
} }
@ -82,7 +82,7 @@ WChName(IN ULONG Char,
sprintf(gCharName, "\\x%04x", Char); sprintf(gCharName, "\\x%04x", Char);
} }
} }
/* Return the name */ /* Return the name */
return gCharName; return gCharName;
} }
@ -93,26 +93,26 @@ PrintNameTable(FILE* FileHandle,
BOOL DeadKey) BOOL DeadKey)
{ {
CHAR CharBuffer[255]; CHAR CharBuffer[255];
PKEYNAME NextName; PKEYNAME NextName;
PCHAR Name, Buffer; PCHAR Name, Buffer;
ULONG i; ULONG i;
/* Loop all key names */ /* Loop all key names */
while (KeyName) while (KeyName)
{ {
/* Go to the next key name */ /* Go to the next key name */
NextName = KeyName->Next; NextName = KeyName->Next;
/* Remember the name and our buffer address */ /* Remember the name and our buffer address */
Name = KeyName->Name; Name = KeyName->Name;
Buffer = CharBuffer; Buffer = CharBuffer;
/* Check if it's an IDS name */ /* Check if it's an IDS name */
if (strncmp(Name, "IDS_", 4)) if (strncmp(Name, "IDS_", 4))
{ {
/* No, so start parsing it. First, handle initial quote */ /* No, so start parsing it. First, handle initial quote */
if (*Name != '\"') *Buffer++ = '\"'; if (*Name != '\"') *Buffer++ = '\"';
/* Next, parse the name */ /* Next, parse the name */
while (*Name) while (*Name)
{ {
@ -130,7 +130,7 @@ PrintNameTable(FILE* FileHandle,
/* Copy 6 characters */ /* Copy 6 characters */
for (i = 0; (*Name) && (i < 6); i++) *Buffer++ = *Name++; for (i = 0; (*Name) && (i < 6); i++) *Buffer++ = *Name++;
} }
/* Check if we still have something at the end */ /* Check if we still have something at the end */
if (*Name) if (*Name)
{ {
@ -142,10 +142,10 @@ PrintNameTable(FILE* FileHandle,
} }
} }
} }
/* Check for terminating quote */ /* Check for terminating quote */
if (*(Buffer - 1) != '\"') *Buffer++ = '\"'; if (*(Buffer - 1) != '\"') *Buffer++ = '\"';
/* Terminate the buffer */ /* Terminate the buffer */
*Buffer++ = '\0'; *Buffer++ = '\0';
} }
@ -168,15 +168,15 @@ PrintNameTable(FILE* FileHandle,
/* Print the entry */ /* Print the entry */
fprintf(FileHandle, " 0x%02x, L%s,\n", KeyName->Code, CharBuffer); fprintf(FileHandle, " 0x%02x, L%s,\n", KeyName->Code, CharBuffer);
} }
/* Cleanup allocation */ /* Cleanup allocation */
free(KeyName->Name); free(KeyName->Name);
free(KeyName); free(KeyName);
/* Move on */ /* Move on */
KeyName = NextName; KeyName = NextName;
} }
/* Is this a dead key? */ /* Is this a dead key? */
if (DeadKey) if (DeadKey)
{ {
@ -199,11 +199,11 @@ kbd_h(IN PLAYOUT Layout)
ULONG i; ULONG i;
CHAR UndefChar; CHAR UndefChar;
USHORT SubCode; USHORT SubCode;
/* Build the keyboard name */ /* Build the keyboard name */
strcpy(OutputFile, gKBDName); strcpy(OutputFile, gKBDName);
strcat(OutputFile, ".H"); strcat(OutputFile, ".H");
/* Open it */ /* Open it */
FileHandle = fopen(OutputFile, "wt"); FileHandle = fopen(OutputFile, "wt");
if (!FileHandle) if (!FileHandle)
@ -212,7 +212,7 @@ kbd_h(IN PLAYOUT Layout)
printf(" %12s : can't open for write.\n", OutputFile); printf(" %12s : can't open for write.\n", OutputFile);
return FALSE; return FALSE;
} }
/* Print the module header */ /* Print the module header */
fprintf(FileHandle, fprintf(FileHandle,
"/****************************** Module Header ******************************\\\n" "/****************************** Module Header ******************************\\\n"
@ -228,7 +228,7 @@ kbd_h(IN PLAYOUT Layout)
gVersion, gVersion,
gSubVersion, gSubVersion,
asctime(Now)); asctime(Now));
/* Print out the includes and defines */ /* Print out the includes and defines */
fprintf(FileHandle, fprintf(FileHandle,
"/*\n" "/*\n"
@ -239,7 +239,7 @@ kbd_h(IN PLAYOUT Layout)
"* Include the basis of all keyboard table values\n" "* Include the basis of all keyboard table values\n"
"*/\n" "*/\n"
"#include \"kbd.h\"\n"); "#include \"kbd.h\"\n");
/* Now print out the virtual key conversion table */ /* Now print out the virtual key conversion table */
fprintf(FileHandle, fprintf(FileHandle,
"/***************************************************************************\\\n" "/***************************************************************************\\\n"
@ -253,7 +253,7 @@ kbd_h(IN PLAYOUT Layout)
"* | Scan | | kbd | kbd | kbd | kbd | kbd | kbd |\n" "* | Scan | | kbd | kbd | kbd | kbd | kbd | kbd |\n"
"* | code | | type 1 | type 2 | type 3 | type 4 | type 5 | type 6 |\n" "* | code | | type 1 | type 2 | type 3 | type 4 | type 5 | type 6 |\n"
"\\****+-------+_+----------+----------+----------+----------+----------+----------+*/\n\n"); "\\****+-------+_+----------+----------+----------+----------+----------+----------+*/\n\n");
/* Loop all keys */ /* Loop all keys */
for (i = 0; i < 110; i++) for (i = 0; i < 110; i++)
{ {
@ -282,7 +282,7 @@ kbd_h(IN PLAYOUT Layout)
printf("Weird scancode value %04x: expected xx, E0xx, or E1xx\n", SubCode); printf("Weird scancode value %04x: expected xx, E0xx, or E1xx\n", SubCode);
exit(1); exit(1);
} }
/* Extended 1 */ /* Extended 1 */
UndefChar = 'Y'; UndefChar = 'Y';
} }
@ -292,7 +292,7 @@ kbd_h(IN PLAYOUT Layout)
/* Normal key */ /* Normal key */
UndefChar = 'T'; UndefChar = 'T';
} }
/* Print out the virtual key redefinition */ /* Print out the virtual key redefinition */
fprintf(FileHandle, fprintf(FileHandle,
"#undef %c%02X\n#define %c%02X _EQ(%43s%23s\n", "#undef %c%02X\n#define %c%02X _EQ(%43s%23s\n",
@ -302,14 +302,14 @@ kbd_h(IN PLAYOUT Layout)
Layout->Entry[i].ScanCode, Layout->Entry[i].ScanCode,
getVKName(Layout->Entry[i].VirtualKey, 0), getVKName(Layout->Entry[i].VirtualKey, 0),
")"); ")");
} }
} }
} }
/* Cleanup and close */ /* Cleanup and close */
fprintf(FileHandle,"\n"); fprintf(FileHandle,"\n");
fclose(FileHandle); fclose(FileHandle);
/* We made it */ /* We made it */
return TRUE; return TRUE;
} }
@ -325,13 +325,13 @@ kbd_rc(IN PKEYNAME DescriptionData,
ULONG Length; ULONG Length;
PCHAR p; PCHAR p;
PKEYNAME NextDescription, NextLanguage; PKEYNAME NextDescription, NextLanguage;
/* Build the keyboard name and internal name */ /* Build the keyboard name and internal name */
strcpy(OutputFile, gKBDName); strcpy(OutputFile, gKBDName);
strcat(OutputFile, ".RC"); strcat(OutputFile, ".RC");
strcpy(InternalName, gKBDName); strcpy(InternalName, gKBDName);
for (p = InternalName; *p; p++) *p = tolower(*p); for (p = InternalName; *p; p++) *p = tolower(*p);
/* Open it */ /* Open it */
FileHandle = fopen(OutputFile, "wb"); FileHandle = fopen(OutputFile, "wb");
if (!FileHandle) if (!FileHandle)
@ -340,24 +340,24 @@ kbd_rc(IN PKEYNAME DescriptionData,
printf(" %12s : can't open for write.\n", OutputFile); printf(" %12s : can't open for write.\n", OutputFile);
return FALSE; return FALSE;
} }
/* Check if we have copyright */ /* Check if we have copyright */
Length = strlen(gCopyright); Length = strlen(gCopyright);
if (!Length) if (!Length)
{ {
/* Set time string */ /* Set time string */
strftime(TimeBuffer, 5, "%Y", Now); strftime(TimeBuffer, 5, "%Y", Now);
/* Add copyright character */ /* Add copyright character */
strcpy(gCopyright, "(C)"); strcpy(gCopyright, "(C)");
/* Add the year */ /* Add the year */
strcat(gCopyright, TimeBuffer); strcat(gCopyright, TimeBuffer);
/* Add blank company */ /* Add blank company */
strcat(gCopyright, " "); strcat(gCopyright, " ");
} }
/* Write the resource file header */ /* Write the resource file header */
fprintf(FileHandle, fprintf(FileHandle,
"#include \"winver.h\"\r\n" "#include \"winver.h\"\r\n"
@ -385,7 +385,7 @@ kbd_rc(IN PKEYNAME DescriptionData,
gDescription, gDescription,
gVersion, gVersion,
gSubVersion); gSubVersion);
/* Continue writing it */ /* Continue writing it */
fprintf(FileHandle, fprintf(FileHandle,
" VALUE \"InternalName\", \"%s (%d.%d)\\0\"\r\n" " VALUE \"InternalName\", \"%s (%d.%d)\\0\"\r\n"
@ -410,7 +410,7 @@ kbd_rc(IN PKEYNAME DescriptionData,
InternalName, InternalName,
gVersion, gVersion,
gSubVersion); gSubVersion);
/* Now check if we have a locale name */ /* Now check if we have a locale name */
Length = strlen(gLocaleName); Length = strlen(gLocaleName);
if (Length) if (Length)
@ -421,7 +421,7 @@ kbd_rc(IN PKEYNAME DescriptionData,
9, 9,
1); 1);
fprintf(FileHandle, "BEGIN\r\n"); fprintf(FileHandle, "BEGIN\r\n");
/* Language or locale? */ /* Language or locale? */
if (strchr(gLocaleName, '\"')) if (strchr(gLocaleName, '\"'))
{ {
@ -433,24 +433,24 @@ kbd_rc(IN PKEYNAME DescriptionData,
/* Write the locale name */ /* Write the locale name */
fprintf(FileHandle, " %d \"%s\"\r\n", gStringIdForLocaleName, gLocaleName); fprintf(FileHandle, " %d \"%s\"\r\n", gStringIdForLocaleName, gLocaleName);
} }
/* Terminate the entry */ /* Terminate the entry */
fprintf(FileHandle, "END\r\n\r\n"); fprintf(FileHandle, "END\r\n\r\n");
} }
/* Check for description information */ /* Check for description information */
while (DescriptionData) while (DescriptionData)
{ {
/* Remember the next pointer */ /* Remember the next pointer */
NextDescription = DescriptionData->Next; NextDescription = DescriptionData->Next;
/* Write the header */ /* Write the header */
fprintf(FileHandle, fprintf(FileHandle,
"\r\nSTRINGTABLE DISCARDABLE\r\nLANGUAGE %d, %d\r\n", "\r\nSTRINGTABLE DISCARDABLE\r\nLANGUAGE %d, %d\r\n",
DescriptionData->Code & 0x3FF, DescriptionData->Code & 0x3FF,
DescriptionData->Code >> 10); DescriptionData->Code >> 10);
fprintf(FileHandle, "BEGIN\r\n"); fprintf(FileHandle, "BEGIN\r\n");
/* Quoted string or not? */ /* Quoted string or not? */
if (strchr(DescriptionData->Name, '\"')) if (strchr(DescriptionData->Name, '\"'))
{ {
@ -462,31 +462,31 @@ kbd_rc(IN PKEYNAME DescriptionData,
/* Write the description name */ /* Write the description name */
fprintf(FileHandle, " %d \"%s\"\r\n", gStringIdForDescriptions, DescriptionData->Name); fprintf(FileHandle, " %d \"%s\"\r\n", gStringIdForDescriptions, DescriptionData->Name);
} }
/* Terminate the entry */ /* Terminate the entry */
fprintf(FileHandle, "END\r\n\r\n"); fprintf(FileHandle, "END\r\n\r\n");
/* Free the allocation */ /* Free the allocation */
free(DescriptionData->Name); free(DescriptionData->Name);
free(DescriptionData); free(DescriptionData);
/* Move to the next entry */ /* Move to the next entry */
DescriptionData = NextDescription; DescriptionData = NextDescription;
} }
/* Check for language information */ /* Check for language information */
while (LanguageData) while (LanguageData)
{ {
/* Remember the next pointer */ /* Remember the next pointer */
NextLanguage = LanguageData->Next; NextLanguage = LanguageData->Next;
/* Write the header */ /* Write the header */
fprintf(FileHandle, fprintf(FileHandle,
"\r\nSTRINGTABLE DISCARDABLE\r\nLANGUAGE %d, %d\r\n", "\r\nSTRINGTABLE DISCARDABLE\r\nLANGUAGE %d, %d\r\n",
LanguageData->Code & 0x3FF, LanguageData->Code & 0x3FF,
LanguageData->Code >> 10); LanguageData->Code >> 10);
fprintf(FileHandle, "BEGIN\r\n"); fprintf(FileHandle, "BEGIN\r\n");
/* Quoted string or not? */ /* Quoted string or not? */
if (strchr(LanguageData->Name, '\"')) if (strchr(LanguageData->Name, '\"'))
{ {
@ -498,18 +498,18 @@ kbd_rc(IN PKEYNAME DescriptionData,
/* Write the language name */ /* Write the language name */
fprintf(FileHandle, " %d \"%s\"\r\n", gStringIdForLanguageNames, LanguageData->Name); fprintf(FileHandle, " %d \"%s\"\r\n", gStringIdForLanguageNames, LanguageData->Name);
} }
/* Terminate the entry */ /* Terminate the entry */
fprintf(FileHandle, "END\r\n\r\n"); fprintf(FileHandle, "END\r\n\r\n");
/* Free the allocation */ /* Free the allocation */
free(LanguageData->Name); free(LanguageData->Name);
free(LanguageData); free(LanguageData);
/* Move to the next entry */ /* Move to the next entry */
LanguageData = NextLanguage; LanguageData = NextLanguage;
} }
/* We're done! */ /* We're done! */
fclose(FileHandle); fclose(FileHandle);
return TRUE; return TRUE;
@ -520,11 +520,11 @@ kbd_def(VOID)
{ {
CHAR OutputFile[13]; CHAR OutputFile[13];
FILE *FileHandle; FILE *FileHandle;
/* Build the keyboard name and internal name */ /* Build the keyboard name and internal name */
strcpy(OutputFile, gKBDName); strcpy(OutputFile, gKBDName);
strcat(OutputFile, ".DEF"); strcat(OutputFile, ".DEF");
/* Open it */ /* Open it */
FileHandle = fopen(OutputFile, "wt"); FileHandle = fopen(OutputFile, "wt");
if (!FileHandle) if (!FileHandle)
@ -533,14 +533,14 @@ kbd_def(VOID)
printf(" %12s : can't open for write.\n", OutputFile); printf(" %12s : can't open for write.\n", OutputFile);
return FALSE; return FALSE;
} }
/* Write the file exports */ /* Write the file exports */
fprintf(FileHandle, fprintf(FileHandle,
"LIBRARY %s\n\n" "LIBRARY %s\n\n"
"EXPORTS\n" "EXPORTS\n"
" KbdLayerDescriptor @1\n", " KbdLayerDescriptor @1\n",
gKBDName); gKBDName);
/* Clean up */ /* Clean up */
fclose(FileHandle); fclose(FileHandle);
return TRUE; return TRUE;
@ -567,11 +567,11 @@ kbd_c(IN ULONG StateCount,
ULONG HighestState; ULONG HighestState;
PVKNAME Entry; PVKNAME Entry;
PCHAR p; PCHAR p;
/* Build the keyboard name and internal name */ /* Build the keyboard name and internal name */
strcpy(OutputFile, gKBDName); strcpy(OutputFile, gKBDName);
strcat(OutputFile, ".C"); strcat(OutputFile, ".C");
/* Open it */ /* Open it */
FileHandle = fopen(OutputFile, "wt"); FileHandle = fopen(OutputFile, "wt");
if (!FileHandle) if (!FileHandle)
@ -580,7 +580,7 @@ kbd_c(IN ULONG StateCount,
printf(" %12s : can't open for write.\n", OutputFile); printf(" %12s : can't open for write.\n", OutputFile);
return FALSE; return FALSE;
} }
/* Print the header */ /* Print the header */
fprintf(FileHandle, fprintf(FileHandle,
"/***************************************************************************\\\n" "/***************************************************************************\\\n"
@ -595,7 +595,7 @@ kbd_c(IN ULONG StateCount,
gVersion, gVersion,
gSubVersion, gSubVersion,
asctime(Now)); asctime(Now));
/* What kind of driver is this? */ /* What kind of driver is this? */
if (FallbackDriver) if (FallbackDriver)
{ {
@ -609,7 +609,7 @@ kbd_c(IN ULONG StateCount,
"#include <windows.h>\n" "#include <windows.h>\n"
"#include \"kbd.h\"\n" "#include \"kbd.h\"\n"
"#include \"%s.h\"\n\n", "#include \"%s.h\"\n\n",
gKBDName); gKBDName);
} }
/* What kind of driver is this? */ /* What kind of driver is this? */
@ -641,7 +641,7 @@ kbd_c(IN ULONG StateCount,
"/***************************************************************************\\\n" "/***************************************************************************\\\n"
"* ausVK[] - Virtual Scan Code to Virtual Key conversion table\n" "* ausVK[] - Virtual Scan Code to Virtual Key conversion table\n"
"\\***************************************************************************/\n\n"); "\\***************************************************************************/\n\n");
/* Table begin */ /* Table begin */
fprintf(FileHandle, fprintf(FileHandle,
"static ALLOC_SECTION_LDATA USHORT ausVK[] = {\n" "static ALLOC_SECTION_LDATA USHORT ausVK[] = {\n"
@ -652,7 +652,7 @@ kbd_c(IN ULONG StateCount,
" T20, T21, T22, T23, T24, T25, T26, T27,\n" " T20, T21, T22, T23, T24, T25, T26, T27,\n"
" T28, T29, T2A, T2B, T2C, T2D, T2E, T2F,\n" " T28, T29, T2A, T2B, T2C, T2D, T2E, T2F,\n"
" T30, T31, T32, T33, T34, T35,\n\n"); " T30, T31, T32, T33, T34, T35,\n\n");
/* Table continue */ /* Table continue */
fprintf(FileHandle, fprintf(FileHandle,
" /*\n" " /*\n"
@ -662,7 +662,7 @@ kbd_c(IN ULONG StateCount,
" T37 | KBDMULTIVK, // numpad_* + Shift/Alt -> SnapShot\n\n" " T37 | KBDMULTIVK, // numpad_* + Shift/Alt -> SnapShot\n\n"
" T38, T39, T3A, T3B, T3C, T3D, T3E,\n" " T38, T39, T3A, T3B, T3C, T3D, T3E,\n"
" T3F, T40, T41, T42, T43, T44,\n\n"); " T3F, T40, T41, T42, T43, T44,\n\n");
/* Table continue */ /* Table continue */
fprintf(FileHandle, fprintf(FileHandle,
" /*\n" " /*\n"
@ -672,7 +672,7 @@ kbd_c(IN ULONG StateCount,
" */\n" " */\n"
" T45 | KBDEXT | KBDMULTIVK,\n\n" " T45 | KBDEXT | KBDMULTIVK,\n\n"
" T46 | KBDMULTIVK,\n\n"); " T46 | KBDMULTIVK,\n\n");
/* Numpad table */ /* Numpad table */
fprintf(FileHandle, fprintf(FileHandle,
" /*\n" " /*\n"
@ -693,7 +693,7 @@ kbd_c(IN ULONG StateCount,
" T51 | KBDNUMPAD | KBDSPECIAL, // Numpad 3 (PgDn),\n" " T51 | KBDNUMPAD | KBDSPECIAL, // Numpad 3 (PgDn),\n"
" T52 | KBDNUMPAD | KBDSPECIAL, // Numpad 0 (Ins),\n" " T52 | KBDNUMPAD | KBDSPECIAL, // Numpad 0 (Ins),\n"
" T53 | KBDNUMPAD | KBDSPECIAL, // Numpad . (Del),\n\n"); " T53 | KBDNUMPAD | KBDSPECIAL, // Numpad . (Del),\n\n");
/* Table finish */ /* Table finish */
fprintf(FileHandle, fprintf(FileHandle,
" T54, T55, T56, T57, T58, T59, T5A, T5B,\n" " T54, T55, T56, T57, T58, T59, T5A, T5B,\n"
@ -703,10 +703,10 @@ kbd_c(IN ULONG StateCount,
" T74, T75, T76, T77, T78, T79, T7A, T7B,\n" " T74, T75, T76, T77, T78, T79, T7A, T7B,\n"
" T7C, T7D, T7E\n\n" " T7C, T7D, T7E\n\n"
"};\n\n"); "};\n\n");
/* Key name table header */ /* Key name table header */
fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_VK aE0VscToVk[] = {\n"); fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_VK aE0VscToVk[] = {\n");
/* Loop 110-key table */ /* Loop 110-key table */
for (i = 0; i < 110; i++) for (i = 0; i < 110; i++)
{ {
@ -729,13 +729,13 @@ kbd_c(IN ULONG StateCount,
} }
} }
} }
/* Key name table finish */ /* Key name table finish */
fprintf(FileHandle, " { 0, 0 }\n};\n\n"); fprintf(FileHandle, " { 0, 0 }\n};\n\n");
/* Extended key name table header */ /* Extended key name table header */
fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_VK aE1VscToVk[] = {\n"); fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_VK aE1VscToVk[] = {\n");
/* Loop 110-key table */ /* Loop 110-key table */
for (i = 0; i < 110; i++) for (i = 0; i < 110; i++)
{ {
@ -758,12 +758,12 @@ kbd_c(IN ULONG StateCount,
} }
} }
} }
/* Extended key name table finish */ /* Extended key name table finish */
fprintf(FileHandle, fprintf(FileHandle,
" { 0x1D, Y1D }, // Pause\n" " { 0x1D, Y1D }, // Pause\n"
" { 0 , 0 }\n};\n\n"); " { 0 , 0 }\n};\n\n");
/* Modifier table description */ /* Modifier table description */
fprintf(FileHandle, fprintf(FileHandle,
"/***************************************************************************\\\n" "/***************************************************************************\\\n"
@ -776,10 +776,10 @@ kbd_c(IN ULONG StateCount,
"* CTRL (L & R) is used to generate control characters\n" "* CTRL (L & R) is used to generate control characters\n"
"* ALT (L & R) used for generating characters by number with numpad\n" "* ALT (L & R) used for generating characters by number with numpad\n"
"\\***************************************************************************/\n"); "\\***************************************************************************/\n");
/* Modifier table header */ /* Modifier table header */
fprintf(FileHandle, "static ALLOC_SECTION_LDATA VK_TO_BIT aVkToBits[] = {\n"); fprintf(FileHandle, "static ALLOC_SECTION_LDATA VK_TO_BIT aVkToBits[] = {\n");
/* Loop modifier table */ /* Loop modifier table */
i = 0; i = 0;
Entry = &Modifiers[0]; Entry = &Modifiers[0];
@ -790,14 +790,14 @@ kbd_c(IN ULONG StateCount,
" { %-12s, %-12s },\n", " { %-12s, %-12s },\n",
getVKName(Entry->VirtualKey, 1), getVKName(Entry->VirtualKey, 1),
Entry->Name); Entry->Name);
/* Move to the next one */ /* Move to the next one */
Entry = &Modifiers[++i]; Entry = &Modifiers[++i];
} }
/* Modifier table finish */ /* Modifier table finish */
fprintf(FileHandle, " { 0, 0 }\n};\n\n"); fprintf(FileHandle, " { 0, 0 }\n};\n\n");
/* Modifier conversion table description */ /* Modifier conversion table description */
fprintf(FileHandle, fprintf(FileHandle,
"/***************************************************************************\\\n" "/***************************************************************************\\\n"
@ -806,10 +806,10 @@ kbd_c(IN ULONG StateCount,
"* See kbd.h for a full description.\n" "* See kbd.h for a full description.\n"
"*\n" "*\n"
"\\***************************************************************************/\n\n"); "\\***************************************************************************/\n\n");
/* Zero out local state data */ /* Zero out local state data */
for (i = 0; i < 8; i++) States[i] = -1; for (i = 0; i < 8; i++) States[i] = -1;
/* Find the highest set state */ /* Find the highest set state */
for (HighestState = 1, i = 0; (i < 8) && (ShiftStates[i] != -1); i++) for (HighestState = 1, i = 0; (i < 8) && (ShiftStates[i] != -1); i++)
{ {
@ -817,7 +817,7 @@ kbd_c(IN ULONG StateCount,
States[ShiftStates[i]] = i; States[ShiftStates[i]] = i;
if (ShiftStates[i] > HighestState) HighestState = ShiftStates[i]; if (ShiftStates[i] > HighestState) HighestState = ShiftStates[i];
} }
/* Modifier conversion table header */ /* Modifier conversion table header */
fprintf(FileHandle, fprintf(FileHandle,
"static ALLOC_SECTION_LDATA MODIFIERS CharModifiers = {\n" "static ALLOC_SECTION_LDATA MODIFIERS CharModifiers = {\n"
@ -827,7 +827,7 @@ kbd_c(IN ULONG StateCount,
" // Modification# // Keys Pressed\n" " // Modification# // Keys Pressed\n"
" // ============= // =============\n", " // ============= // =============\n",
HighestState); HighestState);
/* Loop states */ /* Loop states */
for (i = 0; i <= HighestState; i++) for (i = 0; i <= HighestState; i++)
{ {
@ -843,14 +843,14 @@ kbd_c(IN ULONG StateCount,
if (i == HighestState) if (i == HighestState)
{ {
/* Last state header */ /* Last state header */
fprintf(FileHandle, " %d // ", States[i]); fprintf(FileHandle, " %d // ", States[i]);
} }
else else
{ {
/* Normal state header */ /* Normal state header */
fprintf(FileHandle, " %d, // ", States[i]); fprintf(FileHandle, " %d, // ", States[i]);
} }
/* State 1 or higher? */ /* State 1 or higher? */
if (i >= 1) if (i >= 1)
{ {
@ -864,34 +864,34 @@ kbd_c(IN ULONG StateCount,
fprintf(FileHandle, "+"); fprintf(FileHandle, "+");
NeedPlus = FALSE; NeedPlus = FALSE;
} }
/* Check if it's time to add a modifier */ /* Check if it's time to add a modifier */
if (i & k) if (i & k)
{ {
/* Get the key state name and copy it into our buffer */ /* Get the key state name and copy it into our buffer */
strcpy(KeyNameBuffer, getVKName(Modifiers[j].VirtualKey, 1)); strcpy(KeyNameBuffer, getVKName(Modifiers[j].VirtualKey, 1));
/* Go go the 4th char (past the "KBD") and lower name */ /* Go go the 4th char (past the "KBD") and lower name */
for (p = &KeyNameBuffer[4]; *p; p++) *p = tolower(*p); for (p = &KeyNameBuffer[4]; *p; p++) *p = tolower(*p);
/* Print it */ /* Print it */
fprintf(FileHandle, "%s", &KeyNameBuffer[3]); fprintf(FileHandle, "%s", &KeyNameBuffer[3]);
/* We'll need a plus sign next */ /* We'll need a plus sign next */
NeedPlus = TRUE; NeedPlus = TRUE;
} }
} }
} }
/* Terminate the entry */ /* Terminate the entry */
fprintf(FileHandle, "\n"); fprintf(FileHandle, "\n");
} }
} }
/* Modifier conversion table end */ /* Modifier conversion table end */
fprintf(FileHandle," }\n" "};\n\n"); fprintf(FileHandle," }\n" "};\n\n");
/* Shift state translation table description */ /* Shift state translation table description */
fprintf(FileHandle, fprintf(FileHandle,
"/***************************************************************************\\\n" "/***************************************************************************\\\n"
@ -899,7 +899,7 @@ kbd_c(IN ULONG StateCount,
"* aVkToWch2[] - Virtual Key to WCHAR translation for 2 shift states\n" "* aVkToWch2[] - Virtual Key to WCHAR translation for 2 shift states\n"
"* aVkToWch3[] - Virtual Key to WCHAR translation for 3 shift states\n" "* aVkToWch3[] - Virtual Key to WCHAR translation for 3 shift states\n"
"* aVkToWch4[] - Virtual Key to WCHAR translation for 4 shift states\n"); "* aVkToWch4[] - Virtual Key to WCHAR translation for 4 shift states\n");
/* Check if there's exta shift states */ /* Check if there's exta shift states */
for (i = 5; i < HighestState; i++) for (i = 5; i < HighestState; i++)
{ {
@ -909,7 +909,7 @@ kbd_c(IN ULONG StateCount,
i, i,
i); i);
} }
/* Shift state translation table description continue */ /* Shift state translation table description continue */
fprintf(FileHandle, fprintf(FileHandle,
"*\n" "*\n"
@ -931,7 +931,7 @@ kbd_c(IN ULONG StateCount,
"* WCH_LGTR - Ligature (generates multiple characters)\n" "* WCH_LGTR - Ligature (generates multiple characters)\n"
"*\n" "*\n"
"\\***************************************************************************/\n\n"); "\\***************************************************************************/\n\n");
/* Loop all the states */ /* Loop all the states */
for (i = 2; i <= StateCount; i++) for (i = 2; i <= StateCount; i++)
{ {
@ -945,42 +945,42 @@ kbd_c(IN ULONG StateCount,
if (i == Layout->Entry[j].StateCount) break; if (i == Layout->Entry[j].StateCount) break;
} }
} }
/* Print the table header */ /* Print the table header */
fprintf(FileHandle, fprintf(FileHandle,
"static ALLOC_SECTION_LDATA VK_TO_WCHARS%d aVkToWch%d[] = {\n" "static ALLOC_SECTION_LDATA VK_TO_WCHARS%d aVkToWch%d[] = {\n"
"// | | Shift |", "// | | Shift |",
i, i,
i); i);
/* Print the correct state label */ /* Print the correct state label */
for (k = 2; k < i; k++) fprintf(FileHandle, "%-9.9s|", for (k = 2; k < i; k++) fprintf(FileHandle, "%-9.9s|",
StateLabel[ShiftStates[k]]); StateLabel[ShiftStates[k]]);
/* Print the next separator */ /* Print the next separator */
fprintf(FileHandle, "\n// |=========|=========|"); fprintf(FileHandle, "\n// |=========|=========|");
/* Check for extra states and print their separators too */ /* Check for extra states and print their separators too */
for (k = 2; k < i; k++) fprintf(FileHandle, "=========|"); for (k = 2; k < i; k++) fprintf(FileHandle, "=========|");
/* Finalize the separator header */ /* Finalize the separator header */
fprintf(FileHandle, "\n"); fprintf(FileHandle, "\n");
/* Loop all the scan codes */ /* Loop all the scan codes */
for (j = 0; j < 110; j++) for (j = 0; j < 110; j++)
{ {
/* Check if this is the state for the entry */ /* Check if this is the state for the entry */
if (i != Layout->Entry[j].StateCount) continue; if (i != Layout->Entry[j].StateCount) continue;
/* Print out the entry for this key */ /* Print out the entry for this key */
fprintf(FileHandle, fprintf(FileHandle,
" {%-13s,%-7s", " {%-13s,%-7s",
getVKName(Layout->Entry[j].VirtualKey, 1), getVKName(Layout->Entry[j].VirtualKey, 1),
CapState[Layout->Entry[j].Cap]); CapState[Layout->Entry[j].Cap]);
/* Initialize the buffer for this line */ /* Initialize the buffer for this line */
*LineBuffer = '\0'; *LineBuffer = '\0';
/* Loop states */ /* Loop states */
for (k = 0; k < i; k++) for (k = 0; k < i; k++)
{ {
@ -991,7 +991,7 @@ kbd_c(IN ULONG StateCount,
printf("Dead key data not supported!\n"); printf("Dead key data not supported!\n");
exit(1); exit(1);
} }
/* Check if it's a ligature key */ /* Check if it's a ligature key */
if (Layout->Entry[j].LigatureCharData[k]) if (Layout->Entry[j].LigatureCharData[k])
{ {
@ -999,19 +999,19 @@ kbd_c(IN ULONG StateCount,
printf("Ligature key data not supported!\n"); printf("Ligature key data not supported!\n");
exit(1); exit(1);
} }
/* Print out the WCH_ name */ /* Print out the WCH_ name */
fprintf(FileHandle, fprintf(FileHandle,
",%-9s", ",%-9s",
WChName(Layout->Entry[j].CharData[k], 0)); WChName(Layout->Entry[j].CharData[k], 0));
/* If we have something on the line buffer by now, add WCH_NONE */ /* If we have something on the line buffer by now, add WCH_NONE */
if (*LineBuffer != '\0') strcpy(LineBuffer, "WCH_NONE "); if (*LineBuffer != '\0') strcpy(LineBuffer, "WCH_NONE ");
} }
/* Finish the line */ /* Finish the line */
fprintf(FileHandle, "},\n"); fprintf(FileHandle, "},\n");
/* Do we have any data at all? */ /* Do we have any data at all? */
if (*LineBuffer != '\0') if (*LineBuffer != '\0')
{ {
@ -1019,15 +1019,15 @@ kbd_c(IN ULONG StateCount,
fprintf(FileHandle, "%s},\n", LineBuffer); fprintf(FileHandle, "%s},\n", LineBuffer);
continue; continue;
} }
/* Otherwise, we're done, unless this requires SGCAP data */ /* Otherwise, we're done, unless this requires SGCAP data */
if (Layout->Entry[j].Cap != 2) continue; if (Layout->Entry[j].Cap != 2) continue;
/* Not yet supported */ /* Not yet supported */
printf("SGCAP not yet supported!\n"); printf("SGCAP not yet supported!\n");
exit(1); exit(1);
} }
/* Did we only have two states? */ /* Did we only have two states? */
if (i == 2) if (i == 2)
{ {
@ -1039,7 +1039,7 @@ kbd_c(IN ULONG StateCount,
" {VK_MULTIPLY ,0 ,'*' ,'*' },\n" " {VK_MULTIPLY ,0 ,'*' ,'*' },\n"
" {VK_SUBTRACT ,0 ,'-' ,'-' },\n"); " {VK_SUBTRACT ,0 ,'-' ,'-' },\n");
} }
/* Terminate the table */ /* Terminate the table */
fprintf(FileHandle, " {0 ,0 "); fprintf(FileHandle, " {0 ,0 ");
for (k = 0; k < i; k++) fprintf(FileHandle, ",0 "); for (k = 0; k < i; k++) fprintf(FileHandle, ",0 ");
@ -1047,7 +1047,7 @@ kbd_c(IN ULONG StateCount,
/* Terminate the structure */ /* Terminate the structure */
fprintf(FileHandle, "}\n" "};\n\n"); fprintf(FileHandle, "}\n" "};\n\n");
} }
/* Numpad translation table */ /* Numpad translation table */
fprintf(FileHandle, fprintf(FileHandle,
"// Put this last so that VkKeyScan interprets number characters\n" "// Put this last so that VkKeyScan interprets number characters\n"
@ -1066,10 +1066,10 @@ kbd_c(IN ULONG StateCount,
" { VK_NUMPAD9 , 0 , '9' },\n" " { VK_NUMPAD9 , 0 , '9' },\n"
" { 0 , 0 , '\\0' }\n" " { 0 , 0 , '\\0' }\n"
"};\n\n"); "};\n\n");
/* Translation tables header */ /* Translation tables header */
fprintf(FileHandle,"static ALLOC_SECTION_LDATA VK_TO_WCHAR_TABLE aVkToWcharTable[] = {\n"); fprintf(FileHandle,"static ALLOC_SECTION_LDATA VK_TO_WCHAR_TABLE aVkToWcharTable[] = {\n");
/* Loop states higher than 3 */ /* Loop states higher than 3 */
for (i = 3; i <= StateCount; i++) for (i = 3; i <= StateCount; i++)
{ {
@ -1080,14 +1080,14 @@ kbd_c(IN ULONG StateCount,
i, i,
i); i);
} }
/* Array of translation tables */ /* Array of translation tables */
fprintf(FileHandle, fprintf(FileHandle,
" { (PVK_TO_WCHARS1)aVkToWch2, 2, sizeof(aVkToWch2[0]) },\n" " { (PVK_TO_WCHARS1)aVkToWch2, 2, sizeof(aVkToWch2[0]) },\n"
" { (PVK_TO_WCHARS1)aVkToWch1, 1, sizeof(aVkToWch1[0]) },\n" " { (PVK_TO_WCHARS1)aVkToWch1, 1, sizeof(aVkToWch1[0]) },\n"
" { NULL, 0, 0 },\n" " { NULL, 0, 0 },\n"
"};\n\n"); "};\n\n");
/* Scan code to key name conversion table description */ /* Scan code to key name conversion table description */
fprintf(FileHandle, fprintf(FileHandle,
"/***************************************************************************\\\n" "/***************************************************************************\\\n"
@ -1098,33 +1098,33 @@ kbd_c(IN ULONG StateCount,
"* Only the names of Extended, NumPad, Dead and Non-Printable keys are here.\n" "* Only the names of Extended, NumPad, Dead and Non-Printable keys are here.\n"
"* (Keys producing printable characters are named by that character)\n" "* (Keys producing printable characters are named by that character)\n"
"\\***************************************************************************/\n\n"); "\\***************************************************************************/\n\n");
/* Check for key name data */ /* Check for key name data */
if (KeyNameData) if (KeyNameData)
{ {
/* Table header */ /* Table header */
fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_LPWSTR aKeyNames[] = {\n"); fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_LPWSTR aKeyNames[] = {\n");
/* Print table */ /* Print table */
PrintNameTable(FileHandle, KeyNameData, FALSE); PrintNameTable(FileHandle, KeyNameData, FALSE);
/* Table end */ /* Table end */
fprintf(FileHandle, "};\n\n"); fprintf(FileHandle, "};\n\n");
} }
/* Check for extended key name data */ /* Check for extended key name data */
if (KeyNameExtData) if (KeyNameExtData)
{ {
/* Table header */ /* Table header */
fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_LPWSTR aKeyNamesExt[] = {\n"); fprintf(FileHandle, "static ALLOC_SECTION_LDATA VSC_LPWSTR aKeyNamesExt[] = {\n");
/* Print table */ /* Print table */
PrintNameTable(FileHandle, KeyNameExtData, FALSE); PrintNameTable(FileHandle, KeyNameExtData, FALSE);
/* Table end */ /* Table end */
fprintf(FileHandle, "};\n\n"); fprintf(FileHandle, "};\n\n");
} }
/* Check for dead key name data */ /* Check for dead key name data */
if (KeyNameDeadData) if (KeyNameDeadData)
{ {
@ -1132,7 +1132,7 @@ kbd_c(IN ULONG StateCount,
printf("Dead key name data not supported!\n"); printf("Dead key name data not supported!\n");
exit(1); exit(1);
} }
/* Check for dead key data */ /* Check for dead key data */
if (DeadKeyData) if (DeadKeyData)
{ {
@ -1140,7 +1140,7 @@ kbd_c(IN ULONG StateCount,
printf("Dead key data not supported!\n"); printf("Dead key data not supported!\n");
exit(1); exit(1);
} }
/* Check for ligature data */ /* Check for ligature data */
if (LigatureData) if (LigatureData)
{ {
@ -1148,10 +1148,10 @@ kbd_c(IN ULONG StateCount,
printf("Ligature key data not supported!\n"); printf("Ligature key data not supported!\n");
exit(1); exit(1);
} }
/* Main keyboard table descriptor type */ /* Main keyboard table descriptor type */
fprintf(FileHandle, "static "); fprintf(FileHandle, "static ");
/* FIXME? */ /* FIXME? */
/* Main keyboard table descriptor header */ /* Main keyboard table descriptor header */
@ -1169,7 +1169,7 @@ kbd_c(IN ULONG StateCount,
" * Diacritics\n" " * Diacritics\n"
" */\n", " */\n",
FallbackDriver ? "Fallback" : "" ); FallbackDriver ? "Fallback" : "" );
/* Descriptor dead key data section */ /* Descriptor dead key data section */
if (DeadKeyData) if (DeadKeyData)
{ {
@ -1179,13 +1179,13 @@ kbd_c(IN ULONG StateCount,
{ {
fprintf(FileHandle, " NULL,\n\n"); fprintf(FileHandle, " NULL,\n\n");
} }
/* Descriptor key name comment */ /* Descriptor key name comment */
fprintf(FileHandle, fprintf(FileHandle,
" /*\n" " /*\n"
" * Names of Keys\n" " * Names of Keys\n"
" */\n"); " */\n");
/* Descriptor key name section */ /* Descriptor key name section */
if (KeyNameData) if (KeyNameData)
{ {
@ -1195,7 +1195,7 @@ kbd_c(IN ULONG StateCount,
{ {
fprintf(FileHandle, " NULL,\n"); fprintf(FileHandle, " NULL,\n");
} }
/* Descriptor extended key name section */ /* Descriptor extended key name section */
if (KeyNameExtData) if (KeyNameExtData)
{ {
@ -1205,7 +1205,7 @@ kbd_c(IN ULONG StateCount,
{ {
fprintf(FileHandle, " NULL,\n"); fprintf(FileHandle, " NULL,\n");
} }
/* Descriptor dead key name section */ /* Descriptor dead key name section */
if ((DeadKeyData) && (KeyNameDeadData)) if ((DeadKeyData) && (KeyNameDeadData))
{ {
@ -1215,7 +1215,7 @@ kbd_c(IN ULONG StateCount,
{ {
fprintf(FileHandle, " NULL,\n\n"); fprintf(FileHandle, " NULL,\n\n");
} }
/* Descriptor conversion table section */ /* Descriptor conversion table section */
fprintf(FileHandle, fprintf(FileHandle,
" /*\n" " /*\n"
@ -1228,15 +1228,15 @@ kbd_c(IN ULONG StateCount,
" /*\n" " /*\n"
" * Locale-specific special processing\n" " * Locale-specific special processing\n"
" */\n"); " */\n");
/* FIXME: AttributeData and KLLF_ALTGR stuff */ /* FIXME: AttributeData and KLLF_ALTGR stuff */
/* Descriptor locale-specific section */ /* Descriptor locale-specific section */
fprintf(FileHandle, " MAKELONG(%s, KBD_VERSION),\n\n", "0"); /* FIXME */ fprintf(FileHandle, " MAKELONG(%s, KBD_VERSION),\n\n", "0"); /* FIXME */
/* Descriptor ligature data comment */ /* Descriptor ligature data comment */
fprintf(FileHandle, " /*\n * Ligatures\n */\n %d,\n", 0); /* FIXME */ fprintf(FileHandle, " /*\n * Ligatures\n */\n %d,\n", 0); /* FIXME */
/* Descriptor ligature data section */ /* Descriptor ligature data section */
if (!LigatureData) if (!LigatureData)
{ {
@ -1251,7 +1251,7 @@ kbd_c(IN ULONG StateCount,
/* Descriptor finish */ /* Descriptor finish */
fprintf(FileHandle, "};\n\n"); fprintf(FileHandle, "};\n\n");
/* Keyboard layout callback function */ /* Keyboard layout callback function */
if (!FallbackDriver) fprintf(FileHandle, if (!FallbackDriver) fprintf(FileHandle,
"PKBDTABLES KbdLayerDescriptor(VOID)\n" "PKBDTABLES KbdLayerDescriptor(VOID)\n"
@ -1287,11 +1287,11 @@ DoOutput(IN ULONG StateCount,
{ {
/* It's not, create header file */ /* It's not, create header file */
if (!kbd_h(&g_Layout)) FailureCode = 1; if (!kbd_h(&g_Layout)) FailureCode = 1;
/* Create the resource file */ /* Create the resource file */
if (!kbd_rc(DescriptionData, LanguageData)) FailureCode = 2; if (!kbd_rc(DescriptionData, LanguageData)) FailureCode = 2;
} }
/* Create the C file */ /* Create the C file */
if (!kbd_c(StateCount, if (!kbd_c(StateCount,
ShiftStates, ShiftStates,
@ -1306,14 +1306,14 @@ DoOutput(IN ULONG StateCount,
/* Failed in C file generation */ /* Failed in C file generation */
FailureCode = 3; FailureCode = 3;
} }
/* Check if this just a fallback driver*/ /* Check if this just a fallback driver*/
if (!FallbackDriver) if (!FallbackDriver)
{ {
/* Generate the definition file */ /* Generate the definition file */
if (!kbd_def()) FailureCode = 4; if (!kbd_def()) FailureCode = 4;
} }
/* Done */ /* Done */
return FailureCode; return FailureCode;
} }

View file

@ -53,10 +53,10 @@ ULONG
isKeyWord(PCHAR p) isKeyWord(PCHAR p)
{ {
ULONG i; ULONG i;
/* Check if we know this keyword */ /* Check if we know this keyword */
for (i = 0; i < KEYWORD_COUNT; i++) if (strcmp(KeyWordList[i], p) == 0) break; for (i = 0; i < KEYWORD_COUNT; i++) if (strcmp(KeyWordList[i], p) == 0) break;
/* If we didn't find anything, i will be KEYWORD_COUNT, which is invalid */ /* If we didn't find anything, i will be KEYWORD_COUNT, which is invalid */
return i; return i;
} }
@ -66,7 +66,7 @@ getVKName(IN ULONG VirtualKey,
IN BOOLEAN Prefix) IN BOOLEAN Prefix)
{ {
ULONG i; ULONG i;
/* Loop for standard virtual key */ /* Loop for standard virtual key */
if (((VirtualKey >= 'A') && (VirtualKey <= 'Z')) || if (((VirtualKey >= 'A') && (VirtualKey <= 'Z')) ||
((VirtualKey >= '0') && (VirtualKey <= '9'))) ((VirtualKey >= '0') && (VirtualKey <= '9')))
@ -78,7 +78,7 @@ getVKName(IN ULONG VirtualKey,
gVKeyName[3] = '\0'; gVKeyName[3] = '\0';
return gVKeyName; return gVKeyName;
} }
/* Check if a prefix is required */ /* Check if a prefix is required */
if (Prefix) if (Prefix)
{ {
@ -90,7 +90,7 @@ getVKName(IN ULONG VirtualKey,
/* Otherwise, don't add anything */ /* Otherwise, don't add anything */
strcpy(gVKeyName, ""); strcpy(gVKeyName, "");
} }
/* Loop all virtual keys */ /* Loop all virtual keys */
for (i = 0; i < 36; i++) for (i = 0; i < 36; i++)
{ {
@ -102,7 +102,7 @@ getVKName(IN ULONG VirtualKey,
return gVKeyName; return gVKeyName;
} }
} }
/* If we got here, then we failed, so print out an error name */ /* If we got here, then we failed, so print out an error name */
strcpy(gVKeyName, "#ERROR#"); strcpy(gVKeyName, "#ERROR#");
return gVKeyName; return gVKeyName;
@ -114,11 +114,11 @@ getVKNum(IN PCHAR p)
ULONG Length; ULONG Length;
ULONG i; ULONG i;
ULONG KeyNumber; ULONG KeyNumber;
/* Compute the length of the string */ /* Compute the length of the string */
Length = strlen(p); Length = strlen(p);
if (!Length) return -1; if (!Length) return -1;
/* Check if this is is a simple key */ /* Check if this is is a simple key */
if (Length == 1) if (Length == 1)
{ {
@ -127,10 +127,10 @@ getVKNum(IN PCHAR p)
/* Otherwise, convert the letter to upper case */ /* Otherwise, convert the letter to upper case */
*p = toupper(*p); *p = toupper(*p);
/* And make sure it's a valid letter */ /* And make sure it's a valid letter */
if ((*p >= 'A') && (*p <='Z')) return *p; if ((*p >= 'A') && (*p <='Z')) return *p;
/* Otherwise, fail */ /* Otherwise, fail */
return -1; return -1;
} }
@ -141,7 +141,7 @@ getVKNum(IN PCHAR p)
/* Check if we have a match */ /* Check if we have a match */
if (!strcmp(VKName[i].Name, p)) return VKName[i].VirtualKey; if (!strcmp(VKName[i].Name, p)) return VKName[i].VirtualKey;
} }
/* Check if this is a hex string */ /* Check if this is a hex string */
if ((*p == '0') && ((*(p + 1) == 'x') || (*(p + 1) == 'X'))) if ((*p == '0') && ((*(p + 1) == 'x') || (*(p + 1) == 'X')))
{ {
@ -163,10 +163,10 @@ getCharacterInfo(IN PCHAR State,
ULONG CharInfo = CHAR_NORMAL_KEY; ULONG CharInfo = CHAR_NORMAL_KEY;
UCHAR StateChar; UCHAR StateChar;
ULONG CharCode; ULONG CharCode;
/* Calculate the length of the state */ /* Calculate the length of the state */
Length = strlen(State); Length = strlen(State);
/* Check if this is at least a simple key state */ /* Check if this is at least a simple key state */
if (Length > 1) if (Length > 1)
{ {
@ -183,7 +183,7 @@ getCharacterInfo(IN PCHAR State,
CharInfo = CHAR_OTHER_KEY; CharInfo = CHAR_OTHER_KEY;
} }
} }
/* Check if this is a numerical key state */ /* Check if this is a numerical key state */
if ((Length - 1) >= 2) if ((Length - 1) >= 2)
{ {
@ -194,7 +194,7 @@ getCharacterInfo(IN PCHAR State,
{ {
/* Handle a ligature key */ /* Handle a ligature key */
CharInfo = CHAR_LIGATURE_KEY; CharInfo = CHAR_LIGATURE_KEY;
/* Not yet handled */ /* Not yet handled */
printf("Ligatured character entries not yet supported!\n"); printf("Ligatured character entries not yet supported!\n");
exit(1); exit(1);
@ -225,29 +225,29 @@ getCharacterInfo(IN PCHAR State,
/* Return the type of character this is */ /* Return the type of character this is */
return CharInfo; return CharInfo;
} }
BOOLEAN BOOLEAN
NextLine(PCHAR LineBuffer, NextLine(PCHAR LineBuffer,
ULONG BufferSize, ULONG BufferSize,
FILE *File) FILE *File)
{ {
PCHAR p, pp; PCHAR p, pp;
/* Scan each line */ /* Scan each line */
while (fgets(LineBuffer, BufferSize, File)) while (fgets(LineBuffer, BufferSize, File))
{ {
/* Remember it */ /* Remember it */
gLineCount++; gLineCount++;
/* Reset the pointer at the beginning of the line */ /* Reset the pointer at the beginning of the line */
p = LineBuffer; p = LineBuffer;
/* Now bypass all whitespace (and tabspace) */ /* Now bypass all whitespace (and tabspace) */
while ((*p) && ((*p == ' ') || (*p == '\t'))) p++; while ((*p) && ((*p == ' ') || (*p == '\t'))) p++;
/* If this is an old-style comment, skip the line */ /* If this is an old-style comment, skip the line */
if (*p == ';') continue; if (*p == ';') continue;
/* Otherwise, check for new-style comment */ /* Otherwise, check for new-style comment */
pp = strstr(p, "//"); pp = strstr(p, "//");
if (pp) if (pp)
@ -262,11 +262,11 @@ NextLine(PCHAR LineBuffer,
p = strchr(p, '\n'); p = strchr(p, '\n');
if (p) *p = '\0'; if (p) *p = '\0';
} }
/* We have a line! */ /* We have a line! */
return TRUE; return TRUE;
} }
/* No line found */ /* No line found */
return FALSE; return FALSE;
} }
@ -276,7 +276,7 @@ SkipLines(VOID)
{ {
ULONG KeyWord; ULONG KeyWord;
CHAR KeyWordChars[32]; CHAR KeyWordChars[32];
/* Scan each line, skipping it if it's not a keyword */ /* Scan each line, skipping it if it's not a keyword */
while (NextLine(gBuf, sizeof(gBuf), gfpInput)) while (NextLine(gBuf, sizeof(gBuf), gfpInput))
{ {
@ -288,21 +288,21 @@ SkipLines(VOID)
if (KeyWord < KEYWORD_COUNT) return KeyWord; if (KeyWord < KEYWORD_COUNT) return KeyWord;
} }
} }
/* We skipped all the possible lines, not finding anything */ /* We skipped all the possible lines, not finding anything */
return KEYWORD_COUNT; return KEYWORD_COUNT;
} }
ULONG ULONG
DoKBD(VOID) DoKBD(VOID)
{ {
/* On Unicode files, we need to find the Unicode marker (FEEF) */ /* On Unicode files, we need to find the Unicode marker (FEEF) */
ASSERT(UnicodeFile == FALSE); ASSERT(UnicodeFile == FALSE);
/* Initial values */ /* Initial values */
*gKBDName = '\0'; *gKBDName = '\0';
*gDescription = '\0'; *gDescription = '\0';
/* Scan for the values */ /* Scan for the values */
if (sscanf(gBuf, "KBD %8s \"%40[^\"]\" %d", gKBDName, gDescription, &gID) < 2) if (sscanf(gBuf, "KBD %8s \"%40[^\"]\" %d", gKBDName, gDescription, &gID) < 2)
{ {
@ -310,7 +310,7 @@ DoKBD(VOID)
printf("Unable to read keyboard name or description.\n"); printf("Unable to read keyboard name or description.\n");
exit(1); exit(1);
} }
/* Debug only */ /* Debug only */
DPRINT1("KBD Name: [%8s] Description: [%40s] ID: [%d]\n", gKBDName, gDescription, gID); DPRINT1("KBD Name: [%8s] Description: [%40s] ID: [%d]\n", gKBDName, gDescription, gID);
return SkipLines(); return SkipLines();
@ -318,14 +318,14 @@ DoKBD(VOID)
ULONG ULONG
DoVERSION(VOID) DoVERSION(VOID)
{ {
/* Scan for the value */ /* Scan for the value */
if (sscanf(gBuf, "VERSION %d", &gKbdLayoutVersion) < 1) if (sscanf(gBuf, "VERSION %d", &gKbdLayoutVersion) < 1)
{ {
/* Couldn't find them */ /* Couldn't find them */
printf("Unable to read keyboard version information.\n"); printf("Unable to read keyboard version information.\n");
} }
/* Debug only */ /* Debug only */
DPRINT1("VERSION [%d]\n", gKbdLayoutVersion); DPRINT1("VERSION [%d]\n", gKbdLayoutVersion);
return SkipLines(); return SkipLines();
@ -333,17 +333,17 @@ DoVERSION(VOID)
ULONG ULONG
DoCOPYRIGHT(VOID) DoCOPYRIGHT(VOID)
{ {
/* Initial values */ /* Initial values */
*gCopyright = '\0'; *gCopyright = '\0';
/* Scan for the value */ /* Scan for the value */
if (sscanf(gBuf, "COPYRIGHT \"%40[^\"]\"", gCopyright) < 1) if (sscanf(gBuf, "COPYRIGHT \"%40[^\"]\"", gCopyright) < 1)
{ {
/* Couldn't find them */ /* Couldn't find them */
printf("Unable to read the specified COPYRIGHT string.\n"); printf("Unable to read the specified COPYRIGHT string.\n");
} }
/* Debug only */ /* Debug only */
DPRINT1("COPYRIGHT [%40s]\n", gCopyright); DPRINT1("COPYRIGHT [%40s]\n", gCopyright);
return SkipLines(); return SkipLines();
@ -351,17 +351,17 @@ DoCOPYRIGHT(VOID)
ULONG ULONG
DoCOMPANY(VOID) DoCOMPANY(VOID)
{ {
/* Initial values */ /* Initial values */
*gCompany = '\0'; *gCompany = '\0';
/* Scan for the value */ /* Scan for the value */
if (sscanf(gBuf, "COMPANY \"%85[^\"]\"", gCompany) < 1) if (sscanf(gBuf, "COMPANY \"%85[^\"]\"", gCompany) < 1)
{ {
/* Couldn't find them */ /* Couldn't find them */
printf("Unable to read the specified COMPANY name.\n"); printf("Unable to read the specified COMPANY name.\n");
} }
/* Debug only */ /* Debug only */
DPRINT1("COMPANY [%85s]\n", gCompany); DPRINT1("COMPANY [%85s]\n", gCompany);
return SkipLines(); return SkipLines();
@ -369,17 +369,17 @@ DoCOMPANY(VOID)
ULONG ULONG
DoLOCALENAME(VOID) DoLOCALENAME(VOID)
{ {
/* Initial values */ /* Initial values */
*gLocaleName = '\0'; *gLocaleName = '\0';
/* Scan for the value */ /* Scan for the value */
if (sscanf(gBuf, "LOCALENAME \"%40[^\"]\"", gLocaleName) < 1) if (sscanf(gBuf, "LOCALENAME \"%40[^\"]\"", gLocaleName) < 1)
{ {
/* Couldn't find them */ /* Couldn't find them */
printf("Unable to read the specified COPYRIGHT string.\n"); printf("Unable to read the specified COPYRIGHT string.\n");
} }
/* Debug only */ /* Debug only */
DPRINT1("LOCALENAME [%40s]\n", gLocaleName); DPRINT1("LOCALENAME [%40s]\n", gLocaleName);
return SkipLines(); return SkipLines();
@ -393,23 +393,23 @@ DoDESCRIPTIONS(IN PKEYNAME* DescriptionData)
ULONG LanguageCode; ULONG LanguageCode;
PCHAR p, pp; PCHAR p, pp;
PKEYNAME Description; PKEYNAME Description;
/* Assume nothing */ /* Assume nothing */
*DescriptionData = 0; *DescriptionData = 0;
/* Start scanning */ /* Start scanning */
while (NextLine(gBuf, 256, gfpInput)) while (NextLine(gBuf, 256, gfpInput))
{ {
/* Search for token */ /* Search for token */
if (sscanf(gBuf, "%s", Token) != 1) continue; if (sscanf(gBuf, "%s", Token) != 1) continue;
/* Make sure it's not just a comment */ /* Make sure it's not just a comment */
if (*Token == ';') continue; if (*Token == ';') continue;
/* Make sure it's not a keyword */ /* Make sure it's not a keyword */
KeyWord = isKeyWord(Token); KeyWord = isKeyWord(Token);
if (KeyWord < KEYWORD_COUNT) break; if (KeyWord < KEYWORD_COUNT) break;
/* Now scan for the language code */ /* Now scan for the language code */
if (sscanf(Token, " %4x", &LanguageCode) != 1) if (sscanf(Token, " %4x", &LanguageCode) != 1)
{ {
@ -417,7 +417,7 @@ DoDESCRIPTIONS(IN PKEYNAME* DescriptionData)
printf("An invalid LANGID was specified.\n"); printf("An invalid LANGID was specified.\n");
continue; continue;
} }
/* Now get the actual description */ /* Now get the actual description */
if (sscanf(gBuf, " %*4x %s[^\n]", Token) != 1) if (sscanf(gBuf, " %*4x %s[^\n]", Token) != 1)
{ {
@ -425,15 +425,15 @@ DoDESCRIPTIONS(IN PKEYNAME* DescriptionData)
printf("A language description is missing.\n"); printf("A language description is missing.\n");
continue; continue;
} }
/* Get the description string and find the ending */ /* Get the description string and find the ending */
p = strstr(gBuf, Token); p = strstr(gBuf, Token);
pp = strchr(p, '\n'); pp = strchr(p, '\n');
if (!pp) pp = strchr(p, '\r'); if (!pp) pp = strchr(p, '\r');
/* Terminate the description string here */ /* Terminate the description string here */
if (pp) *pp = 0; if (pp) *pp = 0;
/* Now allocate the description */ /* Now allocate the description */
Description = malloc(sizeof(KEYNAME)); Description = malloc(sizeof(KEYNAME));
if (!Description) if (!Description)
@ -442,15 +442,15 @@ DoDESCRIPTIONS(IN PKEYNAME* DescriptionData)
printf("Unable to allocate the KEYNAME struct (out of memory?).\n"); printf("Unable to allocate the KEYNAME struct (out of memory?).\n");
exit(1); exit(1);
} }
/* Fill out the structure */ /* Fill out the structure */
Description->Code = LanguageCode; Description->Code = LanguageCode;
Description->Name = strdup(p); Description->Name = strdup(p);
Description->Next = NULL; Description->Next = NULL;
/* Debug only */ /* Debug only */
DPRINT1("LANGID: [%4x] Description: [%s]\n", Description->Code, Description->Name); DPRINT1("LANGID: [%4x] Description: [%s]\n", Description->Code, Description->Name);
/* Point to it and advance the pointer */ /* Point to it and advance the pointer */
*DescriptionData = Description; *DescriptionData = Description;
DescriptionData = &Description->Next; DescriptionData = &Description->Next;
@ -468,23 +468,23 @@ DoLANGUAGENAMES(IN PKEYNAME* LanguageData)
ULONG LanguageCode; ULONG LanguageCode;
PCHAR p, pp; PCHAR p, pp;
PKEYNAME Language; PKEYNAME Language;
/* Assume nothing */ /* Assume nothing */
*LanguageData = 0; *LanguageData = 0;
/* Start scanning */ /* Start scanning */
while (NextLine(gBuf, 256, gfpInput)) while (NextLine(gBuf, 256, gfpInput))
{ {
/* Search for token */ /* Search for token */
if (sscanf(gBuf, "%s", Token) != 1) continue; if (sscanf(gBuf, "%s", Token) != 1) continue;
/* Make sure it's not just a comment */ /* Make sure it's not just a comment */
if (*Token == ';') continue; if (*Token == ';') continue;
/* Make sure it's not a keyword */ /* Make sure it's not a keyword */
KeyWord = isKeyWord(Token); KeyWord = isKeyWord(Token);
if (KeyWord < KEYWORD_COUNT) break; if (KeyWord < KEYWORD_COUNT) break;
/* Now scan for the language code */ /* Now scan for the language code */
if (sscanf(Token, " %4x", &LanguageCode) != 1) if (sscanf(Token, " %4x", &LanguageCode) != 1)
{ {
@ -492,7 +492,7 @@ DoLANGUAGENAMES(IN PKEYNAME* LanguageData)
printf("An invalid LANGID was specified.\n"); printf("An invalid LANGID was specified.\n");
continue; continue;
} }
/* Now get the actual language */ /* Now get the actual language */
if (sscanf(gBuf, " %*4x %s[^\n]", Token) != 1) if (sscanf(gBuf, " %*4x %s[^\n]", Token) != 1)
{ {
@ -500,15 +500,15 @@ DoLANGUAGENAMES(IN PKEYNAME* LanguageData)
printf("A language name is missing\n"); printf("A language name is missing\n");
continue; continue;
} }
/* Get the language string and find the ending */ /* Get the language string and find the ending */
p = strstr(gBuf, Token); p = strstr(gBuf, Token);
pp = strchr(p, '\n'); pp = strchr(p, '\n');
if (!pp) pp = strchr(p, '\r'); if (!pp) pp = strchr(p, '\r');
/* Terminate the language string here */ /* Terminate the language string here */
if (pp) *pp = 0; if (pp) *pp = 0;
/* Now allocate the language */ /* Now allocate the language */
Language = malloc(sizeof(KEYNAME)); Language = malloc(sizeof(KEYNAME));
if (!Language) if (!Language)
@ -517,20 +517,20 @@ DoLANGUAGENAMES(IN PKEYNAME* LanguageData)
printf("Unable to allocate the KEYNAME struct (out of memory?).\n"); printf("Unable to allocate the KEYNAME struct (out of memory?).\n");
exit(1); exit(1);
} }
/* Fill out the structure */ /* Fill out the structure */
Language->Code = LanguageCode; Language->Code = LanguageCode;
Language->Name = strdup(p); Language->Name = strdup(p);
Language->Next = NULL; Language->Next = NULL;
/* Debug only */ /* Debug only */
DPRINT1("LANGID: [%4x] Name: [%s]\n", Language->Code, Language->Name); DPRINT1("LANGID: [%4x] Name: [%s]\n", Language->Code, Language->Name);
/* Point to it and advance the pointer */ /* Point to it and advance the pointer */
*LanguageData = Language; *LanguageData = Language;
LanguageData = &Language->Next; LanguageData = &Language->Next;
} }
/* We are done */ /* We are done */
return KeyWord; return KeyWord;
} }
@ -543,23 +543,23 @@ DoKEYNAME(IN PKEYNAME* KeyNameData)
ULONG CharacterCode; ULONG CharacterCode;
PCHAR p, pp; PCHAR p, pp;
PKEYNAME KeyName; PKEYNAME KeyName;
/* Assume nothing */ /* Assume nothing */
*KeyNameData = 0; *KeyNameData = 0;
/* Start scanning */ /* Start scanning */
while (NextLine(gBuf, 256, gfpInput)) while (NextLine(gBuf, 256, gfpInput))
{ {
/* Search for token */ /* Search for token */
if (sscanf(gBuf, "%s", Token) != 1) continue; if (sscanf(gBuf, "%s", Token) != 1) continue;
/* Make sure it's not just a comment */ /* Make sure it's not just a comment */
if (*Token == ';') continue; if (*Token == ';') continue;
/* Make sure it's not a keyword */ /* Make sure it's not a keyword */
KeyWord = isKeyWord(Token); KeyWord = isKeyWord(Token);
if (KeyWord < KEYWORD_COUNT) break; if (KeyWord < KEYWORD_COUNT) break;
/* Now scan for the character code */ /* Now scan for the character code */
if (sscanf(Token, " %4x", &CharacterCode) != 1) if (sscanf(Token, " %4x", &CharacterCode) != 1)
{ {
@ -567,7 +567,7 @@ DoKEYNAME(IN PKEYNAME* KeyNameData)
printf("An invalid character code was specified.\n"); printf("An invalid character code was specified.\n");
continue; continue;
} }
/* Now get the actual key name */ /* Now get the actual key name */
if (sscanf(gBuf, " %*4x %s[^\n]", Token) != 1) if (sscanf(gBuf, " %*4x %s[^\n]", Token) != 1)
{ {
@ -575,15 +575,15 @@ DoKEYNAME(IN PKEYNAME* KeyNameData)
printf("A key name is missing\n"); printf("A key name is missing\n");
continue; continue;
} }
/* Get the key name string and find the ending */ /* Get the key name string and find the ending */
p = strstr(gBuf, Token); p = strstr(gBuf, Token);
pp = strchr(p, '\n'); pp = strchr(p, '\n');
if (!pp) pp = strchr(p, '\r'); if (!pp) pp = strchr(p, '\r');
/* Terminate the key name string here */ /* Terminate the key name string here */
if (pp) *pp = 0; if (pp) *pp = 0;
/* Now allocate the language */ /* Now allocate the language */
KeyName = malloc(sizeof(KEYNAME)); KeyName = malloc(sizeof(KEYNAME));
if (!KeyName) if (!KeyName)
@ -592,22 +592,22 @@ DoKEYNAME(IN PKEYNAME* KeyNameData)
printf("Unable to allocate the KEYNAME struct (out of memory?).\n"); printf("Unable to allocate the KEYNAME struct (out of memory?).\n");
exit(1); exit(1);
} }
/* Fill out the structure */ /* Fill out the structure */
KeyName->Code = CharacterCode; KeyName->Code = CharacterCode;
KeyName->Name = strdup(p); KeyName->Name = strdup(p);
KeyName->Next = NULL; KeyName->Next = NULL;
/* Debug only */ /* Debug only */
DPRINT1("CHARCODE: [%4x] Name: [%s]\n", KeyName->Code, KeyName->Name); DPRINT1("CHARCODE: [%4x] Name: [%s]\n", KeyName->Code, KeyName->Name);
/* Point to it and advance the pointer */ /* Point to it and advance the pointer */
*KeyNameData = KeyName; *KeyNameData = KeyName;
KeyNameData = &KeyName->Next; KeyNameData = &KeyName->Next;
} }
/* We are done */ /* We are done */
return KeyWord; return KeyWord;
} }
ULONG ULONG
@ -618,23 +618,23 @@ DoSHIFTSTATE(IN PULONG StateCount,
ULONG i; ULONG i;
ULONG ShiftState; ULONG ShiftState;
CHAR Token[32]; CHAR Token[32];
/* Reset the shift states */ /* Reset the shift states */
for (i = 0; i < 8; i++) ShiftStates[i] = -1; for (i = 0; i < 8; i++) ShiftStates[i] = -1;
/* Start with no states */ /* Start with no states */
*StateCount = 0; *StateCount = 0;
/* Scan for shift states */ /* Scan for shift states */
while (NextLine(gBuf, 256, gfpInput)) while (NextLine(gBuf, 256, gfpInput))
{ {
/* Search for token */ /* Search for token */
if (sscanf(gBuf, "%s", Token) != 1) continue; if (sscanf(gBuf, "%s", Token) != 1) continue;
/* Make sure it's not a keyword */ /* Make sure it's not a keyword */
KeyWord = isKeyWord(Token); KeyWord = isKeyWord(Token);
if (KeyWord < KEYWORD_COUNT) break; if (KeyWord < KEYWORD_COUNT) break;
/* Now scan for the shift state */ /* Now scan for the shift state */
if (sscanf(gBuf, " %1s[012367]", Token) != 1) if (sscanf(gBuf, " %1s[012367]", Token) != 1)
{ {
@ -642,10 +642,10 @@ DoSHIFTSTATE(IN PULONG StateCount,
if (Verbose) printf("An invalid shift state '%s' was found (use 0, 1, 2, 3, 6, or 7.)\n", Token); if (Verbose) printf("An invalid shift state '%s' was found (use 0, 1, 2, 3, 6, or 7.)\n", Token);
continue; continue;
} }
/* Now read the state */ /* Now read the state */
ShiftState = atoi(Token); ShiftState = atoi(Token);
/* Scan existing states */ /* Scan existing states */
for (i = 0; i < *StateCount; i++) for (i = 0; i < *StateCount; i++)
{ {
@ -657,7 +657,7 @@ DoSHIFTSTATE(IN PULONG StateCount,
break; break;
} }
} }
/* Make sure we won't overflow */ /* Make sure we won't overflow */
if (*StateCount < 8) if (*StateCount < 8)
{ {
@ -670,12 +670,12 @@ DoSHIFTSTATE(IN PULONG StateCount,
if (Verbose) printf("There were too many states (you defined %d).\n", *StateCount); if (Verbose) printf("There were too many states (you defined %d).\n", *StateCount);
} }
} }
/* Debug only */ /* Debug only */
DPRINT1("Found %d Shift States: [", *StateCount); DPRINT1("Found %d Shift States: [", *StateCount);
for (i = 0; i < *StateCount; i++) DPRINT1("%d ", ShiftStates[i]); for (i = 0; i < *StateCount; i++) DPRINT1("%d ", ShiftStates[i]);
DPRINT1("]\n"); DPRINT1("]\n");
/* We are done */ /* We are done */
return KeyWord; return KeyWord;
} }
@ -727,24 +727,24 @@ DoLAYOUT(IN PLAYOUT LayoutData,
ULONG ScanCodeCount = -1; ULONG ScanCodeCount = -1;
PLAYOUTENTRY Entry; PLAYOUTENTRY Entry;
UCHAR CharacterType, LigatureChar; UCHAR CharacterType, LigatureChar;
/* Zero out the layout */ /* Zero out the layout */
memset(LayoutData, 0, sizeof(LAYOUT)); memset(LayoutData, 0, sizeof(LAYOUT));
/* Read each line */ /* Read each line */
Entry = &LayoutData->Entry[0]; Entry = &LayoutData->Entry[0];
while (NextLine(gBuf, 256, gfpInput)) while (NextLine(gBuf, 256, gfpInput))
{ {
/* Search for token */ /* Search for token */
if (sscanf(gBuf, "%s", Token) != 1) continue; if (sscanf(gBuf, "%s", Token) != 1) continue;
/* Make sure it's not just a comment */ /* Make sure it's not just a comment */
if (*Token == ';') continue; if (*Token == ';') continue;
/* Make sure it's not a keyword */ /* Make sure it's not a keyword */
KeyWord = isKeyWord(Token); KeyWord = isKeyWord(Token);
if (KeyWord < KEYWORD_COUNT) break; if (KeyWord < KEYWORD_COUNT) break;
/* Now read the entry */ /* Now read the entry */
TokenCount = sscanf(gBuf, " %x %s %s", &ScanCode, Token, Cap); TokenCount = sscanf(gBuf, " %x %s %s", &ScanCode, Token, Cap);
if (TokenCount == 3) if (TokenCount == 3)
@ -763,7 +763,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
/* Simplified layout with no cap */ /* Simplified layout with no cap */
FullEntry = FALSE; FullEntry = FALSE;
} }
/* One more */ /* One more */
DPRINT1("RAW ENTRY: [%x %s %s]\n", ScanCode, Token, Cap); DPRINT1("RAW ENTRY: [%x %s %s]\n", ScanCode, Token, Cap);
Entry++; Entry++;
@ -773,11 +773,11 @@ DoLAYOUT(IN PLAYOUT LayoutData,
printf("ScanCode %02x - too many scancodes here to parse.\n", ScanCode); printf("ScanCode %02x - too many scancodes here to parse.\n", ScanCode);
exit(1); exit(1);
} }
/* Fill out this entry */ /* Fill out this entry */
Entry->ScanCode = ScanCode; Entry->ScanCode = ScanCode;
Entry->LineCount = gLineCount; Entry->LineCount = gLineCount;
/* Loop scancode table */ /* Loop scancode table */
for (i = 0; i < 110; i++) for (i = 0; i < 110; i++)
{ {
@ -787,7 +787,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
{ {
/* New code */ /* New code */
if (Verbose) printf("A new scancode is being defined: 0x%2X, %s\n", Entry->ScanCode, Token); if (Verbose) printf("A new scancode is being defined: 0x%2X, %s\n", Entry->ScanCode, Token);
/* Fill out the entry */ /* Fill out the entry */
Entry->VirtualKey = getVKNum(Token); Entry->VirtualKey = getVKNum(Token);
break; break;
@ -801,7 +801,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
printf("Scancode %X was previously defined.\n", ScanCode); printf("Scancode %X was previously defined.\n", ScanCode);
exit(1); exit(1);
} }
/* Check if there is a valid virtual key */ /* Check if there is a valid virtual key */
if (ScVk[i].VirtualKey == 0xFFFF) if (ScVk[i].VirtualKey == 0xFFFF)
{ {
@ -809,24 +809,24 @@ DoLAYOUT(IN PLAYOUT LayoutData,
printf("The Scancode you tried to use (%X) is reserved.\n", ScanCode); printf("The Scancode you tried to use (%X) is reserved.\n", ScanCode);
exit(1); exit(1);
} }
/* Fill out the entry */ /* Fill out the entry */
Entry->OriginalVirtualKey = ScVk[i].VirtualKey; Entry->OriginalVirtualKey = ScVk[i].VirtualKey;
Entry->Name = ScVk[i].Name; Entry->Name = ScVk[i].Name;
break; break;
} }
} }
/* The entry is now processed */ /* The entry is now processed */
Entry->Processed = TRUE; Entry->Processed = TRUE;
ScVk[i].Processed = TRUE; ScVk[i].Processed = TRUE;
/* Get the virtual key from the entry */ /* Get the virtual key from the entry */
VirtualKey = getVKNum(Token); VirtualKey = getVKNum(Token);
Entry->VirtualKey = VirtualKey; Entry->VirtualKey = VirtualKey;
DPRINT1("ENTRY: [%x %x %x %s] with ", DPRINT1("ENTRY: [%x %x %x %s] with ",
Entry->VirtualKey, Entry->OriginalVirtualKey, Entry->ScanCode, Entry->Name); Entry->VirtualKey, Entry->OriginalVirtualKey, Entry->ScanCode, Entry->Name);
/* Make sure it's valid */ /* Make sure it's valid */
if (VirtualKey == 0xFFFF) if (VirtualKey == 0xFFFF)
{ {
@ -834,13 +834,13 @@ DoLAYOUT(IN PLAYOUT LayoutData,
if (Verbose) printf("An invalid Virtual Key '%s' was defined.\n", Token); if (Verbose) printf("An invalid Virtual Key '%s' was defined.\n", Token);
continue; continue;
} }
/* Is this a full entry */ /* Is this a full entry */
if (FullEntry) if (FullEntry)
{ {
/* Do we have SGCAP data? Set cap mode to 2 */ /* Do we have SGCAP data? Set cap mode to 2 */
if (!strcmp(Cap, "SGCAP")) *Cap = '2'; if (!strcmp(Cap, "SGCAP")) *Cap = '2';
/* Read the cap mode */ /* Read the cap mode */
if (sscanf(Cap, "%1d[012]", &Entry->Cap) != 1) if (sscanf(Cap, "%1d[012]", &Entry->Cap) != 1)
{ {
@ -849,7 +849,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
exit(1); exit(1);
} }
} }
/* Read the states */ /* Read the states */
Count = sscanf(gBuf, Count = sscanf(gBuf,
" %*s %*s %*s %s %s %s %s %s %s %s %s", " %*s %*s %*s %s %s %s %s %s %s %s %s",
@ -863,7 +863,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
State[7]); State[7]);
Entry->StateCount = Count; Entry->StateCount = Count;
DPRINT1("%d STATES: [", Count); DPRINT1("%d STATES: [", Count);
/* Check if there are less than 2 states */ /* Check if there are less than 2 states */
if ((Count < 2) && (FullEntry)) if ((Count < 2) && (FullEntry))
{ {
@ -871,7 +871,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
printf("You must have at least 2 characters.\n"); printf("You must have at least 2 characters.\n");
exit(1); exit(1);
} }
/* Loop all states */ /* Loop all states */
for (i = 0; i < Count; i++) for (i = 0; i < Count; i++)
{ {
@ -883,7 +883,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
Entry->CharData[i] = -1; Entry->CharData[i] = -1;
continue; continue;
} }
/* Otherwise, check what kind of character this is */ /* Otherwise, check what kind of character this is */
CharacterType = getCharacterInfo(State[i], CharacterType = getCharacterInfo(State[i],
&Entry->CharData[i], &Entry->CharData[i],
@ -899,16 +899,16 @@ DoLAYOUT(IN PLAYOUT LayoutData,
Entry->OtherCharData[i] = 1; Entry->OtherCharData[i] = 1;
} }
} }
/* Check for sanity checks */ /* Check for sanity checks */
DPRINT1("]\n"); DPRINT1("]\n");
if (SanityCheck) if (SanityCheck)
{ {
/* Not yet handled... */ /* Not yet handled... */
printf("Sanity checks not yet handled!\n"); printf("Sanity checks not yet handled!\n");
exit(1); exit(1);
} }
/* Check if we had SGCAP data */ /* Check if we had SGCAP data */
if (Entry->Cap & 2) if (Entry->Cap & 2)
{ {
@ -917,7 +917,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
exit(1); exit(1);
} }
} }
/* Process the scan code table */ /* Process the scan code table */
Entry = &LayoutData->Entry[ScanCodeCount]; Entry = &LayoutData->Entry[ScanCodeCount];
for (i = 0; i < 110; i++) for (i = 0; i < 110; i++)
@ -925,7 +925,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
/* Get the scan code */ /* Get the scan code */
CurrentCode = ScVk[i].ScanCode; CurrentCode = ScVk[i].ScanCode;
if (CurrentCode == 0xFFFF) break; if (CurrentCode == 0xFFFF) break;
/* Check if this entry had been processed */ /* Check if this entry had been processed */
if (ScVk[i].Processed) if (ScVk[i].Processed)
{ {
@ -939,9 +939,9 @@ DoLAYOUT(IN PLAYOUT LayoutData,
{ {
/* Fail */ /* Fail */
printf("ScanCode %02x - too many scancodes here to parse.\n", CurrentCode); printf("ScanCode %02x - too many scancodes here to parse.\n", CurrentCode);
exit(1); exit(1);
} }
/* Build an entry for it */ /* Build an entry for it */
Entry++; Entry++;
Entry->ScanCode = CurrentCode; Entry->ScanCode = CurrentCode;
@ -954,7 +954,7 @@ DoLAYOUT(IN PLAYOUT LayoutData,
Entry->VirtualKey, Entry->ScanCode, Entry->Name); Entry->VirtualKey, Entry->ScanCode, Entry->Name);
} }
} }
/* Skip what's left */ /* Skip what's left */
return KeyWord; return KeyWord;
} }
@ -969,7 +969,7 @@ DoParsing(VOID)
PKEYNAME DescriptionData = NULL, LanguageData = NULL; PKEYNAME DescriptionData = NULL, LanguageData = NULL;
PKEYNAME KeyNameData = NULL, KeyNameExtData = NULL, KeyNameDeadData = NULL; PKEYNAME KeyNameData = NULL, KeyNameExtData = NULL, KeyNameDeadData = NULL;
PVOID AttributeData = NULL, LigatureData = NULL, DeadKeyData = NULL; PVOID AttributeData = NULL, LigatureData = NULL, DeadKeyData = NULL;
/* Parse keywords */ /* Parse keywords */
gLineCount = 0; gLineCount = 0;
KeyWord = SkipLines(); KeyWord = SkipLines();
@ -986,7 +986,7 @@ DoParsing(VOID)
{ {
/* Save this keyword */ /* Save this keyword */
KeyWords[KeyWord]++; KeyWords[KeyWord]++;
/* Check for duplicate entires, other than DEADKEY, which is okay */ /* Check for duplicate entires, other than DEADKEY, which is okay */
if ((KeyWord != 9) && (KeyWords[KeyWord] > 1) && (Verbose)) if ((KeyWord != 9) && (KeyWords[KeyWord] > 1) && (Verbose))
{ {
@ -1000,49 +1000,49 @@ DoParsing(VOID)
{ {
/* KBD */ /* KBD */
case 0: case 0:
DPRINT1("Found KBD section\n"); DPRINT1("Found KBD section\n");
KeyWord = DoKBD(); KeyWord = DoKBD();
break; break;
/* VERSION */ /* VERSION */
case 1: case 1:
DPRINT1("Found VERSION section\n"); DPRINT1("Found VERSION section\n");
KeyWord = DoVERSION(); KeyWord = DoVERSION();
break; break;
/* COPYRIGHT */ /* COPYRIGHT */
case 2: case 2:
DPRINT1("Found COPYRIGHT section\n"); DPRINT1("Found COPYRIGHT section\n");
KeyWord = DoCOPYRIGHT(); KeyWord = DoCOPYRIGHT();
break; break;
/* COMPANY */ /* COMPANY */
case 3: case 3:
DPRINT1("Found COMPANY section\n"); DPRINT1("Found COMPANY section\n");
KeyWord = DoCOMPANY(); KeyWord = DoCOMPANY();
break; break;
/* LOCALENAME */ /* LOCALENAME */
case 4: case 4:
DPRINT1("Found LOCALENAME section\n"); DPRINT1("Found LOCALENAME section\n");
KeyWord = DoLOCALENAME(); KeyWord = DoLOCALENAME();
break; break;
/* MODIFIERS */ /* MODIFIERS */
case 5: case 5:
DPRINT1("Found MODIFIERS section\n"); DPRINT1("Found MODIFIERS section\n");
KeyWord = DoMODIFIERS(); KeyWord = DoMODIFIERS();
break; break;
/* SHIFTSTATE */ /* SHIFTSTATE */
case 6: case 6:
DPRINT1("Found SHIFTSTATE section\n"); DPRINT1("Found SHIFTSTATE section\n");
KeyWord = DoSHIFTSTATE(&StateCount, ShiftStates); KeyWord = DoSHIFTSTATE(&StateCount, ShiftStates);
if (StateCount < 2) if (StateCount < 2)
@ -1053,89 +1053,89 @@ DoParsing(VOID)
exit(1); exit(1);
} }
break; break;
/* ATTRIBUTES */ /* ATTRIBUTES */
case 7: case 7:
DPRINT1("Found ATTRIBUTES section\n"); DPRINT1("Found ATTRIBUTES section\n");
KeyWord = DoATTRIBUTES(&AttributeData); KeyWord = DoATTRIBUTES(&AttributeData);
break; break;
/* LAYOUT */ /* LAYOUT */
case 8: case 8:
DPRINT1("Found LAYOUT section\n"); DPRINT1("Found LAYOUT section\n");
KeyWord = DoLAYOUT(&g_Layout, KeyWord = DoLAYOUT(&g_Layout,
&LigatureData, &LigatureData,
ShiftStates, ShiftStates,
StateCount); StateCount);
break; break;
/* DEADKEY */ /* DEADKEY */
case 9: case 9:
DPRINT1("Found DEADKEY section\n"); DPRINT1("Found DEADKEY section\n");
KeyWord = DoDEADKEY(&DeadKeyData); KeyWord = DoDEADKEY(&DeadKeyData);
break; break;
/* LIGATURE */ /* LIGATURE */
case 10: case 10:
DPRINT1("Found LIGATURE section\n"); DPRINT1("Found LIGATURE section\n");
KeyWord = DoLIGATURE(&LigatureData); KeyWord = DoLIGATURE(&LigatureData);
break; break;
/* KEYNAME */ /* KEYNAME */
case 11: case 11:
DPRINT1("Found KEYNAME section\n"); DPRINT1("Found KEYNAME section\n");
KeyWord = DoKEYNAME(&KeyNameData); KeyWord = DoKEYNAME(&KeyNameData);
break; break;
/* KEYNAME_EXT */ /* KEYNAME_EXT */
case 12: case 12:
DPRINT1("Found KEYNAME_EXT section\n"); DPRINT1("Found KEYNAME_EXT section\n");
KeyWord = DoKEYNAME(&KeyNameExtData); KeyWord = DoKEYNAME(&KeyNameExtData);
break; break;
/* KEYNAME_DEAD */ /* KEYNAME_DEAD */
case 13: case 13:
DPRINT1("Found KEYNAME_DEAD section\n"); DPRINT1("Found KEYNAME_DEAD section\n");
KeyWord = DoKEYNAME(&KeyNameDeadData); KeyWord = DoKEYNAME(&KeyNameDeadData);
break; break;
/* DESCRIPTIONS */ /* DESCRIPTIONS */
case 14: case 14:
DPRINT1("Found DESCRIPTIONS section\n"); DPRINT1("Found DESCRIPTIONS section\n");
KeyWord = DoDESCRIPTIONS(&DescriptionData); KeyWord = DoDESCRIPTIONS(&DescriptionData);
break; break;
/* LANGUAGENAMES */ /* LANGUAGENAMES */
case 15: case 15:
DPRINT1("Found LANGUAGENAMES section\n"); DPRINT1("Found LANGUAGENAMES section\n");
KeyWord = DoLANGUAGENAMES(&LanguageData); KeyWord = DoLANGUAGENAMES(&LanguageData);
break; break;
/* ENDKBD */ /* ENDKBD */
case 16: case 16:
DPRINT1("Found ENDKBD section\n"); DPRINT1("Found ENDKBD section\n");
KeyWord = SkipLines(); KeyWord = SkipLines();
break; break;
default: default:
break; break;
} }
} }
/* We are done */ /* We are done */
fclose(gfpInput); fclose(gfpInput);
/* Now enter the output phase */ /* Now enter the output phase */
return DoOutput(StateCount, return DoOutput(StateCount,
ShiftStates, ShiftStates,