~darkmuggle-deactivatedaccount/ubuntu/quantal/grub2/fix-872244

« back to all changes in this revision

Viewing changes to normal/context.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2006-01-05 15:20:40 UTC
  • mto: (17.3.1 squeeze) (1.9.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20060105152040-b72i5pq1a82z22yi
Tags: upstream-1.92
ImportĀ upstreamĀ versionĀ 1.92

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  GRUB  --  GRand Unified Bootloader
 
3
 *  Copyright (C) 2005  Free Software Foundation, Inc.
 
4
 *
 
5
 *  This program is free software; you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation; either version 2 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 */
 
19
 
 
20
#include <grub/normal.h>
 
21
#include <grub/mm.h>
 
22
 
 
23
static struct grub_context context =
 
24
  {
 
25
    .menu_list = 0
 
26
  };
 
27
 
 
28
/* Return a pointer to the context.  */
 
29
grub_context_t
 
30
grub_context_get (void)
 
31
{
 
32
  return &context;
 
33
}
 
34
 
 
35
/* Return the current menu.  */
 
36
grub_menu_t
 
37
grub_context_get_current_menu (void)
 
38
{
 
39
  if (context.menu_list)
 
40
    return context.menu_list->menu;
 
41
 
 
42
  return 0;
 
43
}
 
44
 
 
45
/* Push a new menu. Return this menu. If any error occurs, return NULL.  */
 
46
grub_menu_t
 
47
grub_context_push_menu (grub_menu_t menu)
 
48
{
 
49
  grub_menu_list_t menu_list;
 
50
 
 
51
  menu_list = grub_malloc (sizeof (*menu_list));
 
52
  if (! menu_list)
 
53
    return 0;
 
54
 
 
55
  menu_list->menu = menu;
 
56
  menu_list->next = context.menu_list;
 
57
  context.menu_list = menu_list;
 
58
 
 
59
  return menu;
 
60
}
 
61
 
 
62
/* Pop a menu.  */
 
63
void
 
64
grub_context_pop_menu (void)
 
65
{
 
66
  grub_menu_list_t menu_list;
 
67
 
 
68
  menu_list = context.menu_list;
 
69
  if (menu_list)
 
70
    {
 
71
      context.menu_list = menu_list->next;
 
72
      grub_free (menu_list);
 
73
    }
 
74
}
 
75