1 /* normal.h - prototypes for the normal mode */
3 * PUPA -- Preliminary Universal Programming Architecture for GRUB
4 * Copyright (C) 2002,2003 Free Software Foundation, Inc.
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.
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.
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.
21 #ifndef PUPA_NORMAL_HEADER
22 #define PUPA_NORMAL_HEADER 1
24 #include <pupa/setjmp.h>
25 #include <pupa/symbol.h>
29 /* The maximum size of a command-line. */
30 #define PUPA_MAX_CMDLINE 1600
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
43 /* The command description. */
49 /* The callback function. */
50 pupa_err_t (*func
) (struct pupa_arg_list
*state
, int argc
, char **args
);
55 /* The summary of the command usage. */
58 /* The description of the command. */
59 const char *description
;
61 /* The argument parser optionlist. */
62 const struct pupa_arg_option
*options
;
64 /* The next element. */
65 struct pupa_command
*next
;
67 typedef struct pupa_command
*pupa_command_t
;
69 /* The command list. */
70 struct pupa_command_list
72 /* The string of a command. */
75 /* The next element. */
76 struct pupa_command_list
*next
;
78 typedef struct pupa_command_list
*pupa_command_list_t
;
81 struct pupa_menu_entry
86 /* The number of commands. */
89 /* The list of commands. */
90 pupa_command_list_t command_list
;
92 /* The next element. */
93 struct pupa_menu_entry
*next
;
95 typedef struct pupa_menu_entry
*pupa_menu_entry_t
;
100 /* The default entry number. */
103 /* The fallback entry number. */
106 /* The timeout to boot the default entry automatically. */
109 /* The size of a menu. */
112 /* The list of menu entries. */
113 pupa_menu_entry_t entry_list
;
115 typedef struct pupa_menu
*pupa_menu_t
;
117 /* To exit from the normal mode. */
118 extern pupa_jmp_buf pupa_exit_env
;
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
),
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
);
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);
161 #endif /* ! PUPA_NORMAL_HEADER */