mirror of
https://github.com/xcat2/xNBA.git
synced 2025-02-12 08:39:36 +00:00
[settings] Remove now-unused fetchf_named_setting() and storef_named_setting()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
652abb6706
commit
bd6c3a1886
@ -1316,120 +1316,6 @@ int setting_name ( struct settings *settings, struct setting *setting,
|
||||
setting->name, setting->type->name );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse and store value of named setting
|
||||
*
|
||||
* @v name Name of setting
|
||||
* @v default_type Default type to use, if none specified
|
||||
* @v value Formatted setting data, or NULL
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int storef_named_setting ( const char *name, struct setting_type *default_type,
|
||||
const char *value ) {
|
||||
struct settings *settings;
|
||||
struct setting setting;
|
||||
char tmp_name[ strlen ( name ) + 1 ];
|
||||
int rc;
|
||||
|
||||
/* Create modifiable copy of setting name */
|
||||
strcpy ( tmp_name, name );
|
||||
|
||||
/* Parse setting name */
|
||||
if ( ( rc = parse_setting_name ( tmp_name, autovivify_child_settings,
|
||||
&settings, &setting ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Apply default type if necessary */
|
||||
if ( ! setting.type )
|
||||
setting.type = default_type;
|
||||
|
||||
/* Store setting */
|
||||
if ( ( rc = storef_setting ( settings, &setting, value ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and format value of named setting
|
||||
*
|
||||
* @v name Name of setting
|
||||
* @v name_buf Buffer to contain canonicalised name
|
||||
* @v name_len Length of canonicalised name buffer
|
||||
* @v value_buf Buffer to contain formatted value
|
||||
* @v value_len Length of formatted value buffer
|
||||
* @ret len Length of formatted value, or negative error
|
||||
*/
|
||||
int fetchf_named_setting ( const char *name,
|
||||
char *name_buf, size_t name_len,
|
||||
char *value_buf, size_t value_len ) {
|
||||
struct settings *settings;
|
||||
struct setting setting;
|
||||
struct settings *origin;
|
||||
char tmp_name[ strlen ( name ) + 1 ];
|
||||
int len;
|
||||
int rc;
|
||||
|
||||
/* Create modifiable copy of setting name */
|
||||
strcpy ( tmp_name, name );
|
||||
|
||||
/* Parse setting name */
|
||||
if ( ( rc = parse_setting_name ( tmp_name, find_child_settings,
|
||||
&settings, &setting ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Fetch setting */
|
||||
if ( ( len = fetchf_setting ( settings, &setting, value_buf,
|
||||
value_len ) ) < 0 )
|
||||
return len;
|
||||
|
||||
/* Construct setting name */
|
||||
origin = fetch_setting_origin ( settings, &setting );
|
||||
assert ( origin != NULL );
|
||||
setting_name ( origin, &setting, name_buf, name_len );
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch and format copy of value of named setting
|
||||
*
|
||||
* @v name Name of setting
|
||||
* @v data Buffer to allocate and fill with formatted value
|
||||
* @ret len Length of formatted value, or negative error
|
||||
*
|
||||
* The caller is responsible for eventually freeing the allocated
|
||||
* buffer.
|
||||
*
|
||||
* To allow the caller to distinguish between a non-existent setting
|
||||
* and an error in allocating memory for the copy, this function will
|
||||
* return success (and a NULL buffer pointer) for a non-existent
|
||||
* setting.
|
||||
*/
|
||||
int fetchf_named_setting_copy ( const char *name, char **data ) {
|
||||
int len;
|
||||
int check_len;
|
||||
|
||||
/* Avoid returning uninitialised data on error */
|
||||
*data = NULL;
|
||||
|
||||
/* Fetch formatted value length, and return success if non-existent */
|
||||
len = fetchf_named_setting ( name, NULL, 0, NULL, 0 );
|
||||
if ( len < 0 )
|
||||
return 0;
|
||||
|
||||
/* Allocate buffer */
|
||||
*data = malloc ( len + 1 /* NUL */ );
|
||||
if ( ! *data )
|
||||
return -ENOMEM;
|
||||
|
||||
/* Fetch formatted value */
|
||||
check_len = fetchf_named_setting ( name, NULL, 0, *data,
|
||||
( len + 1 /* NUL */ ) );
|
||||
assert ( check_len == len );
|
||||
return len;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Setting types
|
||||
|
@ -315,13 +315,6 @@ extern int fetchf_setting_copy ( struct settings *settings,
|
||||
extern int storef_setting ( struct settings *settings,
|
||||
struct setting *setting,
|
||||
const char *value );
|
||||
extern int storef_named_setting ( const char *name,
|
||||
struct setting_type *default_type,
|
||||
const char *value );
|
||||
extern int fetchf_named_setting ( const char *name, char *name_buf,
|
||||
size_t name_len, char *value_buf,
|
||||
size_t value_len );
|
||||
extern int fetchf_named_setting_copy ( const char *name, char **data );
|
||||
extern char * expand_settings ( const char *string );
|
||||
|
||||
extern struct setting_type setting_type_string __setting_type;
|
||||
|
Loading…
x
Reference in New Issue
Block a user