aboutsummaryrefslogtreecommitdiffstats
path: root/com32/menu
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-04-06 15:19:21 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-04-06 15:19:21 -0700
commit2920515b1fe5dbf20cfa2f2890b154cd147831ec (patch)
treeb60d63da0dc91bfd3b134233319b4ee19fc0873a /com32/menu
parentc2636af9b7f4b170ffe791d5008fe6bdd822a59b (diff)
downloadsyslinux-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')
-rw-r--r--com32/menu/menu.h1
-rw-r--r--com32/menu/menumain.c9
-rw-r--r--com32/menu/readconfig.c22
3 files changed, 32 insertions, 0 deletions
diff --git a/com32/menu/menu.h b/com32/menu/menu.h
index e2ffc1bc..43f65947 100644
--- a/com32/menu/menu.h
+++ b/com32/menu/menu.h
@@ -174,6 +174,7 @@ extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list;
/* These are global parameters regardless of which menu we're displaying */
extern int shiftkey;
extern int hiddenmenu;
+extern bool menusave;
extern long long totaltimeout;
void parse_configs(char **argv);
diff --git a/com32/menu/menumain.c b/com32/menu/menumain.c
index f7af90aa..c3da97e4 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -1,6 +1,7 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
+ * Copyright 2009 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
@@ -27,6 +28,7 @@
#include <setjmp.h>
#include <limits.h>
#include <com32.h>
+#include <syslinux/adv.h>
#include "menu.h"
@@ -875,6 +877,13 @@ run_menu(void)
break;
}
}
+ if (done && !me->passwd) {
+ /* Only save a new default if we don't have a password... */
+ if (menusave && me->label) {
+ syslinux_setadv(ADV_MENUSAVE, strlen(me->label), me->label);
+ syslinux_adv_write();
+ }
+ }
break;
case KEY_UP:
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 */