Macros | |
#define | CFG_APME_INI "apme.ini" |
#define | CFG_SEC_APP "apme" |
#define | CFG_KEYSZ 256 |
Functions | |
static bool | cfg_ini_path (char *inifile, size_t inifile_sz) |
static void | cfg_set_dirty (void) |
bool | cfg_init (void) |
bool | cfg_load (void) |
bool | cfg_store (void) |
void | cfg_periodic (void) |
bool | cfg_set_string (char *section, char *name, char *value) |
bool | cfg_set_int (char *section, char *name, int value) |
bool | cfg_get_string (char *section, char *name, char *value, size_t valuesz) |
Variables | |
static dictionary * | cfg_db = NULL |
static uint64_t | cfg_timestamp = 0 |
#define CFG_APME_INI "apme.ini" |
Configuration file name
#define CFG_KEYSZ 256 |
Maximum CFG key size (section + ':' + name)
#define CFG_SEC_APP "apme" |
The application section string
bool cfg_get_string | ( | char * | section, |
char * | name, | ||
char * | value, | ||
size_t | valuesz | ||
) |
Retrieve a string from the configuration run-time configuration database
[in] | section | The configuration section |
[in] | name | The parameter name |
[out] | value | The buffer that will receive the parameter value |
[in] | valuesz | Maximum size of value |
true | On success |
false | On error |
|
static |
Get the location of the INI file, create it if it does not exist
[out] | inifile | Path to the configuration INI file |
[in] | inifile_sz | Maximum number of bytes available in inifile |
true | On success |
false | On erorr |
bool cfg_init | ( | void | ) |
Initialize the configuration sub-system
bool cfg_load | ( | void | ) |
Load the configuration from the default INI file and initialize the global variables
true | If configuration successfully loaded |
false | If there was an error loading the configuration |
void cfg_periodic | ( | void | ) |
Check the cfg_db status periodically. If it is dirty, and more than 1000ms elapsed since the last update, write the configuration to disk.
|
static |
Mark the current configuration as dirty. Refresh the timestamp, so we delay the write a bit.
bool cfg_set_int | ( | char * | section, |
char * | name, | ||
int | value | ||
) |
Set a the configuration parameter name
in section section
to the value value
[in] | section | The parameter section |
[in] | name | Parameter name |
[in] | value | Parameter value |
true | On success |
false | On errror |
bool cfg_set_string | ( | char * | section, |
char * | name, | ||
char * | value | ||
) |
Set a the configuration parameter name
in section section
to the value value
[in] | section | The parameter section |
[in] | name | Parameter name |
[in] | value | Parameter value |
true | On success |
false | On errror |
bool cfg_store | ( | void | ) |
Save the current run-time configuration to the config file
true | If the configuration was saved successfully |
false | If the configuration was not saved |
|
static |
The configuration database
|
static |
Timestamp of the last poll