summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArne Georg Gleditsch <argggh@linpro.no>2006-09-04 08:50:44 +0200
committerH. Peter Anvin <hpa@zytor.com>2006-09-05 13:50:07 -0700
commit329e23c16d0f3ecd4062ec715fbe047bf85f8976 (patch)
treed7dd01dfadeac1a2751a1326f46d449970859d79
parentdd84dc52d32dacbda4b183d5e36f4c90bfe186b9 (diff)
downloadsyslinux-329e23c16d0f3ecd4062ec715fbe047bf85f8976.tar.gz
Simple menu system updates
Hi, I'm attaching a patch to Syslinux dealing with a handful of issues that were preventing me from using the simple menu interface. Issues covered: * Enable "MENU ONERROR" as a keyword on par with "ONERROR". * Enable hidden menu entries to be used as ontimeout and onerror entries (probably the least estheticalla pleasing part, sorry about that.) * Make global "IPAPPEND" directives apply also when using menu.c32. * Memory allocation fix for the ontimeout-variable (unlabel does free()). * Make menu.c32 add ipappend options at end of kernel commend line, as pxelinux generally does. I see 3.30-pre1 is out now, I haven't had time to check applicability of these patches towards this. Hope they can still be of use. -- Arne. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--com32/modules/menu.c5
-rw-r--r--com32/modules/menu.h1
-rw-r--r--com32/modules/readconfig.c48
3 files changed, 49 insertions, 5 deletions
diff --git a/com32/modules/menu.c b/com32/modules/menu.c
index d9db5633..f7d44c52 100644
--- a/com32/modules/menu.c
+++ b/com32/modules/menu.c
@@ -838,8 +838,11 @@ int main(int argc, char *argv[])
cmdline = run_menu();
printf("\033[?25h\033[%d;1H\033[0m", END_ROW);
- if ( cmdline )
+ if ( cmdline ) {
execute(cmdline);
+ if ( onerror )
+ execute(onerror);
+ }
else
return 0; /* Exit */
}
diff --git a/com32/modules/menu.h b/com32/modules/menu.h
index cb2eb6e3..ea17dbc1 100644
--- a/com32/modules/menu.h
+++ b/com32/modules/menu.h
@@ -60,6 +60,7 @@ extern long long totaltimeout;
extern char *menu_title;
extern char *ontimeout;
+extern char *onerror;
extern char *menu_master_passwd;
void parse_config(const char *filename);
diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c
index 37898eb5..69404d0f 100644
--- a/com32/modules/readconfig.c
+++ b/com32/modules/readconfig.c
@@ -23,6 +23,7 @@
#include "menu.h"
int nentries = 0;
+int nhidden = 0;
int defentry = 0;
int allowedit = 1; /* Allow edits of the command line */
int timeout = 0;
@@ -31,10 +32,12 @@ long long totaltimeout = 0;
char *menu_title = "";
char *ontimeout = NULL;
+char *onerror = NULL;
char *menu_master_passwd = NULL;
struct menu_entry menu_entries[MAX_ENTRIES];
+struct menu_entry hide_entries[MAX_ENTRIES];
struct menu_entry *menu_hotkeys[256];
#define astrdup(x) ({ char *__x = (x); \
@@ -159,7 +162,7 @@ record(struct labeldata *ld, char *append)
if ( !a ) a = append;
if ( !a || (a[0] == '-' && !a[1]) ) a = "";
s = a[0] ? " " : "";
- asprintf(&me->cmdline, "%s%s%s%s", ld->kernel, ipoptions, s, a);
+ asprintf(&me->cmdline, "%s%s%s%s", ld->kernel, s, a, ipoptions);
ld->label = NULL;
ld->passwd = NULL;
@@ -181,6 +184,19 @@ record(struct labeldata *ld, char *append)
nentries++;
}
+ else {
+ hide_entries[nhidden].displayname = me->displayname;
+ hide_entries[nhidden].label = me->label;
+ hide_entries[nhidden].cmdline = me->cmdline;
+ hide_entries[nhidden].passwd = me->passwd;
+
+ me->displayname = NULL;
+ me->label = NULL;
+ me->cmdline = NULL;
+ me->passwd = NULL;
+
+ nhidden++;
+ }
}
}
@@ -215,6 +231,21 @@ unlabel(char *str)
}
}
+ for ( i = 0 ; i < nhidden ; i++ ) {
+ me = &hide_entries[i];
+
+ if ( !strncmp(str, me->label, pos) && !me->label[pos] ) {
+ /* Found matching label */
+ q = malloc(strlen(me->cmdline) + strlen(p) + 1);
+ strcpy(q, me->cmdline);
+ strcat(q, p);
+
+ free(str);
+
+ return q;
+ }
+ }
+
return str;
}
@@ -223,6 +254,7 @@ void parse_config(const char *filename)
char line[MAX_LINE], *p, *ep;
FILE *f;
char *append = NULL;
+ unsigned int ipappend = 0;
static struct labeldata ld;
get_ipappend();
@@ -260,6 +292,8 @@ void parse_config(const char *filename)
ld.passwd = strdup(skipspace(p+6));
} else if ( looking_at(p, "shiftkey") ) {
shiftkey = 1;
+ } else if ( looking_at(p, "onerror") ) {
+ onerror = strdup(skipspace(p+7));
} else if ( looking_at(p, "master") ) {
p = skipspace(p+6);
if ( looking_at(p, "passwd") ) {
@@ -289,7 +323,8 @@ void parse_config(const char *filename)
ld.passwd = NULL;
ld.append = NULL;
ld.menulabel = NULL;
- ld.ipappend = ld.menudefault = ld.menuhide = 0;
+ ld.ipappend = ipappend;
+ ld.menudefault = ld.menuhide = 0;
} else if ( looking_at(p, "kernel") ) {
if ( ld.label ) {
free(ld.kernel);
@@ -300,11 +335,14 @@ void parse_config(const char *filename)
} else if ( looking_at(p, "totaltimeout") ) {
totaltimeout = (atoll(skipspace(p+13))*CLK_TCK+9)/10;
} else if ( looking_at(p, "ontimeout") ) {
- ontimeout = skipspace(p+9);
+ ontimeout = strdup(skipspace(p+9));
} else if ( looking_at(p, "allowoptions") ) {
allowedit = atoi(skipspace(p+12));
} else if ( looking_at(p, "ipappend") ) {
- ld.ipappend = atoi(skipspace(p+8));
+ if (ld.label)
+ ld.ipappend = atoi(skipspace(p+8));
+ else
+ ipappend = atoi(skipspace(p+8));
} else if ( looking_at(p, "localboot") ) {
ld.kernel = strdup(".localboot");
ld.append = strdup(skipspace(p+9));
@@ -316,4 +354,6 @@ void parse_config(const char *filename)
if ( ontimeout )
ontimeout = unlabel(ontimeout);
+ if ( onerror )
+ onerror = unlabel(onerror);
}