Use FOR_* macros instead of *_iterate whenever possible.

* commands/handler.c: Removed.
	* commands/help.c (grub_cmd_help): Use FOR_COMMANDS.
	* commands/minicmd.c (grub_mini_cmd_lsmod): Use FOR_DL_MODULES.
	* conf/any-emu.rmk (kernel_img_SOURCES): Remove kern/handler.c.
	* conf/common.rmk (script/lexer.c_DEPENDENCIES): Add grub_script.yy.h.
	(grub_probe_SOURCES): Remove kern/parser.c.
	(util/grub-script-check.c_DEPENDENCIES): Removed.
	(grub_script_check_SOURCES): Remove kern/handler.c, kern/parser.c
	and grub_script_check_init.c.
	(grub_script_check_init.lst): Removed.
	(grub_script_check_init.h): Likewise.
	(grub_script_check_init.c): Likewise.
	(pkglib_MODULES): Remove handler.mod and sh.mod.
	(handler_mod_SOURCES): Removed.
	(handler_mod_CFLAGS): Likewise.
	(handler_mod_LDFLAGS): Likewise.
	(normal_mod_SOURCES): Remove normal/handler.c.
	Add script/main.c, script/script.c, script/execute.c,
	script/function.c, script/lexer.c, grub_script.tab.c
	and grub_script.yy.c.
	* conf/i386-coreboot.rmk (kernel_img_SOURCES): Remove kern/handler.c.
	* conf/i386-ieee1275.rmk (kernel_img_SOURCES): Likewise.
	* conf/i386-pc.rmk (kernel_img_SOURCES): Likewise.
	(grub_setup_SOURCES): Remove kern/parser.c.
	* conf/i386-qemu.rmk (kernel_img_SOURCES): Remove kern/handler.c.
	* conf/mips-qemu-mips.rmk (kernel_img_SOURCES): Likewise.
	* conf/mips-yeeloong.rmk (kernel_img_SOURCES): Likewise.
	* conf/powerpc-ieee1275.rmk (kernel_img_SOURCES): Likewise.
	* conf/sparc64-ieee1275.rmk (kernel_img_SOURCES): Likewise.
	(grub_setup_SOURCES): Remove kern/parser.c.
	* conf/x86-efi.rmk (kernel_img_SOURCES): Remove kern/handler.c.
	* gettext/gettext.c (grub_gettext_delete_list): Don't use grub_list_pop.
	* include/grub/command.h (grub_command_iterate): Removed.
	(FOR_COMMANDS): New macro.
	* include/grub/dl.h (grub_dl): New member next.
	(grub_dl_iterate): Removed.
	(grub_dl_head): New variable declaration.
	(FOR_DL_MODULES): New macro.
	* include/grub/fs.h: Include list.h.
	(grub_fs): Make next first element.
	(grub_fs_list): New variable declaration.
	(grub_fs_register): Make inline.
	(grub_fs_unregister): Likewise.
	(grub_fs_iterate): Removed.
	(FOR_FILESYSTEMS): New macro.
	* include/grub/handler.h: Removed.
	* include/grub/list.h (grub_list_hook_t): Removed.
	(grub_list_test_t): Likewise.
	(grub_list_pop): Likewise.
	(grub_list_iterate): Likewise.
	(grub_list_insert): Likewise.
	(FOR_LIST_ELEMENTS): New macro.
	* include/grub/parser.h (grub_parser_class): Removed.
	(grub_parser_register): Likewise.
	(grub_parser_unregister): Likewise.
	(grub_parser_get_current): Likewise.
	(grub_parser_set_current): Likewise.
	(grub_register_rescue_parser): Likewise.
	(grub_rescue_parse_line): New function.
	* include/grub/partition.h (FOR_PARTITION_MAPS): Use FOR_LIST_ELEMENTS.
	* include/grub/script_sh.h (grub_script_function_list): New variable
	declaration.
	(FOR_SCRIPT_FUNCTIONS): New macro.
	(grub_script_function_iterate): Removed.
	(grub_normal_parse_line): New prototype.
	* include/grub/term.h (FOR_ACTIVE_TERM_INPUTS): Use FOR_LIST_ELEMENTS.
	(FOR_DISABLED_TERM_INPUTS): Likewise.
	(FOR_ACTIVE_TERM_OUTPUTS): Likewise.
	(FOR_DISABLED_TERM_OUTPUTS): Likewise.
	* include/grub/video.h (grub_video_adapter): Move 'next' to first
	element.
	(grub_video_register): Inline.
	(grub_video_unregister): Likewise.
	(grub_video_adapter_list): New variable declaration.
	(grub_video_iterate): Removed.
	(FOR_VIDEO_ADAPTERS): New macro.
	* kern/dl.c (grub_dl_list): Removed. All users updated.
	(grub_dl_iterate): Removed.
	* kern/fs.c (grub_fs_list): Make global.
	(grub_fs_register): Removed.
	(grub_fs_unregister): Likewise.
	(grub_fs_iterate): Likewise.
	* kern/handler.c: Removed.
	* kern/list.c (grub_list_pop): Removed.
	(grub_list_iterate): Likewise.
	(grub_list_insert): Likewise.
	(grub_named_list_find): Use FOR_LIST_ELEMENTS.
	(grub_prio_list_insert): Don't use grub_list_insert.
	* kern/main.c (grub_register_rescue_parser): Don't call
	grub_register_rescue_parser.
	* kern/parser.c (grub_parser_class): Removed.
	(grub_parser_execute): Use grub_rescue_parse_line.
	* kern/rescue_parser.c (grub_rescue_parse_line): Make global.
	(grub_rescue_parser): Removed.
	(grub_register_rescue_parser): Likewise.
	* kern/rescue_reader.c (grub_rescue_run): Use grub_rescue_parse_line.
	* normal/auth.c (is_authenticated): Use FOR_LIST_ELEMENTS.
	(grub_auth_check_authentication): Likewise.
	* normal/completion.c (iterate_command): Removed.
	(grub_normal_do_completion): Use FOR_COMMANDS.
	* normal/handler.c: Removed.
	* normal/main.c (read_config_file): Remove parser changing.
	(grub_normal_execute): Don't call read_handler_list.
	(grub_normal_read_line_real): Statically allocate prompt.
	(grub_cmdline_run): Use grub_normal_parse_line.
	(GRUB_MOD_FINI): Don't call free_handler_list.
	* normal/menu_entry.c (run): Likewise.
	* script/function.c (grub_script_function_list): Make global.
	(grub_script_function_iterate): Removed.
	* script/main.c (grub_normal_parse_line): Make global.
	(grub_sh_parser): Removed.
	(GRUB_MOD_INIT): Likewise.
	(GRUB_MOD_FINI): Likewise.
	* tests/lib/functional_test.c (grub_functional_test): Use
	FOR_LIST_ELEMENTS.
	* tests/lib/test.c (free_failures): Don't use grub_list_pop.
	(grub_test_run): Use FOR_LIST_ELEMENTS.
	* tests/lib/unit_test.c (main): Likewise.
	* util/deviceiter.c (grub_util_iterate_devices): Don't use
	grub_list_pop.
	* util/grub-fstest.c (grub_term_input_class): Removed.
	(grub_term_output_class): Likewise.
	* util/grub-probe.c: Likewise.
	* util/i386/pc/grub-setup.c: Likewise.
	* util/sparc64/ieee1275/grub-setup.c: Likewise.
	* util/grub-script-check.c (main): Don't call grub_init_all and
	grub_fini_all.
	* video/video.c (grub_video_adapter_list): Make global.
	(grub_video_register): Removed.
	(grub_video_unregister): Likewise.
	(grub_video_iterate): Likewise.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-06-11 22:31:16 +02:00
commit 3a37e3226b
52 changed files with 412 additions and 1032 deletions

136
ChangeLog
View file

@ -1,3 +1,139 @@
2010-06-10 Vladimir Serbinenko <phcoder@gmail.com>
Use FOR_* macros instead of *_iterate whenever possible.
* commands/handler.c: Removed.
* commands/help.c (grub_cmd_help): Use FOR_COMMANDS.
* commands/minicmd.c (grub_mini_cmd_lsmod): Use FOR_DL_MODULES.
* conf/any-emu.rmk (kernel_img_SOURCES): Remove kern/handler.c.
* conf/common.rmk (script/lexer.c_DEPENDENCIES): Add grub_script.yy.h.
(grub_probe_SOURCES): Remove kern/parser.c.
(util/grub-script-check.c_DEPENDENCIES): Removed.
(grub_script_check_SOURCES): Remove kern/handler.c, kern/parser.c
and grub_script_check_init.c.
(grub_script_check_init.lst): Removed.
(grub_script_check_init.h): Likewise.
(grub_script_check_init.c): Likewise.
(pkglib_MODULES): Remove handler.mod and sh.mod.
(handler_mod_SOURCES): Removed.
(handler_mod_CFLAGS): Likewise.
(handler_mod_LDFLAGS): Likewise.
(normal_mod_SOURCES): Remove normal/handler.c.
Add script/main.c, script/script.c, script/execute.c,
script/function.c, script/lexer.c, grub_script.tab.c
and grub_script.yy.c.
* conf/i386-coreboot.rmk (kernel_img_SOURCES): Remove kern/handler.c.
* conf/i386-ieee1275.rmk (kernel_img_SOURCES): Likewise.
* conf/i386-pc.rmk (kernel_img_SOURCES): Likewise.
(grub_setup_SOURCES): Remove kern/parser.c.
* conf/i386-qemu.rmk (kernel_img_SOURCES): Remove kern/handler.c.
* conf/mips-qemu-mips.rmk (kernel_img_SOURCES): Likewise.
* conf/mips-yeeloong.rmk (kernel_img_SOURCES): Likewise.
* conf/powerpc-ieee1275.rmk (kernel_img_SOURCES): Likewise.
* conf/sparc64-ieee1275.rmk (kernel_img_SOURCES): Likewise.
(grub_setup_SOURCES): Remove kern/parser.c.
* conf/x86-efi.rmk (kernel_img_SOURCES): Remove kern/handler.c.
* gettext/gettext.c (grub_gettext_delete_list): Don't use grub_list_pop.
* include/grub/command.h (grub_command_iterate): Removed.
(FOR_COMMANDS): New macro.
* include/grub/dl.h (grub_dl): New member next.
(grub_dl_iterate): Removed.
(grub_dl_head): New variable declaration.
(FOR_DL_MODULES): New macro.
* include/grub/fs.h: Include list.h.
(grub_fs): Make next first element.
(grub_fs_list): New variable declaration.
(grub_fs_register): Make inline.
(grub_fs_unregister): Likewise.
(grub_fs_iterate): Removed.
(FOR_FILESYSTEMS): New macro.
* include/grub/handler.h: Removed.
* include/grub/list.h (grub_list_hook_t): Removed.
(grub_list_test_t): Likewise.
(grub_list_pop): Likewise.
(grub_list_iterate): Likewise.
(grub_list_insert): Likewise.
(FOR_LIST_ELEMENTS): New macro.
* include/grub/parser.h (grub_parser_class): Removed.
(grub_parser_register): Likewise.
(grub_parser_unregister): Likewise.
(grub_parser_get_current): Likewise.
(grub_parser_set_current): Likewise.
(grub_register_rescue_parser): Likewise.
(grub_rescue_parse_line): New function.
* include/grub/partition.h (FOR_PARTITION_MAPS): Use FOR_LIST_ELEMENTS.
* include/grub/script_sh.h (grub_script_function_list): New variable
declaration.
(FOR_SCRIPT_FUNCTIONS): New macro.
(grub_script_function_iterate): Removed.
(grub_normal_parse_line): New prototype.
* include/grub/term.h (FOR_ACTIVE_TERM_INPUTS): Use FOR_LIST_ELEMENTS.
(FOR_DISABLED_TERM_INPUTS): Likewise.
(FOR_ACTIVE_TERM_OUTPUTS): Likewise.
(FOR_DISABLED_TERM_OUTPUTS): Likewise.
* include/grub/video.h (grub_video_adapter): Move 'next' to first
element.
(grub_video_register): Inline.
(grub_video_unregister): Likewise.
(grub_video_adapter_list): New variable declaration.
(grub_video_iterate): Removed.
(FOR_VIDEO_ADAPTERS): New macro.
* kern/dl.c (grub_dl_list): Removed. All users updated.
(grub_dl_iterate): Removed.
* kern/fs.c (grub_fs_list): Make global.
(grub_fs_register): Removed.
(grub_fs_unregister): Likewise.
(grub_fs_iterate): Likewise.
* kern/handler.c: Removed.
* kern/list.c (grub_list_pop): Removed.
(grub_list_iterate): Likewise.
(grub_list_insert): Likewise.
(grub_named_list_find): Use FOR_LIST_ELEMENTS.
(grub_prio_list_insert): Don't use grub_list_insert.
* kern/main.c (grub_register_rescue_parser): Don't call
grub_register_rescue_parser.
* kern/parser.c (grub_parser_class): Removed.
(grub_parser_execute): Use grub_rescue_parse_line.
* kern/rescue_parser.c (grub_rescue_parse_line): Make global.
(grub_rescue_parser): Removed.
(grub_register_rescue_parser): Likewise.
* kern/rescue_reader.c (grub_rescue_run): Use grub_rescue_parse_line.
* normal/auth.c (is_authenticated): Use FOR_LIST_ELEMENTS.
(grub_auth_check_authentication): Likewise.
* normal/completion.c (iterate_command): Removed.
(grub_normal_do_completion): Use FOR_COMMANDS.
* normal/handler.c: Removed.
* normal/main.c (read_config_file): Remove parser changing.
(grub_normal_execute): Don't call read_handler_list.
(grub_normal_read_line_real): Statically allocate prompt.
(grub_cmdline_run): Use grub_normal_parse_line.
(GRUB_MOD_FINI): Don't call free_handler_list.
* normal/menu_entry.c (run): Likewise.
* script/function.c (grub_script_function_list): Make global.
(grub_script_function_iterate): Removed.
* script/main.c (grub_normal_parse_line): Make global.
(grub_sh_parser): Removed.
(GRUB_MOD_INIT): Likewise.
(GRUB_MOD_FINI): Likewise.
* tests/lib/functional_test.c (grub_functional_test): Use
FOR_LIST_ELEMENTS.
* tests/lib/test.c (free_failures): Don't use grub_list_pop.
(grub_test_run): Use FOR_LIST_ELEMENTS.
* tests/lib/unit_test.c (main): Likewise.
* util/deviceiter.c (grub_util_iterate_devices): Don't use
grub_list_pop.
* util/grub-fstest.c (grub_term_input_class): Removed.
(grub_term_output_class): Likewise.
* util/grub-probe.c: Likewise.
* util/i386/pc/grub-setup.c: Likewise.
* util/sparc64/ieee1275/grub-setup.c: Likewise.
* util/grub-script-check.c (main): Don't call grub_init_all and
grub_fini_all.
* video/video.c (grub_video_adapter_list): Make global.
(grub_video_register): Removed.
(grub_video_unregister): Likewise.
(grub_video_iterate): Likewise.
2010-06-09 Vladimir Serbinenko <phcoder@gmail.com>
* docs/grub.texi (Vendor power-on button): Add Asus EeePC 1005PE as

View file

@ -1,101 +0,0 @@
/* handler.c - commands to list or select handlers */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/dl.h>
#include <grub/err.h>
#include <grub/misc.h>
#include <grub/term.h>
#include <grub/handler.h>
#include <grub/command.h>
#include <grub/i18n.h>
static grub_err_t
grub_cmd_handler (struct grub_command *cmd __attribute__ ((unused)),
int argc, char **args)
{
void *curr_item = 0;
grub_handler_class_t head;
auto int list_item (grub_named_list_t item);
int list_item (grub_named_list_t item)
{
if (item == curr_item)
grub_putchar ('*');
grub_printf ("%s\n", item->name);
return 0;
}
head = grub_handler_class_list;
if (argc == 0)
{
grub_list_iterate (GRUB_AS_LIST (head), (grub_list_hook_t) list_item);
}
else
{
char *class_name;
grub_handler_class_t class;
class_name = args[0];
argc--;
args++;
class = grub_named_list_find (GRUB_AS_NAMED_LIST (head), class_name);
if (! class)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "class not found");
if (argc == 0)
{
curr_item = class->cur_handler;
grub_list_iterate (GRUB_AS_LIST (class->handler_list),
(grub_list_hook_t) list_item);
}
else
{
grub_handler_t handler;
handler =
grub_named_list_find (GRUB_AS_NAMED_LIST (class->handler_list),
args[0]);
if (! handler)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "handler not found");
grub_handler_set_current (class, handler);
}
}
return 0;
}
static grub_command_t cmd_handler;
GRUB_MOD_INIT(handler)
{
cmd_handler =
grub_register_command ("handler", grub_cmd_handler,
N_("[class [handler]]"),
N_("List or select a handler."));
}
GRUB_MOD_FINI(handler)
{
grub_unregister_command (cmd_handler);
}

View file

@ -33,94 +33,87 @@ grub_cmd_help (grub_extcmd_t ext __attribute__ ((unused)), int argc,
int cnt = 0;
char *currarg;
auto int print_command_info (grub_command_t cmd);
auto int print_command_help (grub_command_t cmd);
int print_command_info (grub_command_t cmd)
{
if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) &&
(cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
{
struct grub_term_output *term;
const char *summary_translated = _(cmd->summary);
char *command_help;
grub_uint32_t *unicode_command_help;
grub_uint32_t *unicode_last_position;
command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated);
if (!command_help)
return 1;
grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help,
&unicode_last_position);
FOR_ACTIVE_TERM_OUTPUTS(term)
{
unsigned stringwidth;
grub_uint32_t *unicode_last_screen_position;
unicode_last_screen_position = unicode_command_help;
stringwidth = 0;
while (unicode_last_screen_position < unicode_last_position &&
stringwidth < ((grub_term_width (term) / 2) - 2))
{
stringwidth
+= grub_term_getcharwidth (term,
*unicode_last_screen_position);
unicode_last_screen_position++;
}
grub_print_ucs4 (unicode_command_help,
unicode_last_screen_position, term);
if (!(cnt % 2))
grub_print_spaces (term, grub_term_width (term) / 2
- stringwidth);
}
if (cnt % 2)
grub_printf ("\n");
cnt++;
grub_free (command_help);
grub_free (unicode_command_help);
}
return 0;
}
int print_command_help (grub_command_t cmd)
{
if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE)
{
if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg)))
{
if (cnt++ > 0)
grub_printf ("\n\n");
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
grub_arg_show_help ((grub_extcmd_t) cmd->data);
else
grub_printf ("%s %s %s\n%s\n", _("Usage:"), cmd->name, _(cmd->summary),
_(cmd->description));
}
}
return 0;
}
if (argc == 0)
{
grub_command_iterate (print_command_info);
grub_command_t cmd;
FOR_COMMANDS(cmd)
{
if ((cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE) &&
(cmd->flags & GRUB_COMMAND_FLAG_CMDLINE))
{
struct grub_term_output *term;
const char *summary_translated = _(cmd->summary);
char *command_help;
grub_uint32_t *unicode_command_help;
grub_uint32_t *unicode_last_position;
command_help = grub_xasprintf ("%s %s", cmd->name, summary_translated);
if (!command_help)
break;
grub_utf8_to_ucs4_alloc (command_help, &unicode_command_help,
&unicode_last_position);
FOR_ACTIVE_TERM_OUTPUTS(term)
{
unsigned stringwidth;
grub_uint32_t *unicode_last_screen_position;
unicode_last_screen_position = unicode_command_help;
stringwidth = 0;
while (unicode_last_screen_position < unicode_last_position &&
stringwidth < ((grub_term_width (term) / 2) - 2))
{
stringwidth
+= grub_term_getcharwidth (term,
*unicode_last_screen_position);
unicode_last_screen_position++;
}
grub_print_ucs4 (unicode_command_help,
unicode_last_screen_position, term);
if (!(cnt % 2))
grub_print_spaces (term, grub_term_width (term) / 2
- stringwidth);
}
if (cnt % 2)
grub_printf ("\n");
cnt++;
grub_free (command_help);
grub_free (unicode_command_help);
}
}
if (!(cnt % 2))
grub_printf ("\n");
}
else
{
int i;
grub_command_t cmd;
for (i = 0; i < argc; i++)
{
currarg = args[i];
grub_command_iterate (print_command_help);
FOR_COMMANDS(cmd)
{
if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE)
{
if (! grub_strncmp (cmd->name, currarg, grub_strlen (currarg)))
{
if (cnt++ > 0)
grub_printf ("\n\n");
if (cmd->flags & GRUB_COMMAND_FLAG_EXTCMD)
grub_arg_show_help ((grub_extcmd_t) cmd->data);
else
grub_printf ("%s %s %s\n%s\b", _("Usage:"), cmd->name, _(cmd->summary),
_(cmd->description));
}
}
}
}
}

View file

@ -301,27 +301,23 @@ grub_mini_cmd_lsmod (struct grub_command *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char *argv[] __attribute__ ((unused)))
{
auto int print_module (grub_dl_t mod);
int print_module (grub_dl_t mod)
{
grub_dl_dep_t dep;
grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count);
for (dep = mod->dep; dep; dep = dep->next)
{
if (dep != mod->dep)
grub_putchar (',');
grub_printf ("%s", dep->mod->name);
}
grub_putchar ('\n');
return 0;
}
grub_dl_t mod;
grub_printf ("Name\tRef Count\tDependencies\n");
grub_dl_iterate (print_module);
FOR_DL_MODULES (mod)
{
grub_dl_dep_t dep;
grub_printf ("%s\t%d\t\t", mod->name, mod->ref_count);
for (dep = mod->dep; dep; dep = dep->next)
{
if (dep != mod->dep)
grub_putchar (',');
grub_printf ("%s", dep->mod->name);
}
grub_putchar ('\n');
}
return 0;
}

View file

@ -3,7 +3,7 @@
kernel_img_RELOCATABLE = yes
pkglib_PROGRAMS = kernel.img
kernel_img_SOURCES = kern/device.c kern/disk.c kern/dl.c kern/env.c \
kern/err.c kern/list.c kern/handler.c kern/command.c \
kern/err.c kern/list.c kern/command.c \
kern/corecmd.c kern/file.c kern/fs.c kern/main.c kern/misc.c \
kern/parser.c kern/partition.c kern/term.c \
kern/rescue_reader.c kern/rescue_parser.c \

View file

@ -1,7 +1,7 @@
# -*- makefile -*-
# Used by various components. These rules need to precede them.
script/lexer.c_DEPENDENCIES = grub_script.tab.h
script/lexer.c_DEPENDENCIES = grub_script.tab.h grub_script.yy.h
sbin_UTILITIES += grub-mkdevicemap
grub_mkdevicemap_SOURCES = gnulib/progname.c util/grub-mkdevicemap.c \
@ -27,7 +27,7 @@ util/grub-probe.c_DEPENDENCIES = grub_probe_init.h
grub_probe_SOURCES = gnulib/progname.c util/grub-probe.c \
kern/emu/hostdisk.c util/misc.c kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c \
kern/device.c kern/disk.c kern/err.c kern/misc.c \
kern/parser.c kern/partition.c kern/file.c kern/list.c \
kern/partition.c kern/file.c kern/list.c \
\
fs/affs.c fs/cpio.c fs/fat.c fs/ext2.c fs/hfs.c \
fs/hfsplus.c fs/iso9660.c fs/udf.c fs/jfs.c fs/minix.c \
@ -88,12 +88,11 @@ DISTCLEANFILES += grub_script.yy.c grub_script.yy.h
# For grub-script-check.
bin_UTILITIES += grub-script-check
util/grub-script-check.c_DEPENDENCIES = grub_script_check_init.h
grub_script_check_SOURCES = gnulib/progname.c gnulib/getdelim.c gnulib/getline.c \
util/grub-script-check.c util/misc.c kern/emu/misc.c kern/emu/mm.c \
script/main.c script/script.c script/function.c script/lexer.c \
kern/handler.c kern/err.c kern/parser.c kern/list.c \
kern/misc.c kern/env.c grub_script_check_init.c grub_script.tab.c \
kern/err.c kern/list.c \
kern/misc.c kern/env.c grub_script.tab.c \
grub_script.yy.c
grub_script_check_CFLAGS = $(GNULIB_UTIL_CFLAGS)
MOSTLYCLEANFILES += symlist.c kernel_syms.lst
@ -102,7 +101,7 @@ DEFSYMFILES += kernel_syms.lst
kernel_img_HEADERS += boot.h cache.h device.h disk.h dl.h elf.h elfload.h \
env.h err.h file.h fs.h kernel.h loader.h misc.h mm.h net.h parser.h \
partition.h msdos_partition.h reader.h symbol.h term.h time.h types.h \
list.h handler.h command.h i18n.h env_private.h libgcc.h
list.h command.h i18n.h env_private.h libgcc.h
ifneq ($(platform), emu)
kernel_img_HEADERS += machine/memory.h machine/loader.h
@ -119,19 +118,6 @@ grub_script.tab.c grub_script.tab.h: script/parser.y
$(YACC) -d -p grub_script_yy -b grub_script $(srcdir)/script/parser.y
DISTCLEANFILES += grub_script.tab.c grub_script.tab.h
# For grub-script-check.
grub_script_check_init.lst: geninit.sh $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES))
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
DISTCLEANFILES += grub_script_check_init.lst
grub_script_check_init.h: grub_script_check_init.lst $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) geninitheader.sh
rm -f $@; sh $(srcdir)/geninitheader.sh $< > $@
DISTCLEANFILES += grub_script_check_init.h
grub_script_check_init.c: grub_script_check_init.lst $(filter-out grub_script_check_init.c,$(grub_script_check_SOURCES)) geninit.sh
rm -f $@; sh $(srcdir)/geninit.sh $< $(filter %.c,$^) > $@
DISTCLEANFILES += grub_script_check_init.c
# For grub-probe.
grub_probe_init.lst: geninit.sh $(filter-out grub_probe_init.c,$(grub_probe_SOURCES))
rm -f $@; grep GRUB_MOD_INIT $(filter %.c,$^) /dev/null > $@
@ -448,12 +434,12 @@ scsi_mod_CFLAGS = $(COMMON_CFLAGS)
scsi_mod_LDFLAGS = $(COMMON_LDFLAGS)
# Commands.
pkglib_MODULES += minicmd.mod extcmd.mod hello.mod handler.mod \
pkglib_MODULES += minicmd.mod extcmd.mod hello.mod \
ls.mod cmp.mod cat.mod help.mod search.mod loopback.mod \
configfile.mod echo.mod \
terminfo.mod test.mod blocklist.mod hexdump.mod \
read.mod sleep.mod loadenv.mod crc.mod parttool.mod \
msdospart.mod memrw.mod normal.mod sh.mod \
msdospart.mod memrw.mod normal.mod \
gptsync.mod true.mod probe.mod password.mod \
keystatus.mod
@ -514,11 +500,6 @@ msdospart_mod_SOURCES = parttool/msdospart.c
msdospart_mod_CFLAGS = $(COMMON_CFLAGS)
msdospart_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For handler.mod.
handler_mod_SOURCES = commands/handler.c
handler_mod_CFLAGS = $(COMMON_CFLAGS)
handler_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For ls.mod.
ls_mod_SOURCES = commands/ls.c
ls_mod_CFLAGS = $(COMMON_CFLAGS)
@ -638,18 +619,14 @@ keystatus_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For normal.mod.
normal_mod_SOURCES = normal/main.c normal/cmdline.c normal/dyncmd.c \
normal/auth.c normal/autofs.c normal/handler.c \
normal/auth.c normal/autofs.c \
normal/color.c normal/completion.c normal/datetime.c normal/menu.c \
normal/menu_entry.c normal/menu_text.c \
normal/misc.c normal/crypto.c normal/term.c normal/context.c
normal_mod_CFLAGS = $(COMMON_CFLAGS)
normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
# For sh.mod.
sh_mod_SOURCES = script/main.c script/script.c script/execute.c \
normal/misc.c normal/crypto.c normal/term.c normal/context.c \
script/main.c script/script.c script/execute.c \
script/function.c script/lexer.c grub_script.tab.c grub_script.yy.c
sh_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error
sh_mod_LDFLAGS = $(COMMON_LDFLAGS)
normal_mod_CFLAGS = $(COMMON_CFLAGS) $(POSIX_CFLAGS) -Wno-error
normal_mod_LDFLAGS = $(COMMON_LDFLAGS)
ifneq (, $(FONT_SOURCE))
font/font.c_DEPENDENCIES = ascii.h

View file

@ -14,7 +14,7 @@ kernel_img_SOURCES = kern/i386/coreboot/startup.S \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
kern/i386/tsc.c kern/i386/pit.c \
kern/generic/rtc_get_time_ms.c \

View file

@ -18,7 +18,7 @@ kernel_img_SOURCES = kern/i386/ieee1275/startup.S \
kern/rescue_parser.c kern/rescue_reader.c \
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
kern/env.c \
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
kern/generic/millisleep.c \
kern/ieee1275/ieee1275.c \
term/ieee1275/ofconsole.c \

View file

@ -43,7 +43,7 @@ kernel_img_SOURCES = kern/i386/pc/startup.S \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
kern/$(target_cpu)/dl.c kern/i386/pc/init.c kern/i386/pc/mmap.c \
kern/parser.c kern/partition.c \
kern/i386/tsc.c kern/i386/pit.c \
@ -66,7 +66,7 @@ util/i386/pc/grub-setup.c_DEPENDENCIES = grub_setup_init.h
grub_setup_SOURCES = gnulib/progname.c util/i386/pc/grub-setup.c \
util/misc.c kern/emu/misc.c kern/emu/getroot.c \
kern/emu/hostdisk.c kern/device.c kern/disk.c kern/err.c \
kern/misc.c kern/parser.c kern/partition.c kern/file.c \
kern/misc.c kern/partition.c kern/file.c \
kern/emu/mm.c kern/fs.c kern/env.c kern/list.c fs/fshelp.c \
\
fs/affs.c fs/cpio.c fs/ext2.c fs/fat.c fs/hfs.c \

View file

@ -23,7 +23,7 @@ kernel_img_SOURCES = kern/i386/qemu/startup.S \
kern/disk.c kern/dl.c kern/file.c kern/fs.c kern/err.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
kern/$(target_cpu)/dl.c kern/parser.c kern/partition.c \
kern/i386/tsc.c kern/i386/pit.c \
kern/generic/rtc_get_time_ms.c \

View file

@ -12,7 +12,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/list.c kern/command.c kern/corecmd.c \
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c kern/time.c \
symlist.c kern/$(target_cpu)/cache.S

View file

@ -16,7 +16,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/startup.S \
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/list.c kern/command.c kern/corecmd.c \
kern/parser.c kern/partition.c kern/env.c kern/$(target_cpu)/dl.c \
kern/generic/millisleep.c kern/generic/rtc_get_time_ms.c kern/time.c \
kern/$(target_cpu)/cache.S \

View file

@ -13,7 +13,7 @@ kernel_img_SOURCES = kern/powerpc/ieee1275/startup.S kern/ieee1275/cmain.c \
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/list.c kern/command.c kern/corecmd.c \
kern/ieee1275/init.c \
kern/ieee1275/mmap.c \
term/ieee1275/ofconsole.c \

View file

@ -26,7 +26,7 @@ kernel_img_SOURCES = kern/sparc64/ieee1275/crt0.S kern/ieee1275/cmain.c \
kern/disk.c kern/dl.c kern/err.c kern/file.c kern/fs.c \
kern/misc.c kern/mm.c kern/term.c \
kern/rescue_parser.c kern/rescue_reader.c \
kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/list.c kern/command.c kern/corecmd.c \
kern/sparc64/ieee1275/ieee1275.c \
kern/sparc64/ieee1275/init.c \
kern/ieee1275/mmap.c \
@ -48,7 +48,7 @@ util/sparc64/ieee1275/grub-setup.c_DEPENDENCIES = grub_setup_init.h
grub_setup_SOURCES = util/sparc64/ieee1275/grub-setup.c \
util/ieee1275/ofpath.c util/misc.c kern/emu/hostdisk.c \
kern/emu/misc.c kern/emu/getroot.c kern/emu/mm.c kern/device.c \
kern/disk.c kern/err.c kern/misc.c kern/parser.c \
kern/disk.c kern/err.c kern/misc.c \
kern/partition.c kern/file.c kern/fs.c kern/env.c kern/list.c \
fs/fshelp.c \
\

View file

@ -25,7 +25,7 @@ kernel_img_SOURCES = kern/$(target_cpu)/efi/startup.S kern/main.c kern/device.c
kern/$(target_cpu)/dl.c kern/i386/efi/init.c kern/parser.c kern/partition.c \
kern/env.c symlist.c kern/efi/efi.c kern/efi/init.c kern/efi/mm.c \
term/efi/console.c disk/efi/efidisk.c \
kern/time.c kern/list.c kern/handler.c kern/command.c kern/corecmd.c \
kern/time.c kern/list.c kern/command.c kern/corecmd.c \
kern/i386/tsc.c kern/i386/pit.c \
kern/generic/rtc_get_time_ms.c \
kern/generic/millisleep.c

View file

@ -309,14 +309,10 @@ grub_gettext_init_ext (const char *lang)
static void
grub_gettext_delete_list (void)
{
struct grub_gettext_msg *item;
while ((item =
grub_list_pop (GRUB_AS_LIST_P (&grub_gettext_msg_list))) != 0)
while (grub_gettext_msg_list)
{
char *original = (char *) ((struct grub_gettext_msg *) item)->name;
grub_free (original);
grub_free ((char *) grub_gettext_msg_list->name);
grub_gettext_msg_list = grub_gettext_msg_list->next;
/* Don't delete the translated message because could be in use. */
}
}

View file

@ -115,12 +115,7 @@ grub_command_execute (const char *name, int argc, char **argv)
return (cmd) ? cmd->func (cmd, argc, argv) : GRUB_ERR_FILE_NOT_FOUND;
}
static inline int
grub_command_iterate (int (*func) (grub_command_t))
{
return grub_list_iterate (GRUB_AS_LIST (grub_command_list),
(grub_list_hook_t) func);
}
#define FOR_COMMANDS(var) FOR_LIST_ELEMENTS((var), grub_command_list)
void grub_register_core_commands (void);

View file

@ -82,6 +82,7 @@ struct grub_dl
Elf_Sym *symtab;
void (*init) (struct grub_dl *mod);
void (*fini) (void);
struct grub_dl *next;
};
typedef struct grub_dl *grub_dl_t;
@ -98,7 +99,10 @@ void grub_dl_unload_all (void);
#endif
int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
void EXPORT_FUNC(grub_dl_iterate) (int (*hook) (grub_dl_t mod));
extern grub_dl_t EXPORT_VAR(grub_dl_head);
#define FOR_DL_MODULES(var) FOR_LIST_ELEMENTS ((var), (grub_dl_head))
grub_dl_t EXPORT_FUNC(grub_dl_get) (const char *name);
grub_err_t grub_dl_register_symbol (const char *name, void *addr,
grub_dl_t mod);

View file

@ -24,6 +24,8 @@
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/list.h>
/* Forward declaration is required, because of mutual reference. */
struct grub_file;
@ -38,6 +40,9 @@ struct grub_dirhook_info
/* Filesystem descriptor. */
struct grub_fs
{
/* The next filesystem. */
struct grub_fs *next;
/* My name. */
const char *name;
@ -72,9 +77,6 @@ struct grub_fs
/* Whether this filesystem reserves first sector for DOS-style boot. */
int reserved_first_sector;
#endif
/* The next filesystem. */
struct grub_fs *next;
};
typedef struct grub_fs *grub_fs_t;
@ -87,10 +89,22 @@ extern struct grub_fs grub_fs_blocklist;
the linked list GRUB_FS_LIST through the function grub_fs_register. */
typedef int (*grub_fs_autoload_hook_t) (void);
extern grub_fs_autoload_hook_t EXPORT_VAR(grub_fs_autoload_hook);
extern grub_fs_t EXPORT_VAR (grub_fs_list);
static inline void
grub_fs_register (grub_fs_t fs)
{
grub_list_push (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
}
static inline void
grub_fs_unregister (grub_fs_t fs)
{
grub_list_remove (GRUB_AS_LIST_P (&grub_fs_list), GRUB_AS_LIST (fs));
}
#define FOR_FILESYSTEMS(var) FOR_LIST_ELEMENTS((var), (grub_fs_list))
void EXPORT_FUNC(grub_fs_register) (grub_fs_t fs);
void EXPORT_FUNC(grub_fs_unregister) (grub_fs_t fs);
void EXPORT_FUNC(grub_fs_iterate) (int (*hook) (const grub_fs_t fs));
grub_fs_t EXPORT_FUNC(grub_fs_probe) (grub_device_t device);
#endif /* ! GRUB_FS_HEADER */

View file

@ -1,60 +0,0 @@
/* handler.h - header for grub handler */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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_HANDLER_HEADER
#define GRUB_HANDLER_HEADER 1
#include <grub/list.h>
#include <grub/err.h>
struct grub_handler
{
struct grub_handler *next;
const char *name;
grub_err_t (*init) (void);
grub_err_t (*fini) (void);
};
typedef struct grub_handler *grub_handler_t;
struct grub_handler_class
{
struct grub_handler_class *next;
const char *name;
grub_handler_t handler_list;
grub_handler_t cur_handler;
};
typedef struct grub_handler_class *grub_handler_class_t;
extern grub_handler_class_t EXPORT_VAR(grub_handler_class_list);
void EXPORT_FUNC(grub_handler_register) (grub_handler_class_t class,
grub_handler_t handler);
void EXPORT_FUNC(grub_handler_unregister) (grub_handler_class_t class,
grub_handler_t handler);
grub_err_t EXPORT_FUNC(grub_handler_set_current) (grub_handler_class_t class,
grub_handler_t handler);
#define GRUB_AS_HANDLER(ptr) \
((GRUB_FIELD_MATCH (ptr, grub_handler_t, next) && \
GRUB_FIELD_MATCH (ptr, grub_handler_t, name) && \
GRUB_FIELD_MATCH (ptr, grub_handler_t, init) && \
GRUB_FIELD_MATCH (ptr, grub_handler_t, fini)) ? \
(grub_handler_t) ptr : grub_bad_type_cast ())
#endif /* ! GRUB_HANDLER_HEADER */

View file

@ -30,15 +30,10 @@ struct grub_list
};
typedef struct grub_list *grub_list_t;
typedef int (*grub_list_hook_t) (grub_list_t item);
typedef int (*grub_list_test_t) (grub_list_t new_item, grub_list_t item);
void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
void * EXPORT_FUNC(grub_list_pop) (grub_list_t *head);
void EXPORT_FUNC(grub_list_remove) (grub_list_t *head, grub_list_t item);
int EXPORT_FUNC(grub_list_iterate) (grub_list_t head, grub_list_hook_t hook);
void EXPORT_FUNC(grub_list_insert) (grub_list_t *head, grub_list_t item,
grub_list_test_t test);
#define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)
static inline void *
grub_bad_type_cast_real (int line, const char *file)

View file

@ -22,7 +22,6 @@
#include <grub/types.h>
#include <grub/err.h>
#include <grub/handler.h>
#include <grub/reader.h>
/* All the states for the command line. */
@ -84,36 +83,9 @@ struct grub_parser
};
typedef struct grub_parser *grub_parser_t;
extern struct grub_handler_class EXPORT_VAR(grub_parser_class);
grub_err_t EXPORT_FUNC(grub_parser_execute) (char *source);
static inline void
grub_parser_register (const char *name __attribute__ ((unused)),
/* `name' is ignored here, but used by genhandlerlist.sh. */
grub_parser_t parser)
{
grub_handler_register (&grub_parser_class, GRUB_AS_HANDLER (parser));
}
static inline void
grub_parser_unregister (grub_parser_t parser)
{
grub_handler_unregister (&grub_parser_class, GRUB_AS_HANDLER (parser));
}
static inline grub_parser_t
grub_parser_get_current (void)
{
return (grub_parser_t) grub_parser_class.cur_handler;
}
static inline grub_err_t
grub_parser_set_current (grub_parser_t parser)
{
return grub_handler_set_current (&grub_parser_class,
GRUB_AS_HANDLER (parser));
}
void grub_register_rescue_parser (void);
grub_err_t
grub_rescue_parse_line (char *line, grub_reader_getline_t getline);
#endif /* ! GRUB_PARSER_HEADER */

View file

@ -91,7 +91,7 @@ grub_partition_map_unregister (grub_partition_map_t partmap)
GRUB_AS_LIST (partmap));
}
#define FOR_PARTITION_MAPS(var) for (var = grub_partition_map_list; var; var = var->next)
#define FOR_PARTITION_MAPS(var) FOR_LIST_ELEMENTS((var), (grub_partition_map_list))
static inline grub_disk_addr_t

View file

@ -335,15 +335,22 @@ struct grub_script_function
};
typedef struct grub_script_function *grub_script_function_t;
extern grub_script_function_t grub_script_function_list;
#define FOR_SCRIPT_FUNCTIONS(var) for((var) = grub_script_function_list; \
(var); (var) = (var)->next)
grub_script_function_t grub_script_function_create (struct grub_script_arg *functionname,
struct grub_script *cmd);
void grub_script_function_remove (const char *name);
grub_script_function_t grub_script_function_find (char *functionname);
int grub_script_function_iterate (int (*iterate) (grub_script_function_t));
int grub_script_function_call (grub_script_function_t func,
int argc, char **args);
char **
grub_script_execute_arglist_to_argv (struct grub_script_arglist *arglist, int *count);
grub_err_t
grub_normal_parse_line (char *line, grub_reader_getline_t getline);
#endif /* ! GRUB_NORMAL_PARSER_HEADER */

View file

@ -38,7 +38,7 @@
#include <grub/err.h>
#include <grub/symbol.h>
#include <grub/types.h>
#include <grub/handler.h>
#include <grub/list.h>
/* These are used to represent the various color states we use. */
typedef enum
@ -245,10 +245,10 @@ grub_term_unregister_output (grub_term_output_t term)
GRUB_AS_LIST (term));
}
#define FOR_ACTIVE_TERM_INPUTS(var) for (var = grub_term_inputs; var; var = var->next)
#define FOR_DISABLED_TERM_INPUTS(var) for (var = grub_term_inputs_disabled; var; var = var->next)
#define FOR_ACTIVE_TERM_OUTPUTS(var) for (var = grub_term_outputs; var; var = var->next)
#define FOR_DISABLED_TERM_OUTPUTS(var) for (var = grub_term_outputs_disabled; var; var = var->next)
#define FOR_ACTIVE_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs))
#define FOR_DISABLED_TERM_INPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_inputs_disabled))
#define FOR_ACTIVE_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs))
#define FOR_DISABLED_TERM_OUTPUTS(var) FOR_LIST_ELEMENTS((var), (grub_term_outputs_disabled))
void EXPORT_FUNC(grub_putchar) (int c);
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code,

View file

@ -21,6 +21,7 @@
#include <grub/err.h>
#include <grub/types.h>
#include <grub/list.h>
/* Video color in hardware dependent format. Users should not assume any
specific coding format. */
@ -187,6 +188,9 @@ typedef enum grub_video_driver_id
struct grub_video_adapter
{
/* The next video adapter. */
struct grub_video_adapter *next;
/* The video adapter name. */
const char *name;
grub_video_driver_id_t id;
@ -255,15 +259,28 @@ struct grub_video_adapter
grub_err_t (*set_active_render_target) (struct grub_video_render_target *target);
grub_err_t (*get_active_render_target) (struct grub_video_render_target **target);
/* The next video adapter. */
struct grub_video_adapter *next;
};
typedef struct grub_video_adapter *grub_video_adapter_t;
void EXPORT_FUNC (grub_video_register) (grub_video_adapter_t adapter);
void grub_video_unregister (grub_video_adapter_t adapter);
void grub_video_iterate (int (*hook) (grub_video_adapter_t adapter));
extern grub_video_adapter_t EXPORT_VAR(grub_video_adapter_list);
/* Register video driver. */
static inline void
grub_video_register (grub_video_adapter_t adapter)
{
grub_list_push (GRUB_AS_LIST_P (&grub_video_adapter_list),
GRUB_AS_LIST (adapter));
}
/* Unregister video driver. */
static inline void
grub_video_unregister (grub_video_adapter_t adapter)
{
grub_list_remove (GRUB_AS_LIST_P (&grub_video_adapter_list),
GRUB_AS_LIST (adapter));
}
#define FOR_VIDEO_ADAPTERS(var) FOR_LIST_ELEMENTS((var), (grub_video_adapter_list))
grub_err_t EXPORT_FUNC (grub_video_restore) (void);

View file

@ -39,31 +39,17 @@
struct grub_dl_list
{
struct grub_dl_list *next;
grub_dl_t mod;
};
typedef struct grub_dl_list *grub_dl_list_t;
static grub_dl_list_t grub_dl_head;
grub_dl_t grub_dl_head = 0;
static grub_err_t
grub_dl_add (grub_dl_t mod)
{
grub_dl_list_t l;
if (grub_dl_get (mod->name))
return grub_error (GRUB_ERR_BAD_MODULE,
"`%s' is already loaded", mod->name);
l = (grub_dl_list_t) grub_malloc (sizeof (*l));
if (! l)
return grub_errno;
l->mod = mod;
l->next = grub_dl_head;
grub_dl_head = l;
mod->next = grub_dl_head;
grub_dl_head = mod;
return GRUB_ERR_NONE;
}
@ -71,13 +57,12 @@ grub_dl_add (grub_dl_t mod)
static void
grub_dl_remove (grub_dl_t mod)
{
grub_dl_list_t *p, q;
grub_dl_t *p, q;
for (p = &grub_dl_head, q = *p; q; p = &q->next, q = *p)
if (q->mod == mod)
if (q == mod)
{
*p = q->next;
grub_free (q);
return;
}
}
@ -85,25 +70,15 @@ grub_dl_remove (grub_dl_t mod)
grub_dl_t
grub_dl_get (const char *name)
{
grub_dl_list_t l;
grub_dl_t l;
for (l = grub_dl_head; l; l = l->next)
if (grub_strcmp (name, l->mod->name) == 0)
return l->mod;
if (grub_strcmp (name, l->name) == 0)
return l;
return 0;
}
void
grub_dl_iterate (int (*hook) (grub_dl_t mod))
{
grub_dl_list_t l;
for (l = grub_dl_head; l; l = l->next)
if (hook (l->mod))
break;
}
struct grub_symbol
@ -694,11 +669,11 @@ grub_dl_unload_unneeded (void)
{
/* Because grub_dl_remove modifies the list of modules, this
implementation is tricky. */
grub_dl_list_t p = grub_dl_head;
grub_dl_t p = grub_dl_head;
while (p)
{
if (grub_dl_unload (p->mod))
if (grub_dl_unload (p))
{
p = grub_dl_head;
continue;
@ -714,13 +689,13 @@ grub_dl_unload_all (void)
{
while (grub_dl_head)
{
grub_dl_list_t p;
grub_dl_t p;
grub_dl_unload_unneeded ();
/* Force to decrement the ref count. This will purge pre-loaded
modules and manually inserted modules. */
for (p = grub_dl_head; p; p = p->next)
p->mod->ref_count--;
p->ref_count--;
}
}

View file

@ -27,40 +27,10 @@
#include <grub/mm.h>
#include <grub/term.h>
static grub_fs_t grub_fs_list;
grub_fs_t grub_fs_list = 0;
grub_fs_autoload_hook_t grub_fs_autoload_hook = 0;
void
grub_fs_register (grub_fs_t fs)
{
fs->next = grub_fs_list;
grub_fs_list = fs;
}
void
grub_fs_unregister (grub_fs_t fs)
{
grub_fs_t *p, q;
for (p = &grub_fs_list, q = *p; q; p = &(q->next), q = q->next)
if (q == fs)
{
*p = q->next;
break;
}
}
void
grub_fs_iterate (int (*hook) (const grub_fs_t fs))
{
grub_fs_t p;
for (p = grub_fs_list; p; p = p->next)
if (hook (p))
break;
}
grub_fs_t
grub_fs_probe (grub_device_t device)
{

View file

@ -1,64 +0,0 @@
/* handler.c - grub handler function */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/handler.h>
grub_handler_class_t grub_handler_class_list;
void
grub_handler_register (grub_handler_class_t class, grub_handler_t handler)
{
int first_handler = (class->handler_list == 0);
grub_list_push (GRUB_AS_LIST_P (&class->handler_list),
GRUB_AS_LIST (handler));
if (first_handler)
{
grub_list_push (GRUB_AS_LIST_P (&grub_handler_class_list),
GRUB_AS_LIST (class));
grub_handler_set_current (class, handler);
}
}
void
grub_handler_unregister (grub_handler_class_t class, grub_handler_t handler)
{
grub_list_remove (GRUB_AS_LIST_P (&class->handler_list),
GRUB_AS_LIST (handler));
if (class->handler_list == 0)
grub_list_remove (GRUB_AS_LIST_P (&grub_handler_class_list),
GRUB_AS_LIST (class));
}
grub_err_t
grub_handler_set_current (grub_handler_class_t class, grub_handler_t handler)
{
if (class->cur_handler && class->cur_handler->fini)
if ((class->cur_handler->fini) () != GRUB_ERR_NONE)
return grub_errno;
if (handler->init)
if ((handler->init) () != GRUB_ERR_NONE)
return grub_errno;
class->cur_handler = handler;
return GRUB_ERR_NONE;
}

View file

@ -28,18 +28,6 @@ grub_list_push (grub_list_t *head, grub_list_t item)
*head = item;
}
void *
grub_list_pop (grub_list_t *head)
{
grub_list_t item;
item = *head;
if (item)
*head = item->next;
return item;
}
void
grub_list_remove (grub_list_t *head, grub_list_t item)
{
@ -53,51 +41,16 @@ grub_list_remove (grub_list_t *head, grub_list_t item)
}
}
int
grub_list_iterate (grub_list_t head, grub_list_hook_t hook)
{
grub_list_t p;
for (p = head; p; p = p->next)
if (hook (p))
return 1;
return 0;
}
void
grub_list_insert (grub_list_t *head, grub_list_t item,
grub_list_test_t test)
{
grub_list_t *p, q;
for (p = head, q = *p; q; p = &(q->next), q = q->next)
if (test (item, q))
break;
*p = item;
item->next = q;
}
void *
grub_named_list_find (grub_named_list_t head, const char *name)
{
grub_named_list_t result = NULL;
grub_named_list_t item;
auto int list_find (grub_named_list_t item);
int list_find (grub_named_list_t item)
{
if (! grub_strcmp (item->name, name))
{
result = item;
return 1;
}
FOR_LIST_ELEMENTS (item, head)
if (grub_strcmp (item->name, name) == 0)
return item;
return 0;
}
grub_list_iterate (GRUB_AS_LIST (head), (grub_list_hook_t) list_find);
return result;
return NULL;
}
void
@ -105,27 +58,30 @@ grub_prio_list_insert (grub_prio_list_t *head, grub_prio_list_t nitem)
{
int inactive = 0;
auto int test (grub_prio_list_t new_item, grub_prio_list_t item);
int test (grub_prio_list_t new_item, grub_prio_list_t item)
grub_prio_list_t *p, q;
for (p = head, q = *p; q; p = &(q->next), q = q->next)
{
int r;
r = grub_strcmp (new_item->name, item->name);
if (r)
return (r < 0);
r = grub_strcmp (nitem->name, q->name);
if (r < 0)
break;
if (r > 0)
continue;
if (new_item->prio >= (item->prio & GRUB_PRIO_LIST_PRIO_MASK))
if (nitem->prio >= (q->prio & GRUB_PRIO_LIST_PRIO_MASK))
{
item->prio &= ~GRUB_PRIO_LIST_FLAG_ACTIVE;
return 1;
q->prio &= ~GRUB_PRIO_LIST_FLAG_ACTIVE;
break;
}
inactive = 1;
return 0;
}
grub_list_insert (GRUB_AS_LIST_P (head), GRUB_AS_LIST (nitem),
(grub_list_test_t) test);
*p = nitem;
nitem->next = q;
if (! inactive)
nitem->prio |= GRUB_PRIO_LIST_FLAG_ACTIVE;
}

View file

@ -191,7 +191,6 @@ grub_main (void)
grub_set_root_dev ();
grub_register_core_commands ();
grub_register_rescue_parser ();
grub_load_config ();
grub_load_normal_mode ();

View file

@ -230,10 +230,6 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
return 0;
}
struct grub_handler_class grub_parser_class = {
.name = "parser"
};
grub_err_t
grub_parser_execute (char *source)
{
@ -261,11 +257,9 @@ grub_parser_execute (char *source)
while (source)
{
char *line;
grub_parser_t parser;
getline (&line, 0);
parser = grub_parser_get_current ();
parser->parse_line (line, getline);
grub_rescue_parse_line (line, getline);
grub_free (line);
}

View file

@ -24,7 +24,7 @@
#include <grub/misc.h>
#include <grub/command.h>
static grub_err_t
grub_err_t
grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
{
char *name;
@ -74,15 +74,3 @@ grub_rescue_parse_line (char *line, grub_reader_getline_t getline)
return grub_errno;
}
static struct grub_parser grub_rescue_parser =
{
.name = "rescue",
.parse_line = grub_rescue_parse_line
};
void
grub_register_rescue_parser (void)
{
grub_parser_register ("rescue", &grub_rescue_parser);
}

View file

@ -86,7 +86,7 @@ grub_rescue_run (void)
if (! line || line[0] == '\0')
continue;
grub_parser_get_current ()->parse_line (line, grub_rescue_read_line);
grub_rescue_parse_line (line, grub_rescue_read_line);
grub_free (line);
}
}

View file

@ -133,25 +133,24 @@ static int
is_authenticated (const char *userlist)
{
const char *superusers;
auto int hook (grub_list_t item);
int hook (grub_list_t item)
{
const char *name;
if (!((struct grub_auth_user *) item)->authenticated)
return 0;
name = ((struct grub_auth_user *) item)->name;
return (userlist && grub_strword (userlist, name))
|| grub_strword (superusers, name);
}
struct grub_auth_user *user;
superusers = grub_env_get ("superusers");
if (!superusers)
return 1;
return grub_list_iterate (GRUB_AS_LIST (users), hook);
FOR_LIST_ELEMENTS (user, users)
{
if (!(user->authenticated))
continue;
if ((userlist && grub_strword (userlist, user->name))
|| grub_strword (superusers, user->name))
return 1;
}
return 0;
}
static int
@ -205,22 +204,7 @@ grub_auth_check_authentication (const char *userlist)
grub_err_t err;
static unsigned long punishment_delay = 1;
char entered[GRUB_AUTH_MAX_PASSLEN];
auto int hook (grub_list_t item);
int hook (grub_list_t item)
{
if (grub_strcmp (login, ((struct grub_auth_user *) item)->name) == 0)
cur = (struct grub_auth_user *) item;
return 0;
}
auto int hook_any (grub_list_t item);
int hook_any (grub_list_t item)
{
if (((struct grub_auth_user *) item)->callback)
cur = (struct grub_auth_user *) item;
return 0;
}
struct grub_auth_user *user;
grub_memset (login, 0, sizeof (login));
@ -240,7 +224,11 @@ grub_auth_check_authentication (const char *userlist)
if (!grub_password_get (entered, GRUB_AUTH_MAX_PASSLEN))
goto access_denied;
grub_list_iterate (GRUB_AS_LIST (users), hook);
FOR_LIST_ELEMENTS (user, users)
{
if (grub_strcmp (login, user->name) == 0)
cur = user;
}
if (!cur || ! cur->callback)
goto access_denied;

View file

@ -176,21 +176,6 @@ iterate_dev (const char *devname)
return 0;
}
static int
iterate_command (grub_command_t cmd)
{
if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE)
{
if (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)
{
if (add_completion (cmd->name, " ", GRUB_COMPLETION_TYPE_COMMAND))
return 1;
}
}
return 0;
}
/* Complete a device. */
static int
complete_device (void)
@ -429,8 +414,18 @@ grub_normal_do_completion (char *buf, int *restore,
if (argc == 1 || argc == 0)
{
/* Complete a command. */
if (grub_command_iterate (iterate_command))
goto fail;
grub_command_t cmd;
FOR_COMMANDS(cmd)
{
if (cmd->prio & GRUB_PRIO_LIST_FLAG_ACTIVE)
{
if (cmd->flags & GRUB_COMMAND_FLAG_CMDLINE)
{
if (add_completion (cmd->name, " ", GRUB_COMPLETION_TYPE_COMMAND))
goto fail;
}
}
}
}
else if (*current_word == '-')
{

View file

@ -1,231 +0,0 @@
/* handler.c - support handler loading */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 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/dl.h>
#include <grub/mm.h>
#include <grub/err.h>
#include <grub/env.h>
#include <grub/misc.h>
#include <grub/command.h>
#include <grub/handler.h>
#include <grub/normal.h>
struct grub_handler_list
{
struct grub_handler_list *next;
char *name;
grub_command_t cmd;
};
static grub_list_t handler_list;
static grub_err_t
grub_handler_cmd (struct grub_command *cmd,
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
char *p;
grub_handler_class_t class;
grub_handler_t handler;
p = grub_strchr (cmd->name, '.');
if (! p)
return grub_error (GRUB_ERR_BAD_ARGUMENT, "invalid command name");
if (cmd->data)
{
if (! grub_dl_get (cmd->data))
{
grub_dl_t mod;
mod = grub_dl_load (cmd->data);
if (mod)
grub_dl_ref (mod);
else
return grub_errno;
}
grub_free (cmd->data);
cmd->data = 0;
}
*p = 0;
class = grub_named_list_find (GRUB_AS_NAMED_LIST (grub_handler_class_list),
cmd->name);
*p = '.';
if (! class)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "class not found");
handler = grub_named_list_find (GRUB_AS_NAMED_LIST (class->handler_list),
p + 1);
if (! handler)
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "handler not found");
grub_handler_set_current (class, handler);
return 0;
}
static void
insert_handler (char *name, char *module)
{
struct grub_handler_list *item;
char *data;
if (grub_command_find (name))
return;
item = grub_malloc (sizeof (*item));
if (! item)
return;
item->name = grub_strdup (name);
if (! item->name)
{
grub_free (item);
return;
}
if (module)
{
data = grub_strdup (module);
if (! data)
{
grub_free (item->name);
grub_free (item);
return;
}
}
else
data = 0;
item->cmd = grub_register_command (item->name, grub_handler_cmd, 0,
"Set active handler.");
if (! item->cmd)
{
grub_free (data);
grub_free (item->name);
grub_free (item);
return;
}
item->cmd->data = data;
grub_list_push (&handler_list, GRUB_AS_LIST (item));
}
/* Read the file handler.lst for auto-loading. */
void
read_handler_list (void)
{
const char *prefix;
static int first_time = 1;
const char *class_name;
auto int iterate_handler (grub_handler_t handler);
int iterate_handler (grub_handler_t handler)
{
char name[grub_strlen (class_name) + grub_strlen (handler->name) + 2];
grub_strcpy (name, class_name);
grub_strcat (name, ".");
grub_strcat (name, handler->name);
insert_handler (name, 0);
return 0;
}
auto int iterate_class (grub_handler_class_t class);
int iterate_class (grub_handler_class_t class)
{
class_name = class->name;
grub_list_iterate (GRUB_AS_LIST (class->handler_list),
(grub_list_hook_t) iterate_handler);
return 0;
}
/* Make sure that this function does not get executed twice. */
if (! first_time)
return;
first_time = 0;
prefix = grub_env_get ("prefix");
if (prefix)
{
char *filename;
filename = grub_xasprintf ("%s/handler.lst", prefix);
if (filename)
{
grub_file_t file;
file = grub_file_open (filename);
if (file)
{
char *buf = NULL;
for (;; grub_free (buf))
{
char *p;
buf = grub_file_getline (file);
if (! buf)
break;
if (! grub_isgraph (buf[0]))
continue;
p = grub_strchr (buf, ':');
if (! p)
continue;
*p = '\0';
while (*++p == ' ')
;
insert_handler (buf, p);
}
grub_file_close (file);
}
grub_free (filename);
}
}
grub_list_iterate (GRUB_AS_LIST (grub_handler_class_list),
(grub_list_hook_t) iterate_class);
/* Ignore errors. */
grub_errno = GRUB_ERR_NONE;
}
void
free_handler_list (void)
{
struct grub_handler_list *item;
while ((item = grub_list_pop (&handler_list)) != 0)
{
grub_free (item->cmd->data);
grub_unregister_command (item->cmd);
grub_free (item->name);
grub_free (item);
}
}

View file

@ -31,6 +31,7 @@
#include <grub/auth.h>
#include <grub/i18n.h>
#include <grub/charset.h>
#include <grub/script_sh.h>
#define GRUB_DEFAULT_HISTORY_SIZE 50
@ -347,7 +348,6 @@ static grub_menu_t
read_config_file (const char *config)
{
grub_file_t file;
grub_parser_t old_parser = 0;
auto grub_err_t getline (char **line, int cont);
grub_err_t getline (char **line, int cont __attribute__ ((unused)))
@ -361,36 +361,7 @@ read_config_file (const char *config)
return grub_errno;
if (buf[0] == '#')
{
if (buf[1] == '!')
{
grub_parser_t parser;
grub_named_list_t list;
buf += 2;
while (grub_isspace (*buf))
buf++;
if (! old_parser)
old_parser = grub_parser_get_current ();
list = GRUB_AS_NAMED_LIST (grub_parser_class.handler_list);
parser = grub_named_list_find (list, buf);
if (parser)
grub_parser_set_current (parser);
else
{
char cmd_name[8 + grub_strlen (buf)];
/* Perhaps it's not loaded yet, try the autoload
command. */
grub_strcpy (cmd_name, "parser.");
grub_strcat (cmd_name, buf);
grub_command_execute (cmd_name, 0, 0);
}
}
grub_free (*line);
}
grub_free (*line);
else
break;
}
@ -426,15 +397,12 @@ read_config_file (const char *config)
if ((getline (&line, 0)) || (! line))
break;
grub_parser_get_current ()->parse_line (line, getline);
grub_normal_parse_line (line, getline);
grub_free (line);
}
grub_file_close (file);
if (old_parser)
grub_parser_set_current (old_parser);
return newmenu;
}
@ -499,7 +467,6 @@ grub_normal_execute (const char *config, int nested, int batch)
const char *prefix = grub_env_get ("prefix");
read_lists (prefix);
read_handler_list ();
grub_register_variable_hook ("prefix", NULL, read_lists_hook);
grub_command_execute ("parser.grub", 0, 0);
@ -605,17 +572,15 @@ grub_normal_reader_init (int nested)
return 0;
}
static grub_err_t
grub_normal_read_line_real (char **line, int cont, int nested)
{
grub_parser_t parser = grub_parser_get_current ();
char *prompt;
const char *prompt;
if (cont)
prompt = grub_xasprintf (">");
prompt = ">";
else
prompt = grub_xasprintf ("%s>", parser->name);
prompt = "grub>";
if (!prompt)
return grub_errno;
@ -629,14 +594,11 @@ grub_normal_read_line_real (char **line, int cont, int nested)
if (cont || nested)
{
grub_free (*line);
grub_free (prompt);
*line = 0;
return grub_errno;
}
}
grub_free (prompt);
return 0;
}
@ -677,7 +639,7 @@ grub_cmdline_run (int nested)
if (! line)
break;
grub_parser_get_current ()->parse_line (line, grub_normal_read_line);
grub_normal_parse_line (line, grub_normal_read_line);
grub_free (line);
}
}
@ -725,5 +687,4 @@ GRUB_MOD_FINI(normal)
grub_set_history (0);
grub_register_variable_hook ("pager", 0, 0);
grub_fs_autoload_hook = 0;
free_handler_list ();
}

View file

@ -23,6 +23,7 @@
#include <grub/loader.h>
#include <grub/command.h>
#include <grub/parser.h>
#include <grub/script_sh.h>
#include <grub/auth.h>
#include <grub/i18n.h>
@ -1189,7 +1190,7 @@ run (struct screen *screen)
while (currline < screen->num_lines)
{
editor_getline (&nextline, 0);
if (grub_parser_get_current ()->parse_line (nextline, editor_getline))
if (grub_normal_parse_line (nextline, editor_getline))
break;
}

View file

@ -21,7 +21,7 @@
#include <grub/parser.h>
#include <grub/mm.h>
static grub_script_function_t grub_script_function_list;
grub_script_function_t grub_script_function_list;
grub_script_function_t
grub_script_function_create (struct grub_script_arg *functionname_arg,
@ -104,18 +104,6 @@ grub_script_function_find (char *functionname)
return func;
}
int
grub_script_function_iterate (int (*iterate) (grub_script_function_t))
{
grub_script_function_t func;
for (func = grub_script_function_list; func; func = func->next)
if (iterate (func))
return 1;
return 0;
}
int
grub_script_function_call (grub_script_function_t func,
int argc __attribute__((unused)),

View file

@ -20,7 +20,7 @@
#include <grub/parser.h>
#include <grub/script_sh.h>
static grub_err_t
grub_err_t
grub_normal_parse_line (char *line, grub_reader_getline_t getline)
{
struct grub_script *parsed_script;
@ -39,19 +39,3 @@ grub_normal_parse_line (char *line, grub_reader_getline_t getline)
return grub_errno;
}
static struct grub_parser grub_sh_parser =
{
.name = "grub",
.parse_line = grub_normal_parse_line
};
GRUB_MOD_INIT(sh)
{
grub_parser_register ("grub", &grub_sh_parser);
}
GRUB_MOD_FINI(sh)
{
grub_parser_unregister (&grub_sh_parser);
}

View file

@ -26,15 +26,10 @@ grub_functional_test (struct grub_extcmd *cmd __attribute__ ((unused)),
int argc __attribute__ ((unused)),
char **args __attribute__ ((unused)))
{
auto int run_test (grub_test_t test);
int run_test (grub_test_t test)
{
grub_test_run (test);
return 0;
}
grub_test_t test;
grub_list_iterate (GRUB_AS_LIST (grub_test_list),
(grub_list_hook_t) run_test);
FOR_LIST_ELEMENTS (test, grub_test_list)
grub_test_run (test);
return GRUB_ERR_NONE;
}

View file

@ -66,8 +66,10 @@ free_failures (void)
{
grub_test_failure_t item;
while ((item = grub_list_pop (GRUB_AS_LIST_P (&failure_list))) != 0)
while (failure_list)
{
item = failure_list;
failure_list = item->next;
if (item->message)
grub_free (item->message);
@ -134,23 +136,17 @@ grub_test_unregister (const char *name)
int
grub_test_run (grub_test_t test)
{
auto int print_failure (grub_test_failure_t item);
int print_failure (grub_test_failure_t item)
{
grub_test_failure_t failure = (grub_test_failure_t) item;
grub_printf (" %s:%s:%u: %s\n",
(failure->file ? : "<unknown_file>"),
(failure->funp ? : "<unknown_function>"),
failure->line, (failure->message ? : "<no message>"));
return 0;
}
grub_test_failure_t failure;
test->main ();
grub_printf ("%s:\n", test->name);
grub_list_iterate (GRUB_AS_LIST (failure_list),
(grub_list_hook_t) print_failure);
FOR_LIST_ELEMENTS (failure, failure_list)
grub_printf (" %s:%s:%u: %s\n",
(failure->file ? : "<unknown_file>"),
(failure->funp ? : "<unknown_function>"),
failure->line, (failure->message ? : "<no message>"));
if (!failure_list)
grub_printf ("%s: PASS\n", test->name);
else

View file

@ -34,16 +34,12 @@ main (int argc __attribute__ ((unused)),
extern void grub_unit_test_init (void);
extern void grub_unit_test_fini (void);
auto int run_test (grub_test_t test);
int run_test (grub_test_t test)
{
status = grub_test_run (test) ? : status;
return 0;
}
grub_test_t test;
grub_unit_test_init ();
grub_list_iterate (GRUB_AS_LIST (grub_test_list),
(grub_list_hook_t) run_test);
FOR_LIST_ELEMENTS (test, grub_test_list)
status = grub_test_run (test) ? : status;
grub_unit_test_fini ();
exit (status);

View file

@ -750,8 +750,8 @@ grub_util_iterate_devices (int NESTED_FUNC_ATTR (*hook) (const char *, int),
free (name);
while (seen)
{
struct dmraid_seen *seen_elt =
grub_list_pop (GRUB_AS_LIST_P (&seen));
struct dmraid_seen *seen_elt = seen;
seen = seen->next;
free (seen_elt);
}
if (task)
@ -776,7 +776,8 @@ dmraid_next_child:
dmraid_end:
while (seen)
{
struct dmraid_seen *seen_elt = grub_list_pop (GRUB_AS_LIST_P (&seen));
struct dmraid_seen *seen_elt = seen;
seen = seen->next;
free (seen_elt);
}
if (task)

View file

@ -21,7 +21,6 @@
#include <grub/types.h>
#include <grub/util/misc.h>
#include <grub/lib/envblk.h>
#include <grub/handler.h>
#include <grub/i18n.h>
#include <stdio.h>

View file

@ -55,9 +55,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{

View file

@ -71,9 +71,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{

View file

@ -26,8 +26,6 @@
#include <grub/parser.h>
#include <grub/script_sh.h>
#include <grub_script_check_init.h>
#define _GNU_SOURCE 1
#include <ctype.h>
@ -239,9 +237,6 @@ main (int argc, char *argv[])
}
}
/* Initialize all modules. */
grub_init_all ();
do
{
input = 0;
@ -260,8 +255,6 @@ main (int argc, char *argv[])
grub_free (input);
} while (script != 0);
/* Free resources. */
grub_fini_all ();
if (file) fclose (file);
return (found_input && script == 0);

View file

@ -76,9 +76,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{

View file

@ -102,9 +102,6 @@ grub_getkey (void)
return -1;
}
struct grub_handler_class grub_term_input_class;
struct grub_handler_class grub_term_output_class;
void
grub_refresh (void)
{

View file

@ -23,44 +23,11 @@
#include <grub/mm.h>
/* The list of video adapters registered to system. */
static grub_video_adapter_t grub_video_adapter_list;
grub_video_adapter_t grub_video_adapter_list = NULL;
/* Active video adapter. */
static grub_video_adapter_t grub_video_adapter_active;
/* Register video driver. */
void
grub_video_register (grub_video_adapter_t adapter)
{
adapter->next = grub_video_adapter_list;
grub_video_adapter_list = adapter;
}
/* Unregister video driver. */
void
grub_video_unregister (grub_video_adapter_t adapter)
{
grub_video_adapter_t *p, q;
for (p = &grub_video_adapter_list, q = *p; q; p = &(q->next), q = q->next)
if (q == adapter)
{
*p = q->next;
break;
}
}
/* Iterate thru all registered video drivers. */
void
grub_video_iterate (int (*hook) (grub_video_adapter_t adapter))
{
grub_video_adapter_t p;
for (p = grub_video_adapter_list; p; p = p->next)
if (hook (p))
break;
}
/* Restore back to initial mode (where applicable). */
grub_err_t
grub_video_restore (void)