Remove handlers

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2010-03-27 00:19:42 +01:00
parent 0959e5ec30
commit d56a6ac7f6
29 changed files with 40 additions and 627 deletions

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

@ -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)
{
@ -262,11 +258,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);
}
}