5 typedef void (*menu_finish_callback)(struct menu_s *menu);
7 typedef struct menu_s {
8 char *name; /* Menu name */
9 int num_options; /* Number of options in this menu */
10 int flags; /* Various flags - see below */
11 int option_align; /* Aligns options to a field width of this much characters if != 0 */
13 struct menu_option_s **options; /* Pointer to this menu's options */
14 menu_finish_callback callback; /* Called when the menu closes */
18 * type: Type of the option (see below)
19 * name: Name to display for this option
20 * help: Optional help string
21 * id : optional id number
22 * sys : pointer for system-specific data, init to NULL and don't touch
25 #define OPTION_PREAMBLE \
34 * There are a number of different layouts for menu options depending
35 * on their types. Currently there are the following possibilities:
38 * This entry links to a new menu.
41 * A simple on/off toggle entry. Booleans can be either yes/no, 0/1 or on/off.
42 * Optionally, this entry can enable/disable a set of other options. An example would
43 * be to enable/disable on-board USB, and if enabled give access to further options like
44 * irq settings, base address etc.
47 * A single line/limited number of characters text entry box. Text can be restricted
48 * to a certain charset (digits/hex digits/all/custom). Result is also available as an
52 * One-of-many type of selection entry. User may choose on of a set of strings, which
53 * maps to a specific value for the variable.
56 * Selecting this calls an entry-specific routine. This can be used for saving contents etc.
59 * Display and behaviour of this entry is defined by a set of callbacks.
62 #define MENU_SUBMENU_TYPE 0
63 typedef struct menu_submenu_s
67 menu_t * submenu; /* Pointer to the submenu */
70 #define MENU_BOOLEAN_TYPE 1
71 typedef struct menu_boolean_s
75 char *variable; /* Name of the variable to getenv()/setenv() */
76 int subtype; /* Subtype (on/off, 0/1, yes/no, enable/disable), see below */
77 int mutex; /* Bit mask of options to enable/disable. Bit 0 is the option
78 immediately following this one, bit 1 is the next one etc.
79 bit 7 = 0 means to disable when this option is off,
80 bit 7 = 1 means to disable when this option is on.
81 An option is disabled when the type field's upper bit is set */
84 /* BOOLEAN Menu flags */
85 #define MENU_BOOLEAN_ONOFF 0x01
86 #define MENU_BOOLEAN_01 0x02
87 #define MENU_BOOLEAN_YESNO 0x03
88 #define MENU_BOOLEAN_ENDIS 0x04
89 #define MENU_BOOLEAN_TYPE_MASK 0x07
92 #define MENU_TEXT_TYPE 2
93 typedef struct menu_text_s
97 char *variable; /* Name of the variable to getenv()/setenv() */
98 int maxchars; /* Max number of characters */
99 char *charset; /* Optional charset to use */
100 int flags; /* Flags - see below */
103 /* TEXT entry menu flags */
104 #define MENU_TEXT_NUMERIC 0x01
105 #define MENU_TEXT_HEXADECIMAL 0x02
106 #define MENU_TEXT_FREE 0x03
107 #define MENU_TEXT_TYPE_MASK 0x07
110 #define MENU_SELECTION_TYPE 3
111 typedef struct menu_select_option_s {
112 char *map_from; /* Map this variable contents ... */
113 char *map_to; /* ... to this menu text and vice versa */
114 } menu_select_option_t;
116 typedef struct menu_select_s {
117 OPTION_PREAMBLE int num_options; /* Number of mappings */
118 menu_select_option_t **options;
119 /* Option list array */
123 #define MENU_ROUTINE_TYPE 4
124 typedef void (*menu_routine_callback) (struct menu_routine_s *);
126 typedef struct menu_routine_s {
127 OPTION_PREAMBLE menu_routine_callback callback;
128 /* routine to be called */
129 void *user_data; /* User data, don't care for system */
133 #define MENU_CUSTOM_TYPE 5
134 typedef void (*menu_custom_draw) (struct menu_custom_s *);
135 typedef void (*menu_custom_key) (struct menu_custom_s *, int);
137 typedef struct menu_custom_s {
138 OPTION_PREAMBLE menu_custom_draw drawfunc;
139 menu_custom_key keyfunc;
144 * The menu option superstructure
146 typedef struct menu_option_s {
148 menu_submenu_t m_sub_menu;
149 menu_boolean_t m_boolean;
151 menu_select_t m_select;
152 menu_routine_t m_routine;
156 /* Init the menu system. Returns <0 on error */
157 int menu_init(menu_t *root);
159 /* Execute a single menu. Returns <0 on error */
160 int menu_do(menu_t *menu);