Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
struct | CONFIG_FILE |
Structure of a config file. More... | |
struct | CONFIG_FILE_SECTION |
Structure of a config section. More... | |
Macros | |
#define | config_endfor |
Foreach elements of CONFIG_FILE macro END. More... | |
#define | config_foreach(__config, __section_name, __key, __val) |
Foreach elements of CONFIG_FILE macro, i.e config_foreach( config , section , key , val ); config_endfor;. More... | |
#define | CONFIG_SECTION_HASH_TABLE_LEN 16 |
size of the hash table of config sections entries More... | |
#define | MAX_CONFIG_LINE_LEN 1024 |
maximum length of a single config line More... | |
Functions | |
int | destroy_config_file (CONFIG_FILE **cfg_file) |
Destroy a loaded config file. More... | |
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. More... | |
int | get_nb_config_file_sections (CONFIG_FILE *cfg_file, char *section_name) |
Get the number of config file with section_name. More... | |
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. More... | |
CONFIG_FILE * | load_config_file (char *filename, int *errors) |
load a config file More... | |
int | write_config_file (CONFIG_FILE *cfg_file, char *filename) |
write a config file More... | |
struct CONFIG_FILE |
Structure of a config file.
Definition at line 40 of file n_config_file.h.
Data Fields | ||
---|---|---|
char * | filename | |
LIST * | sections |
struct CONFIG_FILE_SECTION |
Structure of a config section.
Definition at line 32 of file n_config_file.h.
Data Fields | ||
---|---|---|
HASH_TABLE * | entries | |
char * | section_name |
#define config_endfor |
Foreach elements of CONFIG_FILE macro END.
Will cause errors if ommitted
Definition at line 80 of file n_config_file.h.
#define config_foreach | ( | __config, | |
__section_name, | |||
__key, | |||
__val | |||
) |
Foreach elements of CONFIG_FILE macro, i.e config_foreach( config , section , key , val ); config_endfor;.
Definition at line 60 of file n_config_file.h.
#define CONFIG_SECTION_HASH_TABLE_LEN 16 |
size of the hash table of config sections entries
Definition at line 29 of file n_config_file.h.
#define MAX_CONFIG_LINE_LEN 1024 |
maximum length of a single config line
Definition at line 27 of file n_config_file.h.
int destroy_config_file | ( | CONFIG_FILE ** | cfg_file | ) |
Destroy a loaded config file.
cfg_file | pointer to a loaded config file to destroy |
Definition at line 540 of file n_config_file.c.
References __n_assert, Free, and list_destroy().
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.
cfg_file | name of config file |
section_name | name of section |
section_position | section number |
entry | entry name |
entry_position | entry number |
Definition at line 490 of file n_config_file.c.
References __n_assert, _nstr, free_nstr, ht_get_ptr(), list_foreach, LOG_DEBUG, n_log, and nstrprintf.
int get_nb_config_file_sections | ( | CONFIG_FILE * | cfg_file, |
char * | section_name | ||
) |
Get the number of config file with section_name.
cfg_file | Config file to process |
section_name | name of sections to search , or NULL to have a count of all available sections |
Definition at line 408 of file n_config_file.c.
References __n_assert, and list_foreach.
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.
cfg_file | Config file to process |
section_name | name of sections to search |
section_position | position of the section if there are multiples same name sections |
entry | name of entry to retrieve |
Definition at line 442 of file n_config_file.c.
References __n_assert, _nstr, free_nstr, ht_get_ptr(), list_foreach, and nstrprintf.
CONFIG_FILE * load_config_file | ( | char * | filename, |
int * | errors | ||
) |
load a config file
filename | Filename of the config file |
errors | pointer to an int which will represent the number of errors encountered when reading config file |
Definition at line 51 of file n_config_file.c.
References __n_assert, _nstr, _str, CONFIG_SECTION_HASH_TABLE_LEN, destroy_config_file_section(), Free, free_no_null(), free_nstr, free_split_result(), ht_get_ptr(), ht_put_ptr(), list_push(), LOG_DEBUG, LOG_ERR, Malloc, MAX_CONFIG_LINE_LEN, n_log, new_generic_list(), new_ht(), npcre_delete(), npcre_match(), npcre_new(), nstrprintf, skipu(), split_count(), str_replace(), and trim_nocopy().
int write_config_file | ( | CONFIG_FILE * | cfg_file, |
char * | filename | ||
) |
write a config file
filename | destination filename |
cfg_file | source config file to write |
Definition at line 368 of file n_config_file.c.
References __n_assert, config_endfor, config_foreach, FreeNoLog, LOG_ERR, and n_log.