All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
Configuration Management

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
 

Detailed Description

Macro Definition Documentation

#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

Function Documentation

bool cfg_get_string ( char *  section,
char *  name,
char *  value,
size_t  valuesz 
)

Retrieve a string from the configuration run-time configuration database

Parameters
[in]sectionThe configuration section
[in]nameThe parameter name
[out]valueThe buffer that will receive the parameter value
[in]valueszMaximum size of value
Return values
trueOn success
falseOn error
bool cfg_ini_path ( char *  inifile,
size_t  inifile_sz 
)
static

Get the location of the INI file, create it if it does not exist

Parameters
[out]inifilePath to the configuration INI file
[in]inifile_szMaximum number of bytes available in inifile
Return values
trueOn success
falseOn 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

Return values
trueIf configuration successfully loaded
falseIf 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.

void cfg_set_dirty ( void  )
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

Note
This function will not update the configuration file, use cfg_store() to update it.
Parameters
[in]sectionThe parameter section
[in]nameParameter name
[in]valueParameter value
Return values
trueOn success
falseOn errror
bool cfg_set_string ( char *  section,
char *  name,
char *  value 
)

Set a the configuration parameter name in section section to the value value

Note
This function will not update the configuration file, use cfg_store() to update it.
Parameters
[in]sectionThe parameter section
[in]nameParameter name
[in]valueParameter value
Return values
trueOn success
falseOn errror
bool cfg_store ( void  )

Save the current run-time configuration to the config file

Note
If the configuration was not previously loaded with cfg_load(), nothing will be written.
Return values
trueIf the configuration was saved successfully
falseIf the configuration was not saved

Variable Documentation

dictionary* cfg_db = NULL
static

The configuration database

uint64_t cfg_timestamp = 0
static

Timestamp of the last poll