squareball
0.2.0.53-dd5b
A general-purpose library for C99
|
Functions to parse INI-style configuration files. More...
Go to the source code of this file.
typedef struct _sb_config_t | sb_config_t |
sb_config_t * | sb_config_parse (const char *src, size_t src_len, const char *list_sections[], sb_error_t **err) |
char ** | sb_config_list_sections (sb_config_t *config) |
char ** | sb_config_list_keys (sb_config_t *config, const char *section) |
const char * | sb_config_get (sb_config_t *config, const char *section, const char *key) |
const char * | sb_config_get_with_default (sb_config_t *config, const char *section, const char *key, const char *default_) |
char ** | sb_config_get_list (sb_config_t *config, const char *section) |
void | sb_config_free (sb_config_t *config) |
Functions to parse INI-style configuration files.
typedef struct _sb_config_t sb_config_t |
Configuration opaque structure.
void sb_config_free | ( | sb_config_t * | config | ) |
Function that frees the memory allocated for a configuration object.
config | The configuration object. |
const char* sb_config_get | ( | sb_config_t * | config, |
const char * | section, | ||
const char * | key | ||
) |
Function that returns the value of a given configuration key, for a given configuration section.
config | A sb_config_t object. |
section | A configuration section. |
key | A configuration key. |
NULL
. char** sb_config_get_list | ( | sb_config_t * | config, |
const char * | section | ||
) |
Function that returns an array of values parsed as a list from a given section.
The section must be included in the list_sections
when calling sb_config_parse.
config | A sb_config_t object. |
section | A configuration section. |
const char* sb_config_get_with_default | ( | sb_config_t * | config, |
const char * | section, | ||
const char * | key, | ||
const char * | default_ | ||
) |
Function that returns the value of a given configuration key, for a given configuration section, or returns a default value if the key and/or section does not exists.
config | A sb_config_t object. |
section | A configuration section. |
key | A configuration key. |
default_ | A default value to be returned, if the ken and/or section does not exists. |
default_
. char** sb_config_list_keys | ( | sb_config_t * | config, |
const char * | section | ||
) |
Function that returns an array with configuration keys found in a given configuration section.
config | A sb_config_t object. |
section | A configuration section. |
NULL
. Must be free'd with sb_strv_free. char** sb_config_list_sections | ( | sb_config_t * | config | ) |
Function that returns an array with configuration sections.
config | A sb_config_t object. |
NULL
. Must be free'd with sb_strv_free. sb_config_t* sb_config_parse | ( | const char * | src, |
size_t | src_len, | ||
const char * | list_sections[], | ||
sb_error_t ** | err | ||
) |
Function that parses INI-style configuration from a string.
src | String with the content to be parsed. |
src_len | String length. |
list_sections | List of strings with sections that should be parsed as lists. |
err | Return location for a sb_error_t, or NULL. |
NULL
.