9int main(
int argc,
char *argv[] )
14 n_log(
LOG_ERR,
"Not enough arguments. Use ex_configfile file" );
21 n_log(
LOG_ERR,
"Unable to load config file from %s", argv[ 1 ] );
26 n_log(
LOG_ERR,
"There were %d errors in %s. Check the logs !", errors, argv[ 1 ] );
31 for(
int it = 0 ; it < nb ; it++ )
36 n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
38 n_log(
LOG_INFO,
"refresh_interval:%s", (value!=NULL)?value:
"NULL" );
40 n_log(
LOG_INFO,
"cache_file:%s", (value!=NULL)?value:
"NULL" );
42 n_log(
LOG_INFO,
"cache_file_swp:%s", (value!=NULL)?value:
"NULL" );
44 n_log(
LOG_INFO,
"cache_refresh_interval:%s", (value!=NULL)?value:
"NULL" );
49 for(
int it = 0 ; it < nb ; it++ )
54 n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
56 n_log(
LOG_INFO,
"refresh_interval:%s", (value!=NULL)?value:
"NULL" );
58 n_log(
LOG_INFO,
"cache_file:%s", (value!=NULL)?value:
"NULL" );
60 n_log(
LOG_INFO,
"cache_file_swp:%s", (value!=NULL)?value:
"NULL" );
62 n_log(
LOG_INFO,
"cache_refresh_interval:%s", (value!=NULL)?value:
"NULL" );
67 for(
int it = 0 ; it < nb ; it++ )
76 n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
80 n_log(
LOG_INFO,
"command_timeout:%s", (value!=NULL)?value:
"NULL" );
85 for(
int it = 0 ; it < nb ; it++ )
94 n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
96 n_log(
LOG_INFO,
"command_timeout:%s", (value!=NULL)?value:
"NULL" );
98 for(
int it1 = 0 ; it1 < nb_cmd ; it1 ++ )
106 char *section_name = NULL, *key=NULL, *val = NULL ;
CONFIG_FILE * load_config_file(char *filename, int *errors)
load a config file
char * get_config_section_value(CONFIG_FILE *cfg_file, char *section_name, int section_position, char *entry, int entry_position)
Function to parse sections and get entries values.
#define config_endfor
Foreach elements of CONFIG_FILE macro END.
int destroy_config_file(CONFIG_FILE **cfg_file)
Destroy a loaded config file.
#define config_foreach(__config, __section_name, __key, __val)
Foreach elements of CONFIG_FILE macro, i.e config_foreach( config , section , key ,...
int get_nb_config_file_sections(CONFIG_FILE *cfg_file, char *section_name)
Get the number of config file with section_name.
int get_nb_config_file_sections_entries(CONFIG_FILE *cfg_file, char *section_name, int section_position, char *entry)
Get the number of config file with section_name.
Structure of a config file.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
#define LOG_INFO
informational
Config file reading and writing.