Nilorea Library config api test.
int main( int argc, char *argv[] )
{
if( argc < 2 )
{
n_log(
LOG_ERR,
"Not enough arguments. Use ex_configfile file" );
exit( 1 );
}
int errors = 0 ;
if( !config )
{
n_log(
LOG_ERR,
"Unable to load config file from %s", argv[ 1 ] );
exit( 1 );
}
if( errors != 0 )
{
n_log(
LOG_ERR,
"There were %d errors in %s. Check the logs !", errors, argv[ 1 ] );
}
for( int it = 0 ; it < nb ; it++ )
{
char *value = NULL ;
n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"refresh_interval:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"cache_file_swp:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"cache_refresh_interval:%s", (value!=NULL)?value:
"NULL" );
}
for( int it = 0 ; it < nb ; it++ )
{
char *value = NULL ;
n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"refresh_interval:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"cache_file_swp:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"cache_refresh_interval:%s", (value!=NULL)?value:
"NULL" );
}
for( int it = 0 ; it < nb ; it++ )
{
char *value = NULL ;
n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"command_timeout:%s", (value!=NULL)?value:
"NULL" );
}
for( int it = 0 ; it < nb ; it++ )
{
char *value = NULL ;
n_log(
LOG_INFO,
"check_interval:%s", (value!=NULL)?value:
"NULL" );
n_log(
LOG_INFO,
"command_timeout:%s", (value!=NULL)?value:
"NULL" );
for( int it1 = 0 ; it1 < nb_cmd ; it1 ++ )
{
}
}
char *section_name = NULL, *key=NULL, *val = NULL ;
{
}
exit( 0 );
}
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.