|
@@ -116,7 +116,7 @@ find_or_build_config_setting ( const char *name,
|
116
|
116
|
}
|
117
|
117
|
|
118
|
118
|
/**
|
119
|
|
- * Show value of setting
|
|
119
|
+ * Show value of named setting
|
120
|
120
|
*
|
121
|
121
|
* @v context Configuration context
|
122
|
122
|
* @v name Configuration setting name
|
|
@@ -124,27 +124,27 @@ find_or_build_config_setting ( const char *name,
|
124
|
124
|
* @v len Length of buffer
|
125
|
125
|
* @ret rc Return status code
|
126
|
126
|
*/
|
127
|
|
-int show_setting ( struct config_context *context, const char *name,
|
128
|
|
- char *buf, size_t len ) {
|
|
127
|
+int show_named_setting ( struct config_context *context, const char *name,
|
|
128
|
+ char *buf, size_t len ) {
|
129
|
129
|
struct config_setting *setting;
|
130
|
130
|
struct config_setting tmp_setting;
|
131
|
131
|
|
132
|
132
|
setting = find_or_build_config_setting ( name, &tmp_setting );
|
133
|
133
|
if ( ! setting )
|
134
|
134
|
return -ENOENT;
|
135
|
|
- return setting->type->show ( context, setting, buf, len );
|
|
135
|
+ return show_setting ( context, setting, buf, len );
|
136
|
136
|
}
|
137
|
137
|
|
138
|
138
|
/**
|
139
|
|
- * Set value of setting
|
|
139
|
+ * Set value of named setting
|
140
|
140
|
*
|
141
|
141
|
* @v context Configuration context
|
142
|
142
|
* @v name Configuration setting name
|
143
|
143
|
* @v value Setting value (as a string)
|
144
|
144
|
* @ret rc Return status code
|
145
|
145
|
*/
|
146
|
|
-int set_setting ( struct config_context *context, const char *name,
|
147
|
|
- const char *value ) {
|
|
146
|
+int set_named_setting ( struct config_context *context, const char *name,
|
|
147
|
+ const char *value ) {
|
148
|
148
|
struct config_setting *setting;
|
149
|
149
|
struct config_setting tmp_setting;
|
150
|
150
|
|
|
@@ -155,24 +155,21 @@ int set_setting ( struct config_context *context, const char *name,
|
155
|
155
|
}
|
156
|
156
|
|
157
|
157
|
/**
|
158
|
|
- * Clear setting
|
|
158
|
+ * Set value of setting
|
159
|
159
|
*
|
160
|
160
|
* @v context Configuration context
|
161
|
|
- * @v name Configuration setting name
|
|
161
|
+ * @v setting Configuration setting
|
|
162
|
+ * @v value Setting value (as a string), or NULL
|
162
|
163
|
* @ret rc Return status code
|
163
|
164
|
*/
|
164
|
|
-int clear_setting ( struct config_context *context, const char *name ) {
|
165
|
|
- struct config_setting *setting;
|
166
|
|
- struct config_setting tmp_setting;
|
167
|
|
-
|
168
|
|
- setting = find_or_build_config_setting ( name, &tmp_setting );
|
169
|
|
- if ( ! setting )
|
170
|
|
- return -ENOENT;
|
171
|
|
-
|
172
|
|
- /* All types of settings get cleared the same way */
|
173
|
|
- delete_dhcp_option ( context->options, setting->tag );
|
174
|
|
-
|
175
|
|
- return 0;
|
|
165
|
+int set_setting ( struct config_context *context,
|
|
166
|
+ struct config_setting *setting,
|
|
167
|
+ const char *value ) {
|
|
168
|
+ if ( ( ! value ) || ( ! *value ) ) {
|
|
169
|
+ /* Save putting deletion logic in each individual handler */
|
|
170
|
+ return clear_setting ( context, setting );
|
|
171
|
+ }
|
|
172
|
+ return setting->type->set ( context, setting, value );
|
176
|
173
|
}
|
177
|
174
|
|
178
|
175
|
/**
|
|
@@ -259,7 +256,6 @@ static int set_ipv4 ( struct config_context *context,
|
259
|
256
|
const char *value ) {
|
260
|
257
|
struct dhcp_option *option;
|
261
|
258
|
struct in_addr ipv4;
|
262
|
|
- int rc;
|
263
|
259
|
|
264
|
260
|
if ( inet_aton ( value, &ipv4 ) == 0 )
|
265
|
261
|
return -EINVAL;
|