summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2006-09-20 16:03:29 -0700
committerH. Peter Anvin <hpa@zytor.com>2006-09-20 16:03:29 -0700
commit86b859553463668294b7b573ad067af538ffef1a (patch)
treea8f7f84757cfe1f1167c6e4a97087226c47f05d9
parente3d936b32a531528e7fe12dbd3eebce515a368f9 (diff)
downloadsyslinux-86b859553463668294b7b573ad067af538ffef1a.tar.gz
Support multiple configuration files in the menu systems.
-rw-r--r--README.menu15
-rw-r--r--com32/modules/menu.h2
-rw-r--r--com32/modules/menumain.c2
-rw-r--r--com32/modules/readconfig.c41
4 files changed, 47 insertions, 13 deletions
diff --git a/README.menu b/README.menu
index 83bf3596..dac35966 100644
--- a/README.menu
+++ b/README.menu
@@ -231,6 +231,10 @@ link; you probably want to set your baudrate to 38400 or higher if
possible. It requires a Linux/VT220/ANSI-compatible terminal on the
other end.
+
+ +++ USING AN ALTERNATE CONFIGURATION FILE +++
+
+
It is also possible to load a secondary configuration file, to get to
another menu. To do that, invoke menu.c32 with the name of the
secondary configuration file.
@@ -239,3 +243,14 @@ LABEL othermenu
MENU LABEL Another Menu
KERNEL menu.c32
APPEND othermenu.conf
+
+If you specify more than one file, they will all be read, in the order
+specified. However, global APPEND and IPAPPEND will only apply to the
+file currently being processed.
+
+# The file graphics.conf contains common color and layout commands for
+# all menus.
+LABEL othermenu
+ MENU LABEL Another Menu
+ KERNEL vesamenu.c32
+ APPEND graphics.conf othermenu.conf
diff --git a/com32/modules/menu.h b/com32/modules/menu.h
index e85e4ca5..e856977c 100644
--- a/com32/modules/menu.h
+++ b/com32/modules/menu.h
@@ -65,7 +65,7 @@ extern char *menu_master_passwd;
extern char *menu_background;
-void parse_config(const char *filename);
+void parse_configs(char **argv);
extern int (*draw_background)(const char *filename);
static inline int my_isspace(char c)
diff --git a/com32/modules/menumain.c b/com32/modules/menumain.c
index 433f1694..1f6d3c04 100644
--- a/com32/modules/menumain.c
+++ b/com32/modules/menumain.c
@@ -858,7 +858,7 @@ int menu_main(int argc, char *argv[])
}
WIDTH = cols;
- parse_config(argv[1]);
+ parse_configs(argv+1);
/* If anyone has specified negative parameters, consider them
relative to the bottom row of the screen. */
diff --git a/com32/modules/readconfig.c b/com32/modules/readconfig.c
index 235db828..2c593f0e 100644
--- a/com32/modules/readconfig.c
+++ b/com32/modules/readconfig.c
@@ -361,22 +361,14 @@ static uint32_t parse_argb(char **p)
return argb;
}
-void parse_config(const char *filename)
+static void parse_config_file(FILE *f)
{
char line[MAX_LINE], *p, *ep;
- FILE *f;
char *append = NULL;
unsigned int ipappend = 0;
- static struct labeldata ld;
+ struct labeldata ld;
- get_ipappend();
-
- if ( !filename )
- filename = get_config();
-
- f = fopen(filename, "r");
- if ( !f )
- return;
+ memset(&ld, 0, sizeof ld);
while ( fgets(line, sizeof line, f) ) {
p = strchr(line, '\r');
@@ -502,8 +494,35 @@ void parse_config(const char *filename)
}
record(&ld, append);
+}
+
+static int parse_one_config(const char *filename)
+{
+ FILE *f = fopen(filename, "r");
+ if ( !f )
+ return -1;
+
+ parse_config_file(f);
fclose(f);
+ return 0;
+}
+
+void parse_configs(char **argv)
+{
+ const char *filename;
+
+ get_ipappend();
+
+ if ( !*argv ) {
+ parse_one_config(get_config());
+ } else {
+ while ( (filename = *argv++) )
+ parse_one_config(filename);
+ }
+
+ /* Common postprocessing */
+
if ( ontimeout )
ontimeout = unlabel(ontimeout);
if ( onerror )