gmerlin
|
Typedefs | |
typedef struct bg_cfg_section_s | bg_cfg_section_t |
Configuration section. More... | |
Functions | |
void | bg_cfg_section_2_xml (const bg_cfg_section_t *section, xmlNodePtr xml_section) |
Convert a configuration section into a libxml2 node. More... | |
void | bg_cfg_xml_2_section (xmlDocPtr xml_doc, xmlNodePtr xml_section, bg_cfg_section_t *section) |
Convert libxml2 node into a configuration section. More... | |
void | bg_cfg_section_dump (bg_cfg_section_t *section, const char *filename) |
Dump a config section to a file. More... | |
bg_cfg_section_t * | bg_cfg_section_find_subsection (bg_cfg_section_t *section, const char *name) |
Find a child of a section. More... | |
bg_cfg_section_t * | bg_cfg_section_create_subsection_at_pos (bg_cfg_section_t *section, int pos) |
Create a subsection at the specified position. More... | |
void | bg_cfg_section_move_child (bg_cfg_section_t *section, bg_cfg_section_t *child, int pos) |
Move a subsection to the specified position. More... | |
bg_cfg_section_t * | bg_cfg_section_find_subsection_by_index (bg_cfg_section_t *section, int index) |
Find a child of a section by index. More... | |
bg_cfg_section_t * | bg_cfg_section_create (const char *name) |
Create an empty config section. More... | |
bg_cfg_section_t * | bg_cfg_section_create_from_parameters (const char *name, const bg_parameter_info_t *parameters) |
Create a config section from a parameter array. More... | |
void | bg_cfg_section_create_items (bg_cfg_section_t *section, const bg_parameter_info_t *parameters) |
Create items from a parameter info. More... | |
void | bg_cfg_section_destroy (bg_cfg_section_t *section) |
Destroy a config section. More... | |
bg_cfg_section_t * | bg_cfg_section_copy (const bg_cfg_section_t *src) |
Duplicate a configuration section. More... | |
void | bg_cfg_section_transfer (bg_cfg_section_t *src, bg_cfg_section_t *dst) |
Set values in a configuration section from another section. More... | |
void | bg_cfg_section_transfer_children (bg_cfg_section_t *src, bg_cfg_section_t *dst) |
Like bg_cfg_section_transfer but acts only on the subsections. More... | |
void | bg_cfg_section_add_ref (bg_cfg_section_t *section, bg_cfg_section_t *ref) |
Insert a reference to a section as child. More... | |
const char * | bg_cfg_section_get_name (bg_cfg_section_t *section) |
Get the name of a configuration section. More... | |
char * | bg_cfg_section_get_name_translated (bg_cfg_section_t *section) |
Get the translated name of a configuration section. More... | |
void | bg_cfg_section_set_name (bg_cfg_section_t *section, const char *name, const char *gettext_domain, const char *gettext_directory) |
Set the name of a configuration section. More... | |
void | bg_cfg_section_set_parameter (bg_cfg_section_t *section, const bg_parameter_info_t *info, const bg_parameter_value_t *value) |
Store a value in the section. More... | |
int | bg_cfg_section_set_parameters_from_string (bg_cfg_section_t *section, const bg_parameter_info_t *info, const char *str) |
Set values from an option string. More... | |
void | bg_cfg_section_get_parameter (bg_cfg_section_t *section, const bg_parameter_info_t *info, bg_parameter_value_t *value) |
Read a value from the section. More... | |
void | bg_cfg_section_delete_subsection (bg_cfg_section_t *section, bg_cfg_section_t *subsection) |
Delete a subsection. More... | |
void | bg_cfg_section_delete_subsections (bg_cfg_section_t *section) |
Delete all subsections. More... | |
void | bg_cfg_section_set_parameter_int (bg_cfg_section_t *section, const char *name, int value) |
Store an integer value in a section. More... | |
void | bg_cfg_section_set_parameter_float (bg_cfg_section_t *section, const char *name, float value) |
Store a float value in a section. More... | |
void | bg_cfg_section_set_parameter_string (bg_cfg_section_t *section, const char *name, const char *value) |
Store a string value in a section. More... | |
void | bg_cfg_section_set_parameter_time (bg_cfg_section_t *section, const char *name, gavl_time_t value) |
Store a time value in a section. More... | |
int | bg_cfg_section_get_parameter_int (bg_cfg_section_t *section, const char *name, int *value) |
Get an integer value from a section. More... | |
int | bg_cfg_section_get_parameter_float (bg_cfg_section_t *section, const char *name, float *value) |
Get an float value from a section. More... | |
int | bg_cfg_section_get_parameter_string (bg_cfg_section_t *section, const char *name, const char **value) |
Get an string value from a section. More... | |
int | bg_cfg_section_get_parameter_time (bg_cfg_section_t *section, const char *name, gavl_time_t *value) |
Get an time value from a section. More... | |
void | bg_cfg_section_apply (bg_cfg_section_t *section, const bg_parameter_info_t *parameters, bg_set_parameter_func_t func, void *callback_data) |
Send all parameters to a module. More... | |
void | bg_cfg_section_apply_noterminate (bg_cfg_section_t *section, const bg_parameter_info_t *infos, bg_set_parameter_func_t func, void *callback_data) |
Send all parameters to a module without terminating. More... | |
void | bg_cfg_section_get (bg_cfg_section_t *section, const bg_parameter_info_t *parameters, bg_get_parameter_func_t func, void *callback_data) |
Get parameters from a module. More... | |
int | bg_cfg_section_has_subsection (bg_cfg_section_t *section, const char *name) |
Qurey if a child section is available. More... | |
void | bg_cfg_section_restore_defaults (bg_cfg_section_t *section, const bg_parameter_info_t *info) |
Restore default values of a section. More... | |
Sections are nodes in the configuration tree. They can contain name-value pairs and child sections. Usually, config sections are kept within a configuration registry to store the applications configuration data.
They can, however, be used indepentently from a registry as universal data containers.
typedef struct bg_cfg_section_s bg_cfg_section_t |
Configuration section.
Opaque container for configuration data and child sections
void bg_cfg_section_2_xml | ( | const bg_cfg_section_t * | section, |
xmlNodePtr | xml_section | ||
) |
Convert a configuration section into a libxml2 node.
section | Configuration section |
xml_section | Pointer to the xml node for the section |
See the libxml2 documentation for more infos
void bg_cfg_xml_2_section | ( | xmlDocPtr | xml_doc, |
xmlNodePtr | xml_section, | ||
bg_cfg_section_t * | section | ||
) |
Convert libxml2 node into a configuration section.
xml_doc | Pointer to the xml document |
xml_section | Pointer to the xml node for the section |
section | Configuration section |
See the libxml2 documentation for more infos
void bg_cfg_section_dump | ( | bg_cfg_section_t * | section, |
const char * | filename | ||
) |
Dump a config section to a file.
section | Configuration section |
filename | File to write this to |
Used for debugging
bg_cfg_section_t* bg_cfg_section_find_subsection | ( | bg_cfg_section_t * | section, |
const char * | name | ||
) |
Find a child of a section.
section | A configuration section |
name | name of the subsection |
If the child section does not exist, an empty section is created.
bg_cfg_section_t* bg_cfg_section_create_subsection_at_pos | ( | bg_cfg_section_t * | section, |
int | pos | ||
) |
Create a subsection at the specified position.
section | A configuration section |
pos | Position of the subsection (starting with 0) |
void bg_cfg_section_move_child | ( | bg_cfg_section_t * | section, |
bg_cfg_section_t * | child, | ||
int | pos | ||
) |
Move a subsection to the specified position.
section | A configuration section |
child | Subsection to be moved |
pos | New position of the subsection (starting with 0) |
bg_cfg_section_t* bg_cfg_section_find_subsection_by_index | ( | bg_cfg_section_t * | section, |
int | index | ||
) |
Find a child of a section by index.
section | A configuration section |
index | Index (starting with 0) |
If the child section does not exist, NULL is returned.
bg_cfg_section_t* bg_cfg_section_create | ( | const char * | name | ) |
Create an empty config section.
name | Name |
bg_cfg_section_t* bg_cfg_section_create_from_parameters | ( | const char * | name, |
const bg_parameter_info_t * | parameters | ||
) |
Create a config section from a parameter array.
name | Name |
parameters | A parameter array |
Creates a configuration section from a parameter array. The values in the section are set from the defaults given in the array.
void bg_cfg_section_create_items | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | parameters | ||
) |
Create items from a parameter info.
section | Configuration section |
parameters | A parameter array |
This iterates through parameters and creates all missing entries with the values set to their defaults
void bg_cfg_section_destroy | ( | bg_cfg_section_t * | section | ) |
Destroy a config section.
section | Configuration section |
bg_cfg_section_t* bg_cfg_section_copy | ( | const bg_cfg_section_t * | src | ) |
Duplicate a configuration section.
src | Configuration section |
void bg_cfg_section_transfer | ( | bg_cfg_section_t * | src, |
bg_cfg_section_t * | dst | ||
) |
Set values in a configuration section from another section.
src | Source section |
dst | Destination section |
This function iterates through all entries of src and copies the values to dst. Values, which don't exist in dst, are created. The same is then done for all children of src.
void bg_cfg_section_transfer_children | ( | bg_cfg_section_t * | src, |
bg_cfg_section_t * | dst | ||
) |
Like bg_cfg_section_transfer but acts only on the subsections.
src | Source section |
dst | Destination section |
void bg_cfg_section_add_ref | ( | bg_cfg_section_t * | section, |
bg_cfg_section_t * | ref | ||
) |
Insert a reference to a section as child.
section | Configuration section |
ref | Child section to be added as reference |
const char* bg_cfg_section_get_name | ( | bg_cfg_section_t * | section | ) |
Get the name of a configuration section.
section | Configuration section |
char* bg_cfg_section_get_name_translated | ( | bg_cfg_section_t * | section | ) |
Get the translated name of a configuration section.
section | Configuration section |
The returned string must be freed by the caller
void bg_cfg_section_set_name | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
const char * | gettext_domain, | ||
const char * | gettext_directory | ||
) |
Set the name of a configuration section.
section | Configuration section |
name | The new name |
gettext_domain | First argument for bindtextdomain() |
gettext_directory | Second argument for bindtextdomain() |
void bg_cfg_section_set_parameter | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | info, | ||
const bg_parameter_value_t * | value | ||
) |
Store a value in the section.
section | The configuration section |
info | The parameter destription |
value | The value to be stored |
If the value does not exist in the section, it is created from the parameter description.
int bg_cfg_section_set_parameters_from_string | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | info, | ||
const char * | str | ||
) |
Set values from an option string.
section | The configuration section |
info | The parameter destription |
str | A string describing the values |
This takes a string from the commandline and stores it in the section.
void bg_cfg_section_get_parameter | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | info, | ||
bg_parameter_value_t * | value | ||
) |
Read a value from the section.
section | The configuration section |
info | The parameter destription |
value | The value will be stored here |
If the value does not exist in the section, it is created from the parameter description.
void bg_cfg_section_delete_subsection | ( | bg_cfg_section_t * | section, |
bg_cfg_section_t * | subsection | ||
) |
Delete a subsection.
section | The configuration section |
subsection | The child section to be deleten |
If the subsection if no child of section, this function does nothing.
void bg_cfg_section_delete_subsections | ( | bg_cfg_section_t * | section | ) |
Delete all subsections.
section | The configuration section |
void bg_cfg_section_set_parameter_int | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
int | value | ||
) |
Store an integer value in a section.
section | The configuration section |
name | Name of the entry |
value | Value to be stored |
void bg_cfg_section_set_parameter_float | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
float | value | ||
) |
Store a float value in a section.
section | The configuration section |
name | Name of the entry |
value | Value to be stored |
void bg_cfg_section_set_parameter_string | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
const char * | value | ||
) |
Store a string value in a section.
section | The configuration section |
name | Name of the entry |
value | Value to be stored |
void bg_cfg_section_set_parameter_time | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
gavl_time_t | value | ||
) |
Store a time value in a section.
section | The configuration section |
name | Name of the entry |
value | Value to be stored |
int bg_cfg_section_get_parameter_int | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
int * | value | ||
) |
Get an integer value from a section.
section | The configuration section |
name | Name of the entry |
value | Returns value |
int bg_cfg_section_get_parameter_float | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
float * | value | ||
) |
Get an float value from a section.
section | The configuration section |
name | Name of the entry |
value | Returns value |
int bg_cfg_section_get_parameter_string | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
const char ** | value | ||
) |
Get an string value from a section.
section | The configuration section |
name | Name of the entry |
value | Returns value |
int bg_cfg_section_get_parameter_time | ( | bg_cfg_section_t * | section, |
const char * | name, | ||
gavl_time_t * | value | ||
) |
Get an time value from a section.
section | The configuration section |
name | Name of the entry |
value | Returns value |
void bg_cfg_section_apply | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | parameters, | ||
bg_set_parameter_func_t | func, | ||
void * | callback_data | ||
) |
Send all parameters to a module.
section | The configuration section |
parameters | Parameter array |
func | Function to be called |
callback_data | First argument passed to func |
This function iterates though all parameters and calls func with the stored values. It is the main function to transfer data from the section to a module.
void bg_cfg_section_apply_noterminate | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | infos, | ||
bg_set_parameter_func_t | func, | ||
void * | callback_data | ||
) |
Send all parameters to a module without terminating.
section | The configuration section |
infos | Parameter array |
func | Function to be called |
callback_data | First argument passed to func |
This function works like bg_cfg_section_apply but doesn't call func with a NULL name argument at the end.
void bg_cfg_section_get | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | parameters, | ||
bg_get_parameter_func_t | func, | ||
void * | callback_data | ||
) |
Get parameters from a module.
section | The configuration section |
parameters | Parameter array |
func | Function to be called |
callback_data | First argument passed to func |
This function iterates though all parameters and calls func with the stored values. It is the main function to transfer data from the module to a section. It is used only, if the module has parameters, which are changed internally.
int bg_cfg_section_has_subsection | ( | bg_cfg_section_t * | section, |
const char * | name | ||
) |
Qurey if a child section is available.
section | The configuration section |
name | Name of the child section |
void bg_cfg_section_restore_defaults | ( | bg_cfg_section_t * | section, |
const bg_parameter_info_t * | info | ||
) |
Restore default values of a section.
section | The configuration section |
info | Parameter info |