mirror of https://github.com/ipxe/ipxe.git
[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".pull/1/head
parent
e2613e8896
commit
03398e3389
|
@ -91,7 +91,7 @@ static struct config_setting * find_config_setting ( const char *name ) {
|
||||||
* @ret setting Configuration setting, or NULL
|
* @ret setting Configuration setting, or NULL
|
||||||
*
|
*
|
||||||
* Find setting if it exists. If it doesn't exist, but the name is of
|
* 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 for that tag and data type, and return it. The constructed
|
||||||
* setting will be placed in the temporary buffer.
|
* setting will be placed in the temporary buffer.
|
||||||
*/
|
*/
|
||||||
|
@ -106,13 +106,19 @@ find_or_build_config_setting ( const char *name,
|
||||||
if ( setting )
|
if ( setting )
|
||||||
return 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;
|
setting = tmp_setting;
|
||||||
memset ( setting, 0, sizeof ( *setting ) );
|
memset ( setting, 0, sizeof ( *setting ) );
|
||||||
setting->name = name;
|
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 ) {
|
switch ( *separator ) {
|
||||||
case '.' :
|
case ':' :
|
||||||
setting->type = find_config_setting_type ( separator + 1 );
|
setting->type = find_config_setting_type ( separator + 1 );
|
||||||
break;
|
break;
|
||||||
case '\0' :
|
case '\0' :
|
||||||
|
|
Loading…
Reference in New Issue