unsigned XkbDDXLoadKeymapByNames(DeviceIntPtr keybd, XkbComponentNamesPtr names, unsigned want, unsigned need, XkbDescPtr *xkbRtrn, char *nameRtrn, int nameRtrnLen) { XkbDescPtr xkb; *xkbRtrn = NULL; if ((keybd == NULL) || (keybd->key == NULL) || (keybd->key->xkbInfo == NULL)) xkb = NULL; else xkb = keybd->key->xkbInfo->desc; if ((names->keycodes == NULL) && (names->types == NULL) && (names->compat == NULL) && (names->symbols == NULL) && (names->geometry == NULL)) { LogMessage(X_ERROR, "XKB: No components provided for device %s\n", keybd->name ? keybd->name : "(unnamed keyboard)"); return 0; } else if (!XkbDDXCompileKeymapByNames(xkb, names, want, need, nameRtrn, nameRtrnLen)) { LogMessage(X_ERROR, "XKB: Couldn't compile keymap\n"); return 0; } return LoadXKM(want, need, nameRtrn, xkbRtrn); }
unsigned XkbDDXLoadKeymapByNames(DeviceIntPtr keybd, XkbComponentNamesPtr names, unsigned want, unsigned need, XkbDescPtr *xkbRtrn, char *nameRtrn, int nameRtrnLen) { XkbDescPtr xkb; FILE *file; char fileName[PATH_MAX]; unsigned missing; *xkbRtrn = NULL; if ((keybd == NULL) || (keybd->key == NULL) || (keybd->key->xkbInfo == NULL)) xkb = NULL; else xkb = keybd->key->xkbInfo->desc; if ((names->keycodes == NULL) && (names->types == NULL) && (names->compat == NULL) && (names->symbols == NULL) && (names->geometry == NULL)) { LogMessage(X_ERROR, "XKB: No components provided for device %s\n", keybd->name ? keybd->name : "(unnamed keyboard)"); return 0; } else if (!XkbDDXCompileKeymapByNames(xkb, names, want, need, nameRtrn, nameRtrnLen)) { 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); }
unsigned XkbDDXLoadKeymapByNames( DeviceIntPtr keybd, XkbComponentNamesPtr names, unsigned want, unsigned need, XkbFileInfo * finfoRtrn, char * nameRtrn, int nameRtrnLen) { XkbDescPtr xkb; FILE * file; char fileName[PATH_MAX]; unsigned missing; bzero(finfoRtrn,sizeof(XkbFileInfo)); if ((keybd==NULL)||(keybd->key==NULL)||(keybd->key->xkbInfo==NULL)) xkb= NULL; else xkb= keybd->key->xkbInfo->desc; if ((names->keycodes==NULL)&&(names->types==NULL)&& (names->compat==NULL)&&(names->symbols==NULL)&& (names->geometry==NULL)) { if (names->keymap==NULL) { bzero(finfoRtrn,sizeof(XkbFileInfo)); if (xkb && XkbDetermineFileType(finfoRtrn,XkbXKMFile,NULL) && ((finfoRtrn->defined&need)==need) ) { finfoRtrn->xkb= xkb; nameRtrn[0]= '\0'; return finfoRtrn->defined; } return 0; } else if (!XkbDDXCompileNamedKeymap(xkb,names,nameRtrn,nameRtrnLen)) { #ifdef NOISY ErrorF("Couldn't compile keymap file\n"); #endif return 0; } } else if (!XkbDDXCompileKeymapByNames(xkb,names,want,need, nameRtrn,nameRtrnLen)){ #ifdef NOISY ErrorF("Couldn't compile keymap file\n"); #endif 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,finfoRtrn); if (finfoRtrn->xkb==NULL) { LogMessage(X_ERROR, "Error loading keymap %s\n",fileName); fclose(file); (void) unlink (fileName); return 0; } #ifdef DEBUG else if (xkbDebugFlags) { ErrorF("Loaded %s, defined=0x%x\n",fileName,finfoRtrn->defined); } #endif fclose(file); (void) unlink (fileName); return (need|want)&(~missing); }