diff options
author | H. Peter Anvin <hpa@zytor.com> | 2009-04-06 15:19:21 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2009-04-06 15:19:21 -0700 |
commit | 2920515b1fe5dbf20cfa2f2890b154cd147831ec (patch) | |
tree | b60d63da0dc91bfd3b134233319b4ee19fc0873a /com32/menu/readconfig.c | |
parent | c2636af9b7f4b170ffe791d5008fe6bdd822a59b (diff) | |
download | syslinux-2920515b1fe5dbf20cfa2f2890b154cd147831ec.tar.gz syslinux-2920515b1fe5dbf20cfa2f2890b154cd147831ec.tar.xz syslinux-2920515b1fe5dbf20cfa2f2890b154cd147831ec.zip |
Implement MENU SAVE; fix COM32 setadv functionsyslinux-3.74-pre18
Implement MENU SAVE, which allows the menu system to retain the
previous selection from one boot to another. In the process, fix the
syslinux_setadv() function.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/menu/readconfig.c')
-rw-r--r-- | com32/menu/readconfig.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c index c276c0bf..768591d9 100644 --- a/com32/menu/readconfig.c +++ b/com32/menu/readconfig.c @@ -12,6 +12,7 @@ * ----------------------------------------------------------------------- */ #include <stdio.h> +#include <stdbool.h> #include <stdlib.h> #include <string.h> #include <minmax.h> @@ -19,6 +20,7 @@ #include <inttypes.h> #include <colortbl.h> #include <com32.h> +#include <syslinux/adv.h> #include <syslinux/config.h> #include "menu.h" @@ -33,6 +35,7 @@ struct menu *root_menu, *start_menu, *hide_menu, *menu_list; int shiftkey = 0; /* Only display menu if shift key pressed */ int hiddenmenu = 0; long long totaltimeout = 0; +bool menusave = false; /* Keep track of global default */ static int has_ui = 0; /* DEFAULT only counts if UI is found */ @@ -668,6 +671,8 @@ static void parse_config_file(FILE *f) } } else if ( looking_at(p, "shiftkey") ) { shiftkey = 1; + } else if ( looking_at(p, "save") ) { + menusave = true; } else if ( looking_at(p, "onerror") ) { refstr_put(m->onerror); m->onerror = refstrdup(skipspace(p+7)); @@ -1026,6 +1031,23 @@ void parse_configs(char **argv) } } + /* If "menu save" is active, let the ADV override the global default */ + if (menusave) { + size_t len; + const char *lbl = syslinux_getadv(ADV_MENUSAVE, &len); + char *lstr; + if (lbl && len) { + lstr = refstr_alloc(len); + memcpy(lstr, lbl, len); /* refstr_alloc() adds the final null */ + me = find_label(lstr); + if (me && me->menu != hide_menu) { + me->menu->defentry = me->entry; + start_menu = me->menu; + } + refstr_put(lstr); + } + } + /* Final per-menu initialization, with all labels known */ for (m = menu_list; m; m = m->next) { m->curentry = m->defentry; /* All menus start at their defaults */ |