Fork me on GitHub
config.h
Go to the documentation of this file.
1 
11 #ifndef _JANUS_CONFIG_H
12 #define _JANUS_CONFIG_H
13 
14 #include <glib.h>
15 
17 typedef enum janus_config_type {
27 
29 typedef struct janus_config_container {
33  const char *name;
35  const char *value;
37  GList *list;
39 
42 
45 
48 
50 typedef struct janus_config {
52  gboolean is_jcfg;
54  const char *name;
56  GList *list;
57 } janus_config;
58 
59 
63 janus_config *janus_config_parse(const char *config_file);
72 void janus_config_print(janus_config *config);
77 void janus_config_print_as(janus_config *config, int level);
83 int janus_config_save(janus_config *config, const char *folder, const char *filename);
87 
92 janus_config_item *janus_config_item_create(const char *name, const char *value);
106 
116  janus_config_container *parent, janus_config_type type, const char *name);
125  janus_config_container *parent, janus_config_type type, const char *name);
132 
146 int janus_config_remove(janus_config *config, janus_config_container *parent, const char *name);
147 
169 
170 #endif
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:478
janus_config_category * janus_config_category_create(const char *name)
Method to create a new janus_config_category instance.
Definition: config.c:342
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:492
void janus_config_destroy(janus_config *config)
Destroy a configuration container instance.
Definition: config.c:693
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:506
janus_config_type type
Whether this is a category, an item or an array.
Definition: config.h:31
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:401
const char * value
Value of the item (item only)
Definition: config.h:35
janus_config_container * janus_config_search(janus_config *config,...)
Helper method to quickly lookup an item, category, or array.
Definition: config.c:411
struct janus_config janus_config
Configuration container.
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:554
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:444
GList * list
Linked list of contained items/categories/arrays (category and array only)
Definition: config.h:37
janus_config_array * janus_config_array_create(const char *name)
Method to create a new janus_config_array instance.
Definition: config.c:350
Category.
Definition: config.h:23
janus_config * janus_config_parse(const char *config_file)
Method to parse an INI configuration file.
Definition: config.c:178
const char * name
Name of the configuration.
Definition: config.h:54
janus_config * janus_config_create(const char *name)
Method to create a new, empty, configuration.
Definition: config.c:318
Array.
Definition: config.h:25
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
Configuration container.
Definition: config.h:50
void janus_config_print(janus_config *config)
Helper method to print a configuration on the standard output.
Definition: config.c:522
janus_config_type
Configuration element type.
Definition: config.h:17
struct janus_config_container janus_config_container
Generic configuration container (can be an item, a category or an array)
Generic configuration container (can be an item, a category or an array)
Definition: config.h:29
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&#39;t exist.
Definition: config.c:406
gboolean is_jcfg
Whether this is a libconfig (jcfg for us) or an INI config.
Definition: config.h:52
GList * list
Linked list of items/categories/arrays.
Definition: config.h:56
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:459
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:641
Plain item.
Definition: config.h:21
const char * name
Name of the item/category/array.
Definition: config.h:33
void janus_config_container_destroy(janus_config_container *container)
Helper method to quickly destroy an item, category or array.
Definition: config.c:358
Anything (just for searches)
Definition: config.h:19