~ubuntu-branches/ubuntu/trusty/grub2/trusty-updates

« back to all changes in this revision

Viewing changes to kern/command.c

Tags: upstream-1.99~20101122
ImportĀ upstreamĀ versionĀ 1.99~20101122

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* command.c - support basic command */
2
 
/*
3
 
 *  GRUB  --  GRand Unified Bootloader
4
 
 *  Copyright (C) 2009  Free Software Foundation, Inc.
5
 
 *
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.
10
 
 *
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.
15
 
 *
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/>.
18
 
 */
19
 
 
20
 
#include <grub/mm.h>
21
 
#include <grub/command.h>
22
 
 
23
 
grub_command_t grub_command_list;
24
 
 
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)
31
 
{
32
 
  grub_command_t cmd;
33
 
 
34
 
  cmd = (grub_command_t) grub_zalloc (sizeof (*cmd));
35
 
  if (! cmd)
36
 
    return 0;
37
 
 
38
 
  cmd->name = name;
39
 
  cmd->func = func;
40
 
  cmd->summary = (summary) ? summary : "";
41
 
  cmd->description = description;
42
 
 
43
 
  cmd->flags = GRUB_COMMAND_FLAG_BOTH;
44
 
  cmd->prio = prio;
45
 
 
46
 
  grub_prio_list_insert (GRUB_AS_PRIO_LIST_P (&grub_command_list),
47
 
                         GRUB_AS_PRIO_LIST (cmd));
48
 
 
49
 
  return cmd;
50
 
}
51
 
 
52
 
void
53
 
grub_unregister_command (grub_command_t cmd)
54
 
{
55
 
  grub_prio_list_remove (GRUB_AS_PRIO_LIST_P (&grub_command_list),
56
 
                         GRUB_AS_PRIO_LIST (cmd));
57
 
  grub_free (cmd);
58
 
}