[syslinux] [PATCH] gfxboot: support MENU LABEL statement

Steffen Winterfeldt wfeldt at suse.de
Fri Apr 9 09:08:21 PDT 2010


The config file parser now accepts MENU LABEL. Also, make config statements
case-insensitive.

Signed-off-by: Steffen Winterfeldt <wfeldt at opensuse.org>
---
  com32/gfxboot/gfxboot.c |   69 ++++++++++++++++++++++++++++++++++-------------
  1 files changed, 50 insertions(+), 19 deletions(-)

diff --git a/com32/gfxboot/gfxboot.c b/com32/gfxboot/gfxboot.c
index bfdd8cc..640422b 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]);
@@ -321,19 +321,19 @@ int read_config_file(void)
      if(*t) *t++ = 0;
      t = skip_spaces(t);

-    if(!strcmp(s, "timeout")) {
+    if(!strcasecmp(s, "timeout")) {
        timeout = atoi(t);
        continue;
      }

-    if(!strcmp(s, "default")) {
+    if(!strcasecmp(s, "default")) {
        menu_default->label = strdup(t);
        u = strlen(t);
        if(u > label_size) label_size = u;
        continue;
      }

-    if(!strcmp(s, "label")) {
+    if(!strcasecmp(s, "label")) {
        menu_ptr = *menu_next = calloc(1, sizeof **menu_next);
        menu_next = &menu_ptr->next;
        menu_idx++;
@@ -343,37 +343,51 @@ int read_config_file(void)
        continue;
      }

-    if(!strcmp(s, "kernel") && menu_ptr) {
+    if(!strcasecmp(s, "kernel") && menu_ptr) {
        menu_ptr->kernel = strdup(t);
        continue;
      }

-    if(!strcmp(s, "linux") && menu_ptr) {
+    if(!strcasecmp(s, "linux") && menu_ptr) {
        menu_ptr->linux = strdup(t);
        continue;
      }

-    if(!strcmp(s, "localboot") && menu_ptr) {
+    if(!strcasecmp(s, "localboot") && menu_ptr) {
        menu_ptr->localboot = strdup(t);
        continue;
      }

-    if(!strcmp(s, "initrd") && menu_ptr) {
+    if(!strcasecmp(s, "initrd") && menu_ptr) {
        menu_ptr->initrd = strdup(t);
        continue;
      }

-    if(!strcmp(s, "append")) {
+    if(!strcasecmp(s, "append")) {
        (menu_ptr ?: menu_default)->append = strdup(t);
        u = strlen(t);
        if(u > append_size) append_size = u;
        continue;
      }

-    if(!strcmp(s, "ipappend")) {
+    if(!strcasecmp(s, "ipappend")) {
        (menu_ptr ?: menu_default)->ipappend = strdup(t);
        continue;
      }
+
+    if(!strcasecmp(s, "menu") && menu_ptr) {
+      s = skip_spaces(t);
+      t = skip_nonspaces(s);
+      if(*t) *t++ = 0;
+      t = skip_spaces(t);
+
+      if(!strcasecmp(s, "label")) {
+        menu_ptr->label = strdup(t);
+        u = strlen(t);
+        if(u > label_size) label_size = u;
+        continue;
+      }
+    }
    }

    fclose(f);
@@ -686,21 +700,36 @@ 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;
+  }

-  label = skip_spaces(cmdline);
-  arg = skip_spaces(s = skip_nonspaces(label));
-  *s = 0;
+  // invalid index or menu entry
+  if(!menu_ptr || !menu_ptr->label) return;

-  for(menu_ptr = menu; menu_ptr; menu_ptr = menu_ptr->next) {
-    if(menu_ptr->label && !strcmp(menu_ptr->label, label)) break;
+  arg = skip_spaces(cmdline);
+  label_len = strlen(menu_ptr->label);
+
+  // 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);
  }

@@ -807,6 +836,8 @@ void boot_entry(menu_t *menu_ptr, char *arg)

    __farcall(gfx.code_seg, gfx.jmp_table[GFX_CB_PROGRESS_DONE], &r, &r);

+  gfx_done();
+
    syslinux_boot_linux(kernel, kernel_size, initrd, arg);
  }

-- 
1.6.4.2




More information about the Syslinux mailing list