1
/* handler.c - commands to list or select handlers */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2009 Free Software Foundation, Inc.
6
* GRUB is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* GRUB is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
22
#include <grub/misc.h>
23
#include <grub/term.h>
24
#include <grub/handler.h>
25
#include <grub/command.h>
26
#include <grub/i18n.h>
29
grub_cmd_handler (struct grub_command *cmd __attribute__ ((unused)),
30
int argc, char **args)
33
grub_handler_class_t head;
35
auto int list_item (grub_named_list_t item);
36
int list_item (grub_named_list_t item)
38
if (item == curr_item)
41
grub_printf ("%s\n", item->name);
46
head = grub_handler_class_list;
49
grub_list_iterate (GRUB_AS_LIST (head), (grub_list_hook_t) list_item);
54
grub_handler_class_t class;
60
class = grub_named_list_find (GRUB_AS_NAMED_LIST (head), class_name);
62
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "class not found");
66
curr_item = class->cur_handler;
67
grub_list_iterate (GRUB_AS_LIST (class->handler_list),
68
(grub_list_hook_t) list_item);
72
grub_handler_t handler;
75
grub_named_list_find (GRUB_AS_NAMED_LIST (class->handler_list),
79
return grub_error (GRUB_ERR_FILE_NOT_FOUND, "handler not found");
81
grub_handler_set_current (class, handler);
88
static grub_command_t cmd_handler;
90
GRUB_MOD_INIT(handler)
93
grub_register_command ("handler", grub_cmd_handler,
94
N_("[class [handler]]"),
95
N_("List or select a handler."));
98
GRUB_MOD_FINI(handler)
100
grub_unregister_command (cmd_handler);