Browse Source

Added clear_setting()

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
007ca97f25
2 changed files with 26 additions and 2 deletions
  1. 25
    2
      src/core/settings.c
  2. 1
    0
      src/include/gpxe/settings.h

+ 25
- 2
src/core/settings.c View File

@@ -115,7 +115,8 @@ find_or_build_config_setting ( const char *name,
115 115
 	return setting;
116 116
 }
117 117
 
118
-/** Show value of setting
118
+/**
119
+ * Show value of setting
119 120
  *
120 121
  * @v context		Configuration context
121 122
  * @v name		Configuration setting name
@@ -134,7 +135,8 @@ int show_setting ( struct config_context *context, const char *name,
134 135
 	return setting->type->show ( context, setting, buf, len );
135 136
 }
136 137
 
137
-/** Set value of setting
138
+/**
139
+ * Set value of setting
138 140
  *
139 141
  * @v context		Configuration context
140 142
  * @v name		Configuration setting name
@@ -152,6 +154,27 @@ int set_setting ( struct config_context *context, const char *name,
152 154
 	return setting->type->set ( context, setting, value );
153 155
 }
154 156
 
157
+/**
158
+ * Clear setting
159
+ *
160
+ * @v context		Configuration context
161
+ * @v name		Configuration setting name
162
+ * @ret rc		Return status code
163
+ */
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;
176
+}
177
+
155 178
 /**
156 179
  * Show value of string setting
157 180
  *

+ 1
- 0
src/include/gpxe/settings.h View File

@@ -102,5 +102,6 @@ extern int show_setting ( struct config_context *context, const char *name,
102 102
 			  char *buf, size_t len );
103 103
 extern int set_setting ( struct config_context *context, const char *name,
104 104
 			 const char *value );
105
+extern int clear_setting ( struct config_context *context, const char *name );
105 106
 
106 107
 #endif /* _GPXE_SETTINGS_H */

Loading…
Cancel
Save