env.h 2.21 KB
Newer Older
1
/*
2
 *  GRUB  --  GRand Unified Bootloader
3
 *  Copyright (C) 2003,2005,2006,2007,2009  Free Software Foundation, Inc.
4
 *
5
 *  GRUB 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 3 of the License, or
8 9
 *  (at your option) any later version.
 *
10
 *  GRUB is distributed in the hope that it will be useful,
11 12 13 14 15
 *  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
16
 *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
17 18
 */

19 20
#ifndef GRUB_ENV_HEADER
#define GRUB_ENV_HEADER	1
21

22 23 24
#include <grub/symbol.h>
#include <grub/err.h>
#include <grub/types.h>
25
#include <grub/menu.h>
26

27 28
struct grub_env_var;

29 30
typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
					     const char *val);
31 32 33
typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
					const char *val);

34
struct grub_env_var
35 36 37
{
  char *name;
  char *value;
38 39
  grub_env_read_hook_t read_hook;
  grub_env_write_hook_t write_hook;
40 41
  struct grub_env_var *next;
  struct grub_env_var **prevp;
42
  struct grub_env_var *sorted_next;
43
  int global;
44 45
};

46
grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
47
const char *EXPORT_FUNC(grub_env_get) (const char *name);
48
void EXPORT_FUNC(grub_env_unset) (const char *name);
49 50 51 52
struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);

#define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)

53
grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
54 55
						     grub_env_read_hook_t read_hook,
						     grub_env_write_hook_t write_hook);
56

57
grub_err_t grub_env_context_open (void);
58
grub_err_t grub_env_context_close (void);
59
grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
60 61 62 63

void grub_env_unset_menu (void);
grub_menu_t grub_env_get_menu (void);
void grub_env_set_menu (grub_menu_t nmenu);
64

65
grub_err_t
66
grub_env_extractor_open (int source);
67 68

grub_err_t
69
grub_env_extractor_close (int source);
70 71


72
#endif /* ! GRUB_ENV_HEADER */