syslinux-3.08-2 sources from FC4
[bootcd.git] / syslinux / menu / simple.c
1 /* -*- c -*- ------------------------------------------------------------- *
2  *   
3  *   Copyright 2004-2005 Murali Krishnan Ganapathy - All Rights Reserved
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8  *   Boston MA 02111-1307, USA; either version 2 of the License, or
9  *   (at your option) any later version; incorporated herein by reference.
10  *
11  * ----------------------------------------------------------------------- */
12
13 #ifndef NULL
14 #define NULL ((void *) 0)
15 #endif
16
17 #include "menu.h"
18 #include "com32io.h"
19 #include <string.h>
20
21 int main(void)
22 {
23   t_menuitem * curr;
24
25   char TESTING,RESCUE,MAIN;     /* The menus we're going to declare */
26
27   // Change the video mode here
28   // setvideomode(0)
29
30   // Choose the default title and setup default values for all attributes....
31   init_menusystem(NULL);
32   set_window_size(1,1,23,78); // Leave one row/col border all around
33   
34   // Choose the default values for all attributes and char's
35   // -1 means choose defaults (Actually the next 4 lines are not needed)
36   //set_normal_attr (-1,-1,-1,-1); 
37   //set_status_info (-1,-1); 
38   //set_title_info  (-1,-1); 
39   //set_misc_info(-1,-1,-1,-1);
40   
41   // menuindex = add_menu(" Menu Title ",-1);
42   // add_item("Item string","Status String",TYPE,"any string",NUM)
43   //   TYPE = OPT_RUN | OPT_EXITMENU | OPT_SUBMENU | OPT_CHECKBOX | OPT_INACTIVE
44   //   "any string" not used by the menu system, useful for storing kernel names
45   //   NUM = index of submenu if OPT_SUBMENU, 
46   //         0/1 default checked state if OPT_CHECKBOX
47   //         unused otherwise.
48
49   TESTING = add_menu(" Testing ",-1);
50   add_item("Self Loop","Go to testing",OPT_SUBMENU,NULL,TESTING);
51   add_item("Memory Test","Perform extensive memory testing",OPT_RUN, "memtest",0);
52   add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
53
54   RESCUE = add_menu(" Rescue Options ",-1);
55   add_item("Linux Rescue","linresc",OPT_RUN,"linresc",0);
56   add_item("Dos Rescue","dosresc",OPT_RUN,"dosresc",0);
57   add_item("Windows Rescue","winresc",OPT_RUN,"winresc",0);
58   add_item("Exit this menu","Go one level up",OPT_EXITMENU,"exit",0);
59
60   MAIN = add_menu(" Main Menu ",-1);  
61   add_item("Prepare","prep",OPT_RUN,"prep",0);
62   add_item("Rescue options...","Troubleshoot a system",OPT_SUBMENU,NULL,RESCUE);
63   add_item("Testing...","Options to test hardware",OPT_SUBMENU,NULL,TESTING);
64   add_item("Exit to prompt", "Exit the menu system", OPT_EXITMENU, "exit", 0);
65
66   curr = showmenus(MAIN); // Initial menu is the one with index MAIN
67   if (curr)
68   {
69         if (curr->action == OPT_RUN)
70         {
71             if (issyslinux()) runsyslinuxcmd(curr->data);
72             else csprint(curr->data,0x07);
73             return 1;
74         }
75         csprint("Error in programming!",0x07);
76   }
77   return 0;
78 }