From 91ffa34b5cb9e31e6e76240b292b5e7655287f3b Mon Sep 17 00:00:00 2001 From: sobomax Date: Sat, 12 May 2001 09:16:09 +0000 Subject: Allow path where keyboard maps are looked for to be altered using environment variable. --- usr.sbin/kbdcontrol/kbdcontrol.1 | 4 ++++ usr.sbin/kbdcontrol/kbdcontrol.c | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/usr.sbin/kbdcontrol/kbdcontrol.1 b/usr.sbin/kbdcontrol/kbdcontrol.1 index f2eaf22..4d0baa9 100644 --- a/usr.sbin/kbdcontrol/kbdcontrol.1 +++ b/usr.sbin/kbdcontrol/kbdcontrol.1 @@ -145,6 +145,10 @@ compiled from it to stdout. This option is primarily intended for programmers and is probably of little use under normal circumstances. .El +.Sh ENVIRONMENT +The environment variable +.Ev KEYMAP_PATH +can hold an alternative path to the keyboard map files. .Sh KEYBOARD CONFIGURATION .Ss Boot Time Configuration You may set variables in diff --git a/usr.sbin/kbdcontrol/kbdcontrol.c b/usr.sbin/kbdcontrol/kbdcontrol.c index 935a8d25..8587a42 100644 --- a/usr.sbin/kbdcontrol/kbdcontrol.c +++ b/usr.sbin/kbdcontrol/kbdcontrol.c @@ -746,16 +746,20 @@ load_keymap(char *opt, int dumponly) keymap_t keymap; accentmap_t accentmap; FILE *fd; - int i; + int i, j; char *name, *cp; - char *prefix[] = {"", "", KEYMAP_PATH, KEYMAP_PATH, NULL}; - char *postfix[] = {"", ".kbd", "", ".kbd"}; + char *prefix[] = {"", "", KEYMAP_PATH, NULL}; + char *postfix[] = {"", ".kbd", NULL}; - for (i=0; prefix[i]; i++) { - name = mkfullname(prefix[i], opt, postfix[i]); - if ((fd = fopen(name, "r"))) - break; - } + if (cp = getenv("KEYMAP_PATH")) + prefix[0] = mkfullname(cp, "/", ""); + + for (i=0; prefix[i]; i++) + for (j=0; postfix[j]; j++) { + name = mkfullname(prefix[i], opt, postfix[j]); + if ((fd = fopen(name, "r"))) + prefix[i + 1] = postfix[j + 1] = NULL; + } if (fd == NULL) { warn("keymap file not found"); return; -- cgit v1.1