From 71c5b0c328d5c8d51b3870a3ce326c891606916d Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 30 May 2007 17:45:32 -0700 Subject: [PATCH] Parse F-key help commands in the menu system This adds support for parsing the F-key help commands in the menu system; it still doesn't actually do anything with them. --- com32/modules/menu.h | 6 ++++++ com32/modules/readconfig.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/com32/modules/menu.h b/com32/modules/menu.h index 5c15b39..51b767e 100644 --- a/com32/modules/menu.h +++ b/com32/modules/menu.h @@ -104,6 +104,12 @@ extern char *menu_passprompt_msg; extern char *menu_background; +struct fkey_help { + const char *textname; + const char *background; +}; +extern struct fkey_help fkeyhelp[12]; + void parse_configs(char **argv); extern int (*draw_background)(const char *filename); diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c index 44da72f..3e772c1 100644 --- a/com32/modules/readconfig.c +++ b/com32/modules/readconfig.c @@ -38,6 +38,8 @@ char *onerror = NULL; char *menu_master_passwd = NULL; char *menu_background = NULL; +struct fkey_help fkeyhelp[12]; + struct menu_entry menu_entries[MAX_ENTRIES]; struct menu_entry hide_entries[MAX_ENTRIES]; struct menu_entry *menu_hotkeys[256]; @@ -439,11 +441,31 @@ static char *is_message_name(char *cmdstr, struct messages **msgptr) return NULL; } +static char *is_fkey(char *cmdstr, int *fkeyno) +{ + char *q; + int no; + + if (cmdstr[0] != 'f') + return NULL; + + no = strtoul(cmdstr+1, &q, 10); + if (!my_isspace(*q)) + return NULL; + + if (no < 0 || no > 12) + return NULL; + + *fkeyno = (no == 0) ? 10 : no-1; + return q; +} + static void parse_config_file(FILE *f) { char line[MAX_LINE], *p, *ep, ch; enum kernel_type type; struct messages *msgptr; + int fkeyno; while ( fgets(line, sizeof line, f) ) { p = strchr(line, '\r'); @@ -576,9 +598,25 @@ static void parse_config_file(FILE *f) break; } } + } else if ( (ep = is_fkey(p, &fkeyno)) ) { + p = skipspace(ep); + if (fkeyhelp[fkeyno].textname) { + free((void *)fkeyhelp[fkeyno].textname); + fkeyhelp[fkeyno].textname = NULL; + } + if (fkeyhelp[fkeyno].background) { + free((void *)fkeyhelp[fkeyno].background); + fkeyhelp[fkeyno].background = NULL; + } + + fkeyhelp[fkeyno].textname = dup_word(&p); + if (*p) { + p = skipspace(p); + fkeyhelp[fkeyno].background = dup_word(&p); + } } else if ( (ep = looking_at(p, "include")) ) { - p = skipspace(ep); - parse_one_config(p); + p = skipspace(ep); + parse_one_config(p); } else if ( looking_at(p, "append") ) { char *a = strdup(skipspace(p+6)); if ( ld.label ) -- 2.7.4