Configuration files parsing. More...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "config.h"
#include "debug.h"
#include "utils.h"
Functions | |
janus_config * | janus_config_parse (const char *config_file) |
Method to parse an INI configuration file. More... | |
janus_config * | janus_config_create (const char *name) |
Method to create a new, empty, configuration. More... | |
GList * | janus_config_get_categories (janus_config *config) |
Get the list of all categories from a parsed configuration as a GLib linked list. More... | |
janus_config_category * | janus_config_get_category (janus_config *config, const char *name) |
Get the category with a specific name from a parsed configuration. More... | |
GList * | janus_config_get_items (janus_config_category *category) |
Get the list of all items in a category as a GLib linked list. More... | |
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. More... | |
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. More... | |
janus_config_category * | janus_config_add_category (janus_config *config, const char *category) |
Add a new category with the specific name. More... | |
int | janus_config_remove_category (janus_config *config, const char *category) |
Remove an existing category with the specific name. More... | |
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't exist. More... | |
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. More... | |
void | janus_config_print (janus_config *config) |
Helper method to print a configuration on the standard output. More... | |
gboolean | janus_config_save (janus_config *config, const char *folder, const char *filename) |
Helper method to save a configuration to a file. More... | |
void | janus_config_destroy (janus_config *config) |
Destroy a configuration container instance. More... | |
Configuration files parsing.
Implementation of a parser of INI configuration files.
janus_config_category* janus_config_add_category | ( | janus_config * | config, |
const char * | category | ||
) |
Add a new category with the specific name.
[in] | config | The configuration container |
[in] | category | The category to create |
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't exist.
[in] | config | The configuration container |
[in] | category | The category to add the item to, and to create if it doesn't exist |
[in] | name | The name of the item |
[in] | value | The value of the item |
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 |
GList* janus_config_get_categories | ( | janus_config * | config | ) |
Get the list of all categories from a parsed configuration as a GLib linked list.
[in] | config | The configuration container |
janus_config_category* janus_config_get_category | ( | janus_config * | config, |
const char * | name | ||
) |
Get the category with a specific name from a parsed configuration.
[in] | config | The configuration container |
[in] | name | The name of the category |
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.
[in] | category | The configuration category |
[in] | name | The name of the item |
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.
[in] | config | The configuration container |
[in] | category | The name of the configuration category |
[in] | name | The name of the item |
GList* janus_config_get_items | ( | janus_config_category * | category | ) |
Get the list of all items in a category as a GLib linked list.
[in] | category | The configuration category |
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 |
int janus_config_remove_category | ( | janus_config * | config, |
const char * | category | ||
) |
Remove an existing category with the specific name.
[in] | config | The configuration container |
[in] | category | The category to remove |
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.
[in] | config | The configuration container |
[in] | category | The category to remove the item from |
[in] | name | The name of the item |
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 sav |
[in] | folder | The folder the file should be saved to |
[in] | filename | The file name, extension included (should be .cfg) |