diff options
author | Michael Brown <mcb30@etherboot.org> | 2008-03-20 04:06:07 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2008-03-20 04:06:07 +0000 |
commit | a48b4d9948b6ffb5ca05d59ee8b04391ed24cd3b (patch) | |
tree | 3cd3e953e8d1a921cfca53e488f86bcd759742a6 /src/hci/commands | |
parent | 7067142fb492d911588581d7620797e0a6bc706b (diff) | |
download | ipxe-a48b4d9948b6ffb5ca05d59ee8b04391ed24cd3b.tar.gz |
[Settings] Start revamping the configuration settings API.
Add the concept of an abstract configuration setting, comprising a (DHCP)
tag value and an associated byte sequence.
Add the concept of a settings namespace.
Add functions for extracting string, IPv4 address, and signed and
unsigned integer values from configuration settings (analogous to
dhcp_snprintf(), dhcp_ipv4_option(), etc.).
Update functions for parsing and formatting named/typed options to work
with new settings API.
Update NVO commands and config UI to use new settings API.
Diffstat (limited to 'src/hci/commands')
-rw-r--r-- | src/hci/commands/config_cmd.c | 25 | ||||
-rw-r--r-- | src/hci/commands/nvo_cmd.c | 50 |
2 files changed, 20 insertions, 55 deletions
diff --git a/src/hci/commands/config_cmd.c b/src/hci/commands/config_cmd.c index 368a6ca4..49cc41e7 100644 --- a/src/hci/commands/config_cmd.c +++ b/src/hci/commands/config_cmd.c @@ -4,28 +4,27 @@ #include <gpxe/settings.h> #include <gpxe/settings_ui.h> - -#include <gpxe/nvo.h> -extern struct nvo_block *ugly_nvo_hack; - - static int config_exec ( int argc, char **argv ) { - struct config_context dummy_context; + struct settings *settings; int rc; - if ( argc != 1 ) { - printf ( "Usage: %s\n" + if ( argc > 2 ) { + printf ( "Usage: %s [scope]\n" "Opens the option configuration console\n", argv[0] ); return 1; } - if ( ! ugly_nvo_hack ) { - printf ( "No non-volatile option storage available\n" ); - return 1; + if ( argc == 2 ) { + settings = find_settings ( argv[1] ); + if ( ! settings ) { + printf ( "No such scope \"%s\"\n", argv[1] ); + return 1; + } + } else { + settings = &interactive_settings; } - dummy_context.options = ugly_nvo_hack->options; - if ( ( rc = settings_ui ( &dummy_context ) ) != 0 ) { + if ( ( rc = settings_ui ( settings ) ) != 0 ) { printf ( "Could not save settings: %s\n", strerror ( rc ) ); return 1; diff --git a/src/hci/commands/nvo_cmd.c b/src/hci/commands/nvo_cmd.c index 4c453c77..255e9795 100644 --- a/src/hci/commands/nvo_cmd.c +++ b/src/hci/commands/nvo_cmd.c @@ -4,33 +4,21 @@ #include <string.h> #include <errno.h> #include <getopt.h> -#include <gpxe/nvo.h> -#include <gpxe/dhcp.h> #include <gpxe/settings.h> #include <gpxe/command.h> -extern struct nvo_block *ugly_nvo_hack; - static int show_exec ( int argc, char **argv ) { - struct config_context dummy_context; char buf[256]; int rc; - if ( ! ugly_nvo_hack ) { - printf ( "No non-volatile option storage available\n" ); - return 1; - } - if ( argc != 2 ) { printf ( "Syntax: %s <identifier>\n", argv[0] ); return 1; } - dummy_context.options = ugly_nvo_hack->options; - if ( ( rc = show_named_setting ( &dummy_context, argv[1], buf, - sizeof ( buf ) ) ) < 0 ) { + if ( ( rc = get_named_setting ( argv[1], buf, sizeof ( buf ) ) ) < 0 ){ printf ( "Could not find \"%s\": %s\n", - argv[1], strerror ( -rc ) ); + argv[1], strerror ( rc ) ); return 1; } @@ -39,30 +27,16 @@ static int show_exec ( int argc, char **argv ) { } static int set_exec ( int argc, char **argv ) { - struct config_context dummy_context; int rc; - if ( ! ugly_nvo_hack ) { - printf ( "No non-volatile option storage available\n" ); - return 1; - } - if ( argc != 3 ) { - printf ( "Syntax: %s <identifier> <value>\n", - argv[0] ); + printf ( "Syntax: %s <identifier> <value>\n", argv[0] ); return 1; } - dummy_context.options = ugly_nvo_hack->options; - if ( ( rc = set_named_setting ( &dummy_context, argv[1], - argv[2] ) ) != 0 ) { + if ( ( rc = set_named_setting ( argv[1], argv[2] ) ) != 0 ) { printf ( "Could not set \"%s\"=\"%s\": %s\n", - argv[1], argv[2], strerror ( -rc ) ); - return 1; - } - - if ( nvo_save ( ugly_nvo_hack ) != 0 ) { - printf ( "Could not save options to non-volatile storage\n" ); + argv[1], argv[2], strerror ( rc ) ); return 1; } @@ -70,24 +44,16 @@ static int set_exec ( int argc, char **argv ) { } static int clear_exec ( int argc, char **argv ) { - struct config_context dummy_context; int rc; - if ( ! ugly_nvo_hack ) { - printf ( "No non-volatile option storage available\n" ); - return 1; - } - if ( argc != 2 ) { - printf ( "Syntax: %s <identifier>\n", - argv[0] ); + printf ( "Syntax: %s <identifier>\n", argv[0] ); return 1; } - dummy_context.options = ugly_nvo_hack->options; - if ( ( rc = clear_named_setting ( &dummy_context, argv[1] ) ) != 0 ) { + if ( ( rc = delete_named_setting ( argv[1] ) ) != 0 ) { printf ( "Could not clear \"%s\": %s\n", - argv[1], strerror ( -rc ) ); + argv[1], strerror ( rc ) ); return 1; } |