2010-11-21 17:57:58 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-07-20 20:55:45 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
|
|
* 02110-1301, USA.
|
2010-11-21 17:57:58 +01:00
|
|
|
*/
|
|
|
|
|
2006-12-20 06:37:33 +01:00
|
|
|
#include <string.h>
|
2007-01-19 02:13:12 +01:00
|
|
|
#include <stdio.h>
|
2010-11-21 17:57:58 +01:00
|
|
|
#include <errno.h>
|
|
|
|
#include <getopt.h>
|
2010-04-19 21:16:01 +02:00
|
|
|
#include <ipxe/command.h>
|
2010-11-21 17:57:58 +01:00
|
|
|
#include <ipxe/parseopt.h>
|
2010-04-19 21:16:01 +02:00
|
|
|
#include <ipxe/settings.h>
|
|
|
|
#include <ipxe/settings_ui.h>
|
2006-12-20 06:37:33 +01:00
|
|
|
|
2009-05-01 16:41:06 +02:00
|
|
|
FILE_LICENCE ( GPL2_OR_LATER );
|
|
|
|
|
2010-11-21 17:57:58 +01:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* Configuration UI commands
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** "config" options */
|
|
|
|
struct config_options {};
|
|
|
|
|
|
|
|
/** "config" option list */
|
|
|
|
static struct option_descriptor config_opts[] = {};
|
|
|
|
|
|
|
|
/** "config" command descriptor */
|
|
|
|
static struct command_descriptor config_cmd =
|
2011-03-04 13:14:51 +01:00
|
|
|
COMMAND_DESC ( struct config_options, config_opts, 0, 1, "[<scope>]" );
|
2010-11-21 17:57:58 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* "config" command
|
|
|
|
*
|
|
|
|
* @v argc Argument count
|
|
|
|
* @v argv Argument list
|
|
|
|
* @ret rc Return status code
|
|
|
|
*/
|
2006-12-20 06:37:33 +01:00
|
|
|
static int config_exec ( int argc, char **argv ) {
|
2010-11-21 17:57:58 +01:00
|
|
|
struct config_options opts;
|
2008-07-08 03:10:18 +02:00
|
|
|
struct settings *settings;
|
2006-12-20 12:42:48 +01:00
|
|
|
int rc;
|
2006-12-20 06:37:33 +01:00
|
|
|
|
2010-11-21 17:57:58 +01:00
|
|
|
/* Parse options */
|
|
|
|
if ( ( rc = parse_options ( argc, argv, &config_cmd, &opts ) ) != 0 )
|
|
|
|
return rc;
|
2006-12-20 06:37:33 +01:00
|
|
|
|
2010-11-21 17:57:58 +01:00
|
|
|
/* Parse settings option, if present */
|
|
|
|
if ( ( rc = parse_settings ( ( ( optind < argc ) ? argv[optind] : "" ),
|
|
|
|
&settings ) ) != 0 )
|
|
|
|
return rc;
|
2006-12-20 06:37:33 +01:00
|
|
|
|
2010-11-21 17:57:58 +01:00
|
|
|
/* Run settings UI */
|
2008-03-20 05:06:07 +01:00
|
|
|
if ( ( rc = settings_ui ( settings ) ) != 0 ) {
|
2010-11-21 17:57:58 +01:00
|
|
|
printf ( "Could not save settings: %s\n", strerror ( rc ) );
|
|
|
|
return rc;
|
2006-12-20 12:42:48 +01:00
|
|
|
}
|
2006-12-20 06:37:33 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-11-21 17:57:58 +01:00
|
|
|
/** Configuration UI commands */
|
2006-12-20 06:37:33 +01:00
|
|
|
struct command config_command __command = {
|
|
|
|
.name = "config",
|
|
|
|
.exec = config_exec,
|
|
|
|
};
|