summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-04-14 21:45:54 -0700
committerH. Peter Anvin <hpa@zytor.com>2009-04-14 21:45:54 -0700
commit927a28f0f852b31950fd9d4f9d96049397d1eaa1 (patch)
treec0d0d260ad5b766bbcf64fe6fd1c014ed1a0f527
parent21a05a49eb12c727ead17a71dba3ec3cc6949c03 (diff)
downloadsyslinux-927a28f0f852b31950fd9d4f9d96049397d1eaa1.tar.gz
menu: modify MENU SAVE to be a cascading default
Change MENU SAVE to be a cascading default that can be reverted with MENU NOSAVE. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/menu/menu.h6
-rw-r--r--com32/menu/menumain.c2
-rw-r--r--com32/menu/readconfig.c18
-rw-r--r--doc/menu.txt8
4 files changed, 27 insertions, 7 deletions
diff --git a/com32/menu/menu.h b/com32/menu/menu.h
index 43f65947..98b6fa9b 100644
--- a/com32/menu/menu.h
+++ b/com32/menu/menu.h
@@ -60,6 +60,7 @@ struct menu_entry {
int entry; /* Entry number inside menu */
enum menu_action action;
unsigned char hotkey;
+ bool save; /* Save this entry if selected */
};
static inline bool is_disabled(struct menu_entry *me)
@@ -149,9 +150,11 @@ struct menu {
int nentries;
int nentries_space;
int defentry;
- int allowedit;
int timeout;
+ bool allowedit;
+ bool save; /* MENU SAVE default for this menu */
+
int curentry;
int curtop;
@@ -174,7 +177,6 @@ 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 c3da97e4..b3131faf 100644
--- a/com32/menu/menumain.c
+++ b/com32/menu/menumain.c
@@ -879,7 +879,7 @@ run_menu(void)
}
if (done && !me->passwd) {
/* Only save a new default if we don't have a password... */
- if (menusave && me->label) {
+ if (me->save && me->label) {
syslinux_setadv(ADV_MENUSAVE, strlen(me->label), me->label);
syslinux_adv_write();
}
diff --git a/com32/menu/readconfig.c b/com32/menu/readconfig.c
index 768591d9..376d8181 100644
--- a/com32/menu/readconfig.c
+++ b/com32/menu/readconfig.c
@@ -35,11 +35,11 @@ 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 */
static const char *globaldefault = NULL;
+static bool menusave = false; /* True if there is any "menu save" */
/* Linked list of all entires, hidden or not; used by unlabel() */
static struct menu_entry *all_entries;
@@ -174,6 +174,7 @@ static struct menu * new_menu(struct menu *parent,
m->allowedit = parent->allowedit;
m->timeout = parent->timeout;
+ m->save = parent->save;
m->ontimeout = refstr_get(parent->ontimeout);
m->onerror = refstr_get(parent->onerror);
@@ -193,7 +194,7 @@ static struct menu * new_menu(struct menu *parent,
for (i = 0; i < NPARAMS; i++)
m->mparm[i] = mparm[i].value;
- m->allowedit = 1; /* Allow edits of the command line */
+ m->allowedit = true; /* Allow edits of the command line */
m->color_table = default_color_table();
}
@@ -219,6 +220,7 @@ struct labeldata {
unsigned int menudisabled;
unsigned int menuindent;
enum menu_action action;
+ int save;
struct menu *submenu;
};
@@ -305,6 +307,7 @@ record(struct menu *m, struct labeldata *ld, const char *append)
me->helptext = ld->helptext;
me->hotkey = 0;
me->action = ld->action ? ld->action : MA_CMD;
+ me->save = ld->save ? (ld->save > 0) : m->save;
if ( ld->menuindent ) {
const char *dn;
@@ -673,6 +676,15 @@ static void parse_config_file(FILE *f)
shiftkey = 1;
} else if ( looking_at(p, "save") ) {
menusave = true;
+ if (ld.label)
+ ld.save = 1;
+ else
+ m->save = true;
+ } else if ( looking_at(p, "nosave") ) {
+ if (ld.label)
+ ld.save = -1;
+ else
+ m->save = false;
} else if ( looking_at(p, "onerror") ) {
refstr_put(m->onerror);
m->onerror = refstrdup(skipspace(p+7));
@@ -938,7 +950,7 @@ static void parse_config_file(FILE *f)
} else if ( looking_at(p, "ontimeout") ) {
m->ontimeout = refstrdup(skipspace(p+9));
} else if ( looking_at(p, "allowoptions") ) {
- m->allowedit = atoi(skipspace(p+12));
+ m->allowedit = !!atoi(skipspace(p+12));
} else if ( looking_at(p, "ipappend") ) {
if (ld.label)
ld.ipappend = atoi(skipspace(p+8));
diff --git a/doc/menu.txt b/doc/menu.txt
index 72bc9dca..97e172fc 100644
--- a/doc/menu.txt
+++ b/doc/menu.txt
@@ -276,6 +276,7 @@ DEFAULT label
MENU SAVE
+MENU NOSAVE
Remember the last entry selected and make that the default for
the next boot. A password-protected menu entry is *not*
@@ -289,7 +290,12 @@ MENU SAVE
file gracefully.
The MENU SAVE information can be cleared with
- "extlinux --reset-adv".
+ "extlinux --reset-adv <bootdir>".
+
+ A MENU SAVE or MENU NOSAVE at the top of a (sub)menu affects
+ all entries underneath that (sub)menu except those that in
+ turn have MENU SAVE or MENU NOSAVE declared. This can be used
+ to only save certain entires when selected.
INCLUDE filename [tagname]