mirror of https://github.com/ipxe/ipxe.git
[settings] Display canonical setting name in "config" user interface
Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/1/head
parent
48b66e4f1a
commit
247ac80556
|
@ -1060,6 +1060,27 @@ parse_setting_name ( const char *name,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return full setting name
|
||||
*
|
||||
* @v settings Settings block, or NULL
|
||||
* @v setting Setting
|
||||
* @v buf Buffer
|
||||
* @v len Length of buffer
|
||||
* @ret len Length of setting name, or negative error
|
||||
*/
|
||||
int setting_name ( struct settings *settings, struct setting *setting,
|
||||
char *buf, size_t len ) {
|
||||
const char *name;
|
||||
|
||||
if ( ! settings )
|
||||
settings = &settings_root;
|
||||
|
||||
name = settings_name ( settings );
|
||||
return snprintf ( buf, len, "%s%s%s:%s", name, ( name[0] ? "/" : "" ),
|
||||
setting->name, setting->type->name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and store value of named setting
|
||||
*
|
||||
|
@ -1101,7 +1122,6 @@ int fetchf_named_setting ( const char *name,
|
|||
struct settings *settings;
|
||||
struct setting setting;
|
||||
struct settings *origin;
|
||||
const char *origin_name;
|
||||
char tmp_name[ strlen ( name ) + 1 ];
|
||||
int rc;
|
||||
|
||||
|
@ -1118,10 +1138,7 @@ int fetchf_named_setting ( const char *name,
|
|||
/* Construct setting name */
|
||||
origin = fetch_setting_origin ( settings, &setting );
|
||||
assert ( origin != NULL );
|
||||
origin_name = settings_name ( origin );
|
||||
snprintf ( name_buf, name_len, "%s%s%s:%s",
|
||||
origin_name, ( origin_name[0] ? "/" : "" ),
|
||||
setting.name, setting.type->name );
|
||||
setting_name ( origin, &setting, name_buf, name_len );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -97,7 +97,8 @@ static void vmsg ( unsigned int row, const char *fmt, va_list args ) __nonnull;
|
|||
static void msg ( unsigned int row, const char *fmt, ... ) __nonnull;
|
||||
static void valert ( const char *fmt, va_list args ) __nonnull;
|
||||
static void alert ( const char *fmt, ... ) __nonnull;
|
||||
static void draw_info_row ( struct setting *setting ) __nonnull;
|
||||
static void draw_info_row ( struct settings *settings,
|
||||
struct setting *setting ) __nonnull;
|
||||
static int main_loop ( struct settings *settings ) __nonnull;
|
||||
|
||||
/**
|
||||
|
@ -313,12 +314,23 @@ static void draw_title_row ( void ) {
|
|||
/**
|
||||
* Draw information row
|
||||
*
|
||||
* @v settings Settings block
|
||||
* @v setting Current configuration setting
|
||||
*/
|
||||
static void draw_info_row ( struct setting *setting ) {
|
||||
static void draw_info_row ( struct settings *settings,
|
||||
struct setting *setting ) {
|
||||
struct settings *origin;
|
||||
char buf[32];
|
||||
|
||||
/* Determine a suitable setting name */
|
||||
origin = fetch_setting_origin ( settings, setting );
|
||||
if ( ! origin )
|
||||
origin = settings;
|
||||
setting_name ( origin, setting, buf, sizeof ( buf ) );
|
||||
|
||||
clearmsg ( INFO_ROW );
|
||||
attron ( A_BOLD );
|
||||
msg ( INFO_ROW, "%s - %s", setting->name, setting->description );
|
||||
msg ( INFO_ROW, "%s - %s", buf, setting->description );
|
||||
attroff ( A_BOLD );
|
||||
}
|
||||
|
||||
|
@ -400,7 +412,7 @@ static int main_loop ( struct settings *settings ) {
|
|||
|
||||
while ( 1 ) {
|
||||
/* Redraw information and instruction rows */
|
||||
draw_info_row ( widget.setting );
|
||||
draw_info_row ( widget.settings, widget.setting );
|
||||
draw_instruction_row ( widget.editing );
|
||||
|
||||
/* Redraw current setting */
|
||||
|
|
|
@ -251,6 +251,8 @@ extern const char * settings_name ( struct settings *settings );
|
|||
extern struct settings * find_settings ( const char *name );
|
||||
extern struct setting * find_setting ( const char *name );
|
||||
|
||||
extern int setting_name ( struct settings *settings, struct setting *setting,
|
||||
char *buf, size_t len );
|
||||
extern int storef_setting ( struct settings *settings,
|
||||
struct setting *setting,
|
||||
const char *value );
|
||||
|
|
Loading…
Reference in New Issue