mirror of
https://github.com/ipxe/ipxe
synced 2025-12-27 10:02:42 +03:00
[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.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user