Loading...
Searching...
No Matches
conf.h File Reference

Configuration file parser. More...

Functions

struct spdk_conf * spdk_conf_allocate (void)
 Allocate a configuration struct used for the initialization of SPDK app.
 
void spdk_conf_free (struct spdk_conf *cp)
 Free the configuration struct.
 
int spdk_conf_read (struct spdk_conf *cp, const char *file)
 Read configuration file for spdk_conf struct.
 
struct spdk_conf_section * spdk_conf_find_section (struct spdk_conf *cp, const char *name)
 Find the specified section of the configuration.
 
struct spdk_conf_section * spdk_conf_first_section (struct spdk_conf *cp)
 Get the first section of the configuration.
 
struct spdk_conf_section * spdk_conf_next_section (struct spdk_conf_section *sp)
 Get the next section of the configuration.
 
bool spdk_conf_section_match_prefix (const struct spdk_conf_section *sp, const char *name_prefix)
 Match prefix of the name of section.
 
const char * spdk_conf_section_get_name (const struct spdk_conf_section *sp)
 Get the name of the section.
 
int spdk_conf_section_get_num (const struct spdk_conf_section *sp)
 Get the number of the section.
 
char * spdk_conf_section_get_nmval (struct spdk_conf_section *sp, const char *key, int idx1, int idx2)
 Get the value of the item with name 'key' in the section.
 
char * spdk_conf_section_get_nval (struct spdk_conf_section *sp, const char *key, int idx)
 Get the first value of the item with name 'key' in the section.
 
char * spdk_conf_section_get_val (struct spdk_conf_section *sp, const char *key)
 Get the first value of the first item with name 'key' in the section.
 
int spdk_conf_section_get_intval (struct spdk_conf_section *sp, const char *key)
 Get the first value of the first item with name 'key' in the section.
 
bool spdk_conf_section_get_boolval (struct spdk_conf_section *sp, const char *key, bool default_val)
 Get the bool value of the item with name 'key' in the section.
 
void spdk_conf_set_as_default (struct spdk_conf *cp)
 Set the configuration as the default.
 
void spdk_conf_disable_sections_merge (struct spdk_conf *cp)
 Disable sections merging during 'spdk_conf_read()'.
 

Detailed Description

Configuration file parser.

Function Documentation

◆ spdk_conf_allocate()

struct spdk_conf * spdk_conf_allocate ( void )

Allocate a configuration struct used for the initialization of SPDK app.

Returns
a pointer to the allocated configuration struct.

◆ spdk_conf_disable_sections_merge()

void spdk_conf_disable_sections_merge ( struct spdk_conf * cp)

Disable sections merging during 'spdk_conf_read()'.

Parameters
cpConfiguration to be read

◆ spdk_conf_find_section()

struct spdk_conf_section * spdk_conf_find_section ( struct spdk_conf * cp,
const char * name )

Find the specified section of the configuration.

Parameters
cpConfiguration struct used for the initialization of SPDK app.
nameName of section to find.
Returns
a pointer to the requested section on success or NULL otherwise.

◆ spdk_conf_first_section()

struct spdk_conf_section * spdk_conf_first_section ( struct spdk_conf * cp)

Get the first section of the configuration.

Parameters
cpConfiguration struct used for the initialization of SPDK app.
Returns
a pointer to the requested section on success or NULL otherwise.

◆ spdk_conf_free()

void spdk_conf_free ( struct spdk_conf * cp)

Free the configuration struct.

Parameters
cpConfiguration struct to free.

◆ spdk_conf_next_section()

struct spdk_conf_section * spdk_conf_next_section ( struct spdk_conf_section * sp)

Get the next section of the configuration.

Parameters
spThe current section of the configuration.
Returns
a pointer to the requested section on success or NULL otherwise.

◆ spdk_conf_read()

int spdk_conf_read ( struct spdk_conf * cp,
const char * file )

Read configuration file for spdk_conf struct.

Parameters
cpConfiguration struct used for the initialization of SPDK app.
fileFile to read that is created by user to configure SPDK app.
Returns
0 on success, -1 on failure.

◆ spdk_conf_section_get_boolval()

bool spdk_conf_section_get_boolval ( struct spdk_conf_section * sp,
const char * key,
bool default_val )

Get the bool value of the item with name 'key' in the section.

This is used to check whether the service is enabled.

Parameters
spThe section of the configuration.
keyName of item.
default_valDefault value.
Returns
true if matching 'Yes/Y/True', false if matching 'No/N/False', default value otherwise.

◆ spdk_conf_section_get_intval()

int spdk_conf_section_get_intval ( struct spdk_conf_section * sp,
const char * key )

Get the first value of the first item with name 'key' in the section.

Parameters
spThe section of the configuration.
keyName of item.
Returns
the requested value on success or NULL otherwise.

◆ spdk_conf_section_get_name()

const char * spdk_conf_section_get_name ( const struct spdk_conf_section * sp)

Get the name of the section.

Parameters
spThe section of the configuration.
Returns
the name of the section.

◆ spdk_conf_section_get_nmval()

char * spdk_conf_section_get_nmval ( struct spdk_conf_section * sp,
const char * key,
int idx1,
int idx2 )

Get the value of the item with name 'key' in the section.

If key appears multiple times, idx1 will control which version to retrieve. Indices will start from the top of the configuration file at 0 and increment by one for each new appearance. If the configuration key contains multiple whitespace delimited values, idx2 controls which value is returned. The index begins at 0.

Parameters
spThe section of the configuration.
keyName of item.
idx1The index into the item list for the key.
idx2The index into the value list for the item.
Returns
the requested value on success or NULL otherwise.

◆ spdk_conf_section_get_num()

int spdk_conf_section_get_num ( const struct spdk_conf_section * sp)

Get the number of the section.

Parameters
spThe section of the configuration.
Returns
the number of the section.

◆ spdk_conf_section_get_nval()

char * spdk_conf_section_get_nval ( struct spdk_conf_section * sp,
const char * key,
int idx )

Get the first value of the item with name 'key' in the section.

Parameters
spThe section of the configuration.
keyName of item.
idxThe index into the value list for the item.
Returns
the requested value on success or NULL otherwise.

◆ spdk_conf_section_get_val()

char * spdk_conf_section_get_val ( struct spdk_conf_section * sp,
const char * key )

Get the first value of the first item with name 'key' in the section.

Parameters
spThe section of the configuration.
keyName of item.
Returns
the requested value on success or NULL otherwise.

◆ spdk_conf_section_match_prefix()

bool spdk_conf_section_match_prefix ( const struct spdk_conf_section * sp,
const char * name_prefix )

Match prefix of the name of section.

Parameters
spThe section of the configuration.
name_prefixPrefix name to match.
Returns
true on success, false on failure.

◆ spdk_conf_set_as_default()

void spdk_conf_set_as_default ( struct spdk_conf * cp)

Set the configuration as the default.

Parameters
cpConfiguration to set.