]>
Commit | Line | Data |
---|---|---|
ce5bf700 | 1 | /* normal.h - prototypes for the normal mode */ |
2 | /* | |
3 | * PUPA -- Preliminary Universal Programming Architecture for GRUB | |
4 | * Copyright (C) 2002,2003 Yoshinori K. Okuji <okuji@enbug.org> | |
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> | |
977329f5 | 25 | #include <pupa/symbol.h> |
ce5bf700 | 26 | |
27 | /* The maximum size of a command-line. */ | |
28 | #define PUPA_MAX_CMDLINE 1600 | |
29 | ||
30 | /* Can be run in the command-line. */ | |
31 | #define PUPA_COMMAND_FLAG_CMDLINE 0x1 | |
32 | /* Can be run in the menu. */ | |
33 | #define PUPA_COMMAND_FLAG_MENU 0x2 | |
34 | /* Can be run in both interfaces. */ | |
35 | #define PUPA_COMMAND_FLAG_BOTH 0x3 | |
36 | /* Only for the command title. */ | |
37 | #define PUPA_COMMAND_FLAG_TITLE 0x4 | |
38 | /* Don't print the command on booting. */ | |
39 | #define PUPA_COMMAND_FLAG_NO_ECHO 0x8 | |
40 | ||
41 | /* The command description. */ | |
42 | struct pupa_command | |
43 | { | |
44 | /* The name. */ | |
45 | const char *name; | |
46 | ||
47 | /* The callback function. */ | |
48 | int (*func) (int argc, char *argv[]); | |
49 | ||
50 | /* The flags. */ | |
51 | unsigned flags; | |
52 | ||
53 | /* The summary of the command usage. */ | |
54 | const char *summary; | |
55 | ||
56 | /* The description of the command. */ | |
57 | const char *description; | |
58 | ||
59 | /* The next element. */ | |
60 | struct pupa_command *next; | |
61 | }; | |
62 | typedef struct pupa_command *pupa_command_t; | |
63 | ||
64 | /* The command list. */ | |
65 | struct pupa_command_list | |
66 | { | |
67 | /* The string of a command. */ | |
68 | const char *command; | |
69 | ||
70 | /* The next element. */ | |
71 | struct pupa_command_list *next; | |
72 | }; | |
73 | typedef struct pupa_command_list *pupa_command_list_t; | |
74 | ||
75 | /* The menu entry. */ | |
76 | struct pupa_menu_entry | |
77 | { | |
78 | /* The title name. */ | |
79 | const char *title; | |
80 | ||
81 | /* The number of commands. */ | |
82 | int num; | |
83 | ||
84 | /* The list of commands. */ | |
85 | pupa_command_list_t command_list; | |
86 | ||
87 | /* The next element. */ | |
88 | struct pupa_menu_entry *next; | |
89 | }; | |
90 | typedef struct pupa_menu_entry *pupa_menu_entry_t; | |
91 | ||
92 | /* The menu. */ | |
93 | struct pupa_menu | |
94 | { | |
95 | /* The default entry number. */ | |
96 | int default_entry; | |
97 | ||
98 | /* The fallback entry number. */ | |
99 | int fallback_entry; | |
100 | ||
101 | /* The timeout to boot the default entry automatically. */ | |
102 | int timeout; | |
103 | ||
104 | /* The size of a menu. */ | |
105 | int size; | |
106 | ||
107 | /* The list of menu entries. */ | |
108 | pupa_menu_entry_t entry_list; | |
109 | }; | |
110 | typedef struct pupa_menu *pupa_menu_t; | |
111 | ||
112 | /* To exit from the normal mode. */ | |
113 | extern pupa_jmp_buf pupa_exit_env; | |
114 | ||
115 | void pupa_enter_normal_mode (const char *config); | |
116 | void pupa_normal_execute (const char *config, int nested); | |
117 | void pupa_menu_run (pupa_menu_t menu, int nested); | |
118 | void pupa_cmdline_run (int nested); | |
119 | int pupa_cmdline_get (const char *prompt, char cmdline[], unsigned max_len, | |
120 | int echo_char, int readline); | |
977329f5 | 121 | void EXPORT_FUNC(pupa_register_command) (const char *name, |
ce5bf700 | 122 | int (*func) (int argc, char *argv[]), |
123 | unsigned flags, | |
124 | const char *summary, | |
125 | const char *description); | |
977329f5 | 126 | void EXPORT_FUNC(pupa_unregister_command) (const char *name); |
ce5bf700 | 127 | pupa_command_t pupa_command_find (char *cmdline); |
128 | int pupa_command_execute (char *cmdline); | |
129 | void pupa_command_init (void); | |
130 | void pupa_normal_init_page (void); | |
131 | ||
1f7315a3 | 132 | #ifdef PUPA_UTIL |
133 | void pupa_normal_init (void); | |
134 | void pupa_normal_fini (void); | |
135 | #endif | |
136 | ||
ce5bf700 | 137 | #endif /* ! PUPA_NORMAL_HEADER */ |