mirror of
https://github.com/ipxe/ipxe
synced 2025-12-21 20:40:25 +03:00
Move {show,set,clear}_setting() to {show,set,clear}_named_setting().
Introduce new {show,set,clear}_setting() that take a struct setting *
rather than a const char *.
set_setting() handles calling clear_setting() when appropriate, so that
individual setting types don't have to check for empty strings.
This commit is contained in:
@@ -27,8 +27,8 @@ static int show_exec ( int argc, char **argv ) {
|
||||
}
|
||||
|
||||
dummy_context.options = ugly_nvo_hack->options;
|
||||
if ( ( rc = show_setting ( &dummy_context, argv[1], buf,
|
||||
sizeof ( buf ) ) ) != 0 ) {
|
||||
if ( ( rc = show_named_setting ( &dummy_context, argv[1], buf,
|
||||
sizeof ( buf ) ) ) != 0 ) {
|
||||
printf ( "Could not find \"%s\": %s\n",
|
||||
argv[1], strerror ( -rc ) );
|
||||
return 1;
|
||||
@@ -59,7 +59,8 @@ static int set_exec ( int argc, char **argv ) {
|
||||
}
|
||||
|
||||
dummy_context.options = ugly_nvo_hack->options;
|
||||
if ( ( rc = set_setting ( &dummy_context, argv[1], argv[2] ) ) != 0 ) {
|
||||
if ( ( rc = set_named_setting ( &dummy_context, argv[1],
|
||||
argv[2] ) ) != 0 ) {
|
||||
printf ( "Could not set \"%s\"=\"%s\": %s\n",
|
||||
argv[1], argv[2], strerror ( -rc ) );
|
||||
return 1;
|
||||
@@ -94,7 +95,7 @@ static int clear_exec ( int argc, char **argv ) {
|
||||
}
|
||||
|
||||
dummy_context.options = ugly_nvo_hack->options;
|
||||
if ( ( rc = clear_setting ( &dummy_context, argv[1] ) ) != 0 ) {
|
||||
if ( ( rc = clear_named_setting ( &dummy_context, argv[1] ) ) != 0 ) {
|
||||
printf ( "Could not clear \"%s\": %s\n",
|
||||
argv[1], strerror ( -rc ) );
|
||||
return 1;
|
||||
|
||||
@@ -91,9 +91,8 @@ static void load_setting ( struct setting_widget *widget ) {
|
||||
widget->editing = 0;
|
||||
|
||||
/* Read current setting value */
|
||||
if ( widget->setting->type->show ( widget->context, widget->setting,
|
||||
widget->value,
|
||||
sizeof ( widget->value ) ) != 0 ) {
|
||||
if ( show_setting ( widget->context, widget->setting,
|
||||
widget->value, sizeof ( widget->value ) ) != 0 ) {
|
||||
widget->value[0] = '\0';
|
||||
}
|
||||
|
||||
@@ -110,8 +109,7 @@ static void load_setting ( struct setting_widget *widget ) {
|
||||
* @v widget Setting widget
|
||||
*/
|
||||
static int save_setting ( struct setting_widget *widget ) {
|
||||
return widget->setting->type->set ( widget->context, widget->setting,
|
||||
widget->value );
|
||||
return set_setting ( widget->context, widget->setting, widget->value );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +250,7 @@ static void main_loop ( struct config_context *context ) {
|
||||
if ( ( rc = save_setting ( &widget ) ) != 0 ) {
|
||||
alert ( " Could not set %s: %s ",
|
||||
widget.setting->name,
|
||||
strerror ( -rc ) );
|
||||
strerror ( rc ) );
|
||||
}
|
||||
/* Fall through */
|
||||
case 0x03: /* Ctrl-C */
|
||||
|
||||
Reference in New Issue
Block a user