Optimization for the implement of menu languages.

This commit is contained in:
longpanda
2022-12-19 23:49:25 +08:00
parent 9c3e1a6880
commit 44a3e23740
37 changed files with 1802 additions and 1610 deletions

View File

@@ -1,174 +0,0 @@
/* echo.c - Command to display a line of text */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2006,2007,2010 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/dl.h>
#include <grub/misc.h>
#include <grub/extcmd.h>
#include <grub/i18n.h>
#include <grub/term.h>
GRUB_MOD_LICENSE ("GPLv3+");
extern const char *ventoy_get_vmenu_title(const char *vMenu);
static const struct grub_arg_option options[] =
{
{0, 'n', 0, N_("Do not output the trailing newline."), 0, 0},
{0, 'e', 0, N_("Enable interpretation of backslash escapes."), 0, 0},
{0, 'v', 0, N_("ventoy menu language."), 0, 0},
{0, 'V', 0, N_("ventoy menu language with pre-newline."), 0, 0},
{0, 0, 0, 0, 0, 0}
};
static grub_err_t
grub_cmd_echo (grub_extcmd_context_t ctxt, int argc, char **args)
{
struct grub_arg_list *state = ctxt->state;
char ch;
int vtmenu = 0;
int newline = 1;
int i;
/* Check if `-n' was used. */
if (state[0].set)
newline = 0;
if (state[2].set || state[3].set)
vtmenu = 1;
for (i = 0; i < argc; i++)
{
char *arg = *args;
/* Unescaping results in a string no longer than the original. */
char *unescaped = grub_malloc (grub_strlen (arg) + 1);
char *p = unescaped;
args++;
if (!unescaped)
return grub_errno;
while (*arg)
{
/* In case `-e' is used, parse backslashes. */
if (*arg == '\\' && state[1].set)
{
arg++;
if (*arg == '\0')
break;
switch (*arg)
{
case '\\':
*p++ = '\\';
break;
case 'a':
*p++ = '\a';
break;
case 'c':
newline = 0;
break;
case 'f':
*p++ = '\f';
break;
case 'n':
*p++ = '\n';
break;
case 'r':
*p++ = '\r';
break;
case 't':
*p++ = '\t';
break;
case 'v':
*p++ = '\v';
break;
}
arg++;
continue;
}
/* This was not an escaped character, or escaping is not
enabled. */
*p++ = *arg;
arg++;
}
*p = '\0';
if (vtmenu && grub_strncmp(unescaped, "VTMENU_", 7) == 0)
{
p = unescaped;
while ((*p >= 'A' && *p <= 'Z') || *p == '_')
{
p++;
}
ch = *p;
*p = 0;
if (state[3].set)
{
grub_xputs("\n");
}
grub_xputs(ventoy_get_vmenu_title(unescaped));
*p = ch;
grub_xputs(p);
}
else
{
grub_xputs (unescaped);
}
grub_free (unescaped);
/* If another argument follows, insert a space. */
if ((0 == vtmenu) && (i != argc - 1))
grub_printf (" " );
}
if (newline)
grub_printf ("\n");
grub_refresh ();
return 0;
}
static grub_extcmd_t cmd;
GRUB_MOD_INIT(echo)
{
cmd = grub_register_extcmd ("echo", grub_cmd_echo,
GRUB_COMMAND_ACCEPT_DASH
| GRUB_COMMAND_OPTIONS_AT_START,
N_("[-e|-n] STRING"), N_("Display a line of text."),
options);
}
GRUB_MOD_FINI(echo)
{
grub_unregister_extcmd (cmd);
}

View File

@@ -25,10 +25,6 @@
#include <grub/i18n.h>
#include <grub/normal.h>
typedef const char * (*get_vmenu_title_pf)(const char *vMenu);
static get_vmenu_title_pf g_pfvmenu_title = NULL;
static const struct grub_arg_option options[] =
{
{"class", 1, GRUB_ARG_OPTION_REPEATABLE,
@@ -90,8 +86,6 @@ grub_normal_add_menu_entry (int argc, const char **args,
char *menu_title = NULL;
char *menu_sourcecode = NULL;
char *menu_id = NULL;
const char *vmenu = NULL;
const char *vaddr = NULL;
struct grub_menu_entry_class *menu_classes = NULL;
grub_menu_t menu;
@@ -151,17 +145,7 @@ grub_normal_add_menu_entry (int argc, const char **args,
goto fail;
}
if (!g_pfvmenu_title) {
vaddr = grub_env_get("VTOY_VMENU_FUNC_ADDR");
if (vaddr)
g_pfvmenu_title = (get_vmenu_title_pf)(unsigned long)grub_strtoul(vaddr, NULL, 16);
}
if (g_pfvmenu_title && grub_strncmp(args[0], "@VTMENU_", 8) == 0)
vmenu = g_pfvmenu_title(args[0] + 1);
menu_title = grub_strdup (vmenu ? vmenu : args[0]);
menu_title = grub_strdup (args[0]);
if (! menu_title)
goto fail;

View File

@@ -232,6 +232,10 @@ label_set_property (void *vself, const char *name, const char *value)
}
else if (grub_strcmp (value, "@VTOY_HOTKEY_TIP@") == 0) {
value = g_ventoy_hotkey_tip;
} else if (value[0] == '@' && value[1] == '@' && value[2]) {
value = grub_env_get(value + 2);
if (!value)
value = " ";
}
self->template = grub_strdup (value);

View File

@@ -0,0 +1,250 @@
/* env.c - Environment variables */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,2008,2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/env.h>
#include <grub/env_private.h>
#include <grub/misc.h>
#include <grub/mm.h>
/* The initial context. */
static struct grub_env_context initial_context;
/* The current context. */
struct grub_env_context *grub_current_context = &initial_context;
static grub_env_read_hook_t vtoy_menu_lang_read_hook;
/* Return the hash representation of the string S. */
static unsigned int
grub_env_hashval (const char *s)
{
unsigned int i = 0;
/* XXX: This can be done much more efficiently. */
while (*s)
i += 5 * *(s++);
return i % HASHSZ;
}
static struct grub_env_var *
grub_env_find (const char *name)
{
struct grub_env_var *var;
int idx = grub_env_hashval (name);
/* Look for the variable in the current context. */
for (var = grub_current_context->vars[idx]; var; var = var->next)
if (grub_strcmp (var->name, name) == 0)
return var;
return 0;
}
static void
grub_env_insert (struct grub_env_context *context,
struct grub_env_var *var)
{
int idx = grub_env_hashval (var->name);
/* Insert the variable into the hashtable. */
var->prevp = &context->vars[idx];
var->next = context->vars[idx];
if (var->next)
var->next->prevp = &(var->next);
context->vars[idx] = var;
}
static void
grub_env_remove (struct grub_env_var *var)
{
/* Remove the entry from the variable table. */
*var->prevp = var->next;
if (var->next)
var->next->prevp = var->prevp;
}
grub_err_t
grub_env_set (const char *name, const char *val)
{
struct grub_env_var *var;
/* If the variable does already exist, just update the variable. */
var = grub_env_find (name);
if (var)
{
char *old = var->value;
if (var->write_hook)
var->value = var->write_hook (var, val);
else
var->value = grub_strdup (val);
if (! var->value)
{
var->value = old;
return grub_errno;
}
grub_free (old);
return GRUB_ERR_NONE;
}
/* The variable does not exist, so create a new one. */
var = grub_zalloc (sizeof (*var));
if (! var)
return grub_errno;
var->name = grub_strdup (name);
if (! var->name)
goto fail;
var->value = grub_strdup (val);
if (! var->value)
goto fail;
grub_env_insert (grub_current_context, var);
return GRUB_ERR_NONE;
fail:
grub_free (var->name);
grub_free (var->value);
grub_free (var);
return grub_errno;
}
const char *
grub_env_get (const char *name)
{
struct grub_env_var *var;
if (name && vtoy_menu_lang_read_hook && grub_strncmp(name, "VTLANG_", 7) == 0)
return vtoy_menu_lang_read_hook(NULL, name);
var = grub_env_find (name);
if (! var)
return 0;
if (var->read_hook)
return var->read_hook (var, var->value);
return var->value;
}
void
grub_env_unset (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
return;
if (var->read_hook || var->write_hook)
{
grub_env_set (name, "");
return;
}
grub_env_remove (var);
grub_free (var->name);
grub_free (var->value);
grub_free (var);
}
struct grub_env_var *
grub_env_update_get_sorted (void)
{
struct grub_env_var *sorted_list = 0;
int i;
/* Add variables associated with this context into a sorted list. */
for (i = 0; i < HASHSZ; i++)
{
struct grub_env_var *var;
for (var = grub_current_context->vars[i]; var; var = var->next)
{
struct grub_env_var *p, **q;
for (q = &sorted_list, p = *q; p; q = &((*q)->sorted_next), p = *q)
{
if (grub_strcmp (p->name, var->name) > 0)
break;
}
var->sorted_next = *q;
*q = var;
}
}
return sorted_list;
}
grub_err_t
grub_register_variable_hook (const char *name,
grub_env_read_hook_t read_hook,
grub_env_write_hook_t write_hook)
{
struct grub_env_var *var = grub_env_find (name);
if (! var)
{
if (grub_env_set (name, "") != GRUB_ERR_NONE)
return grub_errno;
var = grub_env_find (name);
/* XXX Insert an assertion? */
}
var->read_hook = read_hook;
var->write_hook = write_hook;
return GRUB_ERR_NONE;
}
grub_err_t
grub_register_vtoy_menu_lang_hook(grub_env_read_hook_t read_hook)
{
vtoy_menu_lang_read_hook = read_hook;
return GRUB_ERR_NONE;
}
grub_err_t
grub_env_export (const char *name)
{
struct grub_env_var *var;
var = grub_env_find (name);
if (! var)
{
grub_err_t err;
err = grub_env_set (name, "");
if (err)
return err;
var = grub_env_find (name);
}
var->global = 1;
return GRUB_ERR_NONE;
}

View File

@@ -269,12 +269,14 @@ static int ventoy_hwinfo_init(void)
grub_snprintf(str, sizeof(str), "%ld", (long)(total_mem / VTOY_SIZE_1MB));
ventoy_env_export("grub_total_ram", str);
#ifdef GRUB_MACHINE_EFI
ventoy_get_uefi_version(str, sizeof(str));
ventoy_env_export("grub_uefi_version", str);
#else
ventoy_env_export("grub_uefi_version", "NA");
#endif
return 0;
}

View File

@@ -618,13 +618,13 @@ grub_err_t ventoy_cmd_browser_disk(grub_extcmd_context_t ctxt, int argc, char **
{
browser_ssprintf(&mbuf, "menuentry \"%-10s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n", "<--",
ventoy_get_vmenu_title("VTMENU_BROWER_RETURN"));
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
}
else
{
browser_ssprintf(&mbuf, "menuentry \"[%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n}\n",
ventoy_get_vmenu_title("VTMENU_BROWER_RETURN"));
ventoy_get_vmenu_title("VTLANG_BROWER_RETURN"));
}
grub_disk_dev_iterate(ventoy_browser_iterate_disk, &mbuf);

View File

@@ -148,6 +148,8 @@ static char g_iso_vd_id_application[130];
static int g_pager_flag = 0;
static char g_old_pager[32];
static char g_vtoy_gfxmode[64];
const char *g_menu_class[img_type_max] =
{
"vtoyiso", "vtoywim", "vtoyefi", "vtoyimg", "vtoyvhd", "vtoyvtoy"
@@ -2355,14 +2357,14 @@ static int ventoy_dynamic_tree_menu(img_iterator_node *node)
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"%-10s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", "<--", ventoy_get_vmenu_title("VTMENU_RET_TO_LISTVIEW"));
"}\n", "<--", ventoy_get_vmenu_title("VTLANG_RET_TO_LISTVIEW"));
}
else
{
vtoy_ssprintf(g_tree_script_buf, g_tree_script_pos,
"menuentry \"[%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", ventoy_get_vmenu_title("VTMENU_RET_TO_LISTVIEW"));
"}\n", ventoy_get_vmenu_title("VTLANG_RET_TO_LISTVIEW"));
}
}
@@ -2943,7 +2945,7 @@ static grub_err_t ventoy_cmd_list_img(grub_extcmd_context_t ctxt, int argc, char
vtoy_ssprintf(g_list_script_buf, g_list_script_pos,
"menuentry \"%s [%s]\" --class=\"vtoyret\" VTOY_RET {\n "
" echo 'return ...' \n"
"}\n", "<--", ventoy_get_vmenu_title("VTMENU_RET_TO_TREEVIEW"));
"}\n", "<--", ventoy_get_vmenu_title("VTLANG_RET_TO_TREEVIEW"));
}
for (cur = g_ventoy_img_list; cur; cur = cur->next)
@@ -3712,14 +3714,14 @@ static grub_err_t ventoy_cmd_sel_auto_install(grub_extcmd_context_t ctxt, int ar
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
}
vtoy_ssprintf(buf, pos, "menuentry \"@VTMENU_NO_AUTOINS_SCRIPT\" --class=\"sel_auto_install\" {\n"
vtoy_ssprintf(buf, pos, "menuentry \"$VTLANG_NO_AUTOINS_SCRIPT\" --class=\"sel_auto_install\" {\n"
" echo %s\n}\n", "");
for (i = 0; i < node->templatenum; i++)
{
vtoy_ssprintf(buf, pos, "menuentry \"%s %s\" --class=\"sel_auto_install\" {\n"
" echo \"\"\n}\n",
ventoy_get_vmenu_title("VTMENU_AUTOINS_USE"),
ventoy_get_vmenu_title("VTLANG_AUTOINS_USE"),
node->templatepath[i].path);
}
@@ -3819,14 +3821,14 @@ static grub_err_t ventoy_cmd_sel_persistence(grub_extcmd_context_t ctxt, int arg
vtoy_ssprintf(buf, pos, "set timeout=%d\n", node->timeout);
}
vtoy_ssprintf(buf, pos, "menuentry \"@VTMENU_NO_PERSISTENCE\" --class=\"sel_persistence\" {\n"
vtoy_ssprintf(buf, pos, "menuentry \"$VTLANG_NO_PERSISTENCE\" --class=\"sel_persistence\" {\n"
" echo %s\n}\n", "");
for (i = 0; i < node->backendnum; i++)
{
vtoy_ssprintf(buf, pos, "menuentry \"%s %s\" --class=\"sel_persistence\" {\n"
" echo \"\"\n}\n",
ventoy_get_vmenu_title("VTMENU_PERSIST_USE"),
ventoy_get_vmenu_title("VTLANG_PERSIST_USE"),
node->backendpath[i].path);
}
@@ -6082,26 +6084,26 @@ static grub_err_t ventoy_cmd_show_secondary_menu(grub_extcmd_context_t ctxt, int
fsize = grub_strtoull(args[2], NULL, 10);
vtoy_dummy_menuentry(cmd, pos, len, "@VTMENU_NORMAL_MODE", "second_normal"); seldata[n++] = 1;
vtoy_dummy_menuentry(cmd, pos, len, "$VTLANG_NORMAL_MODE", "second_normal"); seldata[n++] = 1;
if (grub_strcmp(args[1], "Unix") != 0)
{
if (grub_strcmp(args[1], "Windows") == 0)
{
vtoy_dummy_menuentry(cmd, pos, len, "@VTMENU_WIMBOOT_MODE", "second_wimboot"); seldata[n++] = 2;
vtoy_dummy_menuentry(cmd, pos, len, "$VTLANG_WIMBOOT_MODE", "second_wimboot"); seldata[n++] = 2;
}
else
{
vtoy_dummy_menuentry(cmd, pos, len, "@VTMENU_GRUB2_MODE", "second_grub2"); seldata[n++] = 3;
vtoy_dummy_menuentry(cmd, pos, len, "$VTLANG_GRUB2_MODE", "second_grub2"); seldata[n++] = 3;
}
if (fsize <= VTOY_SIZE_1GB)
{
vtoy_dummy_menuentry(cmd, pos, len, "@VTMENU_MEMDISK_MODE", "second_memdisk"); seldata[n++] = 4;
vtoy_dummy_menuentry(cmd, pos, len, "$VTLANG_MEMDISK_MODE", "second_memdisk"); seldata[n++] = 4;
}
}
vtoy_dummy_menuentry(cmd, pos, len, "@VTMENU_FILE_CHKSUM", "second_checksum"); seldata[n++] = 5;
vtoy_dummy_menuentry(cmd, pos, len, "$VTLANG_FILE_CHKSUM", "second_checksum"); seldata[n++] = 5;
do {
g_ventoy_menu_esc = 1;
@@ -6202,6 +6204,29 @@ static grub_err_t ventoy_cmd_load_menu_lang(grub_extcmd_context_t ctxt, int argc
VENTOY_CMD_RETURN(0);
}
static const char * ventoy_menu_lang_read_hook(struct grub_env_var *var, const char *val)
{
(void)var;
return ventoy_get_vmenu_title(val);
}
static const char * ventoy_gfxmode_read_hook(struct grub_env_var *var, const char *val)
{
(void)var;
(void)val;
return g_vtoy_gfxmode;
}
static char * ventoy_gfxmode_write_hook(struct grub_env_var *var, const char *val)
{
(void)var;
grub_strncpy(g_vtoy_gfxmode, val, sizeof(g_vtoy_gfxmode) - 1);
return grub_strdup(val);
}
int ventoy_env_init(void)
{
int i;
@@ -6209,6 +6234,9 @@ int ventoy_env_init(void)
grub_env_set("vtdebug_flag", "");
grub_register_variable_hook("gfxmode", ventoy_gfxmode_read_hook, ventoy_gfxmode_write_hook);
grub_register_vtoy_menu_lang_hook(ventoy_menu_lang_read_hook);
g_part_list_buf = grub_malloc(VTOY_PART_BUF_LEN);
g_tree_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
g_list_script_buf = grub_malloc(VTOY_MAX_SCRIPT_BUF);
@@ -6248,6 +6276,10 @@ int ventoy_env_init(void)
grub_env_set("VTOY_VMENU_FUNC_ADDR", buf);
grub_env_export("VTOY_VMENU_FUNC_ADDR");
grub_snprintf(buf, sizeof(buf), "%s-%s", GRUB_TARGET_CPU, GRUB_PLATFORM);
grub_env_set("grub_cpu_platform", buf);
grub_env_export("grub_cpu_platform");
return 0;
}
@@ -6417,6 +6449,7 @@ static cmd_para ventoy_cmds[] =
{ "vt_load_menu_lang", ventoy_cmd_load_menu_lang, 0, NULL, "", "", NULL },
{ "vt_init_menu_lang", ventoy_cmd_init_menu_lang, 0, NULL, "", "", NULL },
{ "vt_cur_menu_lang", ventoy_cmd_cur_menu_lang, 0, NULL, "", "", NULL },
};
int ventoy_register_all_cmd(void)

View File

@@ -3371,7 +3371,7 @@ grub_err_t ventoy_cmd_select_theme_cfg(grub_extcmd_context_t ctxt, int argc, cha
}
pos += grub_snprintf(buf + pos, bufsize - pos,
"menuentry '@VTMENU_RETURN_PREVIOUS' --class=vtoyret VTOY_RET {\n"
"menuentry \"$VTLANG_RETURN_PREVIOUS\" --class=vtoyret VTOY_RET {\n"
"echo 'Return ...'\n"
"}\n");
@@ -3521,11 +3521,11 @@ int ventoy_plugin_load_menu_lang(int init, const char *lang)
if (g_default_menu_mode == 0)
{
grub_snprintf(g_ventoy_hotkey_tip, sizeof(g_ventoy_hotkey_tip), "%s", ventoy_get_vmenu_title("VTMENU_STR_HOTKEY_TREE"));
grub_snprintf(g_ventoy_hotkey_tip, sizeof(g_ventoy_hotkey_tip), "%s", ventoy_get_vmenu_title("VTLANG_STR_HOTKEY_TREE"));
}
else
{
grub_snprintf(g_ventoy_hotkey_tip, sizeof(g_ventoy_hotkey_tip), "%s", ventoy_get_vmenu_title("VTMENU_STR_HOTKEY_LIST"));
grub_snprintf(g_ventoy_hotkey_tip, sizeof(g_ventoy_hotkey_tip), "%s", ventoy_get_vmenu_title("VTLANG_STR_HOTKEY_LIST"));
}
if (init == 0)

View File

@@ -0,0 +1,73 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003,2005,2006,2007,2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_ENV_HEADER
#define GRUB_ENV_HEADER 1
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/types.h>
#include <grub/menu.h>
struct grub_env_var;
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
const char *val);
typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
const char *val);
struct grub_env_var
{
char *name;
char *value;
grub_env_read_hook_t read_hook;
grub_env_write_hook_t write_hook;
struct grub_env_var *next;
struct grub_env_var **prevp;
struct grub_env_var *sorted_next;
int global;
};
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
const char *EXPORT_FUNC(grub_env_get) (const char *name);
void EXPORT_FUNC(grub_env_unset) (const char *name);
struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);
#define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
grub_env_read_hook_t read_hook,
grub_env_write_hook_t write_hook);
grub_err_t EXPORT_FUNC(grub_register_vtoy_menu_lang_hook) (grub_env_read_hook_t read_hook);
grub_err_t grub_env_context_open (void);
grub_err_t grub_env_context_close (void);
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
void grub_env_unset_menu (void);
grub_menu_t grub_env_get_menu (void);
void grub_env_set_menu (grub_menu_t nmenu);
grub_err_t
grub_env_extractor_open (int source);
grub_err_t
grub_env_extractor_close (int source);
#endif /* ! GRUB_ENV_HEADER */