![]() |
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. | |
#define | config_foreach(__config, __section_name, __key, __val) |
Foreach elements of CONFIG_FILE macro, i.e config_foreach( config , section , key , val ); config_endfor;. | |
#define | CONFIG_SECTION_HASH_TABLE_LEN 16 |
size of the hash table of config sections entries | |
#define | MAX_CONFIG_LINE_LEN 1024 |
maximum length of a single config line | |
Functions | |
int | destroy_config_file (CONFIG_FILE **cfg_file) |
Destroy a loaded config file. | |
char * | get_config_section_value (CONFIG_FILE *cfg_file, char *section_name, size_t section_position, char *entry, size_t entry_position) |
Function to parse sections and get entries values. | |
size_t | get_nb_config_file_sections (CONFIG_FILE *cfg_file, char *section_name) |
Get the number of config file with section_name. | |
size_t | get_nb_config_file_sections_entries (CONFIG_FILE *cfg_file, char *section_name, size_t section_position, char *entry) |
Get the number of config file with section_name. | |
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 | |
struct CONFIG_FILE |
Structure of a config file.
Definition at line 37 of file n_config_file.h.
Data Fields | ||
---|---|---|
char * | filename | |
LIST * | sections |
struct CONFIG_FILE_SECTION |
Structure of a config section.
Definition at line 31 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 70 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 56 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 28 of file n_config_file.h.
#define MAX_CONFIG_LINE_LEN 1024 |
maximum length of a single config line
Definition at line 26 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 488 of file n_config_file.c.
References __n_assert, Free, and list_destroy().
Referenced by load_app_state(), and main().
char * get_config_section_value | ( | CONFIG_FILE * | cfg_file, |
char * | section_name, | ||
size_t | section_position, | ||
char * | entry, | ||
size_t | 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 446 of file n_config_file.c.
References __n_assert, _nstr, CONFIG_FILE_SECTION::entries, free_nstr, ht_get_ptr(), list_foreach, LOG_DEBUG, n_log, LIST::nb_items, nstrprintf, CONFIG_FILE_SECTION::section_name, and CONFIG_FILE::sections.
Referenced by load_app_state(), and main().
size_t 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 380 of file n_config_file.c.
References __n_assert, list_foreach, CONFIG_FILE_SECTION::section_name, and CONFIG_FILE::sections.
Referenced by load_app_state(), and main().
size_t get_nb_config_file_sections_entries | ( | CONFIG_FILE * | cfg_file, |
char * | section_name, | ||
size_t | 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 406 of file n_config_file.c.
References __n_assert, _nstr, CONFIG_FILE_SECTION::entries, free_nstr, ht_get_ptr(), list_foreach, nstrprintf, CONFIG_FILE_SECTION::section_name, and CONFIG_FILE::sections.
Referenced by main().
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 46 of file n_config_file.c.
References __n_assert, _nstr, _str, CONFIG_SECTION_HASH_TABLE_LEN, destroy_config_file_section(), CONFIG_FILE_SECTION::entries, CONFIG_FILE::filename, Free, free_no_null(), free_nstr, free_split_result(), ht_get_ptr(), ht_put_ptr(), list_push(), LOG_DEBUG, LOG_ERR, Malloc, N_PCRE::match_list, MAX_CONFIG_LINE_LEN, MAX_LIST_ITEMS, n_log, new_generic_list(), new_ht(), npcre_delete(), npcre_match(), npcre_new(), nstrprintf, CONFIG_FILE_SECTION::section_name, CONFIG_FILE::sections, skipu(), split_count(), str_replace(), and trim_nocopy().
Referenced by load_app_state(), and main().
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 335 of file n_config_file.c.
References __n_assert, _str, config_endfor, config_foreach, FreeNoLog, key, LOG_ERR, and n_log.