squareball/sb-configparser.h File Reference

Functions to parse INI-style configuration files. More...

#include <stdlib.h>
#include "sb-error.h"
#include "sb-slist.h"
#include "sb-trie.h"

Go to the source code of this file.



typedef struct _sb_config_t sb_config_t
sb_config_tsb_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)

Detailed Description

Functions to parse INI-style configuration files.


Typedef Documentation

typedef struct _sb_config_t sb_config_t

Configuration opaque structure.

Examples:
hello_configparser.c.

Function Documentation

void sb_config_free ( sb_config_t config  ) 

Function that frees the memory allocated for a configuration object.

Parameters:
config The configuration object.
Examples:
hello_configparser.c.
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.

Parameters:
config A sb_config_t object.
section A configuration section.
key A configuration key.
Returns:
The value of the given configuration key, or NULL.
Examples:
hello_configparser.c.
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.

Parameters:
config A sb_config_t object.
section A configuration section.
Returns:
An NULL-terminated array of strings, that should be free'd with sb_strv_free.
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.

Parameters:
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.
Returns:
The value of the given configuration key, or 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.

Parameters:
config A sb_config_t object.
section A configuration section.
Returns:
An array of strings, or NULL. Must be free'd with sb_strv_free.
Examples:
hello_configparser.c.
char** sb_config_list_sections ( sb_config_t config  ) 

Function that returns an array with configuration sections.

Parameters:
config A sb_config_t object.
Returns:
An array of strings, or NULL. Must be free'd with sb_strv_free.
Examples:
hello_configparser.c.
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.

Parameters:
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.
Returns:
An object with the parsed data, or NULL.
Examples:
hello_configparser.c.

Generated on 7 Apr 2018 for squareball by  doxygen 1.6.1