DTS Application Library
0.2.3
Application library containing referenced objects and interfaces to common libraries
|
Reads a ini config file into grouped hashed buckets. More...
Files | |
file | config.c |
INI style config file interface. | |
Data Structures | |
struct | config_category |
Configuration file category. More... | |
struct | config_file |
Config file. More... | |
struct | config_entry |
Configuration category entry. More... | |
Typedefs | |
typedef void(* | config_filecb )(struct bucket_list *, const char *, const char *) |
Calback used when processing config files. More... | |
typedef void(* | config_catcb )(struct bucket_list *, const char *) |
Calback used when processing a category. More... | |
typedef void(* | config_entrycb )(const char *, const char *) |
Callback used when processing a entry. More... | |
Functions | |
void | unrefconfigfiles (void) |
Empty out and unreference config files. More... | |
int | process_config (const char *configname, const char *configfile) |
Process a configfile into buckets. More... | |
struct bucket_list * | get_config_file (const char *configname) |
Returns the catergories bucket for a config file. More... | |
struct bucket_list * | get_config_category (const char *configname, const char *category) |
Return a single category. More... | |
struct bucket_list * | get_category_next (struct bucket_loop *cloop, char *name, int len) |
Iterate through categories returning the entries bucket. More... | |
struct bucket_loop * | get_category_loop (const char *configname) |
Return a bucket loop to allow iterating over categories. More... | |
void | config_entry_callback (struct bucket_list *entries, config_entrycb entry_cb) |
Callback Wraper that iterates through all items calling a callback for each item. More... | |
void | config_cat_callback (struct bucket_list *categories, config_catcb cat_cb) |
Callback wrapper that iterates through categories calling a callback on each category. More... | |
void | config_file_callback (config_filecb file_cb) |
Callback wrapper to iterate over all configfiles calling a callback on each file. More... | |
struct config_entry * | get_config_entry (struct bucket_list *categories, const char *item) |
Find the entry in a config file. More... | |
Reads a ini config file into grouped hashed buckets.
typedef void(* config_catcb)(struct bucket_list *, const char *) |
typedef void(* config_entrycb)(const char *, const char *) |
typedef void(* config_filecb)(struct bucket_list *, const char *, const char *) |
void config_cat_callback | ( | struct bucket_list * | categories, |
config_catcb | cat_cb | ||
) |
Callback wrapper that iterates through categories calling a callback on each category.
categories | Bucketlist from a config file containing categories. |
cat_cb | Callback to call on each category. |
Definition at line 383 of file config.c.
References bucketlist_callback().
void config_entry_callback | ( | struct bucket_list * | entries, |
config_entrycb | entry_cb | ||
) |
Callback Wraper that iterates through all items calling a callback for each item.
entries | Bucketlist of entries (from a category). |
entry_cb | The callback to call on each entry. |
Definition at line 365 of file config.c.
References bucketlist_callback().
void config_file_callback | ( | config_filecb | file_cb | ) |
Callback wrapper to iterate over all configfiles calling a callback on each file.
file_cb | Callback to call. |
Definition at line 400 of file config.c.
References bucketlist_callback().
struct bucket_loop* get_category_loop | ( | const char * | configname | ) |
Return a bucket loop to allow iterating over categories.
configname | Name assigned to the config file when calling process_config(). |
Definition at line 341 of file config.c.
References get_config_file(), init_bucket_loop(), and objunref().
struct bucket_list* get_category_next | ( | struct bucket_loop * | cloop, |
char * | name, | ||
int | len | ||
) |
Iterate through categories returning the entries bucket.
As well as the entries returned name will be filled upto len bytes with the category name
cloop | Iterator created with get_category_loop. |
name | Buffer where the category name is copied. |
len | limit the number of characters copied to len. |
Definition at line 317 of file config.c.
References config_category::entries, config_category::name, next_bucket_loop(), objref(), objunref(), and strlenzero().
struct bucket_list* get_config_category | ( | const char * | configname, |
const char * | category | ||
) |
Return a single category.
If category is NULL the category "default" is returned.
configname | Name assigned to the config file when calling process_config(). |
category | Configuration category to return or "default" if NULL. |
Definition at line 286 of file config.c.
References bucket_list_find_key(), config_category::entries, get_config_file(), objref(), and objunref().
struct config_entry* get_config_entry | ( | struct bucket_list * | categories, |
const char * | item | ||
) |
Find the entry in a config file.
categories | Categories bucketlist. |
item | Item to search for. |
Definition at line 408 of file config.c.
References bucket_list_find_key().
struct bucket_list* get_config_file | ( | const char * | configname | ) |
Returns the catergories bucket for a config file.
configname | Name assigned to the config file when calling process_config(). |
Definition at line 263 of file config.c.
References bucket_list_find_key(), config_file::cat, objref(), and objunref().
Referenced by get_category_loop(), and get_config_category().
int process_config | ( | const char * | configname, |
const char * | configfile | ||
) |
Process a configfile into buckets.
configname | Name of the configuration. |
configfile | File to load into this configuration container. |
Definition at line 197 of file config.c.
References addtobucket(), config_file::cat, config_file::filepath, objunref(), strlenzero(), and trim().
void unrefconfigfiles | ( | void | ) |
Empty out and unreference config files.
Definition at line 78 of file config.c.
References objunref().
Referenced by framework_init().