summaryrefslogtreecommitdiffstats
path: root/src/core/settings.c
diff options
context:
space:
mode:
authorMichael Brown2008-03-18 05:13:11 +0100
committerMichael Brown2008-03-18 05:13:11 +0100
commit03398e33894536b69565c88797cf97a22f14fbc7 (patch)
treef6ab69e12edd7d35289d266f1bad0d2878808985 /src/core/settings.c
parent[Settings] Add int16, int32 and hex-string configuration setting types (diff)
downloadipxe-03398e33894536b69565c88797cf97a22f14fbc7.tar.gz
ipxe-03398e33894536b69565c88797cf97a22f14fbc7.tar.xz
ipxe-03398e33894536b69565c88797cf97a22f14fbc7.zip
[Settings] Allow encapsulated options to be specified as named settings
Allow encapsulated options to be specified as e.g. "175.3". As a side-effect, change the separator character for the type field from "." to ":"; for example, the IP address pseudo-option is now "175.3:ipv4".
Diffstat (limited to 'src/core/settings.c')
-rw-r--r--src/core/settings.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/core/settings.c b/src/core/settings.c
index 11afd824..42de5c4e 100644
--- a/src/core/settings.c
+++ b/src/core/settings.c
@@ -91,7 +91,7 @@ static struct config_setting * find_config_setting ( const char *name ) {
* @ret setting Configuration setting, or NULL
*
* Find setting if it exists. If it doesn't exist, but the name is of
- * the form "<num>.<type>" (e.g. "12.string"), then construct a
+ * the form "<num>:<type>" (e.g. "12:string"), then construct a
* setting for that tag and data type, and return it. The constructed
* setting will be placed in the temporary buffer.
*/
@@ -106,13 +106,19 @@ find_or_build_config_setting ( const char *name,
if ( setting )
return setting;
- /* If name is of the form "<num>.<type>", try to construct a setting */
+ /* If name is of the form "<num>:<type>", try to construct a setting */
setting = tmp_setting;
memset ( setting, 0, sizeof ( *setting ) );
setting->name = name;
- setting->tag = strtoul ( name, &separator, 10 );
+ for ( separator = ( char * ) name ; 1 ; separator++ ) {
+ setting->tag = ( ( setting->tag << 8 ) |
+ strtoul ( separator, &separator, 0 ) );
+ if ( *separator != '.' )
+ break;
+ }
+
switch ( *separator ) {
- case '.' :
+ case ':' :
setting->type = find_config_setting_type ( separator + 1 );
break;
case '\0' :