aboutsummaryrefslogtreecommitdiffstats
path: root/menu/complex.c
diff options
context:
space:
mode:
Diffstat (limited to 'menu/complex.c')
-rw-r--r--menu/complex.c104
1 files changed, 69 insertions, 35 deletions
diff --git a/menu/complex.c b/menu/complex.c
index dcdba8ab..aa8828ea 100644
--- a/menu/complex.c
+++ b/menu/complex.c
@@ -22,18 +22,23 @@
/* Global variables */
char infoline[160];
+// Different network options
+static char nonet[] = "network [none]";
+static char dhcpnet[]="network [dhcp]";
+static char statnet[]="network [static]";
+
struct {
unsigned int baseurl : 1; // Do we need to specify by url
unsigned int mountcd : 1; // Should we mount the cd
- unsigned int network : 1; // want network?
- unsigned int dhcp : 1; // want dhcp / static ip
unsigned int winrep : 1; // Want to repair windows?
unsigned int linrep : 1; // Want to repair linux?
} flags;
-t_menuitem *baseurl,*mountcd,*network,*dhcp,*runprep,*winrep,*linrep;
+t_menuitem *baseurl,*mountcd,*network,*runprep,*winrep,*linrep;
+// Some menu options
+t_menuitem * stat,*dhcp,*none;
// all the menus we are going to declare
-char TESTING,RESCUE,MAIN,PREP;
+char TESTING,RESCUE,MAIN,PREP,NETMENU;
/* End globals */
@@ -42,6 +47,7 @@ char TESTING,RESCUE,MAIN,PREP;
void msys_handler(t_menusystem *ms, t_menuitem *mi)
{
char nc;
+ void *v;
nc = getnumcols(); // Get number of columns
if (mi->parindex != PREP) // If we are not in the PREP MENU
@@ -53,40 +59,42 @@ void msys_handler(t_menusystem *ms, t_menuitem *mi)
strcpy (infoline," ");
if (flags.baseurl) strcat(infoline,"baseurl=http://192.168.11.12/gui ");
if (flags.mountcd) strcat(infoline,"mountcd=yes ");
- if (!flags.network)
- strcat(infoline,"network=no ");
- else if (!flags.dhcp) strcat(infoline,"network=static ");
+ v = (void *)network->data;
+ if (v!=NULL) // Some network option specified
+ {
+ strcat(infoline,"network=");
+ strcat(infoline,(char *)(((t_menuitem *)v)->data));
+ }
if (flags.winrep) strcat(infoline,"repair=win ");
if (flags.linrep) strcat(infoline,"repair=lin ");
+
gotoxy(INFLINE,0,ms->menupage);
cprint(' ',0x07,nc,ms->menupage);
gotoxy(INFLINE+1,0,ms->menupage);
cprint(' ',0x07,nc,ms->menupage);
gotoxy(INFLINE,0,ms->menupage);
- csprint("Kernel Arguments:");
+ csprint("Kernel Arguments:",0x07);
gotoxy(INFLINE,17,ms->menupage);
- csprint(infoline);
+ csprint(infoline,0x07);
+}
+
+void network_handler(t_menusystem *ms, t_menuitem *mi)
+{
+ // mi=network since this is handler only for that.
+ (void)ms; // Unused
+
+ if (mi->data == (void *)none) mi->item = nonet;
+ if (mi->data == (void *)stat) mi->item = statnet;
+ if (mi->data == (void *)dhcp) mi->item = dhcpnet;
}
void checkbox_handler(t_menusystem *ms, t_menuitem *mi)
{
- (void)ms; /* Unused */
+ (void)ms; /* Unused */
if (mi->action != OPT_CHECKBOX) return;
if (strcmp(mi->data,"baseurl") == 0) flags.baseurl = (mi->itemdata.checked ? 1 : 0);
- if (strcmp(mi->data,"network") == 0) {
- if (mi->itemdata.checked)
- {
- flags.network = 1;
- dhcp->action = OPT_CHECKBOX;
- }
- else
- {
- flags.network = 0;
- dhcp->action = OPT_INACTIVE;
- }
- }
if (strcmp(mi->data,"winrepair") == 0) {
if (mi->itemdata.checked)
{
@@ -112,7 +120,25 @@ void checkbox_handler(t_menusystem *ms, t_menuitem *mi)
}
}
if (strcmp(mi->data,"mountcd") == 0) flags.mountcd = (mi->itemdata.checked ? 1 : 0);
- if (strcmp(mi->data,"dhcp") == 0) flags.dhcp = (mi->itemdata.checked ? 1 : 0);
+}
+
+/*
+ Clears keyboard buffer and then
+ wait for stepsize*numsteps milliseconds for user to press any key
+ checks for keypress every stepsize milliseconds.
+ Returns: 1 if user pressed a key (not read from the buffer),
+ 0 if time elapsed
+*/
+int checkkeypress(int stepsize, int numsteps)
+{
+ int i;
+ clearkbdbuf();
+ for (i=0; i < numsteps; i++)
+ {
+ if (checkkbdbuf()) return 1;
+ sleep(stepsize);
+ }
+ return 0;
}
int menumain(char *cmdline)
@@ -139,10 +165,16 @@ int menumain(char *cmdline)
// Register the menusystem handler
reg_handler(&msys_handler);
-
+
+ NETMENU = add_menu(" Init Network ");
+ none = add_item("None","Dont start network",OPT_RADIOITEM,"no ",0);
+ dhcp = add_item("dhcp","Use DHCP",OPT_RADIOITEM,"dhcp ",0);
+ stat = add_item("static","Use static IP I will specify later",OPT_RADIOITEM,"static ",0);
+
TESTING = add_menu(" Testing ");
- set_menu_pos(5,60);
+ set_menu_pos(5,55);
add_item("Memory Test","Perform extensive memory testing",OPT_RUN, "memtest",0);
+ add_item("Invisible","You dont see this",OPT_INVISIBLE,"junk",0);
add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
RESCUE = add_menu(" Rescue Options ");
@@ -154,9 +186,7 @@ int menumain(char *cmdline)
PREP = add_menu(" Prep options ");
baseurl = add_item("baseurl by IP?","Specify gui baseurl by IP address",OPT_CHECKBOX,"baseurl",0);
mountcd = add_item("mountcd?","Mount the cdrom drive?",OPT_CHECKBOX,"mountcd",0);
- add_sep();
- network = add_item("network?","Try to initialise network device?",OPT_CHECKBOX,"network",1);
- dhcp = add_item("dhcp?","Use dhcp to get ipaddr?",OPT_CHECKBOX,"dhcp",1);
+ network = add_item(dhcpnet,"How to initialise network device?",OPT_RADIOMENU,NULL,NETMENU);
add_sep();
winrep = add_item("Reinstall windows","Re-install the windows side of a dual boot setup",OPT_CHECKBOX,"winrepair",0);
linrep = add_item("Reinstall linux","Re-install the linux side of a dual boot setup",OPT_CHECKBOX,"linrepair",0);
@@ -165,14 +195,11 @@ int menumain(char *cmdline)
add_item("Exit this menu","Go up one level",OPT_EXITMENU,"exitmenu",0);
baseurl->handler = &checkbox_handler;
mountcd->handler = &checkbox_handler;
- network->handler = &checkbox_handler;
- dhcp->handler = &checkbox_handler;
winrep->handler = &checkbox_handler;
linrep->handler = &checkbox_handler;
+ network->handler = &network_handler;
flags.baseurl = 0;
flags.mountcd = 0;
- flags.network = 1;
- flags.dhcp = 1;
flags.winrep = 0;
flags.linrep = 0;
@@ -183,6 +210,13 @@ int menumain(char *cmdline)
add_item("Testing...","Options to test hardware",OPT_SUBMENU,NULL,TESTING);
add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
+ csprint("Press any key within 5 seconds to show menu...",0x07);
+ if (!checkkeypress(200,25)) // Granularity of 200 milliseconds
+ {
+ csprint("Sorry! Time's up.\r\n",0x07);
+ return 1;
+ }
+ else clearkbdbuf(); // Just in case user pressed something important
curr = showmenus(MAIN);
if (curr)
{
@@ -193,9 +227,9 @@ int menumain(char *cmdline)
if (curr == runprep)
{
strcat(cmd,infoline);
- if (flags.network && !flags.dhcp) // We want static
+ if (network->data == (void *)stat) // We want static
{
- csprint("Enter IP address (last two octets only): ");
+ csprint("Enter IP address (last two octets only): ",0x07);
getstring(ip, sizeof ip);
strcat(cmd,"ipaddr=192.168.");
strcat(cmd,ip);
@@ -203,7 +237,7 @@ int menumain(char *cmdline)
}
if (syslinux)
runcommand(cmd);
- else csprint(cmd);
+ else csprint(cmd,0x07);
return 1;
}
}