27#ifndef __N_CONFIG_FILE__
28#define __N_CONFIG_FILE__
44#define MAX_CONFIG_LINE_LEN 1024
46#define CONFIG_SECTION_HASH_TABLE_LEN 16
78#define config_foreach(__config, __section_name, __key, __val) \
79 if (!__config || !__config->sections) { \
80 n_log(LOG_ERR, "No config file for %s", #__config); \
82 list_foreach(listnode, __config->sections) { \
83 CONFIG_FILE_SECTION* __section = (CONFIG_FILE_SECTION*)listnode->ptr; \
84 __section_name = __section->section_name; \
85 ht_foreach(entry, __section->entries) { \
86 HASH_NODE* htnode = (HASH_NODE*)entry->ptr; \
87 if (htnode && htnode->data.ptr) { \
88 __key = htnode->key; \
89 __val = htnode->data.ptr;
92#define config_endfor \
HASH_TABLE * entries
hash table of key-value entries
char * section_name
name of the config section
char * filename
path and name of the config file
LIST * sections
list of CONFIG_FILE_SECTION
CONFIG_FILE * load_config_file(char *filename, int *errors)
load a config from a file
int write_config_file(CONFIG_FILE *cfg_file, char *filename)
write file from config
int destroy_config_file(CONFIG_FILE **cfg_file)
destroy a loaded config
char * get_config_section_value(CONFIG_FILE *cfg_file, char *section_name, size_t section_position, char *entry, size_t entry_position)
get a loaded config value
size_t get_nb_config_file_sections(CONFIG_FILE *cfg_file, const char *section_name)
get the number of section for section name
size_t get_nb_config_file_sections_entries(CONFIG_FILE *cfg_file, const char *section_name, size_t section_position, char *entry)
get the number of entries for section_name/entry
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.