summaryrefslogtreecommitdiff
path: root/com32/menu/readconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'com32/menu/readconfig.c')
-rw-r--r--com32/menu/readconfig.c48
1 files changed, 47 insertions, 1 deletions
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index f3b0f96d..0ac2564a 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -1,7 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2004-2009 H. Peter Anvin - All Rights Reserved
- * Copyright 2009-2010 Intel Corporation; author: H. Peter Anvin
+ * Copyright 2009-2011 Intel Corporation; author: H. Peter Anvin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@ int shiftkey = 0; /* Only display menu if shift key pressed */
int hiddenmenu = 0;
int clearmenu = 0;
long long totaltimeout = 0;
+const char *hide_key[KEY_MAX];
/* Keep track of global default */
static int has_ui = 0; /* DEFAULT only counts if UI is found */
@@ -141,6 +142,22 @@ static char *looking_at(char *line, const char *kwd)
return my_isspace(*p) ? p : NULL; /* Must be EOL or whitespace */
}
+/* Get a single word into a new refstr; advances the input pointer */
+static char *get_word(char *str, char **word)
+{
+ char *p = str;
+ char *q;
+
+ while (*p && !my_isspace(*p))
+ p++;
+
+ *word = q = refstr_alloc(p - str);
+ memcpy(q, str, p - str);
+ /* refstr_alloc() already inserted a terminating NUL */
+
+ return p;
+}
+
static struct menu *new_menu(struct menu *parent,
struct menu_entry *parent_entry, const char *label)
{
@@ -703,6 +720,28 @@ static void parse_config_file(FILE * f)
m->menu_background = refdup_word(&p);
} else if ((ep = looking_at(p, "hidden"))) {
hiddenmenu = 1;
+ } else if (looking_at(p, "hiddenkey")) {
+ char *key_name, *k, *ek;
+ const char *command;
+ int key;
+ p = get_word(skipspace(p + 9), &key_name);
+ command = refstrdup(skipspace(p));
+ k = key_name;
+ for (;;) {
+ ek = strchr(k+1, ',');
+ if (ek)
+ *ek = '\0';
+ key = key_name_to_code(k);
+ if (key >= 0) {
+ refstr_put(hide_key[key]);
+ hide_key[key] = refstr_get(command);
+ }
+ if (!ek)
+ break;
+ k = ek+1;
+ }
+ refstr_put(key_name);
+ refstr_put(command);
} else if ((ep = looking_at(p, "clear"))) {
clearmenu = 1;
} else if ((ep = is_message_name(p, &msgnr))) {
@@ -1036,6 +1075,7 @@ void parse_configs(char **argv)
const char *filename;
struct menu *m;
struct menu_entry *me;
+ int k;
empty_string = refstrdup("");
@@ -1097,4 +1137,10 @@ void parse_configs(char **argv)
if (m->onerror)
m->onerror = unlabel(m->onerror);
}
+
+ /* Final global initialization, with all labels known */
+ for (k = 0; k < KEY_MAX; k++) {
+ if (hide_key[k])
+ hide_key[k] = unlabel(hide_key[k]);
+ }
}