summaryrefslogtreecommitdiff
path: root/com32/gfxboot/gfxboot.c
diff options
context:
space:
mode:
authorSteffen Winterfeldt <wfeldt@opensuse.org>2010-04-13 17:38:39 +0200
committerSebastian Herbszt <herbszt@gmx.de>2010-04-24 21:58:21 +0200
commit10f337808c0b1cfe66686c3625a8949e293e77a0 (patch)
tree447e9c4d8dce41339849ea24142e42f21644d8a7 /com32/gfxboot/gfxboot.c
parent67496f7afab45f17a6a4ce4fc183d9e0c15ead03 (diff)
downloadsyslinux-10f337808c0b1cfe66686c3625a8949e293e77a0.tar.gz
gfxboot: support MENU LABEL statement
Signed-off-by: Steffen Winterfeldt <wfeldt@opensuse.org> Signed-off-by: Sebastian Herbszt <herbszt@gmx.de>
Diffstat (limited to 'com32/gfxboot/gfxboot.c')
-rw-r--r--com32/gfxboot/gfxboot.c49
1 files changed, 39 insertions, 10 deletions
diff --git a/com32/gfxboot/gfxboot.c b/com32/gfxboot/gfxboot.c
index bfdd8cce..e0ff8f54 100644
--- a/com32/gfxboot/gfxboot.c
+++ b/com32/gfxboot/gfxboot.c
@@ -165,7 +165,7 @@ void gfx_done(void);
int gfx_input(void);
ssize_t save_read(int fd, void *buf, size_t size);
void *load_one(char *file, ssize_t *file_size);
-void boot(void);
+void boot(int index);
void boot_entry(menu_t *menu_ptr, char *arg);
@@ -234,7 +234,7 @@ int main(int argc, char **argv)
}
// does not return if it succeeds
- boot();
+ boot(menu_index);
}
if(argc > 2) show_message(argv[2]);
@@ -374,6 +374,20 @@ int read_config_file(void)
(menu_ptr ?: menu_default)->ipappend = strdup(t);
continue;
}
+
+ if(!strcmp(s, "menu") && menu_ptr) {
+ s = skip_spaces(t);
+ t = skip_nonspaces(s);
+ if(*t) *t++ = 0;
+ t = skip_spaces(t);
+
+ if(!strcmp(s, "label")) {
+ menu_ptr->label = strdup(t);
+ u = strlen(t);
+ if(u > label_size) label_size = u;
+ continue;
+ }
+ }
}
fclose(f);
@@ -686,20 +700,35 @@ void *load_one(char *file, ssize_t *file_size)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-// Locate menu entry and boot.
+// Boot menu entry.
//
-void boot(void)
+// cmdline can optionally start with label string.
+//
+void boot(int index)
{
- char *label, *arg, *s;
+ char *arg;
menu_t *menu_ptr;
+ int label_len;
+
+ for(menu_ptr = menu; menu_ptr; menu_ptr = menu_ptr->next, index--) {
+ if(!index) break;
+ }
+
+ // invalid index or menu entry
+ if(!menu_ptr || !menu_ptr->label) return;
- label = skip_spaces(cmdline);
- arg = skip_spaces(s = skip_nonspaces(label));
- *s = 0;
+ arg = skip_spaces(cmdline);
+ label_len = strlen(menu_ptr->label);
- for(menu_ptr = menu; menu_ptr; menu_ptr = menu_ptr->next) {
- if(menu_ptr->label && !strcmp(menu_ptr->label, label)) break;
+ // if it does not start with label string, skip first word
+ if(strncmp(arg, menu_ptr->label, label_len)) {
+ arg = skip_nonspaces(arg);
}
+ else {
+ arg += label_len;
+ }
+
+ arg = skip_spaces(arg);
boot_entry(menu_ptr, arg);
}