Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / hci / commands / config_cmd.c
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
20 #include <string.h>
21 #include <stdio.h>
22 #include <errno.h>
23 #include <getopt.h>
24 #include <ipxe/command.h>
25 #include <ipxe/parseopt.h>
26 #include <ipxe/settings.h>
27 #include <ipxe/settings_ui.h>
28
29 FILE_LICENCE ( GPL2_OR_LATER );
30
31 /** @file
32  *
33  * Configuration UI commands
34  *
35  */
36
37 /** "config" options */
38 struct config_options {};
39
40 /** "config" option list */
41 static struct option_descriptor config_opts[] = {};
42
43 /** "config" command descriptor */
44 static struct command_descriptor config_cmd =
45         COMMAND_DESC ( struct config_options, config_opts, 0, 1, "[<scope>]" );
46
47 /**
48  * "config" command
49  *
50  * @v argc              Argument count
51  * @v argv              Argument list
52  * @ret rc              Return status code
53  */
54 static int config_exec ( int argc, char **argv ) {
55         struct config_options opts;
56         struct settings *settings;
57         int rc;
58
59         /* Parse options */
60         if ( ( rc = parse_options ( argc, argv, &config_cmd, &opts ) ) != 0 )
61                 return rc;
62
63         /* Parse settings option, if present */
64         if ( ( rc = parse_settings ( ( ( optind < argc ) ? argv[optind] : "" ),
65                                      &settings ) ) != 0 )
66                 return rc;
67
68         /* Run settings UI */
69         if ( ( rc = settings_ui ( settings ) ) != 0 ) {
70                 printf ( "Could not save settings: %s\n", strerror ( rc ) );
71                 return rc;
72         }
73
74         return 0;
75 }
76
77 /** Configuration UI commands */
78 struct command config_command __command = {
79         .name = "config",
80         .exec = config_exec,
81 };