From 35edecac34e129ea075e00d021fc6e786fa20777 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 20 Dec 2006 04:20:13 +0000 Subject: 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. --- src/include/gpxe/settings.h | 52 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) (limited to 'src/include') diff --git a/src/include/gpxe/settings.h b/src/include/gpxe/settings.h index ab0de5b43..f84378afd 100644 --- a/src/include/gpxe/settings.h +++ b/src/include/gpxe/settings.h @@ -96,12 +96,54 @@ struct config_setting { /** Declare a configuration setting */ #define __config_setting __table ( config_settings, 01 ) -/* Function prototypes */ +/** + * Show value of setting + * + * @v context Configuration context + * @v setting Configuration setting + * @v buf Buffer to contain value + * @v len Length of buffer + * @ret rc Return status code + */ +static inline int show_setting ( struct config_context *context, + struct config_setting *setting, + char *buf, size_t len ) { + return setting->type->show ( context, setting, buf, len ); +} -extern int show_setting ( struct config_context *context, const char *name, - char *buf, size_t len ); -extern int set_setting ( struct config_context *context, const char *name, +extern int set_setting ( struct config_context *context, + struct config_setting *setting, const char *value ); -extern int clear_setting ( struct config_context *context, const char *name ); + +/** + * Clear setting + * + * @v context Configuration context + * @v setting Configuration setting + * @ret rc Return status code + */ +static inline int clear_setting ( struct config_context *context, + struct config_setting *setting ) { + delete_dhcp_option ( context->options, setting->tag ); + return 0; +} + +/* Function prototypes */ +extern int show_named_setting ( struct config_context *context, + const char *name, char *buf, size_t len ); +extern int set_named_setting ( struct config_context *context, + const char *name, const char *value ); + +/** + * Clear named setting + * + * @v context Configuration context + * @v name Configuration setting name + * @ret rc Return status code + */ +static inline int clear_named_setting ( struct config_context *context, + const char *name ) { + return set_named_setting ( context, name, NULL ); +} #endif /* _GPXE_SETTINGS_H */ -- cgit v1.2.3-55-g7522