FOSSology  4.4.0
Open Source License Compliance by Open Source Software
fossconfig.h
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: GPL-2.0-only
5 */
10 #ifndef FOSSCONFIG_H_INCLUDE
11 #define FOSSCONFIG_H_INCLUDE
12 
13 #include <glib.h>
14 
16 #define PARSE_ERROR 1
17 #define RETRIEVE_ERROR 2
18 
20 typedef enum
21 {
31 
33 typedef struct
34 {
35  GTree* group_map;
36  GTree* key_sets;
37  char** group_set;
38  int n_groups;
39 } fo_conf;
40 
41 fo_conf* fo_config_load(char* fname, GError** error);
43 void fo_config_join(fo_conf* dst, fo_conf* src, GError** error);
44 
45 char* fo_config_get(fo_conf* conf, const char* group, const char* key, GError** error);
46 char* fo_config_get_list(fo_conf* conf, char* group, char* key, int idx, GError** error);
47 int fo_config_is_list(fo_conf* conf, char* group, char* key, GError** error);
48 int fo_config_list_length(fo_conf* conf, char* group, char* key, GError** error);
49 
50 char** fo_config_group_set(fo_conf* conf, int* length);
51 char** fo_config_key_set(fo_conf* conf, char* group, int* length);
52 int fo_config_has_group(fo_conf* conf, char* group);
53 int fo_config_has_key(fo_conf* conf, char* group, char* key);
54 char* trim(char* ptext);
55 
56 #endif /* FOSSCONFIG_H_INCLUDE */
fo_conf * conf
The loaded configuration data.
Definition: fo_cli.c:39
char * fo_config_get_list(fo_conf *conf, char *group, char *key, int idx, GError **error)
Definition: fossconfig.c:382
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:475
char * trim(char *ptext)
Trimming whitespace.
Definition: fossconfig.c:690
void fo_config_free(fo_conf *conf)
Frees the memory associated with the internal configuration data structures.
Definition: fossconfig.c:506
fo_conf * fo_config_load(char *fname, GError **error)
Load the configuration information from the provided file.
Definition: fossconfig.c:275
char ** fo_config_group_set(fo_conf *conf, int *length)
Gets the set of group names.
Definition: fossconfig.c:572
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,...
Definition: fossconfig.c:336
fo_error_codes
Definition: fossconfig.h:21
@ fo_load_config
Unable to load config.
Definition: fossconfig.h:29
@ fo_missing_key
Required key is missing.
Definition: fossconfig.h:24
@ fo_invalid_join
Join is invalid.
Definition: fossconfig.h:28
@ fo_invalid_file
File is invalid.
Definition: fossconfig.h:27
@ fo_missing_file
File is missing.
Definition: fossconfig.h:22
@ fo_invalid_group
Requested group is invalid.
Definition: fossconfig.h:26
@ fo_missing_group
Required group is missing.
Definition: fossconfig.h:23
@ fo_invalid_key
Requested key is invalid.
Definition: fossconfig.h:25
int fo_config_has_group(fo_conf *conf, char *group)
Checks if the currently parsed configuration file has a specific group.
Definition: fossconfig.c:651
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:439
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:531
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:614
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:668
char ** group_set
Array of groups.
Definition: fossconfig.h:37
int n_groups
Number of groups.
Definition: fossconfig.h:38
GTree * group_map
Tree of groups in conf file.
Definition: fossconfig.h:35
GTree * key_sets
Tree of sets of keys.
Definition: fossconfig.h:36