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 struct janus_config_item {
19  const char *name;
21  const char *value;
23 
25 typedef struct janus_config_category {
27  const char *name;
29  GList *items;
31 
33 typedef struct janus_config {
35  const char *name;
37  GList *items;
39  GList *categories;
40 } janus_config;
41 
42 
46 janus_config *janus_config_parse(const char *config_file);
75 janus_config_item *janus_config_get_item_drilldown(janus_config *config, const char *category, const char *name);
81 janus_config_category *janus_config_add_category(janus_config *config, const char *category);
87 int janus_config_remove_category(janus_config *config, const char *category);
95 janus_config_item *janus_config_add_item(janus_config *config, const char *category, const char *name, const char *value);
101 int janus_config_remove_item(janus_config *config, const char *category, const char *name);
104 void janus_config_print(janus_config *config);
110 int janus_config_save(janus_config *config, const char *folder, const char *filename);
113 void janus_config_destroy(janus_config *config);
114 
115 
116 #endif
const char * value
Value of the item.
Definition: config.h:21
void janus_config_destroy(janus_config *config)
Destroy a configuration container instance.
Definition: config.c:429
janus_config_item * janus_config_add_item(janus_config *config, const char *category, const char *name, const char *value)
Add a new item with the specific name and value to a category, and create the category if it doesn&#39;t ...
Definition: config.c:271
janus_config_category * janus_config_get_category(janus_config *config, const char *name)
Get the category with a specific name from a parsed configuration.
Definition: config.c:200
struct janus_config_category janus_config_category
Configuration category ([category])
Configuration item (name=value)
Definition: config.h:17
struct janus_config janus_config
Configuration container.
int janus_config_remove_item(janus_config *config, const char *category, const char *name)
Remove an existing item with the specific name from a category.
Definition: config.c:303
janus_config_item * janus_config_get_item(janus_config_category *category, const char *name)
Get the item with a specific name from a category of a parsed configuration.
Definition: config.c:221
janus_config_item * janus_config_get_item_drilldown(janus_config *config, const char *category, const char *name)
Get the item with a specific name from a category with a specific name from a parsed configuration...
Definition: config.c:236
const char * name
Name of the category.
Definition: config.h:27
struct janus_config_item janus_config_item
Configuration item (name=value)
Configuration category ([category])
Definition: config.h:25
janus_config * janus_config_parse(const char *config_file)
Method to parse an INI configuration file.
Definition: config.c:77
GList * categories
Linked list of categories category.
Definition: config.h:39
const char * name
Name of the configuration.
Definition: config.h:35
janus_config * janus_config_create(const char *name)
Method to create a new, empty, configuration.
Definition: config.c:186
GList * janus_config_get_items(janus_config_category *category)
Get the list of all items in a category as a GLib linked list.
Definition: config.c:215
int janus_config_remove_category(janus_config *config, const char *category)
Remove an existing category with the specific name.
Definition: config.c:259
Configuration container.
Definition: config.h:33
void janus_config_print(janus_config *config)
Helper method to print a configuration on the standard output.
Definition: config.c:317
const char * name
Name of the item.
Definition: config.h:19
GList * janus_config_get_categories(janus_config *config)
Get the list of all categories from a parsed configuration as a GLib linked list. ...
Definition: config.c:194
GList * items
Linked list of items.
Definition: config.h:29
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:347
janus_config_category * janus_config_add_category(janus_config *config, const char *category)
Add a new category with the specific name.
Definition: config.c:245
GList * items
Linked list of uncategorized items.
Definition: config.h:37