8#ifndef __N_CONFIG_FILE__
9#define __N_CONFIG_FILE__
27#define MAX_CONFIG_LINE_LEN 1024
29#define CONFIG_SECTION_HASH_TABLE_LEN 16
60#define config_foreach( __config , __section_name , __key , __val ) \
61 if( !__config || !__config -> sections ) \
63 n_log( LOG_ERR , "No config file for %s" , #__config ); \
67 list_foreach( listnode , __config -> sections ) \
69 CONFIG_FILE_SECTION *__section = (CONFIG_FILE_SECTION *)listnode -> ptr ; \
70 __section_name = __section -> section_name ; \
71 ht_foreach( entry , __section -> entries ) \
73 HASH_NODE *htnode = (HASH_NODE *)entry -> ptr ; \
74 if( htnode && htnode -> data . ptr ) \
76 __key = htnode -> key ; \
77 __val = htnode -> data . ptr ;
80#define config_endfor \
CONFIG_FILE * load_config_file(char *filename, int *errors)
load a config file
int write_config_file(CONFIG_FILE *cfg_file, char *filename)
write 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.
int destroy_config_file(CONFIG_FILE **cfg_file)
Destroy a loaded config file.
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.
Structure of a config section.
structure of a hash table
Structure of a generic LIST container.
Hash functions and table.
N_STR and string function declaration.