FOSSology
4.4.0
Open Source License Compliance by Open Source Software
|
FOSSology library to read config file. More...
#include <glib.h>
Go to the source code of this file.
Classes | |
struct | fo_conf |
Macros | |
#define | PARSE_ERROR 1 |
#define | RETRIEVE_ERROR 2 |
Enumerations | |
enum | fo_error_codes { fo_missing_file , fo_missing_group , fo_missing_key , fo_invalid_key , fo_invalid_group , fo_invalid_file , fo_invalid_join , fo_load_config } |
Functions | |
fo_conf * | fo_config_load (char *fname, GError **error) |
Load the configuration information from the provided file. More... | |
void | fo_config_free (fo_conf *conf) |
Frees the memory associated with the internal configuration data structures. More... | |
void | fo_config_join (fo_conf *dst, fo_conf *src, GError **error) |
Takes all groups and key from a fo_conf and adds them to another. More... | |
char * | fo_config_get (fo_conf *conf, const char *group, const char *key, GError **error) |
Gets an element based on its group name and key name. If the group or key is not found, the error object is set and NULL is returned. More... | |
char * | fo_config_get_list (fo_conf *conf, char *group, char *key, int idx, GError **error) |
int | fo_config_is_list (fo_conf *conf, char *group, char *key, GError **error) |
Checks if a particular value is a list or just a normal value. More... | |
int | fo_config_list_length (fo_conf *conf, char *group, char *key, GError **error) |
Gets the length of the list associated with a particular list key. More... | |
char ** | fo_config_group_set (fo_conf *conf, int *length) |
Gets the set of group names. More... | |
char ** | fo_config_key_set (fo_conf *conf, char *group, int *length) |
Gets the set of key names for a particular group. More... | |
int | fo_config_has_group (fo_conf *conf, char *group) |
Checks if the currently parsed configuration file has a specific group. More... | |
int | fo_config_has_key (fo_conf *conf, char *group, char *key) |
Checks if the a specific group in the currently parsed configuration file has a specific key. More... | |
char * | trim (char *ptext) |
Trimming whitespace. More... | |
FOSSology library to read config file.
Definition in file fossconfig.h.
#define PARSE_ERROR 1 |
The parser error domain
Definition at line 16 of file fossconfig.h.
enum fo_error_codes |
Parser error codes
Enumerator | |
---|---|
fo_missing_file | File is missing. |
fo_missing_group | Required group is missing. |
fo_missing_key | Required key is missing. |
fo_invalid_key | Requested key is invalid. |
fo_invalid_group | Requested group is invalid. |
fo_invalid_file | File is invalid. |
fo_invalid_join | Join is invalid. |
fo_load_config | Unable to load config. |
Definition at line 20 of file fossconfig.h.
void fo_config_free | ( | fo_conf * | conf | ) |
Frees the memory associated with the internal configuration data structures.
conf | The fo_conf struct to free |
Definition at line 506 of file fossconfig.c.
char* fo_config_get | ( | fo_conf * | conf, |
const char * | group, | ||
const char * | key, | ||
GError ** | error | ||
) |
Gets an element based on its group name and key name. If the group or key is not found, the error object is set and NULL is returned.
conf | fo_conf object to load from |
group | C string that is the name of the group |
key | C string that is the name of the key for the key/value pair |
Definition at line 336 of file fossconfig.c.
char* fo_config_get_list | ( | fo_conf * | conf, |
char * | group, | ||
char * | key, | ||
int | idx, | ||
GError ** | error | ||
) |
Keys can be associated with multiple values. If this is the case for a particular key, use this function instead of fo_config_get(). This also takes the index of the element in the list. Index work identically to standard c-array indices. It is important to note event though keys will appear as "key[]" in the config file this function just takes "key" as the key
conf | fo_conf object to load from |
group | C string that is the name of the group |
key | C string that is the name of the key for the key/value pair |
idx | The index of the value in the value list |
error | object that allows errors to propagate up the stack |
Definition at line 382 of file fossconfig.c.
char** fo_config_group_set | ( | fo_conf * | conf, |
int * | length | ||
) |
Gets the set of group names.
This function returns an array of strings that the user can iterate to get all group names. The user does not own the return of this function and should not free any of the memory associated with it.
conf | fo_conf object to load from |
length | Pointer allowing the number of groups to be returned |
Definition at line 572 of file fossconfig.c.
int fo_config_has_group | ( | fo_conf * | conf, |
char * | group | ||
) |
Checks if the currently parsed configuration file has a specific group.
conf | fo_conf object to load from |
group | The name of the group to check for |
Definition at line 651 of file fossconfig.c.
int fo_config_has_key | ( | fo_conf * | conf, |
char * | group, | ||
char * | key | ||
) |
Checks if the a specific group in the currently parsed configuration file has a specific key.
group | The group to check for the key |
key | The key to check for |
Definition at line 668 of file fossconfig.c.
int fo_config_is_list | ( | fo_conf * | conf, |
char * | group, | ||
char * | key, | ||
GError ** | error | ||
) |
Checks if a particular value is a list or just a normal value.
conf | fo_conf object to load from |
group | C string name of the group |
key | C string name of the key |
Definition at line 439 of file fossconfig.c.
Takes all groups and key from a fo_conf and adds them to another.
This will iterate across the groups of a configuration and add each to another configuration. This joins the two configurations, making it possible to see multiple configuration files as a single configuration.
dst | The destination for all the information in src |
src | The information that will be duplicated into dst |
error | A location to returns errors from |
Definition at line 531 of file fossconfig.c.
char** fo_config_key_set | ( | fo_conf * | conf, |
char * | group, | ||
int * | length | ||
) |
Gets the set of key names for a particular group.
This returns an array of strings that the user can iterate to get all of the key's for a particular group. This is useful if the keys are not known for a particular group. The array returned by this is owned by the config library and should not be freed by the caller.
conf | fo_conf object to load from |
group | C string name of the group |
length | Pointer allowing the number of keys to be returned |
Definition at line 614 of file fossconfig.c.
int fo_config_list_length | ( | fo_conf * | conf, |
char * | group, | ||
char * | key, | ||
GError ** | error | ||
) |
Gets the length of the list associated with a particular list key.
group | C string name of the group |
key | C string name of the key |
Definition at line 475 of file fossconfig.c.
fo_conf* fo_config_load | ( | char * | rawname, |
GError ** | error | ||
) |
Load the configuration information from the provided file.
If the user has not done a fo_config_free since the last fo_config_load, this will make sure to call that first. In other words, it is assumed that if this is called the configuration file has changed and the user would like to use the new copy.
rawname | The name of the configuration file |
error | Object that allows errors to propagate up the stack |
Definition at line 275 of file fossconfig.c.
char* trim | ( | char * | ptext | ) |
Trimming whitespace.
Will trim the lead/trail space
ptext | The string to trim |
Definition at line 690 of file fossconfig.c.