void dumpNames(Bool wantRules, Bool wantCNames) { if (wantRules) { if (settings.rules.value) MSG1("rules: %s\n", settings.rules.value); if (settings.model.value) MSG1("model: %s\n", settings.model.value); if (settings.layout.value) MSG1("layout: %s\n", settings.layout.value); if (settings.variant.value) MSG1("variant: %s\n", settings.variant.value); if (options.item) { char *opt_str = stringFromOptions(NULL, &options); MSG1("options: %s\n", opt_str); free(opt_str); } } if (wantCNames) { if (settings.keymap.value) MSG1("keymap: %s\n", settings.keymap.value); if (settings.keycodes.value) MSG1("keycodes: %s\n", settings.keycodes.value); if (settings.types.value) MSG1("types: %s\n", settings.types.value); if (settings.compat.value) MSG1("compat: %s\n", settings.compat.value); if (settings.symbols.value) MSG1("symbols: %s\n", settings.symbols.value); if (settings.geometry.value) MSG1("geometry: %s\n", settings.geometry.value); } return; }
void dumpNames(Bool wantRules, Bool wantCNames) { if (wantRules) { if (svValue[RULES_NDX]) MSG1("rules: %s\n", svValue[RULES_NDX]); if (svValue[MODEL_NDX]) MSG1("model: %s\n", svValue[MODEL_NDX]); if (svValue[LAYOUT_NDX]) MSG1("layout: %s\n", svValue[LAYOUT_NDX]); if (svValue[VARIANT_NDX]) MSG1("variant: %s\n", svValue[VARIANT_NDX]); if (options) { char *opt_str = stringFromOptions(NULL, numOptions, options); MSG1("options: %s\n", opt_str); free(opt_str); } } if (wantCNames) { if (svValue[KEYMAP_NDX]) MSG1("keymap: %s\n", svValue[KEYMAP_NDX]); if (svValue[KEYCODES_NDX]) MSG1("keycodes: %s\n", svValue[KEYCODES_NDX]); if (svValue[TYPES_NDX]) MSG1("types: %s\n", svValue[TYPES_NDX]); if (svValue[COMPAT_NDX]) MSG1("compat: %s\n", svValue[COMPAT_NDX]); if (svValue[SYMBOLS_NDX]) MSG1("symbols: %s\n", svValue[SYMBOLS_NDX]); if (svValue[GEOMETRY_NDX]) MSG1("geometry: %s\n", svValue[GEOMETRY_NDX]); } return; }
/** * If any of model, layout, variant or options is specified, then compile the * options into the * * @return True on success or false otherwise. */ Bool applyRules(void) { int i; char *rfName; if (settings.model.src || settings.layout.src || settings.variant.src || options.item) { char buf[PATH_MAX]; XkbComponentNamesRec rnames; if (settings.variant.src < settings.layout.src) settings.variant.value = NULL; rdefs.model = settings.model.value; rdefs.layout = settings.layout.value; rdefs.variant = settings.variant.value; if (options.item) rdefs.options = stringFromOptions(rdefs.options, &options); if (settings.rules.src) rfName = settings.rules.value; else rfName = DFLT_XKB_RULES_FILE; if (rfName[0] == '/') { rules = tryLoadRules(rfName, settings.locale.value, True, True); } else { /* try to load rules files from all include paths until the first * we succeed with */ for (i = 0; (i < inclPath.num) && (!rules); i++) { if (snprintf(buf, PATH_MAX, "%s/rules/%s", inclPath.item[i], rfName) >= PATH_MAX) { VMSG2(0, "Path too long (%s/rules/%s). Ignored.\n", inclPath.item[i], rfName); continue; } rules = tryLoadRules(buf, settings.locale.value, True, True); } } if (!rules) { ERR1("Couldn't find rules file (%s) \n", rfName); return False; } /* Let the rules file to the magic, then update the svValues with * those returned after processing the rules */ XkbRF_GetComponents(rules, &rdefs, &rnames); if (rnames.keycodes) { trySetString(&settings.keycodes, rnames.keycodes, FROM_RULES); rnames.keycodes = NULL; } if (rnames.symbols) { trySetString(&settings.symbols, rnames.symbols, FROM_RULES); rnames.symbols = NULL; } if (rnames.types) { trySetString(&settings.types, rnames.types, FROM_RULES); rnames.types = NULL; } if (rnames.compat) { trySetString(&settings.compat, rnames.compat, FROM_RULES); rnames.compat = NULL; } if (rnames.geometry) { trySetString(&settings.geometry, rnames.geometry, FROM_RULES); rnames.geometry = NULL; } if (rnames.keymap) { trySetString(&settings.keymap, rnames.keymap, FROM_RULES); rnames.keymap = NULL; } if (verbose > 6) { MSG1("Applied rules from %s:\n", rfName); dumpNames(True, False); } } else if (verbose > 6) { MSG("No rules variables specified. Rules file ignored\n"); } return True; }
/** * If any of model, layout, variant or options is specified, then compile the * options into the * * @return True on success or false otherwise. */ Bool applyRules(void) { int i; char *rfName; if (svSrc[MODEL_NDX] || svSrc[LAYOUT_NDX] || svSrc[VARIANT_NDX] || options) { char buf[PATH_MAX]; XkbComponentNamesRec rnames; if (svSrc[VARIANT_NDX] < svSrc[LAYOUT_NDX]) svValue[VARIANT_NDX] = NULL; rdefs.model = svValue[MODEL_NDX]; rdefs.layout = svValue[LAYOUT_NDX]; rdefs.variant = svValue[VARIANT_NDX]; if (options) rdefs.options = stringFromOptions(rdefs.options, numOptions, options); if (svSrc[RULES_NDX]) rfName = svValue[RULES_NDX]; else rfName = DFLT_XKB_RULES_FILE; if (rfName[0] == '/') { rules = XkbRF_Load(rfName, svValue[LOCALE_NDX], True, True); } else { /* try to load rules files from all include paths until the first * we succeed with */ for (i = 0; (i < numInclPath) && (!rules); i++) { if ((strlen(inclPath[i]) + strlen(rfName) + 8) > PATH_MAX) { VMSG2(0, "Path too long (%s/rules/%s). Ignored.\n", inclPath[i], rfName); continue; } sprintf(buf, "%s/rules/%s", inclPath[i], svValue[RULES_NDX]); rules = XkbRF_Load(buf, svValue[LOCALE_NDX], True, True); } } if (!rules) { ERR1("Couldn't find rules file (%s) \n", svValue[RULES_NDX]); return False; } /* Let the rules file to the magic, then update the svValues with * those returned after processing the rules */ XkbRF_GetComponents(rules, &rdefs, &rnames); if (rnames.keycodes) { trySetString(KEYCODES_NDX, rnames.keycodes, FROM_RULES); rnames.keycodes = NULL; } if (rnames.symbols) { trySetString(SYMBOLS_NDX, rnames.symbols, FROM_RULES); rnames.symbols = NULL; } if (rnames.types) { trySetString(TYPES_NDX, rnames.types, FROM_RULES); rnames.types = NULL; } if (rnames.compat) { trySetString(COMPAT_NDX, rnames.compat, FROM_RULES); rnames.compat = NULL; } if (rnames.geometry) { trySetString(GEOMETRY_NDX, rnames.geometry, FROM_RULES); rnames.geometry = NULL; } if (rnames.keymap) { trySetString(KEYMAP_NDX, rnames.keymap, FROM_RULES); rnames.keymap = NULL; } if (verbose > 6) { MSG1("Applied rules from %s:\n", svValue[RULES_NDX]); dumpNames(True, False); } } else if (verbose > 6) { MSG("No rules variables specified. Rules file ignored\n"); } return True; }