Table of Contents
- CONFIGURATIONS: classic config file loading/saving
CONFIGURATIONS: classic config file loading/saving
Structures
| Name | |
|---|---|
| struct | CONFIG_FILE_SECTION Structure of a config section. |
| struct | CONFIG_FILE Structure of a config file. |
Functions
| Name | |
|---|---|
| int | write_config_file(CONFIG_FILE * cfg_file, char * filename) write file from config |
| CONFIG_FILE * | load_config_file(char * filename, int * errors) load a config from a file |
| 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 |
| size_t | get_nb_config_file_sections(CONFIG_FILE * cfg_file, const char * section_name) get the number of section for section name |
| 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 |
| int | destroy_config_file(CONFIG_FILE ** cfg_file) destroy a loaded config |
Defines
| Name | |
|---|---|
| config_foreach(__config, __section_name, __key, __val) Foreach elements of CONFIG_FILE macro, i.e config_foreach( config , section , key , val ); config_endfor;. |
|
| config_endfor Foreach elements of CONFIG_FILE macro END. |
|
| MAX_CONFIG_LINE_LEN maximum length of a single config line |
|
| CONFIG_SECTION_HASH_TABLE_LEN size of the hash table of config sections entries |
Functions Documentation
function write_config_file
int write_config_file(
CONFIG_FILE * cfg_file,
char * filename
)
write file from config
Parameters:
- filename destination filename
- cfg_file source config file to write
Return: TRUE or FALSE
write a config file
write file from config
function load_config_file
CONFIG_FILE * load_config_file(
char * filename,
int * errors
)
load a config from a file
Parameters:
- filename Filename of the config file
- errors pointer to an int which will represent the number of errors encountered when reading config file
Return: NULL or a loaded config file
load a config file
load a config from a file
function get_nb_config_file_sections_entries
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
Parameters:
- 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
Return: The number of named sections entries or 0
Get the number of config file with section_name.
get the number of entries for section_name/entry
function get_nb_config_file_sections
size_t get_nb_config_file_sections(
CONFIG_FILE * cfg_file,
const char * section_name
)
get the number of section for section name
Parameters:
- cfg_file Config file to process
- section_name name of sections to search , or NULL to have a count of all available sections
Return: The number of named sections or a 0
Get the number of config file with section_name.
get the number of section for section name
function get_config_section_value
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
Parameters:
- cfg_file name of config file
- section_name name of section
- section_position section number
- entry entry name
- entry_position entry number
Return: the value of the named entry in section[ position ]
Function to parse sections and get entries values.
get a loaded config value
function destroy_config_file
int destroy_config_file(
CONFIG_FILE ** cfg_file
)
destroy a loaded config
Parameters:
- cfg_file pointer to a loaded config file to destroy
Return: TRUE or FALSE
Destroy a loaded config file.
destroy a loaded config
Macros Documentation
define config_foreach
#define config_foreach(
__config,
__section_name,
__key,
__val
)
if (!__config || !__config->sections) { \
n_log(LOG_ERR, "No config file for %s", #__config); \
} else { \
list_foreach(listnode, __config->sections) { \
CONFIG_FILE_SECTION* __section = (CONFIG_FILE_SECTION*)listnode->ptr; \
__section_name = __section->section_name; \
ht_foreach(entry, __section->entries) { \
HASH_NODE* htnode = (HASH_NODE*)entry->ptr; \
if (htnode && htnode->data.ptr) { \
__key = htnode->key; \
__val = htnode->data.ptr;
Foreach elements of CONFIG_FILE macro, i.e config_foreach( config , section , key , val ); config_endfor;.
define config_endfor
#define config_endfor } \
} \
} \
}
Foreach elements of CONFIG_FILE macro END.
Will cause errors if ommitted
define MAX_CONFIG_LINE_LEN
#define MAX_CONFIG_LINE_LEN 1024
maximum length of a single config line
define CONFIG_SECTION_HASH_TABLE_LEN
#define CONFIG_SECTION_HASH_TABLE_LEN 16
size of the hash table of config sections entries
Modules
- AABB3D
- ACCEPT_POOL
- ALLEGRO4
- ALLEGRO5
- ANIM_LIB
- ASTAR
- ATLAS_LIB
- AVRO
- CLOCK_SYNC
- COMMONS
- CONFIGFILE
- CYPHER_BASE64
- CYPHER_VIGENERE
- DEAD_RECKONING
- ENUMS
- EXCEPTIONS
- GAME_ENV
- GIT
- GUI
- HASH_TABLE
- ISOMETRIC_ENGINE
- LIST
- LOG
- LOGNODUP
- LZ4
- NETWORKING
- NETWORK_MSG
- N_COOKIES
- N_DIFF
- N_DIGEST
- N_DISK_CACHE
- N_DNS
- N_ECC
- N_ENTROPY
- N_FILES
- N_FLUIDS
- N_GUI_COLOR
- N_GUI_COLORWHEEL
- N_GUI_CURVE
- N_GUI_GRID
- N_GUI_POPUP
- N_HEX
- N_HTTP3
- N_HTTP_COOKIE
- N_HTTP_FORM
- N_HTTP_MIME
- N_HTTP_REQ
- N_HTTP_RESP
- N_HTTP_ROUTER
- N_HTTP_SERVER
- N_ICC
- N_JSON
- N_KAFKA
- N_LINALG
- N_MODULE
- N_OPENSSL_COMPAT
- N_PRETTY
- N_PTH
- N_QUERY
- N_RANDOM
- N_SHA256
- N_STR
- N_TIFF
- N_TIME
- N_USER
- N_X509
- N_ZIP
- PARTICLES
- PCRE
- PHYSICS
- SIGNALS
- STACK
- THREADS
- TRAJECTORY
- TREE
- ZLIB