]> git.proxmox.com Git - grub2.git/blob - include/grub/normal.h
2004-03-14 Marco Gerards <metgerards@student.han.nl>
[grub2.git] / include / grub / normal.h
1 /* normal.h - prototypes for the normal mode */
2 /*
3 * PUPA -- Preliminary Universal Programming Architecture for GRUB
4 * Copyright (C) 2002,2003 Free Software Foundation, Inc.
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
21 #ifndef PUPA_NORMAL_HEADER
22 #define PUPA_NORMAL_HEADER 1
23
24 #include <pupa/setjmp.h>
25 #include <pupa/symbol.h>
26 #include <pupa/err.h>
27 #include <pupa/arg.h>
28
29 /* The maximum size of a command-line. */
30 #define PUPA_MAX_CMDLINE 1600
31
32 /* Can be run in the command-line. */
33 #define PUPA_COMMAND_FLAG_CMDLINE 0x1
34 /* Can be run in the menu. */
35 #define PUPA_COMMAND_FLAG_MENU 0x2
36 /* Can be run in both interfaces. */
37 #define PUPA_COMMAND_FLAG_BOTH 0x3
38 /* Only for the command title. */
39 #define PUPA_COMMAND_FLAG_TITLE 0x4
40 /* Don't print the command on booting. */
41 #define PUPA_COMMAND_FLAG_NO_ECHO 0x8
42
43 /* The command description. */
44 struct pupa_command
45 {
46 /* The name. */
47 const char *name;
48
49 /* The callback function. */
50 pupa_err_t (*func) (struct pupa_arg_list *state, int argc, char **args);
51
52 /* The flags. */
53 unsigned flags;
54
55 /* The summary of the command usage. */
56 const char *summary;
57
58 /* The description of the command. */
59 const char *description;
60
61 /* The argument parser optionlist. */
62 const struct pupa_arg_option *options;
63
64 /* The next element. */
65 struct pupa_command *next;
66 };
67 typedef struct pupa_command *pupa_command_t;
68
69 /* The command list. */
70 struct pupa_command_list
71 {
72 /* The string of a command. */
73 const char *command;
74
75 /* The next element. */
76 struct pupa_command_list *next;
77 };
78 typedef struct pupa_command_list *pupa_command_list_t;
79
80 /* The menu entry. */
81 struct pupa_menu_entry
82 {
83 /* The title name. */
84 const char *title;
85
86 /* The number of commands. */
87 int num;
88
89 /* The list of commands. */
90 pupa_command_list_t command_list;
91
92 /* The next element. */
93 struct pupa_menu_entry *next;
94 };
95 typedef struct pupa_menu_entry *pupa_menu_entry_t;
96
97 /* The menu. */
98 struct pupa_menu
99 {
100 /* The default entry number. */
101 int default_entry;
102
103 /* The fallback entry number. */
104 int fallback_entry;
105
106 /* The timeout to boot the default entry automatically. */
107 int timeout;
108
109 /* The size of a menu. */
110 int size;
111
112 /* The list of menu entries. */
113 pupa_menu_entry_t entry_list;
114 };
115 typedef struct pupa_menu *pupa_menu_t;
116
117 /* To exit from the normal mode. */
118 extern pupa_jmp_buf pupa_exit_env;
119
120 void pupa_enter_normal_mode (const char *config);
121 void pupa_normal_execute (const char *config, int nested);
122 void pupa_menu_run (pupa_menu_t menu, int nested);
123 void pupa_cmdline_run (int nested);
124 int pupa_cmdline_get (const char *prompt, char cmdline[], unsigned max_len,
125 int echo_char, int readline);
126 void EXPORT_FUNC(pupa_register_command) (const char *name,
127 pupa_err_t (*func) (struct pupa_arg_list *state,
128 int argc, char **args),
129 unsigned flags,
130 const char *summary,
131 const char *description,
132 const struct pupa_arg_option *parser);
133 void EXPORT_FUNC(pupa_unregister_command) (const char *name);
134 pupa_command_t pupa_command_find (char *cmdline);
135 pupa_err_t pupa_set_history (int newsize);
136 int pupa_iterate_commands (int (*iterate) (pupa_command_t));
137 int pupa_command_execute (char *cmdline);
138 void pupa_command_init (void);
139 void pupa_normal_init_page (void);
140 int pupa_arg_parse (pupa_command_t parser, int argc, char **argv,
141 struct pupa_arg_list *usr, char ***args, int *argnum);
142
143
144 #ifdef PUPA_UTIL
145 void pupa_normal_init (void);
146 void pupa_normal_fini (void);
147 void pupa_hello_init (void);
148 void pupa_hello_fini (void);
149 void pupa_ls_init (void);
150 void pupa_ls_fini (void);
151 void pupa_cat_init (void);
152 void pupa_cat_fini (void);
153 void pupa_boot_init (void);
154 void pupa_boot_fini (void);
155 void pupa_cmp_init (void);
156 void pupa_cmp_fini (void);
157 void pupa_terminal_init (void);
158 void pupa_terminal_fini (void);
159 #endif
160
161 #endif /* ! PUPA_NORMAL_HEADER */