]>
Commit | Line | Data |
---|---|---|
ce5bf700 | 1 | /* normal.h - prototypes for the normal mode */ |
2 | /* | |
4b13b216 | 3 | * GRUB -- GRand Unified Bootloader |
5822ff87 | 4 | * Copyright (C) 2002,2003,2005 Free Software Foundation, Inc. |
ce5bf700 | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | */ | |
20 | ||
4b13b216 | 21 | #ifndef GRUB_NORMAL_HEADER |
22 | #define GRUB_NORMAL_HEADER 1 | |
ce5bf700 | 23 | |
4b13b216 | 24 | #include <grub/setjmp.h> |
25 | #include <grub/symbol.h> | |
26 | #include <grub/err.h> | |
27 | #include <grub/arg.h> | |
77c4a393 | 28 | #include <grub/script.h> |
ce5bf700 | 29 | |
30 | /* The maximum size of a command-line. */ | |
4b13b216 | 31 | #define GRUB_MAX_CMDLINE 1600 |
ce5bf700 | 32 | |
33 | /* Can be run in the command-line. */ | |
4b13b216 | 34 | #define GRUB_COMMAND_FLAG_CMDLINE 0x1 |
ce5bf700 | 35 | /* Can be run in the menu. */ |
4b13b216 | 36 | #define GRUB_COMMAND_FLAG_MENU 0x2 |
ce5bf700 | 37 | /* Can be run in both interfaces. */ |
4b13b216 | 38 | #define GRUB_COMMAND_FLAG_BOTH 0x3 |
ce5bf700 | 39 | /* Only for the command title. */ |
4b13b216 | 40 | #define GRUB_COMMAND_FLAG_TITLE 0x4 |
ce5bf700 | 41 | /* Don't print the command on booting. */ |
4b13b216 | 42 | #define GRUB_COMMAND_FLAG_NO_ECHO 0x8 |
b47efe30 | 43 | /* Don't print the command on booting. */ |
44 | #define GRUB_COMMAND_FLAG_NO_ARG_PARSE 0x10 | |
5822ff87 | 45 | /* Not loaded yet. Used for auto-loading. */ |
46 | #define GRUB_COMMAND_FLAG_NOT_LOADED 0x20 | |
ce5bf700 | 47 | |
992ffbbe | 48 | /* The type of a completion item. */ |
49 | enum grub_completion_type | |
50 | { | |
51 | GRUB_COMPLETION_TYPE_COMMAND, | |
52 | GRUB_COMPLETION_TYPE_DEVICE, | |
53 | GRUB_COMPLETION_TYPE_PARTITION, | |
54 | GRUB_COMPLETION_TYPE_FILE, | |
67f44c86 | 55 | GRUB_COMPLETION_TYPE_ARGUMENT |
992ffbbe | 56 | }; |
57 | typedef enum grub_completion_type grub_completion_type_t; | |
58 | ||
ce5bf700 | 59 | /* The command description. */ |
4b13b216 | 60 | struct grub_command |
ce5bf700 | 61 | { |
62 | /* The name. */ | |
5822ff87 | 63 | char *name; |
ce5bf700 | 64 | |
65 | /* The callback function. */ | |
4b13b216 | 66 | grub_err_t (*func) (struct grub_arg_list *state, int argc, char **args); |
ce5bf700 | 67 | |
68 | /* The flags. */ | |
69 | unsigned flags; | |
70 | ||
71 | /* The summary of the command usage. */ | |
72 | const char *summary; | |
73 | ||
74 | /* The description of the command. */ | |
75 | const char *description; | |
76 | ||
db1771cf | 77 | /* The argument parser optionlist. */ |
4b13b216 | 78 | const struct grub_arg_option *options; |
db1771cf | 79 | |
5822ff87 | 80 | /* The name of a module. Used for auto-loading. */ |
81 | char *module_name; | |
82 | ||
ce5bf700 | 83 | /* The next element. */ |
4b13b216 | 84 | struct grub_command *next; |
ce5bf700 | 85 | }; |
4b13b216 | 86 | typedef struct grub_command *grub_command_t; |
ce5bf700 | 87 | |
ce5bf700 | 88 | /* The menu entry. */ |
4b13b216 | 89 | struct grub_menu_entry |
ce5bf700 | 90 | { |
91 | /* The title name. */ | |
92 | const char *title; | |
93 | ||
77c4a393 | 94 | /* The commands associated with this menu entry. */ |
95 | struct grub_script *commands; | |
ce5bf700 | 96 | |
77c4a393 | 97 | /* The sourcecode of the menu entry, used by the editor. */ |
98 | const char *sourcecode; | |
ce5bf700 | 99 | |
100 | /* The next element. */ | |
4b13b216 | 101 | struct grub_menu_entry *next; |
ce5bf700 | 102 | }; |
4b13b216 | 103 | typedef struct grub_menu_entry *grub_menu_entry_t; |
ce5bf700 | 104 | |
105 | /* The menu. */ | |
4b13b216 | 106 | struct grub_menu |
ce5bf700 | 107 | { |
108 | /* The default entry number. */ | |
109 | int default_entry; | |
110 | ||
111 | /* The fallback entry number. */ | |
112 | int fallback_entry; | |
113 | ||
114 | /* The timeout to boot the default entry automatically. */ | |
115 | int timeout; | |
116 | ||
117 | /* The size of a menu. */ | |
118 | int size; | |
119 | ||
120 | /* The list of menu entries. */ | |
4b13b216 | 121 | grub_menu_entry_t entry_list; |
ce5bf700 | 122 | }; |
4b13b216 | 123 | typedef struct grub_menu *grub_menu_t; |
ce5bf700 | 124 | |
93f3a1d8 | 125 | /* A list of menus. */ |
126 | struct grub_menu_list | |
127 | { | |
128 | grub_menu_t menu; | |
129 | struct grub_menu_list *next; | |
130 | }; | |
131 | typedef struct grub_menu_list *grub_menu_list_t; | |
132 | ||
133 | /* The context. A context holds some global information. */ | |
134 | struct grub_context | |
135 | { | |
136 | /* The menu list. */ | |
137 | grub_menu_list_t menu_list; | |
138 | }; | |
139 | typedef struct grub_context *grub_context_t; | |
140 | ||
39c9d41d | 141 | /* This is used to store the names of filesystem modules for auto-loading. */ |
142 | struct grub_fs_module_list | |
143 | { | |
144 | char *name; | |
145 | struct grub_fs_module_list *next; | |
146 | }; | |
147 | typedef struct grub_fs_module_list *grub_fs_module_list_t; | |
148 | ||
ce5bf700 | 149 | /* To exit from the normal mode. */ |
4b13b216 | 150 | extern grub_jmp_buf grub_exit_env; |
ce5bf700 | 151 | |
4b13b216 | 152 | void grub_enter_normal_mode (const char *config); |
153 | void grub_normal_execute (const char *config, int nested); | |
154 | void grub_menu_run (grub_menu_t menu, int nested); | |
e6b92c8a | 155 | void grub_menu_entry_run (grub_menu_entry_t entry); |
4b13b216 | 156 | void grub_cmdline_run (int nested); |
157 | int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, | |
ce5bf700 | 158 | int echo_char, int readline); |
5822ff87 | 159 | grub_command_t grub_register_command (const char *name, |
160 | grub_err_t (*func) (struct grub_arg_list *state, | |
161 | int argc, | |
162 | char **args), | |
163 | unsigned flags, | |
164 | const char *summary, | |
165 | const char *description, | |
166 | const struct grub_arg_option *parser); | |
93f3a1d8 | 167 | void grub_unregister_command (const char *name); |
4b13b216 | 168 | grub_command_t grub_command_find (char *cmdline); |
169 | grub_err_t grub_set_history (int newsize); | |
170 | int grub_iterate_commands (int (*iterate) (grub_command_t)); | |
0a74e62f | 171 | int grub_command_execute (char *cmdline, int interactive); |
4b13b216 | 172 | void grub_command_init (void); |
173 | void grub_normal_init_page (void); | |
4d4e372e | 174 | void grub_menu_init_page (int nested, int edit); |
4b13b216 | 175 | int grub_arg_parse (grub_command_t parser, int argc, char **argv, |
176 | struct grub_arg_list *usr, char ***args, int *argnum); | |
990cf3aa | 177 | void grub_arg_show_help (grub_command_t cmd); |
93f3a1d8 | 178 | grub_context_t grub_context_get (void); |
179 | grub_menu_t grub_context_get_current_menu (void); | |
180 | grub_menu_t grub_context_push_menu (grub_menu_t menu); | |
181 | void grub_context_pop_menu (void); | |
992ffbbe | 182 | char *grub_normal_do_completion (char *buf, int *restore, |
183 | void (*hook) (const char *item, grub_completion_type_t type, int count)); | |
184 | grub_err_t grub_normal_print_device_info (const char *name); | |
77c4a393 | 185 | grub_err_t grub_normal_menu_addentry (const char *title, |
186 | struct grub_script *script, | |
187 | const char *sourcecode); | |
4b13b216 | 188 | |
189 | #ifdef GRUB_UTIL | |
190 | void grub_normal_init (void); | |
191 | void grub_normal_fini (void); | |
192 | void grub_hello_init (void); | |
193 | void grub_hello_fini (void); | |
194 | void grub_ls_init (void); | |
195 | void grub_ls_fini (void); | |
196 | void grub_cat_init (void); | |
197 | void grub_cat_fini (void); | |
198 | void grub_boot_init (void); | |
199 | void grub_boot_fini (void); | |
200 | void grub_cmp_init (void); | |
201 | void grub_cmp_fini (void); | |
202 | void grub_terminal_init (void); | |
203 | void grub_terminal_fini (void); | |
67bbaf0f | 204 | void grub_loop_init (void); |
205 | void grub_loop_fini (void); | |
990cf3aa | 206 | void grub_help_init (void); |
207 | void grub_help_fini (void); | |
e6b92c8a | 208 | void grub_halt_init (void); |
209 | void grub_halt_fini (void); | |
210 | void grub_reboot_init (void); | |
211 | void grub_reboot_fini (void); | |
93f3a1d8 | 212 | void grub_default_init (void); |
213 | void grub_default_fini (void); | |
214 | void grub_timeout_init (void); | |
215 | void grub_timeout_fini (void); | |
062aaf39 | 216 | void grub_configfile_init (void); |
217 | void grub_configfile_fini (void); | |
6a85ce79 | 218 | void grub_search_init (void); |
219 | void grub_search_fini (void); | |
daac212a | 220 | void grub_test_init (void); |
221 | void grub_test_fini (void); | |
1f7315a3 | 222 | #endif |
223 | ||
4b13b216 | 224 | #endif /* ! GRUB_NORMAL_HEADER */ |