Make the command line available to the program
authorhpa <hpa>
Tue, 3 Feb 2004 18:36:06 +0000 (18:36 +0000)
committerhpa <hpa>
Tue, 3 Feb 2004 18:36:06 +0000 (18:36 +0000)
menu/complex.c
menu/main.c
menu/menu.h
menu/simple.c
menu/startup.S16

index c0bb30b..47cf373 100644 (file)
@@ -110,12 +110,14 @@ void checkbox_handler(t_menusystem *ms, t_menuitem *mi)
     if (strcmp(mi->data,"dhcp") == 0) flags.dhcp    = (mi->itemdata.checked ? 1 : 0);
 }
 
-int menumain(void)
+int menumain(char *cmdline)
 {
   t_menuitem * curr;
-  char cmdline[160];
+  char cmd[160];
   char ip[30];
 
+  (void)cmdline;               /* Not used */
+
   // Choose the default title and setup default values for all attributes....
   init_menusystem(NULL);
   
@@ -172,21 +174,21 @@ int menumain(void)
         if (curr->action == OPT_EXIT) return 0;
         if (curr->action == OPT_RUN)
         {
-            strcpy(cmdline,curr->data);
+            strcpy(cmd,curr->data);
             if (curr == runprep)
             {
-                strcat(cmdline,infoline);
+                strcat(cmd,infoline);
                 if (flags.network && !flags.dhcp) // We want static
                 {
                     csprint("Enter IP address (last two octets only): ");
                     getstring(ip, sizeof ip);
-                    strcat(cmdline,"ipaddr=128.135.");
-                    strcat(cmdline,ip);
+                    strcat(cmd,"ipaddr=128.135.");
+                    strcat(cmd,ip);
                 }
             }
             if (syslinux)
-               runcommand(cmdline);
-            else csprint(cmdline);
+               runcommand(cmd);
+            else csprint(cmd);
             return 1;
         }
   }
index 63765c0..e6d7d26 100644 (file)
 
 int syslinux;
 
-int main(void)
+int _cstart(char *cmdline)
 {
   int rv;
-  int origpage;
-  char r,c;
 
   syslinux = issyslinux();      /* Find if syslinux is running */
   if (syslinux) gototxtmode();  /* (else assume we are running in DOS) */
 
-  rv = menumain();             /* Run the actual menu system */
+  rv = menumain(cmdline);      /* Run the actual menu system */
 
   return rv;
 }
index ff9a701..cf41173 100644 (file)
@@ -190,6 +190,6 @@ int add_menu(const char *title);
 t_menuitem * add_item(const char *item, const char *status, t_action action, const char *data, char itemdata); 
 
 // Main function for the user's config file
-int menumain(void);
+int menumain(char *cmdline);
 
 #endif
index 7870a94..2d26af8 100644 (file)
 #include "string.h"
 #include "syslinux.h"
 
-char TESTING,RESCUE,MAIN,PREP;
-
-int menumain(void)
+int menumain(char *cmdline)
 {
   t_menuitem * curr;
 
+  char TESTING,RESCUE,MAIN;    /* The menus we're going to declare */
+  (void)cmdline;               /* Not used */
+
   // Choose the default title and setup default values for all attributes....
   init_menusystem(NULL);
   
index 6ca7ced..63f31c0 100644 (file)
@@ -14,8 +14,21 @@ _start:
        cld
        rep ; stosl
 
-       /* Invoke main() */
-       calll main
+       /* Normalize the command line.  At startup 0x80 = length and
+          the command line starts at 0x81, but with whitespace */
+       movl $0x81,%esi
+       movzbl (0x80),%ebx
+       movb $0,(%bx,%si)               /* Null-terminate the string */
+1:
+       lodsb
+       dec %al                         /* Stop on null */
+       cmp $31,%al                     /* Whitespace? */
+       jbe 1
+       dec %si                         /* Unskip first character */
+
+       /* Invoke _cstart */
+       pushl %esi                      /* Pointer to command line */
+       calll _cstart
 
        /* Terminate program (with error code in %al) */
        movb $0x4c,%ah