env.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * (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. #ifndef GRUB_ENV_HEADER
  19. #define GRUB_ENV_HEADER 1
  20. #include <grub/symbol.h>
  21. #include <grub/err.h>
  22. #include <grub/types.h>
  23. #include <grub/menu.h>
  24. struct grub_env_var;
  25. typedef const char *(*grub_env_read_hook_t) (struct grub_env_var *var,
  26. const char *val);
  27. typedef char *(*grub_env_write_hook_t) (struct grub_env_var *var,
  28. const char *val);
  29. struct grub_env_var
  30. {
  31. char *name;
  32. char *value;
  33. grub_env_read_hook_t read_hook;
  34. grub_env_write_hook_t write_hook;
  35. struct grub_env_var *next;
  36. struct grub_env_var **prevp;
  37. struct grub_env_var *sorted_next;
  38. int global;
  39. };
  40. grub_err_t EXPORT_FUNC(grub_env_set) (const char *name, const char *val);
  41. const char *EXPORT_FUNC(grub_env_get) (const char *name);
  42. bool EXPORT_FUNC(grub_env_get_bool) (const char *name, bool if_unset);
  43. void EXPORT_FUNC(grub_env_unset) (const char *name);
  44. struct grub_env_var *EXPORT_FUNC(grub_env_update_get_sorted) (void);
  45. #define FOR_SORTED_ENV(var) for (var = grub_env_update_get_sorted (); var; var = var->sorted_next)
  46. grub_err_t EXPORT_FUNC(grub_register_variable_hook) (const char *name,
  47. grub_env_read_hook_t read_hook,
  48. grub_env_write_hook_t write_hook);
  49. grub_err_t grub_env_context_open (void);
  50. grub_err_t grub_env_context_close (void);
  51. grub_err_t EXPORT_FUNC(grub_env_export) (const char *name);
  52. void grub_env_unset_menu (void);
  53. grub_menu_t grub_env_get_menu (void);
  54. void grub_env_set_menu (grub_menu_t nmenu);
  55. grub_err_t
  56. grub_env_extractor_open (int source);
  57. grub_err_t
  58. grub_env_extractor_close (int source);
  59. #endif /* ! GRUB_ENV_HEADER */