Browse Source

[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.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
a48b4d9948

+ 606
- 301
src/core/settings.c
File diff suppressed because it is too large
View File


+ 12
- 13
src/hci/commands/config_cmd.c View File

@@ -4,28 +4,27 @@
4 4
 #include <gpxe/settings.h>
5 5
 #include <gpxe/settings_ui.h>
6 6
 
7
-
8
-#include <gpxe/nvo.h>
9
-extern struct nvo_block *ugly_nvo_hack;
10
-
11
-
12 7
 static int config_exec ( int argc, char **argv ) {
13
-	struct config_context dummy_context;
8
+	struct settings *settings;
14 9
 	int rc;
15 10
 
16
-	if ( argc != 1 ) {
17
-		printf ( "Usage: %s\n"
11
+	if ( argc > 2 ) {
12
+		printf ( "Usage: %s [scope]\n"
18 13
 			 "Opens the option configuration console\n", argv[0] );
19 14
 		return 1;
20 15
 	}
21 16
 
22
-	if ( ! ugly_nvo_hack ) {
23
-		printf ( "No non-volatile option storage available\n" );
24
-		return 1;
17
+	if ( argc == 2 ) {
18
+		settings = find_settings ( argv[1] );
19
+		if ( ! settings ) {
20
+			printf ( "No such scope \"%s\"\n", argv[1] );
21
+			return 1;
22
+		}
23
+	} else {
24
+		settings = &interactive_settings;
25 25
 	}
26 26
 
27
-	dummy_context.options = ugly_nvo_hack->options;
28
-	if ( ( rc = settings_ui ( &dummy_context ) ) != 0 ) {
27
+	if ( ( rc = settings_ui ( settings ) ) != 0 ) {
29 28
 		printf ( "Could not save settings: %s\n",
30 29
 			 strerror ( rc ) );
31 30
 		return 1;

+ 8
- 42
src/hci/commands/nvo_cmd.c View File

@@ -4,33 +4,21 @@
4 4
 #include <string.h>
5 5
 #include <errno.h>
6 6
 #include <getopt.h>
7
-#include <gpxe/nvo.h>
8
-#include <gpxe/dhcp.h>
9 7
 #include <gpxe/settings.h>
10 8
 #include <gpxe/command.h>
11 9
 
12
-extern struct nvo_block *ugly_nvo_hack;
13
-
14 10
 static int show_exec ( int argc, char **argv ) {
15
-	struct config_context dummy_context;
16 11
 	char buf[256];
17 12
 	int rc;
18 13
 
19
-	if ( ! ugly_nvo_hack ) {
20
-		printf ( "No non-volatile option storage available\n" );
21
-		return 1;
22
-	}
23
-
24 14
 	if ( argc != 2 ) {
25 15
 		printf ( "Syntax: %s <identifier>\n", argv[0] );
26 16
 		return 1;
27 17
 	}
28 18
 
29
-	dummy_context.options = ugly_nvo_hack->options;
30
-	if ( ( rc = show_named_setting ( &dummy_context, argv[1], buf,
31
-					 sizeof ( buf ) ) ) < 0 ) {
19
+	if ( ( rc = get_named_setting ( argv[1], buf, sizeof ( buf ) ) ) < 0 ){
32 20
 		printf ( "Could not find \"%s\": %s\n",
33
-			 argv[1], strerror ( -rc ) );
21
+			 argv[1], strerror ( rc ) );
34 22
 		return 1;
35 23
 	}
36 24
 
@@ -39,30 +27,16 @@ static int show_exec ( int argc, char **argv ) {
39 27
 }
40 28
 
41 29
 static int set_exec ( int argc, char **argv ) {
42
-	struct config_context dummy_context;
43 30
 	int rc;
44 31
 
45
-	if ( ! ugly_nvo_hack ) {
46
-		printf ( "No non-volatile option storage available\n" );
47
-		return 1;
48
-	}
49
-
50 32
 	if ( argc != 3 ) {
51
-		printf ( "Syntax: %s <identifier> <value>\n",
52
-			 argv[0] );
33
+		printf ( "Syntax: %s <identifier> <value>\n", argv[0] );
53 34
 		return 1;
54 35
 	}
55 36
 
56
-	dummy_context.options = ugly_nvo_hack->options;
57
-	if ( ( rc = set_named_setting ( &dummy_context, argv[1],
58
-					argv[2] ) ) != 0 ) {
37
+	if ( ( rc = set_named_setting ( argv[1], argv[2] ) ) != 0 ) {
59 38
 		printf ( "Could not set \"%s\"=\"%s\": %s\n",
60
-			 argv[1], argv[2], strerror ( -rc ) );
61
-		return 1;
62
-	}
63
-	
64
-	if ( nvo_save ( ugly_nvo_hack ) != 0 ) {
65
-		printf ( "Could not save options to non-volatile storage\n" );
39
+			 argv[1], argv[2], strerror ( rc ) );
66 40
 		return 1;
67 41
 	}
68 42
 
@@ -70,24 +44,16 @@ static int set_exec ( int argc, char **argv ) {
70 44
 }
71 45
 
72 46
 static int clear_exec ( int argc, char **argv ) {
73
-	struct config_context dummy_context;
74 47
 	int rc;
75 48
 
76
-	if ( ! ugly_nvo_hack ) {
77
-		printf ( "No non-volatile option storage available\n" );
78
-		return 1;
79
-	}
80
-
81 49
 	if ( argc != 2 ) {
82
-		printf ( "Syntax: %s <identifier>\n",
83
-			 argv[0] );
50
+		printf ( "Syntax: %s <identifier>\n", argv[0] );
84 51
 		return 1;
85 52
 	}
86 53
 
87
-	dummy_context.options = ugly_nvo_hack->options;
88
-	if ( ( rc = clear_named_setting ( &dummy_context, argv[1] ) ) != 0 ) {
54
+	if ( ( rc = delete_named_setting ( argv[1] ) ) != 0 ) {
89 55
 		printf ( "Could not clear \"%s\": %s\n",
90
-			 argv[1], strerror ( -rc ) );
56
+			 argv[1], strerror ( rc ) );
91 57
 		return 1;
92 58
 	}
93 59
 	

+ 37
- 43
src/hci/tui/settings_ui.c View File

@@ -33,9 +33,6 @@
33 33
  *
34 34
  */
35 35
 
36
-#include <gpxe/nvo.h>
37
-extern struct nvo_block *ugly_nvo_hack;
38
-
39 36
 /* Colour pairs */
40 37
 #define CPAIR_NORMAL	1
41 38
 #define CPAIR_SELECT	2
@@ -64,10 +61,10 @@ struct setting_row {
64 61
 
65 62
 /** A setting widget */
66 63
 struct setting_widget {
67
-	/** Configuration context */
68
-	struct config_context *context;
64
+	/** Settings block */
65
+	struct settings *settings;
69 66
 	/** Configuration setting */
70
-	struct config_setting *setting;
67
+	struct named_setting *setting;
71 68
 	/** Screen row */
72 69
 	unsigned int row;
73 70
 	/** Screen column */
@@ -81,32 +78,32 @@ struct setting_widget {
81 78
 };
82 79
 
83 80
 /** Registered configuration settings */
84
-static struct config_setting config_settings[0]
85
-	__table_start ( struct config_setting, config_settings );
86
-static struct config_setting config_settings_end[0]
87
-	__table_end ( struct config_setting, config_settings );
88
-#define NUM_SETTINGS ( ( unsigned ) ( config_settings_end - config_settings ) )
81
+static struct named_setting named_settings[0]
82
+	__table_start ( struct named_setting, named_settings );
83
+static struct named_setting named_settings_end[0]
84
+	__table_end ( struct named_setting, named_settings );
85
+#define NUM_SETTINGS ( ( unsigned ) ( named_settings_end - named_settings ) )
89 86
 
90 87
 static void load_setting ( struct setting_widget *widget ) __nonnull;
91 88
 static int save_setting ( struct setting_widget *widget ) __nonnull;
92 89
 static void init_setting ( struct setting_widget *widget,
93
-                           struct config_context *context,
94
-                           struct config_setting *setting,
90
+                           struct settings *settings,
91
+                           struct named_setting *setting,
95 92
                            unsigned int row, unsigned int col ) __nonnull;
96 93
 static void draw_setting ( struct setting_widget *widget ) __nonnull;
97 94
 static int edit_setting ( struct setting_widget *widget, int key ) __nonnull;
98 95
 static void init_setting_index ( struct setting_widget *widget,
99
-                                 struct config_context *context,
96
+                                 struct settings *settings,
100 97
                                  unsigned int index ) __nonnull;
101 98
 static void vmsg ( unsigned int row, const char *fmt, va_list args ) __nonnull;
102 99
 static void msg ( unsigned int row, const char *fmt, ... ) __nonnull;
103 100
 static void valert ( const char *fmt, va_list args ) __nonnull;
104 101
 static void alert ( const char *fmt, ... ) __nonnull;
105
-static void draw_info_row ( struct config_setting *setting ) __nonnull;
106
-static int main_loop ( struct config_context *context ) __nonnull;
102
+static void draw_info_row ( struct named_setting *setting ) __nonnull;
103
+static int main_loop ( struct settings *settings ) __nonnull;
107 104
 
108 105
 /**
109
- * Load setting widget value from configuration context
106
+ * Load setting widget value from configuration settings
110 107
  *
111 108
  * @v widget		Setting widget
112 109
  *
@@ -117,8 +114,9 @@ static void load_setting ( struct setting_widget *widget ) {
117 114
 	widget->editing = 0;
118 115
 
119 116
 	/* Read current setting value */
120
-	if ( show_setting ( widget->context, widget->setting,
121
-			    widget->value, sizeof ( widget->value ) ) < 0 ) {
117
+	if ( get_typed_setting ( widget->settings, widget->setting->tag,
118
+				 widget->setting->type, widget->value,
119
+				 sizeof ( widget->value ) ) < 0 ) {
122 120
 		widget->value[0] = '\0';
123 121
 	}	
124 122
 
@@ -130,31 +128,32 @@ static void load_setting ( struct setting_widget *widget ) {
130 128
 }
131 129
 
132 130
 /**
133
- * Save setting widget value back to configuration context
131
+ * Save setting widget value back to configuration settings
134 132
  *
135 133
  * @v widget		Setting widget
136 134
  */
137 135
 static int save_setting ( struct setting_widget *widget ) {
138
-	return set_setting ( widget->context, widget->setting, widget->value );
136
+	return set_typed_setting ( widget->settings, widget->setting->tag,
137
+				   widget->setting->type, widget->value );
139 138
 }
140 139
 
141 140
 /**
142 141
  * Initialise setting widget
143 142
  *
144 143
  * @v widget		Setting widget
145
- * @v context		Configuration context
144
+ * @v settings		Settings block
146 145
  * @v setting		Configuration setting
147 146
  * @v row		Screen row
148 147
  * @v col		Screen column
149 148
  */
150 149
 static void init_setting ( struct setting_widget *widget,
151
-			   struct config_context *context,
152
-			   struct config_setting *setting,
150
+			   struct settings *settings,
151
+			   struct named_setting *setting,
153 152
 			   unsigned int row, unsigned int col ) {
154 153
 
155 154
 	/* Initialise widget structure */
156 155
 	memset ( widget, 0, sizeof ( *widget ) );
157
-	widget->context = context;
156
+	widget->settings = settings;
158 157
 	widget->setting = setting;
159 158
 	widget->row = row;
160 159
 	widget->col = col;
@@ -219,13 +218,13 @@ static int edit_setting ( struct setting_widget *widget, int key ) {
219 218
  * Initialise setting widget by index
220 219
  *
221 220
  * @v widget		Setting widget
222
- * @v context		Configuration context
221
+ * @v settings		Settings block
223 222
  * @v index		Index of setting with settings list
224 223
  */
225 224
 static void init_setting_index ( struct setting_widget *widget,
226
-				 struct config_context *context,
225
+				 struct settings *settings,
227 226
 				 unsigned int index ) {
228
-	init_setting ( widget, context, &config_settings[index],
227
+	init_setting ( widget, settings, &named_settings[index],
229 228
 		       ( SETTINGS_LIST_ROW + index ), SETTINGS_LIST_COL );
230 229
 }
231 230
 
@@ -312,11 +311,10 @@ static void draw_title_row ( void ) {
312 311
  *
313 312
  * @v setting		Current configuration setting
314 313
  */
315
-static void draw_info_row ( struct config_setting *setting ) {
314
+static void draw_info_row ( struct named_setting *setting ) {
316 315
 	clearmsg ( INFO_ROW );
317 316
 	attron ( A_BOLD );
318
-	msg ( INFO_ROW, "%s (%s) - %s", setting->name,
319
-	      setting->type->description, setting->description );
317
+	msg ( INFO_ROW, "%s - %s", setting->name, setting->description );
320 318
 	attroff ( A_BOLD );
321 319
 }
322 320
 
@@ -333,11 +331,11 @@ static void draw_instruction_row ( int editing ) {
333 331
 		      "Ctrl-C - discard changes" );
334 332
 	} else {
335 333
 		msg ( INSTRUCTION_ROW,
336
-		      "Ctrl-S - save configuration" );
334
+		      "Ctrl-X - exit configuration utility" );
337 335
 	}
338 336
 }
339 337
 
340
-static int main_loop ( struct config_context *context ) {
338
+static int main_loop ( struct settings *settings ) {
341 339
 	struct setting_widget widget;
342 340
 	unsigned int current = 0;
343 341
 	unsigned int next;
@@ -349,7 +347,7 @@ static int main_loop ( struct config_context *context ) {
349 347
 	draw_title_row();
350 348
 	color_set ( CPAIR_NORMAL, NULL );
351 349
 	for ( i = ( NUM_SETTINGS - 1 ) ; i >= 0 ; i-- ) {
352
-		init_setting_index ( &widget, context, i );
350
+		init_setting_index ( &widget, settings, i );
353 351
 		draw_setting ( &widget );
354 352
 	}
355 353
 
@@ -394,19 +392,15 @@ static int main_loop ( struct config_context *context ) {
394 392
 				if ( next > 0 )
395 393
 					next--;
396 394
 				break;
397
-			case CTRL_S:
398
-				if ( ( rc = nvo_save ( ugly_nvo_hack ) ) != 0){
399
-					alert ( " Could not save options: %s ",
400
-						strerror ( rc ) );
401
-				}
402
-				return rc;
395
+			case CTRL_X:
396
+				return 0;
403 397
 			default:
404 398
 				edit_setting ( &widget, key );
405 399
 				break;
406 400
 			}	
407 401
 			if ( next != current ) {
408 402
 				draw_setting ( &widget );
409
-				init_setting_index ( &widget, context, next );
403
+				init_setting_index ( &widget, settings, next );
410 404
 				current = next;
411 405
 			}
412 406
 		}
@@ -414,7 +408,7 @@ static int main_loop ( struct config_context *context ) {
414 408
 	
415 409
 }
416 410
 
417
-int settings_ui ( struct config_context *context ) {
411
+int settings_ui ( struct settings *settings ) {
418 412
 	int rc;
419 413
 
420 414
 	initscr();
@@ -426,7 +420,7 @@ int settings_ui ( struct config_context *context ) {
426 420
 	color_set ( CPAIR_NORMAL, NULL );
427 421
 	erase();
428 422
 	
429
-	rc = main_loop ( context );
423
+	rc = main_loop ( settings );
430 424
 
431 425
 	endwin();
432 426
 

+ 122
- 80
src/include/gpxe/settings.h View File

@@ -8,73 +8,96 @@
8 8
  */
9 9
 
10 10
 #include <stdint.h>
11
-#include <gpxe/dhcp.h>
12 11
 #include <gpxe/tables.h>
12
+#include <gpxe/list.h>
13
+#include <gpxe/refcnt.h>
13 14
 
14
-struct config_setting;
15
+struct settings;
16
+struct in_addr;
15 17
 
16
-/**
17
- * A configuration context
18
- *
19
- * This identifies the context within which settings are inspected and
20
- * changed.  For example, the context might be global, or might be
21
- * restricted to the settings stored in NVS on a particular device.
22
- */
23
-struct config_context {
24
-	/** DHCP options block, or NULL
18
+/** Settings block operations */
19
+struct settings_operations {
20
+	/** Set value of setting
21
+	 *
22
+	 * @v settings		Settings block
23
+	 * @v tag		Setting tag number
24
+	 * @v data		Setting data, or NULL to clear setting
25
+	 * @v len		Length of setting data
26
+	 * @ret rc		Return status code
27
+	 */
28
+	int ( * set ) ( struct settings *settings, unsigned int tag,
29
+			const void *data, size_t len );
30
+	/** Get value of setting
31
+	 *
32
+	 * @v settings		Settings block
33
+	 * @v tag		Setting tag number
34
+	 * @v data		Buffer to fill with setting data
35
+	 * @v len		Length of buffer
36
+	 * @ret len		Length of setting data, or negative error
25 37
 	 *
26
-	 * If NULL, all registered DHCP options blocks will be used.
38
+	 * The actual length of the setting will be returned even if
39
+	 * the buffer was too small.
27 40
 	 */
28
-	struct dhcp_option_block *options;
41
+	int ( * get ) ( struct settings *settings, unsigned int tag,
42
+			void *data, size_t len );
43
+};
44
+
45
+/** A settings block */
46
+struct settings {
47
+	/** Reference counter */
48
+	struct refcnt *refcnt;
49
+	/** Name */
50
+	char name[16];
51
+	/** List of all settings */
52
+	struct list_head list;
53
+	/** Settings block operations */
54
+	struct settings_operations *op;
29 55
 };
30 56
 
31 57
 /**
32
- * A configuration setting type
58
+ * A setting type
33 59
  *
34
- * This represents a type of configuration setting (e.g. string, IPv4
35
- * address, etc.).
60
+ * This represents a type of setting (e.g. string, IPv4 address,
61
+ * etc.).
36 62
  */
37
-struct config_setting_type {
63
+struct setting_type {
38 64
 	/** Name
39 65
 	 *
40 66
 	 * This is the name exposed to the user (e.g. "string").
41 67
 	 */
42 68
 	const char *name;
43
-	/** Description */
44
-	const char *description;
45
-	/** Show value of setting
69
+	/** Parse and set value of setting
46 70
 	 *
47
-	 * @v context		Configuration context
48
-	 * @v setting		Configuration setting
49
-	 * @v buf		Buffer to contain value
71
+	 * @v settings		Settings block
72
+	 * @v tag		Setting tag number
73
+	 * @v value		Formatted setting data
74
+	 * @ret rc		Return status code
75
+	 */
76
+	int ( * setf ) ( struct settings *settings, unsigned int tag,
77
+			 const char *value );
78
+	/** Get and format value of setting
79
+	 *
80
+	 * @v settings		Settings block, or NULL to search all blocks
81
+	 * @v tag		Setting tag number
82
+	 * @v buf		Buffer to contain formatted value
50 83
 	 * @v len		Length of buffer
51 84
 	 * @ret len		Length of formatted value, or negative error
52 85
 	 */
53
-	int ( * show ) ( struct config_context *context,
54
-			 struct config_setting *setting,
86
+	int ( * getf ) ( struct settings *settings, unsigned int tag,
55 87
 			 char *buf, size_t len );
56
-	/** Set value of setting
57
-	 *
58
-	 * @v context		Configuration context
59
-	 * @v setting		Configuration setting
60
-	 * @v value		Setting value (as a string)
61
-	 * @ret rc		Return status code
62
-	 */ 
63
-	int ( * set ) ( struct config_context *context,
64
-			struct config_setting *setting,
65
-			const char *value );
66 88
 };
67 89
 
68 90
 /** Declare a configuration setting type */
69
-#define	__config_setting_type \
70
-	__table ( struct config_setting_type, config_setting_types, 01 )
91
+#define	__setting_type \
92
+	__table ( struct setting_type, setting_types, 01 )
71 93
 
72 94
 /**
73
- * A configuration setting
95
+ * A named setting
74 96
  *
75
- * This represents a single configuration setting (e.g. "hostname").
97
+ * This represents a single setting (e.g. "hostname"), encapsulating
98
+ * the information about the setting's tag number and type.
76 99
  */
77
-struct config_setting {
100
+struct named_setting {
78 101
 	/** Name
79 102
 	 *
80 103
 	 * This is the human-readable name for the setting.  Where
@@ -84,71 +107,90 @@ struct config_setting {
84 107
 	const char *name;
85 108
 	/** Description */
86 109
 	const char *description;
87
-	/** DHCP option tag
88
-	 *
89
-	 * This is the DHCP tag used to identify the option in DHCP
90
-	 * packets and stored option blocks.
91
-	 */
110
+	/** Setting tag number */
92 111
 	unsigned int tag;
93
-	/** Configuration setting type
112
+	/** Setting type
94 113
 	 *
95 114
 	 * This identifies the type of setting (e.g. string, IPv4
96 115
 	 * address, etc.).
97 116
 	 */
98
-	struct config_setting_type *type;
117
+	struct setting_type *type;
99 118
 };
100 119
 
101 120
 /** Declare a configuration setting */
102
-#define	__config_setting __table ( struct config_setting, config_settings, 01 )
121
+#define	__named_setting __table ( struct named_setting, named_settings, 01 )
122
+
123
+extern struct settings interactive_settings;
124
+
125
+extern int get_setting ( struct settings *settings, unsigned int tag,
126
+			 void *data, size_t len );
127
+extern int get_setting_len ( struct settings *settings, unsigned int tag );
128
+extern int get_string_setting ( struct settings *settings, unsigned int tag,
129
+				char *data, size_t len );
130
+extern int get_ipv4_setting ( struct settings *settings, unsigned int tag,
131
+			      struct in_addr *inp );
132
+extern int get_int_setting ( struct settings *settings, unsigned int tag,
133
+			     long *value );
134
+extern int get_uint_setting ( struct settings *settings, unsigned int tag,
135
+			      unsigned long *value );
136
+extern struct settings * find_settings ( const char *name );
137
+extern int set_typed_setting ( struct settings *settings,
138
+			       unsigned int tag, struct setting_type *type,
139
+			       const char *value );
140
+extern int set_named_setting ( const char *name, const char *value );
141
+extern int get_named_setting ( const char *name, char *buf, size_t len );
103 142
 
104 143
 /**
105
- * Show value of setting
144
+ * Set value of setting
106 145
  *
107
- * @v context		Configuration context
108
- * @v setting		Configuration setting
109
- * @v buf		Buffer to contain value
110
- * @v len		Length of buffer
111
- * @ret len		Length of formatted value, or negative error
146
+ * @v settings		Settings block
147
+ * @v tag		Setting tag number
148
+ * @v data		Setting data, or NULL to clear setting
149
+ * @v len		Length of setting data
150
+ * @ret rc		Return status code
112 151
  */
113
-static inline int show_setting ( struct config_context *context,
114
-				 struct config_setting *setting,
115
-				 char *buf, size_t len ) {
116
-	return setting->type->show ( context, setting, buf, len );
152
+static inline int set_setting ( struct settings *settings, unsigned int tag,
153
+				const void *data, size_t len ) {
154
+	return settings->op->set ( settings, tag, data, len );
117 155
 }
118 156
 
119
-extern int set_setting ( struct config_context *context,
120
-			 struct config_setting *setting,
121
-			 const char *value );
122
-
123 157
 /**
124
- * Clear setting
158
+ * Delete setting
125 159
  *
126
- * @v context		Configuration context
127
- * @v setting		Configuration setting
160
+ * @v settings		Settings block
161
+ * @v tag		Setting tag number
128 162
  * @ret rc		Return status code
129 163
  */
130
-static inline int clear_setting ( struct config_context *context,
131
-				  struct config_setting *setting ) {
132
-	delete_dhcp_option ( context->options, setting->tag );
133
-	return 0;
164
+static inline int delete_setting ( struct settings *settings,
165
+				   unsigned int tag ) {
166
+	return set_setting ( settings, tag, NULL, 0 );
134 167
 }
135 168
 
136
-/* Function prototypes */
137
-extern int show_named_setting ( struct config_context *context,
138
-				const char *name, char *buf, size_t len );
139
-extern int set_named_setting ( struct config_context *context,
140
-			       const char *name, const char *value );
169
+/**
170
+ * Get and format value of setting
171
+ *
172
+ * @v settings		Settings block, or NULL to search all blocks
173
+ * @v tag		Setting tag number
174
+ * @v type		Settings type
175
+ * @v buf		Buffer to contain formatted value
176
+ * @v len		Length of buffer
177
+ * @ret len		Length of formatted value, or negative error
178
+ */
179
+static inline int get_typed_setting ( struct settings *settings,
180
+				      unsigned int tag,
181
+				      struct setting_type *type,
182
+				      char *buf, size_t len ) {
183
+	return type->getf ( settings, tag, buf, len );
184
+}
141 185
 
142 186
 /**
143
- * Clear named setting
187
+ * Delete named setting
144 188
  *
145
- * @v context		Configuration context
146
- * @v name		Configuration setting name
189
+ * @v name		Name of setting
147 190
  * @ret rc		Return status code
148 191
  */
149
-static inline int clear_named_setting ( struct config_context *context,
150
-					const char *name ) {
151
-	return set_named_setting ( context, name, NULL );
192
+static inline int delete_named_setting ( const char *name ) {
193
+	return set_named_setting ( name, NULL );
152 194
 }
153 195
 
154 196
 #endif /* _GPXE_SETTINGS_H */

+ 2
- 2
src/include/gpxe/settings_ui.h View File

@@ -7,8 +7,8 @@
7 7
  *
8 8
  */
9 9
 
10
-struct config_context;
10
+struct settings;
11 11
 
12
-extern int settings_ui ( struct config_context *context ) __nonnull;
12
+extern int settings_ui ( struct settings *settings ) __nonnull;
13 13
 
14 14
 #endif /* _GPXE_SETTINGS_UI_H */

Loading…
Cancel
Save