Adding upstream version 3.86+dfsg.
[syslinux-debian/hramrach.git] / com32 / menu / menu.h
blob1e596e1dbb68f2ef721e15eaaa0880d940847fec
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 save; /* Save this entry if selected */
69 static inline bool is_disabled(struct menu_entry *me)
71 return me->action == MA_DISABLED;
74 enum kernel_type {
75 /* Meta-types for internal use */
76 KT_NONE,
77 KT_LOCALBOOT,
79 /* The ones we can pass off to SYSLINUX, in order */
80 KT_KERNEL, /* Undefined type */
81 KT_LINUX, /* Linux kernel */
82 KT_BOOT, /* Bootstrap program */
83 KT_BSS, /* Boot sector with patch */
84 KT_PXE, /* PXE NBP */
85 KT_FDIMAGE, /* Floppy disk image */
86 KT_COMBOOT, /* COMBOOT image */
87 KT_COM32, /* COM32 image */
88 KT_CONFIG, /* Configuration file */
91 extern const char *const kernel_types[];
93 /* Configurable integer parameters */
94 enum parameter_number {
95 P_WIDTH,
96 P_MARGIN,
97 P_PASSWD_MARGIN,
98 P_MENU_ROWS,
99 P_TABMSG_ROW,
100 P_CMDLINE_ROW,
101 P_END_ROW,
102 P_PASSWD_ROW,
103 P_TIMEOUT_ROW,
104 P_HELPMSG_ROW,
105 P_HELPMSGEND_ROW,
106 P_HSHIFT,
107 P_VSHIFT,
108 P_HIDDEN_ROW,
110 NPARAMS
113 /* Configurable messages */
114 enum message_number {
115 MSG_TITLE,
116 MSG_AUTOBOOT,
117 MSG_TAB,
118 MSG_NOTAB,
119 MSG_PASSPROMPT,
121 MSG_COUNT
124 struct messages {
125 const char *name; /* Message configuration name */
126 const char *defmsg; /* Default message text */
129 struct menu_parameter {
130 const char *name;
131 int value;
134 extern const struct menu_parameter mparm[NPARAMS];
136 struct fkey_help {
137 const char *textname;
138 const char *background;
141 struct menu {
142 struct menu *next; /* Linked list of all menus */
143 const char *label; /* Goto label for this menu */
144 struct menu *parent;
145 struct menu_entry *parent_entry; /* Entry for self in parent */
147 struct menu_entry **menu_entries;
148 struct menu_entry *menu_hotkeys[256];
150 const char *messages[MSG_COUNT];
151 int mparm[NPARAMS];
153 int nentries;
154 int nentries_space;
155 int defentry;
156 int timeout;
158 bool allowedit;
159 bool save; /* MENU SAVE default for this menu */
161 int curentry;
162 int curtop;
164 const char *title;
165 const char *ontimeout;
166 const char *onerror;
167 const char *menu_master_passwd;
168 const char *menu_background;
170 struct color_table *color_table;
172 struct fkey_help fkeyhelp[12];
175 extern struct menu *root_menu, *start_menu, *hide_menu, *menu_list;
177 /* 2048 is the current definition inside syslinux */
178 #define MAX_CMDLINE_LEN 2048
180 /* These are global parameters regardless of which menu we're displaying */
181 extern int shiftkey;
182 extern int hiddenmenu;
183 extern int clearmenu;
184 extern long long totaltimeout;
186 void parse_configs(char **argv);
187 int draw_background(const char *filename);
188 void set_resolution(int x, int y);
189 void start_console(void);
190 void local_cursor_enable(bool);
192 static inline int my_isspace(char c)
194 return (unsigned char)c <= ' ';
197 int my_isxdigit(char c);
198 unsigned int hexval(char c);
199 unsigned int hexval2(const char *p);
200 uint32_t parse_argb(char **p);
202 extern const int message_base_color, menu_color_table_size;
203 int mygetkey(clock_t timeout);
204 int show_message_file(const char *filename, const char *background);
206 /* passwd.c */
207 int passwd_compare(const char *passwd, const char *entry);
209 /* colors.c */
210 #define MSG_COLORS_DEF_FG 0x90ffffff
211 #define MSG_COLORS_DEF_BG 0x80ffffff
212 #define MSG_COLORS_DEF_SHADOW SHADOW_NORMAL
213 void set_msg_colors_global(struct color_table *tbl,
214 unsigned int fg, unsigned int bg,
215 enum color_table_shadow shadow);
216 struct color_table *default_color_table(void);
217 struct color_table *copy_color_table(const struct color_table *master);
218 extern const int message_base_color;
220 /* background.c */
221 extern const char *current_background;
222 void set_background(const char *new_background);
224 /* execute.c */
225 void execute(const char *cmdline, enum kernel_type type);
227 /* drain.c */
228 void drain_keyboard(void);
230 #endif /* MENU_H */