Author: ablackmann
Date: Sun Nov 1 19:26:53 2009
New Revision: 43901
URL:
http://svn.reactos.org/svn/reactos?rev=43901&view=rev
Log:
Implement DoKEYNAME (again, very similar to the previous two). Fixup KEYNAME structure
once more to make the field names portable accross different usages (LanguageCode becomes
Code). The tool now supports KEYNAME, KEYNAME_EXT and KEYNAME_DEAD sections in the layout
file.
Modified:
trunk/reactos/tools/kbdtool/parser.c
Modified: trunk/reactos/tools/kbdtool/parser.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/kbdtool/parser.c?rev…
==============================================================================
--- trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] (original)
+++ trunk/reactos/tools/kbdtool/parser.c [iso-8859-1] Sun Nov 1 19:26:53 2009
@@ -16,7 +16,7 @@
typedef struct tagKEYNAME
{
- ULONG LanguageCode;
+ ULONG Code;
PCHAR Name;
struct tagKEYNAME* Next;
} KEYNAME, *PKEYNAME;
@@ -233,12 +233,6 @@
}
ULONG
-DoMODIFIERS(VOID)
-{
- return SkipLines();
-}
-
-ULONG
DoDESCRIPTIONS(IN PKEYNAME* DescriptionData)
{
ULONG KeyWord = 0;
@@ -297,12 +291,12 @@
}
/* Fill out the structure */
- Description->LanguageCode = LanguageCode;
+ Description->Code = LanguageCode;
Description->Name = strdup(p);
Description->Next = NULL;
/* Debug only */
- DPRINT1("LANGID: [%4x] Description: [%s]\n",
Description->LanguageCode, Description->Name);
+ DPRINT1("LANGID: [%4x] Description: [%s]\n", Description->Code,
Description->Name);
/* Point to it and advance the pointer */
*DescriptionData = Description;
@@ -311,24 +305,6 @@
/* We are done */
return KeyWord;
-}
-
-ULONG
-DoKEYNAME(PVOID KeyNameData)
-{
- return SkipLines();
-}
-
-ULONG
-DoLIGATURE(PVOID LigatureData)
-{
- return SkipLines();
-}
-
-ULONG
-DoATTRIBUTES(PVOID AttributeData)
-{
- return SkipLines();
}
ULONG
@@ -390,12 +366,12 @@
}
/* Fill out the structure */
- Language->LanguageCode = LanguageCode;
+ Language->Code = LanguageCode;
Language->Name = strdup(p);
Language->Next = NULL;
/* Debug only */
- DPRINT1("LANGID: [%4x] Name: [%s]\n", Language->LanguageCode,
Language->Name);
+ DPRINT1("LANGID: [%4x] Name: [%s]\n", Language->Code,
Language->Name);
/* Point to it and advance the pointer */
*LanguageData = Language;
@@ -407,9 +383,78 @@
}
ULONG
-DoDEADKEY(PVOID DeadKeyData)
-{
- return SkipLines();
+DoKEYNAME(IN PKEYNAME* KeyNameData)
+{
+ ULONG KeyWord = 0;
+ CHAR Token[32];
+ ULONG CharacterCode;
+ PCHAR p, pp;
+ PKEYNAME KeyName;
+
+ /* Assume nothing */
+ *KeyNameData = 0;
+
+ /* Start scanning */
+ while (NextLine(gBuf, 256, gfpInput))
+ {
+ /* Search for token */
+ if (sscanf(gBuf, "%s", Token) != 1) continue;
+
+ /* Make sure it's not just a comment */
+ if (*Token == ';') continue;
+
+ /* Make sure it's not a keyword */
+ KeyWord = isKeyWord(Token);
+ if (KeyWord < KEYWORD_COUNT) break;
+
+ /* Now scan for the character code */
+ if (sscanf(Token, " %4x", &CharacterCode) != 1)
+ {
+ /* Skip */
+ printf("An invalid character code was specified.\n");
+ continue;
+ }
+
+ /* Now get the actual key name */
+ if (sscanf(gBuf, " %*4x %s[^\n]", Token) != 1)
+ {
+ /* Skip */
+ printf("A key name is missing\n");
+ continue;
+ }
+
+ /* Get the key name string and find the ending */
+ p = strstr(gBuf, Token);
+ pp = strchr(p, '\n');
+ if (!pp) pp = strchr(p, '\r');
+
+ /* Terminate the key name string here */
+ if (pp) *pp = 0;
+
+ /* Now allocate the language */
+ KeyName = malloc(sizeof(KEYNAME));
+ if (!KeyName)
+ {
+ /* Fail */
+ printf("Unable to allocate the KEYNAME struct (out of
memory?).\n");
+ exit(1);
+ }
+
+ /* Fill out the structure */
+ KeyName->Code = CharacterCode;
+ KeyName->Name = strdup(p);
+ KeyName->Next = NULL;
+
+ /* Debug only */
+ DPRINT1("CHARCODE: [%4x] Name: [%s]\n", KeyName->Code,
KeyName->Name);
+
+ /* Point to it and advance the pointer */
+ *KeyNameData = KeyName;
+ KeyNameData = &KeyName->Next;
+ }
+
+ /* We are done */
+ return KeyWord;
}
ULONG
@@ -447,7 +492,7 @@
/* Now read the state */
ShiftState = atoi(Token);
-
+
/* Scan existing states */
for (i = 0; i < *StateCount; i++)
{
@@ -472,7 +517,7 @@
if (Verbose) printf("There were too many states (you defined
%d).\n", *StateCount);
}
}
-
+
/* Debug only */
DPRINT1("Found %d Shift States: [", *StateCount);
for (i = 0; i < *StateCount; i++) DPRINT1("%d ", ShiftStates[i]);
@@ -480,6 +525,30 @@
/* We are done */
return KeyWord;
+}
+
+ULONG
+DoLIGATURE(PVOID LigatureData)
+{
+ return SkipLines();
+}
+
+ULONG
+DoATTRIBUTES(PVOID AttributeData)
+{
+ return SkipLines();
+}
+
+ULONG
+DoMODIFIERS(VOID)
+{
+ return SkipLines();
+}
+
+ULONG
+DoDEADKEY(PVOID DeadKeyData)
+{
+ return SkipLines();
}
ULONG
@@ -499,8 +568,8 @@
ULONG StateCount;
ULONG ShiftStates[8];
PKEYNAME DescriptionData, LanguageData;
+ PKEYNAME KeyNameData, KeyNameExtData, KeyNameDeadData;
PVOID AttributeData, LigatureData, DeadKeyData;
- PVOID KeyNameData, KeyNameExtData, KeyNameDeadData;
/* Parse keywords */
gLineCount = 0;