configfile.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* configfile.c - command to manually load config file */
  2. /*
  3. * GRUB -- GRand Unified Bootloader
  4. * Copyright (C) 2005,2006,2007,2009 Free Software Foundation, Inc.
  5. *
  6. * GRUB is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * GRUB is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <grub/dl.h>
  20. #include <grub/term.h>
  21. #include <grub/env.h>
  22. #include <grub/menu.h>
  23. #include <grub/command.h>
  24. #include <grub/i18n.h>
  25. static grub_err_t
  26. grub_cmd_source (grub_command_t cmd, int argc, char **args)
  27. {
  28. int new_env;
  29. if (argc != 1)
  30. return grub_error (GRUB_ERR_BAD_ARGUMENT, "file name required");
  31. new_env = (cmd->name[0] == 'c');
  32. if (new_env)
  33. {
  34. grub_cls ();
  35. grub_env_context_open (1);
  36. }
  37. grub_menu_execute (args[0], 1, ! new_env);
  38. if (new_env)
  39. grub_env_context_close ();
  40. return 0;
  41. }
  42. static grub_command_t cmd_configfile, cmd_source, cmd_dot;
  43. GRUB_MOD_INIT(configfile)
  44. {
  45. cmd_configfile =
  46. grub_register_command ("configfile", grub_cmd_source,
  47. N_("FILE"), N_("Load another config file."));
  48. cmd_source =
  49. grub_register_command ("source", grub_cmd_source,
  50. N_("FILE"),
  51. N_("Load another config file without changing context.")
  52. );
  53. cmd_dot =
  54. grub_register_command (".", grub_cmd_source,
  55. N_("FILE"),
  56. N_("Load another config file without changing context.")
  57. );
  58. }
  59. GRUB_MOD_FINI(configfile)
  60. {
  61. grub_unregister_command (cmd_configfile);
  62. grub_unregister_command (cmd_source);
  63. grub_unregister_command (cmd_dot);
  64. }