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 * ----------------------------------------------------------------------- */
16 * Header file for the simple menu system
24 #include <sys/times.h>
35 # define CLK_TCK sysconf(_SC_CLK_TCK)
40 /* Note: the _UNRES variants must always be immediately after their
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 */
55 struct menu
*menu
; /* Parent menu */
56 const char *displayname
;
62 struct menu_entry
*next
; /* Linked list of all labels across menus */
63 int entry
; /* Entry number inside menu */
64 enum menu_action action
;
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
;
76 /* Meta-types for internal use */
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 */
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
{
114 /* Configurable messages */
115 enum message_number
{
126 const char *name
; /* Message configuration name */
127 const char *defmsg
; /* Default message text */
130 struct menu_parameter
{
135 extern const struct menu_parameter mparm
[NPARAMS
];
138 const char *textname
;
139 const char *background
;
143 struct menu
*next
; /* Linked list of all menus */
144 const char *label
; /* Goto label for this menu */
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
];
160 bool immediate
; /* MENU IMMEDIATE default for this menu */
161 bool save
; /* MENU SAVE default for this menu */
167 const char *ontimeout
;
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 */
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
);
209 int passwd_compare(const char *passwd
, const char *entry
);
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
;
223 extern const char *current_background
;
224 void set_background(const char *new_background
);
227 void execute(const char *cmdline
, enum kernel_type type
);
230 void drain_keyboard(void);