FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
fossconfig.h
Go to the documentation of this file.
1 /* **************************************************************
2  Copyright (C) 2011 Hewlett-Packard Development Company, L.P.
3 
4  This program is free software; you can redistribute it and/or
5  modify it under the terms of the GNU General Public License
6  version 2 as published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 
17  ************************************************************** */
22 #ifndef FOSSCONFIG_H_INCLUDE
23 #define FOSSCONFIG_H_INCLUDE
24 
25 #include <glib.h>
26 
28 #define PARSE_ERROR 1
29 #define RETRIEVE_ERROR 2
30 
32 typedef enum
33 {
43 
45 typedef struct
46 {
47  GTree* group_map;
48  GTree* key_sets;
49  char** group_set;
50  int n_groups;
51 } fo_conf;
52 
53 fo_conf* fo_config_load(char* fname, GError** error);
55 void fo_config_join(fo_conf* dst, fo_conf* src, GError** error);
56 
57 char* fo_config_get(fo_conf* conf, const char* group, const char* key, GError** error);
58 char* fo_config_get_list(fo_conf* conf, char* group, char* key, int idx, GError** error);
59 int fo_config_is_list(fo_conf* conf, char* group, char* key, GError** error);
60 int fo_config_list_length(fo_conf* conf, char* group, char* key, GError** error);
61 
62 char** fo_config_group_set(fo_conf* conf, int* length);
63 char** fo_config_key_set(fo_conf* conf, char* group, int* length);
64 int fo_config_has_group(fo_conf* conf, char* group);
65 int fo_config_has_key(fo_conf* conf, char* group, char* key);
66 char* trim(char* ptext);
67 
68 #endif /* FOSSCONFIG_H_INCLUDE */
char * fo_config_get_list(fo_conf *conf, char *group, char *key, int idx, GError **error)
Definition: fossconfig.c:387
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:695
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.
Definition: fossconfig.c:480
char ** group_set
Array of groups.
Definition: fossconfig.h:49
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.
Definition: fossconfig.c:536
GTree * key_sets
Tree of sets of keys.
Definition: fossconfig.h:48
GTree * group_map
Tree of groups in conf file.
Definition: fossconfig.h:47
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.
Definition: fossconfig.c:444
File is missing.
Definition: fossconfig.h:34
File is invalid.
Definition: fossconfig.h:39
void fo_config_free(fo_conf *conf)
Frees the memory associated with the internal configuration data structures.
Definition: fossconfig.c:511
char ** fo_config_key_set(fo_conf *conf, char *group, int *length)
Gets the set of key names for a particular group.
Definition: fossconfig.c:619
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.
Definition: fossconfig.c:341
fo_conf * conf
The loaded configuration data.
Definition: fo_cli.c:50
Required group is missing.
Definition: fossconfig.h:35
Requested group is invalid.
Definition: fossconfig.h:38
char ** fo_config_group_set(fo_conf *conf, int *length)
Gets the set of group names.
Definition: fossconfig.c:577
Required key is missing.
Definition: fossconfig.h:36
Requested key is invalid.
Definition: fossconfig.h:37
int n_groups
Number of groups.
Definition: fossconfig.h:50
fo_conf * fo_config_load(char *fname, GError **error)
Load the configuration information from the provided file.
Definition: fossconfig.c:280
fo_error_codes
Definition: fossconfig.h:32
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...
Definition: fossconfig.c:673
int fo_config_has_group(fo_conf *conf, char *group)
Checks if the currently parsed configuration file has a specific group.
Definition: fossconfig.c:656
Unable to load config.
Definition: fossconfig.h:41
Join is invalid.
Definition: fossconfig.h:40