![]() |
Arax -8d09c51940345c86062e8ef2427c705ae66e5926
A Runtime Framework for Decoupling Applications from Heterogeneous Accelerators
|
#include <stddef.h>
Go to the source code of this file.
Enumerations | |
enum | utils_config_source { CONFIG_FILE , CONFIG_ENV } |
Functions | |
char * | utils_config_alloc_path (const char *path) |
void | utils_config_free_path (char *path) |
int | utils_config_get_str (char *path, const char *key, char *value, size_t value_size, const char *def_val) |
int | utils_config_get_bool (char *path, const char *key, int *value, int def_val) |
int | utils_config_get_int (char *path, const char *key, int *value, int def_val) |
int | utils_config_get_long (char *path, const char *key, long *value, long def_val) |
int | utils_config_get_size (char *path, const char *key, size_t *value, size_t def_val) |
enum utils_config_source | utils_config_get_source () |
Persistent configuration utility functions.
Configuration file format: Each line(terminated with a newline character
) contains a single key value pair in the following format:
KEY VALUE
The key value can have any printable character except white space, it should not be larger than 32 characters. The value begins after KEY and any whites-pace after it. Value ends at the first newline character.
Definition in file config.h.
enum utils_config_source |
char * utils_config_alloc_path | ( | const char * | path | ) |
Create configuration based on path
NOTE: free returned value with utils_config_free_path().
path
is scanned for the following characters and replaced: ~:Gets replaced with users home path (e.g. /home/user)
path |
Definition at line 94 of file config.c.
References arax_assert, and system_home_path().
Referenced by _arax_init(), arax_clean(), async_meta_init_always(), and async_meta_init_once().
void utils_config_free_path | ( | char * | path | ) |
Free path
allocated with utils_config_alloc_path.
path | Return value of a utils_config_alloc_path invocation. |
Definition at line 128 of file config.c.
Referenced by arax_clean(), arax_exit(), async_meta_init_always(), and async_meta_init_once().
int utils_config_get_bool | ( | char * | path, |
const char * | key, | ||
int * | value, | ||
int | def_val ) |
Get value corresponding to key
as a boolean (0,1)
Will search the path
file for a key/value pair matching the key
. If the value is not found 0 will be returned. If during the search any error occurs, 0 will be returned and a message will be printed on stderr. If the value is found and the value equals to 1 then *value
will be assigned 1, otherwise *value will be set to 0.
path | Config path. |
key | c style string, with the key of interest. |
value | pointer to allocated array of size value_size . |
def_val | Default value in case the key is not found. |
Definition at line 178 of file config.c.
References utils_config_get_int().
Referenced by _arax_init(), and async_meta_init_once().
int utils_config_get_int | ( | char * | path, |
const char * | key, | ||
int * | value, | ||
int | def_val ) |
Get value corresponding to key
as an integer
Will search the path
file for a key/value pair matching the key
. If during the search any error occurs, 0 will be returned and a message will be printed on stderr. If the value is found it will be converted to an integer using atoi() and the result will be assigned to val
. If no value is found val
will be assigned def_val
and 0 will be returned.
path | Config path. |
key | c style string string, with the key of interest. |
value | pointer to allocated array of size value_size . |
def_val | Default value in case the key is not found. |
Definition at line 190 of file config.c.
References utils_config_get_long().
Referenced by utils_config_get_bool().
int utils_config_get_long | ( | char * | path, |
const char * | key, | ||
long * | value, | ||
long | def_val ) |
Get value corresponding to key
as a long
Will search the path
file for a key/value pair matching the key
. If during the search any error occurs, 0 will be returned and a message will be printed on stderr. If the value is found it will be converted to a long using strtol() and the result will be assigned to val
. If no value is found val
will be assigned def_val
and 0 will be returned.
path | Config path. |
key | c style string string, with the key of interest. |
value | pointer to allocated array of size value_size . |
def_val | Default value in case the key is not found. |
Definition at line 206 of file config.c.
References _utils_config_get_str(), and utils_config_write_long().
Referenced by utils_config_get_int(), and utils_config_get_size().
int utils_config_get_size | ( | char * | path, |
const char * | key, | ||
size_t * | value, | ||
size_t | def_val ) |
Get value corresponding to key
as a size_t
Value is retrieved with utils_config_get_long(). If acquired value value is in [SIZE_MAX,0] it is assigned to val
and 1 is returned.
Otherwise 0 is returned and val
is assigned def_val
.
path | Config path. |
key | c style string string, with the key of interest. |
value | pointer to allocated array of size value_size . |
def_val | Default value in case value was not found/appropriate. |
Definition at line 226 of file config.c.
References utils_config_get_long().
Referenced by _arax_init().
enum utils_config_source utils_config_get_source | ( | ) |
Return the current configuration source.
Definition at line 242 of file config.c.
References CONFIG_ENV, CONFIG_FILE, and system_env_var().
Referenced by _arax_init(), conf_get(), and conf_set().
int utils_config_get_str | ( | char * | path, |
const char * | key, | ||
char * | value, | ||
size_t | value_size, | ||
const char * | def_val ) |
Get value corresponding to key
as a string
Will search the path
file for a key/value pair matching the key
. If the value is not found 0 will be returned. If during the search any error occurs, 0 will be returned and a message will be printed on stderr.
path | Config path, returned by utils_config_alloc_path. |
key | c style string string, with the key of interest. |
value | pointer to allocated array of size value_size . |
value_size | Size of value array, in bytes. |
def_val | Default value in case the key is not found. |
Definition at line 164 of file config.c.
References _utils_config_get_str(), and utils_config_write_str().
Referenced by _arax_init(), arax_clean(), and async_meta_init_always().