選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

config_cmd.c 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License as
  6. * published by the Free Software Foundation; either version 2 of the
  7. * License, or any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA.
  18. */
  19. #include <string.h>
  20. #include <stdio.h>
  21. #include <errno.h>
  22. #include <getopt.h>
  23. #include <ipxe/command.h>
  24. #include <ipxe/parseopt.h>
  25. #include <ipxe/settings.h>
  26. #include <ipxe/settings_ui.h>
  27. FILE_LICENCE ( GPL2_OR_LATER );
  28. /** @file
  29. *
  30. * Configuration UI commands
  31. *
  32. */
  33. /** "config" options */
  34. struct config_options {};
  35. /** "config" option list */
  36. static struct option_descriptor config_opts[] = {};
  37. /** "config" command descriptor */
  38. static struct command_descriptor config_cmd =
  39. COMMAND_DESC ( struct config_options, config_opts, 0, 1, "[<scope>]" );
  40. /**
  41. * "config" command
  42. *
  43. * @v argc Argument count
  44. * @v argv Argument list
  45. * @ret rc Return status code
  46. */
  47. static int config_exec ( int argc, char **argv ) {
  48. struct config_options opts;
  49. struct settings *settings;
  50. int rc;
  51. /* Parse options */
  52. if ( ( rc = parse_options ( argc, argv, &config_cmd, &opts ) ) != 0 )
  53. return rc;
  54. /* Parse settings option, if present */
  55. if ( ( rc = parse_settings ( ( ( optind < argc ) ? argv[optind] : "" ),
  56. &settings ) ) != 0 )
  57. return rc;
  58. /* Run settings UI */
  59. if ( ( rc = settings_ui ( settings ) ) != 0 ) {
  60. printf ( "Could not save settings: %s\n", strerror ( rc ) );
  61. return rc;
  62. }
  63. return 0;
  64. }
  65. /** Configuration UI commands */
  66. struct command config_command __command = {
  67. .name = "config",
  68. .exec = config_exec,
  69. };