3.8 KiB
3.8 KiB
configmodule_interface_t *load_configmodule(int argc, char **argv)
- 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.
void End_configmodule(void)
- Free memory which has been allocated by the configuration module since its initialization.
- Possibly calls the
config_<config source>_endfunction
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. The following bits can possibly be set in theparamflagsmask before calling
PARAMFLAG_MANDATORY: -1 is returned if the parameter is not explicitly defined in the config source.PARAMFLAG_DISABLECMDLINE: parameter cannot be modified via the command linePARAMFLAG_DONOTREAD: ignore the parameter, can be used at run-time, to alter a pre-definedparamdef_tarray which is used in severalconfig_getor/andconfig_getlistcalls.PARAMFLAG_NOFREE: do not free the memory possibly allocated by the config module to store the value of the parameter. Default behavior is for the config module to free the memory it has allocated when theconfig_endfunction is called.PARAMFLAG_BOOL: Only relevant for integer types. tell the config module that when processing the command line, the corresponding option can be specified without any arggument and that in this case it must set the value to 1.
paramsis also used as an output parameter,< XXX >ptr >field is used by the config module to store the value it has read. The following bits can possibly be set in theparamflagsmask after the call:PARAMFLAG_MALLOCINCONFIG: memory has been allocated for the< XXX >ptr >fieldPARAMFLAG_PARAMSET: parameter has been found in the config source, it is not set to default value.PARAMFLAG_PARAMSET: parameter has been set to its default value
numparamsis the number of entries in the params arrayprefixis 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
Configuration module developer main page
Configuration module home