ReactOS 0.4.16-dev-329-g9223134
kbdtool.h File Reference
#include <ctype.h>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <typedefs.h>
Include dependency graph for kbdtool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  tagKEYNAME
 
struct  tagSCVK
 
struct  tagVKNAME
 
struct  tagLAYOUTENTRY
 
struct  tagLAYOUT
 

Macros

#define KEYWORD_COUNT   17
 
#define CHAR_NORMAL_KEY   0
 
#define CHAR_DEAD_KEY   1
 
#define CHAR_OTHER_KEY   2
 
#define CHAR_INVALID_KEY   3
 
#define CHAR_LIGATURE_KEY   4
 

Typedefs

typedef struct tagKEYNAME KEYNAME
 
typedef struct tagKEYNAMEPKEYNAME
 
typedef struct tagSCVK SCVK
 
typedef struct tagSCVKPSCVK
 
typedef struct tagVKNAME VKNAME
 
typedef struct tagVKNAMEPVKNAME
 
typedef struct tagLAYOUTENTRY LAYOUTENTRY
 
typedef struct tagLAYOUTENTRYPLAYOUTENTRY
 
typedef struct tagLAYOUT LAYOUT
 
typedef struct tagLAYOUTPLAYOUT
 

Functions

ULONG DoOutput (IN ULONG StateCount, IN PULONG ShiftStates, IN PKEYNAME DescriptionData, IN PKEYNAME LanguageData, IN PVOID AttributeData, IN PVOID DeadKeyData, IN PVOID LigatureData, IN PKEYNAME KeyNameData, IN PKEYNAME KeyNameExtData, IN PKEYNAME KeyNameDeadData)
 
PCHAR getVKName (IN ULONG VirtualKey, IN BOOLEAN Prefix)
 
ULONG DoParsing (VOID)
 

Variables

BOOLEAN Verbose
 
BOOLEAN UnicodeFile
 
BOOLEAN SanityCheck
 
BOOLEAN FallbackDriver
 
PCHAR gpszFileName
 
FILEgfpInput
 
VKNAME VKName []
 
VKNAME Modifiers []
 
SCVK ScVk []
 
PCHAR StateLabel []
 
PCHAR CapState []
 
LAYOUT g_Layout
 
CHAR gVKeyName [32]
 
CHAR gKBDName [10]
 
CHAR gCopyright [256]
 
CHAR gDescription [256]
 
CHAR gCompany [256]
 
CHAR gLocaleName [256]
 
ULONG gVersion
 
ULONG gSubVersion
 

Macro Definition Documentation

◆ CHAR_DEAD_KEY

#define CHAR_DEAD_KEY   1

Definition at line 22 of file kbdtool.h.

◆ CHAR_INVALID_KEY

#define CHAR_INVALID_KEY   3

Definition at line 24 of file kbdtool.h.

◆ CHAR_LIGATURE_KEY

#define CHAR_LIGATURE_KEY   4

Definition at line 25 of file kbdtool.h.

◆ CHAR_NORMAL_KEY

#define CHAR_NORMAL_KEY   0

Definition at line 21 of file kbdtool.h.

◆ CHAR_OTHER_KEY

#define CHAR_OTHER_KEY   2

Definition at line 23 of file kbdtool.h.

◆ KEYWORD_COUNT

#define KEYWORD_COUNT   17

Definition at line 19 of file kbdtool.h.

Typedef Documentation

◆ KEYNAME

◆ LAYOUT

◆ LAYOUTENTRY

◆ PKEYNAME

◆ PLAYOUT

◆ PLAYOUTENTRY

◆ PSCVK

typedef struct tagSCVK * PSCVK

◆ PVKNAME

◆ SCVK

typedef struct tagSCVK SCVK

◆ VKNAME

Function Documentation

◆ DoOutput()

ULONG DoOutput ( IN ULONG  StateCount,
IN PULONG  ShiftStates,
IN PKEYNAME  DescriptionData,
IN PKEYNAME  LanguageData,
IN PVOID  AttributeData,
IN PVOID  DeadKeyData,
IN PVOID  LigatureData,
IN PKEYNAME  KeyNameData,
IN PKEYNAME  KeyNameExtData,
IN PKEYNAME  KeyNameDeadData 
)

Definition at line 1268 of file output.c.

1278{
1279 ULONG FailureCode = 0;
1280
1281 /* Take the time */
1282 time(&Clock);
1283 Now = localtime(&Clock);
1284
1285 /* Check if this just a fallback driver*/
1286 if (!FallbackDriver)
1287 {
1288 /* It's not, create header file */
1289 if (!kbd_h(&g_Layout)) FailureCode = 1;
1290
1291 /* Create the resource file */
1292 if (!kbd_rc(DescriptionData, LanguageData)) FailureCode = 2;
1293 }
1294
1295 /* Create the C file */
1296 if (!kbd_c(StateCount,
1297 ShiftStates,
1299 &g_Layout,
1300 DeadKeyData,
1301 LigatureData,
1302 KeyNameData,
1303 KeyNameExtData,
1304 KeyNameDeadData))
1305 {
1306 /* Failed in C file generation */
1307 FailureCode = 3;
1308 }
1309
1310 /* Check if this just a fallback driver*/
1311 if (!FallbackDriver)
1312 {
1313 /* Generate the definition file */
1314 if (!kbd_def()) FailureCode = 4;
1315 }
1316
1317 /* Done */
1318 return FailureCode;
1319}
@ AttributeData
Definition: ntfs.h:168
LAYOUT g_Layout
Definition: parser.c:25
BOOLEAN FallbackDriver
Definition: kbdtool.h:95
__u16 time
Definition: mkdosfs.c:8
BOOLEAN kbd_h(IN PLAYOUT Layout)
Definition: output.c:195
struct tm * Now
Definition: output.c:19
BOOLEAN kbd_c(IN ULONG StateCount, IN PULONG ShiftStates, IN PVOID AttributeData, IN PLAYOUT Layout, IN PVOID DeadKeyData, IN PVOID LigatureData, IN PKEYNAME KeyNameData, IN PKEYNAME KeyNameExtData, IN PKEYNAME KeyNameDeadData)
Definition: output.c:550
BOOLEAN kbd_rc(IN PKEYNAME DescriptionData, IN PKEYNAME LanguageData)
Definition: output.c:318
BOOLEAN kbd_def(VOID)
Definition: output.c:519
time_t Clock
Definition: output.c:18
_CRTIMP struct tm *__cdecl localtime(const time_t *_Time)
Definition: time.h:416
uint32_t ULONG
Definition: typedefs.h:59

Referenced by DoParsing().

◆ DoParsing()

ULONG DoParsing ( VOID  )

Definition at line 972 of file parser.c.

973{
974 ULONG KeyWords[KEYWORD_COUNT];
975 ULONG KeyWord;
976 ULONG StateCount;
977 ULONG ShiftStates[8];
978 PKEYNAME DescriptionData = NULL, LanguageData = NULL;
979 PKEYNAME KeyNameData = NULL, KeyNameExtData = NULL, KeyNameDeadData = NULL;
980 PVOID AttributeData = NULL, LigatureData = NULL, DeadKeyData = NULL;
981
982 /* Parse keywords */
983 gLineCount = 0;
984 KeyWord = SkipLines();
985 if (KeyWord >= KEYWORD_COUNT)
986 {
987 /* Invalid keyword count, fail */
989 printf("No keywords were found in '%s'.\n", gpszFileName);
990 exit(1);
991 }
992
993 /* Now parse the keywords */
994 memset(KeyWords, 0, sizeof(KeyWords));
995 while (KeyWord < (KEYWORD_COUNT - 1))
996 {
997 /* Save this keyword */
998 KeyWords[KeyWord]++;
999
1000 /* Check for duplicate entires, other than DEADKEY, which is okay */
1001 if ((KeyWord != 9) && (KeyWords[KeyWord] > 1) && (Verbose))
1002 {
1003 /* On a verbose run, warn the user */
1004 printf("The '%s' keyword appeared multiple times.\n",
1005 KeyWordList[KeyWord]);
1006 }
1007
1008 /* Now parse this keyword */
1009 switch (KeyWord)
1010 {
1011 /* KBD */
1012 case 0:
1013
1014 DPRINT1("Found KBD section\n");
1015 KeyWord = DoKBD();
1016 break;
1017
1018 /* VERSION */
1019 case 1:
1020
1021 DPRINT1("Found VERSION section\n");
1022 KeyWord = DoVERSION();
1023 break;
1024
1025 /* COPYRIGHT */
1026 case 2:
1027
1028 DPRINT1("Found COPYRIGHT section\n");
1029 KeyWord = DoCOPYRIGHT();
1030 break;
1031
1032 /* COMPANY */
1033 case 3:
1034
1035 DPRINT1("Found COMPANY section\n");
1036 KeyWord = DoCOMPANY();
1037 break;
1038
1039 /* LOCALENAME */
1040 case 4:
1041
1042 DPRINT1("Found LOCALENAME section\n");
1043 KeyWord = DoLOCALENAME();
1044 break;
1045
1046 /* MODIFIERS */
1047 case 5:
1048
1049 DPRINT1("Found MODIFIERS section\n");
1050 KeyWord = DoMODIFIERS();
1051 break;
1052
1053 /* SHIFTSTATE */
1054 case 6:
1055
1056 DPRINT1("Found SHIFTSTATE section\n");
1057 KeyWord = DoSHIFTSTATE(&StateCount, ShiftStates);
1058 if (StateCount < 2)
1059 {
1060 /* Fail */
1062 printf("ERROR");
1063 exit(1);
1064 }
1065 break;
1066
1067 /* ATTRIBUTES */
1068 case 7:
1069
1070 DPRINT1("Found ATTRIBUTES section\n");
1071 KeyWord = DoATTRIBUTES(&AttributeData);
1072 break;
1073
1074 /* LAYOUT */
1075 case 8:
1076
1077 DPRINT1("Found LAYOUT section\n");
1078 KeyWord = DoLAYOUT(&g_Layout,
1079 &LigatureData,
1080 ShiftStates,
1081 StateCount);
1082 break;
1083
1084 /* DEADKEY */
1085 case 9:
1086
1087 DPRINT1("Found DEADKEY section\n");
1088 KeyWord = DoDEADKEY(&DeadKeyData);
1089 break;
1090
1091 /* LIGATURE */
1092 case 10:
1093
1094 DPRINT1("Found LIGATURE section\n");
1095 KeyWord = DoLIGATURE(&LigatureData);
1096 break;
1097
1098 /* KEYNAME */
1099 case 11:
1100
1101 DPRINT1("Found KEYNAME section\n");
1102 KeyWord = DoKEYNAME(&KeyNameData);
1103 break;
1104
1105 /* KEYNAME_EXT */
1106 case 12:
1107
1108 DPRINT1("Found KEYNAME_EXT section\n");
1109 KeyWord = DoKEYNAME(&KeyNameExtData);
1110 break;
1111
1112 /* KEYNAME_DEAD */
1113 case 13:
1114
1115 DPRINT1("Found KEYNAME_DEAD section\n");
1116 KeyWord = DoKEYNAME(&KeyNameDeadData);
1117 break;
1118
1119 /* DESCRIPTIONS */
1120 case 14:
1121
1122 DPRINT1("Found DESCRIPTIONS section\n");
1123 KeyWord = DoDESCRIPTIONS(&DescriptionData);
1124 break;
1125
1126 /* LANGUAGENAMES */
1127 case 15:
1128
1129 DPRINT1("Found LANGUAGENAMES section\n");
1130 KeyWord = DoLANGUAGENAMES(&LanguageData);
1131 break;
1132
1133 /* ENDKBD */
1134 case 16:
1135
1136 DPRINT1("Found ENDKBD section\n");
1137 KeyWord = SkipLines();
1138 break;
1139
1140
1141 default:
1142 break;
1143 }
1144 }
1145
1146 /* We are done */
1148
1149 /* Now enter the output phase */
1150 return DoOutput(StateCount,
1151 ShiftStates,
1152 DescriptionData,
1153 LanguageData,
1155 DeadKeyData,
1156 LigatureData,
1157 KeyNameData,
1158 KeyNameExtData,
1159 KeyNameDeadData);
1160}
#define DPRINT1
Definition: precomp.h:8
BOOL Verbose
Definition: chkdsk.c:72
#define NULL
Definition: types.h:112
#define printf
Definition: freeldr.h:97
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
FILE * gfpInput
Definition: main.c:21
#define KEYWORD_COUNT
Definition: kbdtool.h:19
ULONG DoOutput(IN ULONG StateCount, IN PULONG ShiftStates, IN PKEYNAME DescriptionData, IN PKEYNAME LanguageData, IN PVOID AttributeData, IN PVOID DeadKeyData, IN PVOID LigatureData, IN PKEYNAME KeyNameData, IN PKEYNAME KeyNameExtData, IN PKEYNAME KeyNameDeadData)
Definition: output.c:1268
PCHAR gpszFileName
Definition: main.c:20
#define exit(n)
Definition: config.h:202
#define memset(x, y, z)
Definition: compat.h:39
ULONG DoLAYOUT(IN PLAYOUT LayoutData, IN PVOID LigatureData, IN PULONG ShiftStates, IN ULONG StateCount)
Definition: parser.c:712
ULONG DoMODIFIERS(VOID)
Definition: parser.c:698
ULONG DoVERSION(VOID)
Definition: parser.c:320
ULONG DoKBD(VOID)
Definition: parser.c:297
LAYOUT g_Layout
Definition: parser.c:25
ULONG DoKEYNAME(IN PKEYNAME *KeyNameData)
Definition: parser.c:539
ULONG DoDESCRIPTIONS(IN PKEYNAME *DescriptionData)
Definition: parser.c:389
ULONG DoLIGATURE(PVOID LigatureData)
Definition: parser.c:684
ULONG SkipLines(VOID)
Definition: parser.c:275
ULONG DoATTRIBUTES(PVOID AttributeData)
Definition: parser.c:691
ULONG DoCOMPANY(VOID)
Definition: parser.c:353
ULONG DoSHIFTSTATE(IN PULONG StateCount, IN OUT PULONG ShiftStates)
Definition: parser.c:614
ULONG DoDEADKEY(PVOID DeadKeyData)
Definition: parser.c:705
ULONG DoCOPYRIGHT(VOID)
Definition: parser.c:335
ULONG gLineCount
Definition: parser.c:26
PCHAR KeyWordList[KEYWORD_COUNT]
Definition: parser.c:29
ULONG DoLOCALENAME(VOID)
Definition: parser.c:371
ULONG DoLANGUAGENAMES(IN PKEYNAME *LanguageData)
Definition: parser.c:464

Referenced by main().

◆ getVKName()

PCHAR getVKName ( IN ULONG  VirtualKey,
IN BOOLEAN  Prefix 
)

Definition at line 65 of file parser.c.

67{
68 ULONG i;
69
70 /* Loop for standard virtual key */
71 if (((VirtualKey >= 'A') && (VirtualKey <= 'Z')) ||
72 ((VirtualKey >= '0') && (VirtualKey <= '9')))
73 {
74 /* Fill out the name */
75 gVKeyName[0] = '\'';
76 gVKeyName[1] = VirtualKey;
77 gVKeyName[2] = '\'';
78 gVKeyName[3] = '\0';
79 return gVKeyName;
80 }
81
82 /* Check if a prefix is required */
83 if (Prefix)
84 {
85 /* Add it */
86 strcpy(gVKeyName, "VK_");
87 }
88 else
89 {
90 /* Otherwise, don't add anything */
91 strcpy(gVKeyName, "");
92 }
93
94 /* Loop all virtual keys */
95 for (i = 0; i < 36; i++)
96 {
97 /* Check if this key matches */
98 if (VKName[i].VirtualKey == VirtualKey)
99 {
100 /* Copy the key's name into the buffer */
102 return gVKeyName;
103 }
104 }
105
106 /* If we got here, then we failed, so print out an error name */
107 strcpy(gVKeyName, "#ERROR#");
108 return gVKeyName;
109}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
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
VKNAME VKName[]
Definition: data.c:16
CHAR gVKeyName[32]
Definition: parser.c:22
_In_ __drv_aliasesMem PSTRING Prefix
Definition: rtlfuncs.h:1647

Referenced by kbd_c(), and kbd_h().

Variable Documentation

◆ CapState

PCHAR CapState[]
extern

Definition at line 135 of file data.c.

Referenced by kbd_c().

◆ FallbackDriver

BOOLEAN FallbackDriver

Definition at line 95 of file kbdtool.h.

Referenced by DoOutput(), and kbd_c().

◆ g_Layout

LAYOUT g_Layout
extern

Definition at line 25 of file parser.c.

Referenced by DoOutput(), and DoParsing().

◆ gCompany

CHAR gCompany[256]
extern

Definition at line 20 of file parser.c.

Referenced by DoCOMPANY(), and kbd_rc().

◆ gCopyright

CHAR gCopyright[256]
extern

Definition at line 17 of file version.c.

Referenced by DoCOPYRIGHT().

◆ gDescription

CHAR gDescription[256]
extern

Definition at line 19 of file parser.c.

Referenced by DoKBD(), and kbd_rc().

◆ gfpInput

FILE* gfpInput
extern

◆ gKBDName

CHAR gKBDName[10]
extern

Definition at line 17 of file parser.c.

Referenced by DoKBD(), kbd_c(), kbd_def(), kbd_h(), and kbd_rc().

◆ gLocaleName

CHAR gLocaleName[256]
extern

Definition at line 21 of file parser.c.

Referenced by DoLOCALENAME(), and kbd_rc().

◆ gpszFileName

PCHAR gpszFileName
extern

Definition at line 20 of file main.c.

Referenced by DoParsing(), and main().

◆ gSubVersion

ULONG gSubVersion

Definition at line 110 of file kbdtool.h.

Referenced by kbd_c(), kbd_h(), and kbd_rc().

◆ gVersion

ULONG gVersion
extern

Definition at line 22 of file init.c.

Referenced by main(), PrintUsage(), Usage(), and WriteDefaultFirewallPrefs().

◆ gVKeyName

CHAR gVKeyName[32]
extern

Definition at line 22 of file parser.c.

Referenced by getVKName().

◆ Modifiers

VKNAME Modifiers[]
extern

Definition at line 56 of file data.c.

Referenced by GetEnhancedVar(), and kbd_c().

◆ SanityCheck

BOOLEAN SanityCheck

Definition at line 95 of file kbdtool.h.

Referenced by DoLAYOUT().

◆ ScVk

SCVK ScVk[]
extern

Definition at line 146 of file data.c.

Referenced by DoLAYOUT().

◆ StateLabel

PCHAR StateLabel[]
extern

Definition at line 64 of file data.c.

Referenced by kbd_c().

◆ UnicodeFile

BOOLEAN UnicodeFile

Definition at line 95 of file kbdtool.h.

Referenced by DoKBD().

◆ Verbose

◆ VKName

VKNAME VKName[]
extern

Definition at line 16 of file data.c.

Referenced by getVKName(), and getVKNum().