]> git.proxmox.com Git - grub2.git/blob - include/grub/normal.h
2007-07-22 Yoshinori K. Okuji <okuji@enbug.org>
[grub2.git] / include / grub / normal.h
1 /* normal.h - prototypes for the normal mode */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2002,2003,2005,2006,2007 Free Software Foundation, Inc.
5 *
6 * GRUB 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 3 of the License, or
9 * (at your option) any later version.
10 *
11 * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef GRUB_NORMAL_HEADER
21 #define GRUB_NORMAL_HEADER 1
22
23 #include <grub/setjmp.h>
24 #include <grub/symbol.h>
25 #include <grub/err.h>
26 #include <grub/arg.h>
27
28 /* The maximum size of a command-line. */
29 #define GRUB_MAX_CMDLINE 1600
30
31 /* Can be run in the command-line. */
32 #define GRUB_COMMAND_FLAG_CMDLINE 0x1
33 /* Can be run in the menu. */
34 #define GRUB_COMMAND_FLAG_MENU 0x2
35 /* Can be run in both interfaces. */
36 #define GRUB_COMMAND_FLAG_BOTH 0x3
37 /* Only for the command title. */
38 #define GRUB_COMMAND_FLAG_TITLE 0x4
39 /* Don't print the command on booting. */
40 #define GRUB_COMMAND_FLAG_NO_ECHO 0x8
41 /* Don't print the command on booting. */
42 #define GRUB_COMMAND_FLAG_NO_ARG_PARSE 0x10
43 /* Not loaded yet. Used for auto-loading. */
44 #define GRUB_COMMAND_FLAG_NOT_LOADED 0x20
45
46 /* The type of a completion item. */
47 enum grub_completion_type
48 {
49 GRUB_COMPLETION_TYPE_COMMAND,
50 GRUB_COMPLETION_TYPE_DEVICE,
51 GRUB_COMPLETION_TYPE_PARTITION,
52 GRUB_COMPLETION_TYPE_FILE,
53 GRUB_COMPLETION_TYPE_ARGUMENT
54 };
55 typedef enum grub_completion_type grub_completion_type_t;
56
57 /* The command description. */
58 struct grub_command
59 {
60 /* The name. */
61 char *name;
62
63 /* The callback function. */
64 grub_err_t (*func) (struct grub_arg_list *state, int argc, char **args);
65
66 /* The flags. */
67 unsigned flags;
68
69 /* The summary of the command usage. */
70 const char *summary;
71
72 /* The description of the command. */
73 const char *description;
74
75 /* The argument parser optionlist. */
76 const struct grub_arg_option *options;
77
78 /* The name of a module. Used for auto-loading. */
79 char *module_name;
80
81 /* The next element. */
82 struct grub_command *next;
83 };
84 typedef struct grub_command *grub_command_t;
85
86 /* The menu entry. */
87 struct grub_menu_entry
88 {
89 /* The title name. */
90 const char *title;
91
92 /* The commands associated with this menu entry. */
93 struct grub_script *commands;
94
95 /* The sourcecode of the menu entry, used by the editor. */
96 const char *sourcecode;
97
98 /* The next element. */
99 struct grub_menu_entry *next;
100 };
101 typedef struct grub_menu_entry *grub_menu_entry_t;
102
103 /* The menu. */
104 struct grub_menu
105 {
106 /* The size of a menu. */
107 int size;
108
109 /* The list of menu entries. */
110 grub_menu_entry_t entry_list;
111 };
112 typedef struct grub_menu *grub_menu_t;
113
114 /* This is used to store the names of filesystem modules for auto-loading. */
115 struct grub_fs_module_list
116 {
117 char *name;
118 struct grub_fs_module_list *next;
119 };
120 typedef struct grub_fs_module_list *grub_fs_module_list_t;
121
122 /* To exit from the normal mode. */
123 extern grub_jmp_buf grub_exit_env;
124
125 void grub_enter_normal_mode (const char *config);
126 void grub_normal_execute (const char *config, int nested);
127 void grub_menu_run (grub_menu_t menu, int nested);
128 void grub_menu_entry_run (grub_menu_entry_t entry);
129 void grub_cmdline_run (int nested);
130 int grub_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
131 int echo_char, int readline);
132 grub_command_t grub_register_command (const char *name,
133 grub_err_t (*func) (struct grub_arg_list *state,
134 int argc,
135 char **args),
136 unsigned flags,
137 const char *summary,
138 const char *description,
139 const struct grub_arg_option *parser);
140 void grub_unregister_command (const char *name);
141 grub_command_t grub_command_find (char *cmdline);
142 grub_err_t grub_set_history (int newsize);
143 int grub_iterate_commands (int (*iterate) (grub_command_t));
144 int grub_command_execute (char *cmdline, int interactive);
145 void grub_command_init (void);
146 void grub_normal_init_page (void);
147 void grub_menu_init_page (int nested, int edit);
148 int grub_arg_parse (grub_command_t parser, int argc, char **argv,
149 struct grub_arg_list *usr, char ***args, int *argnum);
150 void grub_arg_show_help (grub_command_t cmd);
151 char *grub_normal_do_completion (char *buf, int *restore,
152 void (*hook) (const char *item, grub_completion_type_t type, int count));
153 grub_err_t grub_normal_print_device_info (const char *name);
154 grub_err_t grub_normal_menu_addentry (const char *title,
155 struct grub_script *script,
156 const char *sourcecode);
157
158 #ifdef GRUB_UTIL
159 void grub_normal_init (void);
160 void grub_normal_fini (void);
161 void grub_hello_init (void);
162 void grub_hello_fini (void);
163 void grub_ls_init (void);
164 void grub_ls_fini (void);
165 void grub_cat_init (void);
166 void grub_cat_fini (void);
167 void grub_boot_init (void);
168 void grub_boot_fini (void);
169 void grub_cmp_init (void);
170 void grub_cmp_fini (void);
171 void grub_terminal_init (void);
172 void grub_terminal_fini (void);
173 void grub_loop_init (void);
174 void grub_loop_fini (void);
175 void grub_help_init (void);
176 void grub_help_fini (void);
177 void grub_halt_init (void);
178 void grub_halt_fini (void);
179 void grub_reboot_init (void);
180 void grub_reboot_fini (void);
181 void grub_configfile_init (void);
182 void grub_configfile_fini (void);
183 void grub_search_init (void);
184 void grub_search_fini (void);
185 void grub_test_init (void);
186 void grub_test_fini (void);
187 void grub_blocklist_init (void);
188 void grub_blocklist_fini (void);
189 #endif
190
191 #endif /* ! GRUB_NORMAL_HEADER */