3.7 KiB
config module management
configmodule_interface_t *load_configmodule(int argc, char **argv, uint32_t initflags)
- Parses the command line options, looking for the –O argument
- Loads the
libparams_<configsource>.so(todaylibparams_libconfig.so) shared library - Looks for
config_<config source>_initsymbol and calls it , passing it an array of string corresponding to the « : » separated strings used in the –O option - Looks for
config_<config source>_get,config_<config source>_getlistandconfig_<config source>_endsymbols which are the three functions a configuration library should implement. Get and getlist are mandatory, end is optional. - Stores all the necessary information in a
configmodule_interface_t structure, which is of no use for caller as long as we only use one configuration source. - if the bit CONFIG_ENABLECMDLINEONLY is set in
initflagsthen the module allows parameters to be set only via the command line. This is used for the oai UE.
void end_configmodule(void)
- Free memory which has been allocated by the configuration module for storing parameters values, when
PARAMFLAG_NOFREEflag is not specified in the parameter definition. - Possibly calls the
config_<config source>_endfunction This call should be used when all configurations have been read. The program will still be able to use parameter values allocated by the config module WHEN THEPARAMFLAG_NOFREEflag has been specified in the parameter definition. The config module can be reloaded later in the program (not fully tested as not used today)
Retrieving parameter's values
int config_get(paramdef_t *params,int numparams, char *prefix)
-
Reads as many parameters as described in params, they must all be in the same configuration file section
-
Calls the
config_<config source>_getfunction -
Calls the
config_process_cmdlinefunction -
paramspoints to an array ofparamdef_tstructures which describes the parameters to be read, possibly including a pointer to a checking function.Theparamflagsbit mask can be used to modify how a specific parameter is processed and the same mask is also used by the configuration module to return information about how the parameter has been processed. Bits definitions are described in theparamdef_tstructure description -
numparamsis the number of entries in the params array -
prefixis a character string to be appended to the parameters name, it defines the parameters position in the configuration file hierarchy (the section name in libconfig terminology). -
The returned value is the number of parameters which have been assigned a value or -1 if a severe error occured
int config_libconfig_getlist(paramlist_def_t *ParamList, paramdef_t *params, int numparams, char *prefix)
- Reads multiple occurrences of a parameters array
- Calls the
config_<config source>_getfunction for each list occurrence paramspoints to an array ofparamdef_tstructures which describes the parameters in each occurrence of the listParamListpoints to a structure, whereparamarrayfield points to an array ofparamdef_tstructure, allocated by the function. It is used to return the values of the parameters.- The returned value is the number of occurrences in the list or -1 in case of severe error
utility functions and macros
The configuration module also defines APIs to access the paramdef_t and configmodule_interface_t fields. They are listed in the configuration module include file common/config/config_userapi.h
Configuration module developer main page Configuration module home