Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
#ifndef JANUS_CONFIG_H
#define JANUS_CONFIG_H
#include <glib.h>
typedef enum janus_config_type {
janus_config_type_any = 1,
janus_config_type_item,
janus_config_type_category,
janus_config_type_array,
} janus_config_type;
typedef struct janus_config_container {
janus_config_type type;
const char *name;
const char *value;
GList *list;
} janus_config_container;
typedef struct janus_config_container janus_config_item;
typedef struct janus_config_container janus_config_category;
typedef struct janus_config_container janus_config_array;
typedef struct janus_config {
gboolean is_jcfg;
const char *name;
GList *list;
} janus_config;
janus_config *janus_config_parse(const char *config_file);
janus_config *janus_config_create(const char *name);
void janus_config_print(janus_config *config);
void janus_config_print_as(janus_config *config, int level);
int janus_config_save(janus_config *config, const char *folder, const char *filename);
void janus_config_destroy(janus_config *config);
janus_config_item *janus_config_item_create(const char *name, const char *value);
janus_config_category *janus_config_category_create(const char *name);
janus_config_array *janus_config_array_create(const char *name);
void janus_config_container_destroy(janus_config_container *container);
janus_config_container *janus_config_get(janus_config *config,
janus_config_container *parent, janus_config_type type, const char *name);
janus_config_container *janus_config_get_create(janus_config *config,
janus_config_container *parent, janus_config_type type, const char *name);
janus_config_container *janus_config_search(janus_config *config, ...);
int janus_config_add(janus_config *config, janus_config_container *parent, janus_config_container *item);
int janus_config_remove(janus_config *config, janus_config_container *parent, const char *name);
GList *janus_config_get_items(janus_config *config, janus_config_container *parent);
GList *janus_config_get_categories(janus_config *config, janus_config_container *parent);
GList *janus_config_get_arrays(janus_config *config, janus_config_container *parent);
#endif
janus_config_array
struct janus_config_container janus_config_array
Configuration array.
Definition config.h:47
janus_config_remove
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.
Definition config.c:466
janus_config_array_create
janus_config_array * janus_config_array_create(const char *name)
Method to create a new janus_config_array instance.
Definition config.c:350
janus_config_get_create
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.
Definition config.c:409
janus_config_get_items
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.
Definition config.c:485
janus_config_get_categories
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.
Definition config.c:499
janus_config_item
struct janus_config_container janus_config_item
Configuration item (defined for backwards compatibility).
Definition config.h:41
janus_config_parse
janus_config * janus_config_parse(const char *config_file)
Method to parse an INI configuration file.
Definition config.c:178
janus_config_get_arrays
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.
Definition config.c:513
janus_config_search
janus_config_container * janus_config_search(janus_config *config,...)
Helper method to quickly lookup an item, category, or array.
Definition config.c:414
janus_config_container_destroy
void janus_config_container_destroy(janus_config_container *container)
Helper method to quickly destroy an item, category or array.
Definition config.c:358
janus_config_add
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.
Definition config.c:447
janus_config_print_as
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 LO...
Definition config.c:561
janus_config_print
void janus_config_print(janus_config *config)
Helper method to print a configuration on the standard output.
Definition config.c:529
janus_config_get
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.
Definition config.c:404
janus_config_item_create
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.
Definition config.c:330
janus_config_type
janus_config_type
Configuration element type.
Definition config.h:17
janus_config_type_array
@ janus_config_type_array
Array.
Definition config.h:25
janus_config_type_any
@ janus_config_type_any
Anything (just for searches).
Definition config.h:19
janus_config_type_item
@ janus_config_type_item
Plain item.
Definition config.h:21
janus_config_type_category
@ janus_config_type_category
Category.
Definition config.h:23
janus_config_save
int janus_config_save(janus_config *config, const char *folder, const char *filename)
Helper method to save a configuration to a file.
Definition config.c:648
janus_config_category_create
janus_config_category * janus_config_category_create(const char *name)
Method to create a new janus_config_category instance.
Definition config.c:342
janus_config_destroy
void janus_config_destroy(janus_config *config)
Destroy a configuration container instance.
Definition config.c:700
janus_config_create
janus_config * janus_config_create(const char *name)
Method to create a new, empty, configuration.
Definition config.c:318
janus_config_category
struct janus_config_container janus_config_category
Configuration category (defined for backwards compatibility).
Definition config.h:44
janus_config_container
Generic configuration container (can be an item, a category or an array).
Definition config.h:29
janus_config_container::type
janus_config_type type
Whether this is a category, an item or an array.
Definition config.h:31
janus_config_container::value
const char * value
Value of the item (item only).
Definition config.h:35
janus_config_container::list
GList * list
Linked list of contained items/categories/arrays (category and array only).
Definition config.h:37
janus_config_container::name
const char * name
Name of the item/category/array.
Definition config.h:33
janus_config
Configuration container.
Definition config.h:50
janus_config::is_jcfg
gboolean is_jcfg
Whether this is a libconfig (jcfg for us) or an INI config.
Definition config.h:52
janus_config::list
GList * list
Linked list of items/categories/arrays.
Definition config.h:56
janus_config::name
const char * name
Name of the configuration.
Definition config.h:54