Adding upstream version 4.00~pre61+dfsg.
[syslinux-debian/hramrach.git] / com32 / menu / menu.h
blob63e1859aaeda6848c6ea2d52d9fd4b906033b160
1 /* ----------------------------------------------------------------------- *
3 * Copyright 2004-2008 H. Peter Anvin - All Rights Reserved
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., 51 Franklin St, Fifth Floor,
8 * Boston MA 02110-1301, USA; either version 2 of the License, or
9 * (at your option) any later version; incorporated herein by reference.
11 * ----------------------------------------------------------------------- */
14 * menu.h
16 * Header file for the simple menu system
19 #ifndef MENU_H
20 #define MENU_H
22 #include <time.h>
23 #include <sys/time.h>
24 #include <sys/times.h>
25 #include <inttypes.h>
26 #include <unistd.h>
27 #include <colortbl.h>
28 #include <stdbool.h>
29 #include "refstr.h"
31 /* #define DEBUG 1 */
32 #include <dprintf.h>
34 #ifndef CLK_TCK
35 # define CLK_TCK sysconf(_SC_CLK_TCK)
36 #endif
38 struct menu;
40 /* Note: the _UNRES variants must always be immediately after their
41 "normal" versions. */
42 enum menu_action {
43 MA_NONE, /* Undefined value */
44 MA_CMD, /* Execute a command */
45 MA_DISABLED, /* Disabled menu entry */
46 MA_SUBMENU, /* This is a submenu entry */
47 MA_GOTO, /* Go to another menu */
48 MA_GOTO_UNRES, /* Unresolved go to */
49 MA_QUIT, /* Quit to CLI */
50 MA_EXIT, /* Exit to higher-level menu */
51 MA_EXIT_UNRES, /* Unresolved exit */
54 struct menu_entry {
55 struct menu *menu; /* Parent menu */
56 const char *displayname;
57 const char *label;
58 const char *passwd;
59 char *helptext;
60 const char *cmdline;
61 struct menu *submenu;
62 struct menu_entry *next; /* Linked list of all labels across menus */
63 int entry; /* Entry number inside menu */
64 enum menu_action action;
65 unsigned char hotkey;
66 bool immediate; /* Hotkey action does not require Enter */
67 bool save; /* Save this entry if selected */
70 static inline bool is_disabled(struct menu_entry *me)
72 return me->action == MA_DISABLED;
75 enum kernel_type {
76 /* Meta-types for internal use */
77 KT_NONE,
78 KT_LOCALBOOT,
80 /* The ones we can pass off to SYSLINUX, in order */
81 KT_KERNEL, /* Undefined type */
82 KT_LINUX, /* Linux kernel */
83 KT_BOOT, /* Bootstrap program */
84 KT_BSS, /* Boot sector with patch */
85 KT_PXE, /* PXE NBP */
86 KT_FDIMAGE, /* Floppy disk image */
87 KT_COMBOOT, /* COMBOOT image */
88 KT_COM32, /* COM32 image */
89 KT_CONFIG, /* Configuration file */
92 extern const char *const kernel_types[];
94 /* Configurable integer parameters */
95 enum parameter_number {
96 P_WIDTH,
97 P_MARGIN,
98 P_PASSWD_MARGIN,
99 P_MENU_ROWS,
100 P_TABMSG_ROW,
101 P_CMDLINE_ROW,
102 P_END_ROW,
103 P_PASSWD_ROW,
104 P_TIMEOUT_ROW,
105 P_HELPMSG_ROW,
106 P_HELPMSGEND_ROW,
107 P_HSHIFT,
108 P_VSHIFT,
109 P_HIDDEN_ROW,
111 NPARAMS
114 /* Configurable messages */
115 enum message_number {
116 MSG_TITLE,
117 MSG_AUTOBOOT,
118 MSG_TAB,
119 MSG_NOTAB,
120 MSG_PASSPROMPT,
122 MSG_COUNT
125 struct messages {
126 const char *name; /* Message configuration name */
127 const char *defmsg; /* Default message text */
130 struct menu_parameter {
131 const char *name;
132 int value;
135 extern const struct menu_parameter mparm[NPARAMS];
137 struct fkey_help {
138 const char *textname;
139 const char *background;
142 struct menu {
143 struct menu *next; /* Linked list of all menus */
144 const char *label; /* Goto label for this menu */
145 struct menu *parent;
146 struct menu_entry *parent_entry; /* Entry for self in parent */
148 struct menu_entry **menu_entries;
149 struct menu_entry *menu_hotkeys[256];
151 const char *messages[MSG_COUNT];
152 int mparm[NPARAMS];
154 int nentries;
155 int nentries_space;
156 int defentry;
157 int timeout;
159 bool allowedit;
160 bool immediate; /* MENU IMMEDIATE default for this menu */
161 bool save; /* MENU SAVE default for this menu */
163 int curentry;
164 int curtop;
166 const char *title;
167 const char *ontimeout;
168 const char *onerror;
169 const char *menu_master_passwd;
170 const char *menu_background;
172 struct color_table *color_table;
174 struct fkey_help fkeyhelp[12];
177 extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list;
179 /* 2048 is the current definition inside syslinux */
180 #define MAX_CMDLINE_LEN 2048
182 /* These are global parameters regardless of which menu we're displaying */
183 extern int shiftkey;
184 extern int hiddenmenu;
185 extern int clearmenu;
186 extern long long totaltimeout;
188 void parse_configs(char **argv);
189 int draw_background(const char *filename);
190 void set_resolution(int x, int y);
191 void start_console(void);
192 void local_cursor_enable(bool);
194 static inline int my_isspace(char c)
196 return (unsigned char)c <= ' ';
199 int my_isxdigit(char c);
200 unsigned int hexval(char c);
201 unsigned int hexval2(const char *p);
202 uint32_t parse_argb(char **p);
204 extern const int message_base_color, menu_color_table_size;
205 int mygetkey(clock_t timeout);
206 int show_message_file(const char *filename, const char *background);
208 /* passwd.c */
209 int passwd_compare(const char *passwd, const char *entry);
211 /* colors.c */
212 #define MSG_COLORS_DEF_FG 0x90ffffff
213 #define MSG_COLORS_DEF_BG 0x80ffffff
214 #define MSG_COLORS_DEF_SHADOW SHADOW_NORMAL
215 void set_msg_colors_global(struct color_table *tbl,
216 unsigned int fg, unsigned int bg,
217 enum color_table_shadow shadow);
218 struct color_table *default_color_table(void);
219 struct color_table *copy_color_table(const struct color_table *master);
220 extern const int message_base_color;
222 /* background.c */
223 extern const char *current_background;
224 void set_background(const char *new_background);
226 /* execute.c */
227 void execute(const char *cmdline, enum kernel_type type);
229 /* drain.c */
230 void drain_keyboard(void);
232 #endif /* MENU_H */