2009-11-21 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2/phcoder/solaris.git] / kern / command.c
blob63b536eb766c67bd23f4c7b27140ca508d037a0d
1 /* command.c - support basic command */
2 /*
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/>.
20 #include <grub/mm.h>
21 #include <grub/command.h>
23 grub_command_t grub_command_list;
25 grub_command_t
26 grub_register_command_prio (const char *name,
27 grub_command_func_t func,
28 const char *summary,
29 const char *description,
30 int prio)
32 grub_command_t cmd;
34 cmd = (grub_command_t) grub_malloc (sizeof (*cmd));
35 if (! cmd)
36 return 0;
38 cmd->name = name;
39 cmd->func = func;
40 cmd->summary = (summary) ? summary : name;
41 cmd->description = description;
43 cmd->flags = GRUB_COMMAND_FLAG_BOTH;
44 cmd->prio = prio;
45 cmd->data = 0;
47 grub_prio_list_insert (GRUB_AS_PRIO_LIST_P (&grub_command_list),
48 GRUB_AS_PRIO_LIST (cmd));
50 return cmd;
53 void
54 grub_unregister_command (grub_command_t cmd)
56 grub_prio_list_remove (GRUB_AS_PRIO_LIST_P (&grub_command_list),
57 GRUB_AS_PRIO_LIST (cmd));
58 grub_free (cmd);