Configuration files parsing. More...
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <errno.h>#include <libgen.h>#include <libconfig.h>#include "config.h"#include "debug.h"#include "utils.h"
Macros | |
| #define | JANUS_CONFIG_INDENT 4 |
Functions | |
| janus_config * | janus_config_parse (const char *config_file) |
| Method to parse an INI configuration file. | |
| janus_config * | janus_config_create (const char *name) |
| Method to create a new, empty, configuration. | |
| janus_config_item * | janus_config_item_create (const char *name, const char *value) |
| Method to create a new janus_config_item instance from name and value. | |
| janus_config_category * | janus_config_category_create (const char *name) |
| Method to create a new janus_config_category instance. | |
| janus_config_array * | janus_config_array_create (const char *name) |
| Method to create a new janus_config_array instance. | |
| void | janus_config_container_destroy (janus_config_container *container) |
| Helper method to quickly destroy an item, category or array. | |
| janus_config_container * | janus_config_get (janus_config *config, janus_config_container *parent, janus_config_type type, const char *name) |
| Helper method to quickly get an item, category, or array. | |
| janus_config_container * | janus_config_get_create (janus_config *config, janus_config_container *parent, janus_config_type type, const char *name) |
| Same as janus_config_get, but creates the element if it doesn't exist. | |
| janus_config_container * | janus_config_search (janus_config *config,...) |
| Helper method to quickly lookup an item, category, or array. | |
| int | janus_config_add (janus_config *config, janus_config_container *container, janus_config_container *item) |
| Add an item/category/array instance to a category or array. | |
| int | janus_config_remove (janus_config *config, janus_config_container *container, const char *name) |
| Remove an existing item with the specific name from a category/array. | |
| GList * | janus_config_get_items (janus_config *config, janus_config_container *parent) |
| Helper method to return the list of plain items, either in root or from a parent. | |
| GList * | janus_config_get_categories (janus_config *config, janus_config_container *parent) |
| Helper method to return the list of categories, either in root or from a parent. | |
| GList * | janus_config_get_arrays (janus_config *config, janus_config_container *parent) |
| Helper method to return the list of arrays, either in root or from a parent. | |
| void | janus_config_print (janus_config *config) |
| Helper method to print a configuration on the standard output. | |
| void | janus_config_print_as (janus_config *config, int level) |
| Helper method to print a configuration on the standard output using a different logging level than LOG_VERB. | |
| gboolean | janus_config_save (janus_config *config, const char *folder, const char *filename) |
| Helper method to save a configuration to a file. | |
| void | janus_config_destroy (janus_config *config) |
| Destroy a configuration container instance. | |
Configuration files parsing.
Implementation of a parser of INI and libconfig configuration files.
| #define JANUS_CONFIG_INDENT 4 |
| int janus_config_add | ( | janus_config * | config, |
| janus_config_container * | parent, | ||
| janus_config_container * | item ) |
Add an item/category/array instance to a category or array.
| [in] | config | The configuration instance |
| [in] | parent | The category or array to add the item to, if any |
| [in] | item | The item/category/array to add |
| janus_config_array * janus_config_array_create | ( | const char * | name | ) |
Method to create a new janus_config_array instance.
| [in] | name | Name to give to the array |
| janus_config_category * janus_config_category_create | ( | const char * | name | ) |
Method to create a new janus_config_category instance.
| [in] | name | Name to give to the category |
| void janus_config_container_destroy | ( | janus_config_container * | container | ) |
Helper method to quickly destroy an item, category or array.
| [in] | container | The item/category/array to destroy |
| janus_config * janus_config_create | ( | const char * | name | ) |
Method to create a new, empty, configuration.
| [in] | name | Name to give to the configuration |
| void janus_config_destroy | ( | janus_config * | config | ) |
Destroy a configuration container instance.
| [in] | config | The configuration to destroy |
| janus_config_container * janus_config_get | ( | janus_config * | config, |
| janus_config_container * | parent, | ||
| janus_config_type | type, | ||
| const char * | name ) |
Helper method to quickly get an item, category, or array.
| [in] | config | The configuration instance |
| [in] | parent | The parent container (category or array), if any |
| [in] | type | The type of container to look for |
| [in] | name | The name of the item/category/array to look for |
| GList * janus_config_get_arrays | ( | janus_config * | config, |
| janus_config_container * | parent ) |
Helper method to return the list of arrays, either in root or from a parent.
| [in] | config | The configuration instance |
| [in] | parent | The parent container (category or array), if any |
| GList * janus_config_get_categories | ( | janus_config * | config, |
| janus_config_container * | parent ) |
Helper method to return the list of categories, either in root or from a parent.
| [in] | config | The configuration instance |
| [in] | parent | The parent container (category or array), if any |
| janus_config_container * janus_config_get_create | ( | janus_config * | config, |
| janus_config_container * | parent, | ||
| janus_config_type | type, | ||
| const char * | name ) |
Same as janus_config_get, but creates the element if it doesn't exist.
| [in] | config | The configuration instance |
| [in] | parent | The parent container (category or array), if any |
| [in] | type | The type of container to look for |
| [in] | name | The name of the item/category/array to look for |
| GList * janus_config_get_items | ( | janus_config * | config, |
| janus_config_container * | parent ) |
Helper method to return the list of plain items, either in root or from a parent.
| [in] | config | The configuration instance |
| [in] | parent | The parent container (category or array), if any |
| janus_config_item * janus_config_item_create | ( | const char * | name, |
| const char * | value ) |
Method to create a new janus_config_item instance from name and value.
| [in] | name | Name to give to the item |
| [in] | value | Value of the item (optional) |
| janus_config * janus_config_parse | ( | const char * | config_file | ) |
Method to parse an INI configuration file.
| [in] | config_file | Path to the configuration file |
| void janus_config_print | ( | janus_config * | config | ) |
Helper method to print a configuration on the standard output.
| [in] | config | The configuration to print |
| void janus_config_print_as | ( | janus_config * | config, |
| int | level ) |
Helper method to print a configuration on the standard output using a different logging level than LOG_VERB.
| [in] | config | The configuration to print |
| [in] | level | The debugging level to use |
| int janus_config_remove | ( | janus_config * | config, |
| janus_config_container * | parent, | ||
| const char * | name ) |
Remove an existing item with the specific name from a category/array.
| [in] | config | The configuration instance |
| [in] | parent | The category/array to remove the item from, if any |
| [in] | name | The name of the item/category/array to remove |
| gboolean janus_config_save | ( | janus_config * | config, |
| const char * | folder, | ||
| const char * | filename ) |
Helper method to save a configuration to a file.
| [in] | config | The configuration to save |
| [in] | folder | The folder the file should be saved to |
| [in] | filename | The file name, extension included (should be .jcfg, or .cfg for legacy INI files) |
| janus_config_container * janus_config_search | ( | janus_config * | config, |
| ... ) |
Helper method to quickly lookup an item, category, or array.
| [in] | config | The configuration instance |