]> git.proxmox.com Git - grub2.git/blob - include/grub/env.h
2007-07-22 Yoshinori K. Okuji <okuji@enbug.org>
[grub2.git] / include / grub / env.h
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2003,2005,2006,2007 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 * (at your option) any later version.
9 *
10 * GRUB 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 GRUB. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef GRUB_ENV_HEADER
20 #define GRUB_ENV_HEADER 1
21
22 #include <grub/symbol.h>
23 #include <grub/err.h>
24 #include <grub/types.h>
25
26 struct grub_env_var;
27
28 typedef char *(*grub_env_read_hook_t) (struct grub_env_var *var,
29 const char *val);
30 typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
31 const char *val);
32
33 enum grub_env_var_type
34 {
35 /* The default variable type which is local in current context. */
36 GRUB_ENV_VAR_LOCAL,
37
38 /* The exported type, which is passed to new contexts. */
39 GRUB_ENV_VAR_GLOBAL,
40
41 /* The data slot type, which is used to store arbitrary data. */
42 GRUB_ENV_VAR_DATA
43 };
44
45 struct grub_env_var
46 {
47 char *name;
48 char *value;
49 grub_env_read_hook_t read_hook;
50 grub_env_write_hook_t write_hook;
51 struct grub_env_var *next;
52 struct grub_env_var **prevp;
53 enum grub_env_var_type type;
54 };
55
56 grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
57 char *EXPORT_FUNC(grub_env_get) (const char *name);
58 void EXPORT_FUNC(grub_env_unset) (const char *name);
59 void EXPORT_FUNC(grub_env_iterate) (int (*func) (struct grub_env_var *var));
60 grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
61 grub_env_read_hook_t read_hook,
62 grub_env_write_hook_t write_hook);
63 grub_err_t EXPORT_FUNC(grub_env_context_open) (void);
64 grub_err_t EXPORT_FUNC(grub_env_context_close) (void);
65 grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
66
67 grub_err_t EXPORT_FUNC(grub_env_set_data_slot) (const char *name,
68 const void *ptr);
69 void *EXPORT_FUNC(grub_env_get_data_slot) (const char *name);
70 void EXPORT_FUNC(grub_env_unset_data_slot) (const char *name);
71
72 #endif /* ! GRUB_ENV_HEADER */