2003-01-20 04:13:46 +00:00
|
|
|
/*
|
2004-04-04 13:46:03 +00:00
|
|
|
* GRUB -- GRand Unified Bootloader
|
2008-01-05 12:10:28 +00:00
|
|
|
* Copyright (C) 2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc.
|
2003-01-20 04:13:46 +00:00
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is free software: you can redistribute it and/or modify
|
2003-01-20 04:13:46 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-21 23:32:33 +00:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2003-01-20 04:13:46 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
2007-07-21 23:32:33 +00:00
|
|
|
* GRUB is distributed in the hope that it will be useful,
|
2003-01-20 04:13:46 +00:00
|
|
|
* 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
|
2007-07-21 23:32:33 +00:00
|
|
|
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
|
2003-01-20 04:13:46 +00:00
|
|
|
*/
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
#include <grub/normal.h>
|
|
|
|
#include <grub/term.h>
|
|
|
|
#include <grub/misc.h>
|
2004-09-10 20:31:55 +00:00
|
|
|
#include <grub/loader.h>
|
2004-09-18 13:42:05 +00:00
|
|
|
#include <grub/mm.h>
|
2004-09-10 20:31:55 +00:00
|
|
|
#include <grub/machine/time.h>
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
#include <grub/env.h>
|
2006-10-28 14:00:05 +00:00
|
|
|
#include <grub/script.h>
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2008-01-05 12:10:28 +00:00
|
|
|
static grub_uint8_t grub_color_menu_normal;
|
|
|
|
static grub_uint8_t grub_color_menu_highlight;
|
|
|
|
|
|
|
|
/* Wait until the user pushes any key so that the user
|
|
|
|
can see what happened. */
|
|
|
|
void
|
|
|
|
grub_wait_after_message (void)
|
|
|
|
{
|
|
|
|
grub_printf ("\nPress any key to continue...");
|
|
|
|
(void) grub_getkey ();
|
|
|
|
}
|
2007-12-25 11:10:47 +00:00
|
|
|
|
2003-01-20 04:13:46 +00:00
|
|
|
static void
|
|
|
|
draw_border (void)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y);
|
|
|
|
grub_putcode (GRUB_TERM_DISP_UL);
|
2005-08-12 19:53:33 +00:00
|
|
|
for (i = 0; i < (unsigned) GRUB_TERM_BORDER_WIDTH - 2; i++)
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_putcode (GRUB_TERM_DISP_HLINE);
|
|
|
|
grub_putcode (GRUB_TERM_DISP_UR);
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
for (i = 0; i < (unsigned) GRUB_TERM_NUM_ENTRIES; i++)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_MARGIN, GRUB_TERM_TOP_BORDER_Y + i + 1);
|
|
|
|
grub_putcode (GRUB_TERM_DISP_VLINE);
|
2005-08-21 07:22:51 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_MARGIN + GRUB_TERM_BORDER_WIDTH - 1,
|
|
|
|
GRUB_TERM_TOP_BORDER_Y + i + 1);
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_putcode (GRUB_TERM_DISP_VLINE);
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
|
2005-08-21 07:22:51 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_MARGIN,
|
|
|
|
GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES + 1);
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_putcode (GRUB_TERM_DISP_LL);
|
2005-08-12 19:53:33 +00:00
|
|
|
for (i = 0; i < (unsigned) GRUB_TERM_BORDER_WIDTH - 2; i++)
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_putcode (GRUB_TERM_DISP_HLINE);
|
|
|
|
grub_putcode (GRUB_TERM_DISP_LR);
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
2005-01-22 13:29:18 +00:00
|
|
|
|
2005-08-21 07:22:51 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_MARGIN,
|
|
|
|
(GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES
|
|
|
|
+ GRUB_TERM_MARGIN + 1));
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-09-18 13:42:05 +00:00
|
|
|
print_message (int nested, int edit)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
|
|
|
|
2004-09-18 13:42:05 +00:00
|
|
|
if (edit)
|
|
|
|
{
|
|
|
|
grub_printf ("\n\
|
|
|
|
Minimum Emacs-like screen editing is supported. TAB lists\n\
|
|
|
|
available completions. Press C-x (\'x\' with Ctrl) to boot,\n\
|
|
|
|
C-c (\'c\' with Ctrl) for a command-line or ESC to return menu.");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
grub_printf ("\n\
|
2003-09-25 20:15:53 +00:00
|
|
|
Use the %C and %C keys to select which entry is highlighted.\n",
|
2005-02-19 20:56:07 +00:00
|
|
|
(grub_uint32_t) GRUB_TERM_DISP_UP, (grub_uint32_t) GRUB_TERM_DISP_DOWN);
|
2004-09-18 13:42:05 +00:00
|
|
|
grub_printf ("\
|
2003-01-20 04:13:46 +00:00
|
|
|
Press enter to boot the selected OS, \'e\' to edit the\n\
|
2004-09-18 13:42:05 +00:00
|
|
|
commands before booting or \'c\' for a command-line.");
|
|
|
|
if (nested)
|
|
|
|
grub_printf ("\n\
|
2003-01-20 04:13:46 +00:00
|
|
|
ESC to return previous menu.");
|
2004-09-18 13:42:05 +00:00
|
|
|
}
|
|
|
|
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
static grub_menu_entry_t
|
|
|
|
get_entry (grub_menu_t menu, int no)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_menu_entry_t e;
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
|
|
for (e = menu->entry_list; e && no > 0; e = e->next, no--)
|
|
|
|
;
|
|
|
|
|
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-04-04 13:46:03 +00:00
|
|
|
print_entry (int y, int highlight, grub_menu_entry_t entry)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
|
|
|
int x;
|
|
|
|
const char *title;
|
2005-08-21 07:22:51 +00:00
|
|
|
grub_ssize_t len;
|
|
|
|
grub_uint32_t *unicode_title;
|
|
|
|
grub_ssize_t i;
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_uint8_t old_color_normal, old_color_highlight;
|
2007-12-25 11:10:47 +00:00
|
|
|
|
2003-01-20 04:13:46 +00:00
|
|
|
title = entry ? entry->title : "";
|
2005-08-21 07:22:51 +00:00
|
|
|
unicode_title = grub_malloc (grub_strlen (title) * sizeof (*unicode_title));
|
|
|
|
if (! unicode_title)
|
|
|
|
/* XXX How to show this error? */
|
|
|
|
return;
|
|
|
|
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
len = grub_utf8_to_ucs4 (unicode_title, (grub_uint8_t *) title,
|
|
|
|
grub_strlen (title));
|
2005-08-21 07:22:51 +00:00
|
|
|
if (len < 0)
|
|
|
|
{
|
|
|
|
/* It is an invalid sequence. */
|
|
|
|
grub_free (unicode_title);
|
|
|
|
return;
|
|
|
|
}
|
2008-01-05 12:10:28 +00:00
|
|
|
|
|
|
|
grub_getcolor (&old_color_normal, &old_color_highlight);
|
|
|
|
grub_setcolor (grub_color_menu_normal, grub_color_menu_highlight);
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_setcolorstate (highlight
|
|
|
|
? GRUB_TERM_COLOR_HIGHLIGHT
|
|
|
|
: GRUB_TERM_COLOR_NORMAL);
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN, y);
|
|
|
|
|
2005-08-21 07:22:51 +00:00
|
|
|
for (x = GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_MARGIN + 1, i = 0;
|
2005-02-19 20:56:07 +00:00
|
|
|
x < GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH - GRUB_TERM_MARGIN;
|
2005-08-21 07:22:51 +00:00
|
|
|
i++)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2005-08-21 07:22:51 +00:00
|
|
|
if (i < len
|
|
|
|
&& x <= (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH
|
|
|
|
- GRUB_TERM_MARGIN - 1))
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2005-08-21 07:22:51 +00:00
|
|
|
grub_ssize_t width;
|
|
|
|
|
|
|
|
width = grub_getcharwidth (unicode_title[i]);
|
|
|
|
|
|
|
|
if (x + width > (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH
|
|
|
|
- GRUB_TERM_MARGIN - 1))
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_putcode (GRUB_TERM_DISP_RIGHT);
|
2003-01-20 04:13:46 +00:00
|
|
|
else
|
2005-08-21 07:22:51 +00:00
|
|
|
grub_putcode (unicode_title[i]);
|
|
|
|
|
|
|
|
x += width;
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
else
|
2005-08-21 07:22:51 +00:00
|
|
|
{
|
|
|
|
grub_putchar (' ');
|
|
|
|
x++;
|
|
|
|
}
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
2007-12-25 11:10:47 +00:00
|
|
|
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
|
|
|
grub_putchar (' ');
|
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_CURSOR_X, y);
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_setcolor (old_color_normal, old_color_highlight);
|
|
|
|
grub_setcolorstate (GRUB_TERM_COLOR_NORMAL);
|
2005-08-21 07:22:51 +00:00
|
|
|
grub_free (unicode_title);
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-04-04 13:46:03 +00:00
|
|
|
print_entries (grub_menu_t menu, int first, int offset)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_menu_entry_t e;
|
2003-01-20 04:13:46 +00:00
|
|
|
int i;
|
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH,
|
|
|
|
GRUB_TERM_FIRST_ENTRY_Y);
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
|
|
if (first)
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_putcode (GRUB_TERM_DISP_UP);
|
2003-01-20 04:13:46 +00:00
|
|
|
else
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_putchar (' ');
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
|
|
e = get_entry (menu, first);
|
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
for (i = 0; i < GRUB_TERM_NUM_ENTRIES; i++)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2005-02-19 20:56:07 +00:00
|
|
|
print_entry (GRUB_TERM_FIRST_ENTRY_Y + i, offset == i, e);
|
2003-01-20 04:13:46 +00:00
|
|
|
if (e)
|
|
|
|
e = e->next;
|
|
|
|
}
|
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_LEFT_BORDER_X + GRUB_TERM_BORDER_WIDTH,
|
|
|
|
GRUB_TERM_TOP_BORDER_Y + GRUB_TERM_NUM_ENTRIES);
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
|
|
if (e)
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_putcode (GRUB_TERM_DISP_DOWN);
|
2003-01-20 04:13:46 +00:00
|
|
|
else
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_putchar (' ');
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
/* Initialize the screen. If NESTED is non-zero, assume that this menu
|
|
|
|
is run from another menu or a command-line. If EDIT is non-zero, show
|
|
|
|
a message for the menu entry editor. */
|
|
|
|
void
|
|
|
|
grub_menu_init_page (int nested, int edit)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_uint8_t old_color_normal, old_color_highlight;
|
|
|
|
|
|
|
|
grub_getcolor (&old_color_normal, &old_color_highlight);
|
|
|
|
|
|
|
|
/* By default, use the same colors for the menu. */
|
|
|
|
grub_color_menu_normal = old_color_normal;
|
|
|
|
grub_color_menu_highlight = old_color_highlight;
|
|
|
|
|
|
|
|
/* Then give user a chance to replace them. */
|
|
|
|
grub_parse_color_name_pair (&grub_color_menu_normal, grub_env_get ("menu_color_normal"));
|
|
|
|
grub_parse_color_name_pair (&grub_color_menu_highlight, grub_env_get ("menu_color_highlight"));
|
2007-12-25 11:10:47 +00:00
|
|
|
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_normal_init_page ();
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_setcolor (grub_color_menu_normal, grub_color_menu_highlight);
|
2003-01-20 04:13:46 +00:00
|
|
|
draw_border ();
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_setcolor (old_color_normal, old_color_highlight);
|
2004-09-18 13:42:05 +00:00
|
|
|
print_message (nested, edit);
|
|
|
|
}
|
|
|
|
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
/* Return the current timeout. If the variable "timeout" is not set or
|
|
|
|
invalid, return -1. */
|
|
|
|
static int
|
|
|
|
get_timeout (void)
|
|
|
|
{
|
|
|
|
char *val;
|
|
|
|
int timeout;
|
|
|
|
|
|
|
|
val = grub_env_get ("timeout");
|
|
|
|
if (! val)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
grub_error_push ();
|
|
|
|
|
|
|
|
timeout = (int) grub_strtoul (val, 0, 0);
|
|
|
|
|
|
|
|
/* If the value is invalid, unset the variable. */
|
|
|
|
if (grub_errno != GRUB_ERR_NONE)
|
|
|
|
{
|
|
|
|
grub_env_unset ("timeout");
|
|
|
|
grub_errno = GRUB_ERR_NONE;
|
|
|
|
timeout = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
grub_error_pop ();
|
|
|
|
|
|
|
|
return timeout;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current timeout in the variable "timeout". */
|
|
|
|
static void
|
|
|
|
set_timeout (int timeout)
|
|
|
|
{
|
|
|
|
/* Ignore TIMEOUT if it is zero, because it will be unset really soon. */
|
|
|
|
if (timeout > 0)
|
|
|
|
{
|
|
|
|
char buf[16];
|
|
|
|
|
|
|
|
grub_sprintf (buf, "%d", timeout);
|
|
|
|
grub_env_set ("timeout", buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the entry number from the variable NAME. */
|
|
|
|
static int
|
|
|
|
get_entry_number (const char *name)
|
|
|
|
{
|
|
|
|
char *val;
|
|
|
|
int entry;
|
|
|
|
|
|
|
|
val = grub_env_get (name);
|
|
|
|
if (! val)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
grub_error_push ();
|
|
|
|
|
|
|
|
entry = (int) grub_strtoul (val, 0, 0);
|
|
|
|
|
|
|
|
if (grub_errno != GRUB_ERR_NONE)
|
|
|
|
{
|
|
|
|
grub_errno = GRUB_ERR_NONE;
|
|
|
|
entry = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
grub_error_pop ();
|
|
|
|
|
|
|
|
return entry;
|
|
|
|
}
|
|
|
|
|
2003-01-20 04:13:46 +00:00
|
|
|
static int
|
2004-04-04 13:46:03 +00:00
|
|
|
run_menu (grub_menu_t menu, int nested)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
|
|
|
int first, offset;
|
2004-09-10 20:31:55 +00:00
|
|
|
unsigned long saved_time;
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
int default_entry;
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
|
|
first = 0;
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
|
|
|
|
default_entry = get_entry_number ("default");
|
|
|
|
|
|
|
|
/* If DEFAULT_ENTRY is not within the menu entries, fall back to
|
|
|
|
the first entry. */
|
|
|
|
if (default_entry < 0 || default_entry >= menu->size)
|
|
|
|
default_entry = 0;
|
|
|
|
|
|
|
|
offset = default_entry;
|
2005-02-19 20:56:07 +00:00
|
|
|
if (offset > GRUB_TERM_NUM_ENTRIES - 1)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2005-02-19 20:56:07 +00:00
|
|
|
first = offset - (GRUB_TERM_NUM_ENTRIES - 1);
|
|
|
|
offset = GRUB_TERM_NUM_ENTRIES - 1;
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
|
2004-09-18 13:42:05 +00:00
|
|
|
/* Initialize the time. */
|
|
|
|
saved_time = grub_get_rtc ();
|
|
|
|
|
|
|
|
refresh:
|
|
|
|
grub_setcursor (0);
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_menu_init_page (nested, 0);
|
2003-01-20 04:13:46 +00:00
|
|
|
print_entries (menu, first, offset);
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_refresh ();
|
2004-09-10 20:31:55 +00:00
|
|
|
|
2003-01-20 04:13:46 +00:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
int c;
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
int timeout;
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
timeout = get_timeout ();
|
|
|
|
|
|
|
|
if (timeout > 0)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2004-09-10 20:31:55 +00:00
|
|
|
unsigned long current_time;
|
|
|
|
|
|
|
|
current_time = grub_get_rtc ();
|
|
|
|
if (current_time - saved_time >= GRUB_TICKS_PER_SECOND)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
timeout--;
|
|
|
|
set_timeout (timeout);
|
2004-09-10 20:31:55 +00:00
|
|
|
saved_time = current_time;
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
2004-09-10 20:31:55 +00:00
|
|
|
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
|
2004-09-18 13:42:05 +00:00
|
|
|
/* NOTE: Do not remove the trailing space characters.
|
|
|
|
They are required to clear the line. */
|
|
|
|
grub_printf ("\
|
2007-08-20 14:35:20 +00:00
|
|
|
The highlighted entry will be booted automatically in %d s. ",
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
timeout);
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
|
2004-09-10 20:31:55 +00:00
|
|
|
grub_refresh ();
|
|
|
|
}
|
|
|
|
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
if (timeout == 0)
|
2005-02-27 21:19:06 +00:00
|
|
|
{
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
grub_env_unset ("timeout");
|
|
|
|
return default_entry;
|
2005-02-27 21:19:06 +00:00
|
|
|
}
|
2004-09-10 20:31:55 +00:00
|
|
|
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
if (grub_checkkey () >= 0 || timeout < 0)
|
2004-09-10 20:31:55 +00:00
|
|
|
{
|
|
|
|
c = GRUB_TERM_ASCII_CHAR (grub_getkey ());
|
|
|
|
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
if (timeout >= 0)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (0, GRUB_TERM_HEIGHT - 3);
|
2004-09-18 13:42:05 +00:00
|
|
|
grub_printf ("\
|
|
|
|
");
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
grub_env_unset ("timeout");
|
|
|
|
grub_env_unset ("fallback");
|
2005-02-19 20:56:07 +00:00
|
|
|
grub_gotoxy (GRUB_TERM_CURSOR_X, GRUB_TERM_FIRST_ENTRY_Y + offset);
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
2004-09-10 20:31:55 +00:00
|
|
|
|
|
|
|
switch (c)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2004-09-10 20:31:55 +00:00
|
|
|
case 16:
|
|
|
|
case '^':
|
|
|
|
if (offset > 0)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2005-02-19 20:56:07 +00:00
|
|
|
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 0,
|
2003-01-20 04:13:46 +00:00
|
|
|
get_entry (menu, first + offset));
|
2004-09-10 20:31:55 +00:00
|
|
|
offset--;
|
2005-02-19 20:56:07 +00:00
|
|
|
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 1,
|
2003-01-20 04:13:46 +00:00
|
|
|
get_entry (menu, first + offset));
|
|
|
|
}
|
2004-09-10 20:31:55 +00:00
|
|
|
else if (first > 0)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
2004-09-10 20:31:55 +00:00
|
|
|
first--;
|
2003-01-20 04:13:46 +00:00
|
|
|
print_entries (menu, first, offset);
|
|
|
|
}
|
2004-09-10 20:31:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
case 'v':
|
|
|
|
if (menu->size > first + offset + 1)
|
|
|
|
{
|
2005-02-19 20:56:07 +00:00
|
|
|
if (offset < GRUB_TERM_NUM_ENTRIES - 1)
|
2004-09-10 20:31:55 +00:00
|
|
|
{
|
2005-02-19 20:56:07 +00:00
|
|
|
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 0,
|
2004-09-10 20:31:55 +00:00
|
|
|
get_entry (menu, first + offset));
|
|
|
|
offset++;
|
2005-02-19 20:56:07 +00:00
|
|
|
print_entry (GRUB_TERM_FIRST_ENTRY_Y + offset, 1,
|
2004-09-10 20:31:55 +00:00
|
|
|
get_entry (menu, first + offset));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
first++;
|
|
|
|
print_entries (menu, first, offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case '\n':
|
|
|
|
case '\r':
|
|
|
|
case 6:
|
|
|
|
grub_setcursor (1);
|
|
|
|
return first + offset;
|
|
|
|
|
|
|
|
case '\e':
|
|
|
|
if (nested)
|
|
|
|
{
|
|
|
|
grub_setcursor (1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
grub_cmdline_run (1);
|
2004-09-18 13:42:05 +00:00
|
|
|
goto refresh;
|
|
|
|
|
|
|
|
case 'e':
|
2007-11-10 20:32:32 +00:00
|
|
|
{
|
|
|
|
grub_menu_entry_t e = get_entry (menu, first + offset);
|
|
|
|
if (e)
|
|
|
|
grub_menu_entry_run (e);
|
|
|
|
}
|
2004-09-18 13:42:05 +00:00
|
|
|
goto refresh;
|
2004-09-10 20:31:55 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
2004-09-10 20:31:55 +00:00
|
|
|
|
|
|
|
grub_refresh ();
|
|
|
|
}
|
|
|
|
}
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2004-09-10 20:31:55 +00:00
|
|
|
/* Never reach here. */
|
|
|
|
return -1;
|
|
|
|
}
|
2003-01-20 04:13:46 +00:00
|
|
|
|
2004-09-10 20:31:55 +00:00
|
|
|
/* Run a menu entry. */
|
|
|
|
static void
|
|
|
|
run_menu_entry (grub_menu_entry_t entry)
|
|
|
|
{
|
2006-01-17 09:50:47 +00:00
|
|
|
grub_script_execute (entry->commands);
|
2004-09-10 20:31:55 +00:00
|
|
|
|
|
|
|
if (grub_errno == GRUB_ERR_NONE && grub_loader_is_loaded ())
|
|
|
|
/* Implicit execution of boot, only if something is loaded. */
|
2005-08-14 19:36:55 +00:00
|
|
|
grub_command_execute ("boot", 0);
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-04-04 13:46:03 +00:00
|
|
|
grub_menu_run (grub_menu_t menu, int nested)
|
2003-01-20 04:13:46 +00:00
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
int boot_entry;
|
2004-09-10 20:31:55 +00:00
|
|
|
grub_menu_entry_t e;
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
int fallback_entry;
|
2003-01-20 04:13:46 +00:00
|
|
|
|
|
|
|
boot_entry = run_menu (menu, nested);
|
|
|
|
if (boot_entry < 0)
|
|
|
|
break;
|
|
|
|
|
2007-11-10 20:32:32 +00:00
|
|
|
e = get_entry (menu, boot_entry);
|
|
|
|
if (! e)
|
|
|
|
continue; /* Menu is empty. */
|
|
|
|
|
2004-09-10 20:31:55 +00:00
|
|
|
grub_cls ();
|
|
|
|
grub_setcursor (1);
|
|
|
|
|
|
|
|
grub_printf (" Booting \'%s\'\n\n", e->title);
|
|
|
|
|
|
|
|
run_menu_entry (e);
|
|
|
|
|
|
|
|
/* Deal with a fallback entry. */
|
2004-09-17 09:36:52 +00:00
|
|
|
/* FIXME: Multiple fallback entries like GRUB Legacy. */
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
fallback_entry = get_entry_number ("fallback");
|
|
|
|
if (fallback_entry >= 0)
|
2004-09-10 20:31:55 +00:00
|
|
|
{
|
|
|
|
grub_print_error ();
|
|
|
|
grub_errno = GRUB_ERR_NONE;
|
|
|
|
|
2006-05-07 Yoshinori K. Okuji <okuji@enbug.org>
Use the environment context in the menu. Remove the commands
"default" and "timeout", and use variables instead.
* normal/menu.c: Include grub/env.h.
(print_entry): Cast TITLE to silence gcc.
(get_timeout): New function.
(set_timeout): Likewise.
(get_entry_number): Likewise.
(run_menu): Use a default entry, a fallback entry and a timeout
in the environment variables "default", "fallback" and
"timeout". Also, tweak the default entry if it is not within the
current menu entries.
(grub_menu_run): Use a fallback entry in the environment variable
"fallback".
* normal/main.c (read_config_file): Do not initialize
NEWMENU->DEFAULT_ENTRY, NEWMENU->FALLBACK_ENTRY or
NEWMENU->TIMEOUT.
(grub_normal_execute): Use a data slot to store the menu.
* include/grub/normal.h (struct grub_menu): Removed default_entry,
fallback_entry and timeout.
(struct grub_menu_list): Removed.
(grub_menu_list_t): Likewise.
(struct grub_context): Likewise.
(grub_context_t): Likewise.
(grub_context_get): Likewise.
(grub_context_get_current_menu): Likewise.
(grub_context_push_menu): Likewise.
(grub_context_pop_menu): Likewise.
(grub_default_init): Likewise.
(grub_default_fini): Likewise.
(grub_timeout_init): Likewise.
(grub_timeout_fini): Likewise.
* conf/sparc64-ieee1275.rmk (pkgdata_MODULES): Removed default.mod
and timeout.mod.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/powerpc-ieee1275.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-pc.rmk (grub_emu_SOURCES): Removed commands/default.c,
commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/i386-efi.rmk (grub_emu_SOURCES): Removed
commands/default.c, commands/timeout.c and normal/context.c.
(normal_mod_SOURCES): Removed normal/context.c.
* conf/common.rmk (pkgdata_MODULES): Removed default.mod and
timeout.mod.
(default_mod_SOURCES): Removed.
(default_mod_CFLAGS): Likewise.
(default_mod_LDFLAGS): Likewise.
(timeout_mod_SOURCES): Removed.
(timeout_mod_CFLAGS): Likewise.
(timeout_mod_LDFLAGS): Likewise.
* DISTLIST: Removed commands/default.c, commands/timeout.c and
normal/context.c.
* commands/default.c: Removed.
* commands/timeout.c: Likewise.
* normal/context.c: Likewise.
2006-05-07 18:28:24 +00:00
|
|
|
e = get_entry (menu, fallback_entry);
|
|
|
|
grub_env_unset ("fallback");
|
2004-09-10 20:31:55 +00:00
|
|
|
grub_printf ("\n Falling back to \'%s\'\n\n", e->title);
|
|
|
|
run_menu_entry (e);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (grub_errno != GRUB_ERR_NONE)
|
|
|
|
{
|
|
|
|
grub_print_error ();
|
|
|
|
grub_errno = GRUB_ERR_NONE;
|
|
|
|
|
2008-01-05 12:10:28 +00:00
|
|
|
grub_wait_after_message ();
|
2004-09-10 20:31:55 +00:00
|
|
|
}
|
2003-01-20 04:13:46 +00:00
|
|
|
}
|
|
|
|
}
|