2009-11-02 Samuel Thibault <samuel.thibault@ens-lyon.org>
[grub2/jjazz.git] / include / grub / env.h
blob440185a59d78871665fb56c67d27e9922328fae6
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2003,2005,2006,2007,2009 Free Software Foundation, Inc.
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.
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.
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/>.
19 #ifndef GRUB_ENV_HEADER
20 #define GRUB_ENV_HEADER 1
22 #include <grub/symbol.h>
23 #include <grub/err.h>
24 #include <grub/types.h>
26 struct grub_env_var;
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);
33 enum grub_env_var_type
35 /* The default variable type which is local in current context. */
36 GRUB_ENV_VAR_LOCAL,
38 /* The exported type, which is passed to new contexts. */
39 GRUB_ENV_VAR_GLOBAL,
41 /* The data slot type, which is used to store arbitrary data. */
42 GRUB_ENV_VAR_DATA
45 struct grub_env_var
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;
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) (int export);
64 grub_err_t EXPORT_FUNC(grub_env_context_close) (void);
65 grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
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);
72 #endif /* ! GRUB_ENV_HEADER */