diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2014-03-12 17:18:22 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-03-17 15:10:37 +1000 |
commit | cb9a1d01468732196fd25c6422991e784639ffce (patch) | |
tree | a6a49af99302ad44c6716f62f712f66c8518556d /xkb/ddxLoad.c | |
parent | 4391cf27f40ec53d41ac7e437cde49848eb32bde (diff) |
xkb: factor out xkb loading to LoadXkm
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
Diffstat (limited to 'xkb/ddxLoad.c')
-rw-r--r-- | xkb/ddxLoad.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c index 33247cf66..0361b9be5 100644 --- a/xkb/ddxLoad.c +++ b/xkb/ddxLoad.c @@ -291,6 +291,35 @@ XkbDDXOpenConfigFile(const char *mapName, char *fileNameRtrn, int fileNameRtrnLe return file; } +static unsigned +LoadXKM(unsigned want, unsigned need, const char *keymap, XkbDescPtr *xkbRtrn) +{ + FILE *file; + char fileName[PATH_MAX]; + unsigned missing; + + file = XkbDDXOpenConfigFile(keymap, fileName, PATH_MAX); + if (file == NULL) { + LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n", + fileName); + return 0; + } + missing = XkmReadFile(file, need, want, xkbRtrn); + if (*xkbRtrn == NULL) { + LogMessage(X_ERROR, "Error loading keymap %s\n", fileName); + fclose(file); + (void) unlink(fileName); + return 0; + } + else { + DebugF("Loaded XKB keymap %s, defined=0x%x\n", fileName, + (*xkbRtrn)->defined); + } + fclose(file); + (void) unlink(fileName); + return (need | want) & (~missing); +} + unsigned XkbDDXLoadKeymapByNames(DeviceIntPtr keybd, XkbComponentNamesPtr names, @@ -299,9 +328,6 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd, XkbDescPtr *xkbRtrn, char *nameRtrn, int nameRtrnLen) { XkbDescPtr xkb; - FILE *file; - char fileName[PATH_MAX]; - unsigned missing; *xkbRtrn = NULL; if ((keybd == NULL) || (keybd->key == NULL) || @@ -321,26 +347,8 @@ XkbDDXLoadKeymapByNames(DeviceIntPtr keybd, LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n"); return 0; } - file = XkbDDXOpenConfigFile(nameRtrn, fileName, PATH_MAX); - if (file == NULL) { - LogMessage(X_ERROR, "Couldn't open compiled keymap file %s\n", - fileName); - return 0; - } - missing = XkmReadFile(file, need, want, xkbRtrn); - if (*xkbRtrn == NULL) { - LogMessage(X_ERROR, "Error loading keymap %s\n", fileName); - fclose(file); - (void) unlink(fileName); - return 0; - } - else { - DebugF("Loaded XKB keymap %s, defined=0x%x\n", fileName, - (*xkbRtrn)->defined); - } - fclose(file); - (void) unlink(fileName); - return (need | want) & (~missing); + + return LoadXKM(want, need, nameRtrn, xkbRtrn); } Bool |