Lely core libraries
2.2.5
|
This header file is part of the utilities library; it contains the configuration functions. More...
Go to the source code of this file.
Typedefs | |
typedef struct __config | config_t |
An opaque configuration type. | |
typedef void | config_foreach_func_t(const char *section, const char *key, const char *value, void *data) |
The type of a function called by config_foreach() for each key in a configuration struct. More... | |
Enumerations | |
enum | { CONFIG_CASE = 1 << 0 } |
Functions | |
config_t * | config_create (int flags) |
Creates a new configuration struct with an unnamed empty root section. More... | |
void | config_destroy (config_t *config) |
Destroys a configuration struct. More... | |
size_t | config_get_sections (const config_t *config, size_t n, const char **sections) |
Retrieves a list of section names from a configuration struct. More... | |
size_t | config_get_keys (const config_t *config, const char *section, size_t n, const char **keys) |
Retrieves a list of key names from a section in a configuration struct. More... | |
const char * | config_get (const config_t *config, const char *section, const char *key) |
Retrieves a key from a configuration struct. More... | |
const char * | config_set (config_t *config, const char *section, const char *key, const char *value) |
Sets a key in or removes a key from a configuration struct. More... | |
void | config_foreach (const config_t *config, config_foreach_func_t *func, void *data) |
Invokes a function for each key in a configuration struct. More... | |
size_t | config_parse_ini_file (config_t *config, const char *filename) |
Parses an INI file and adds the keys to a configuration struct. More... | |
size_t | config_parse_ini_text (config_t *config, const char *begin, const char *end, struct floc *at) |
Parses a string in INI-format and adds the keys to a configuration struct. More... | |
size_t | config_print_ini_file (const config_t *config, const char *filename) |
Prints a configuration struct to an INI file. More... | |
size_t | config_print_ini_text (const config_t *config, char **pbegin, char *end) |
Prints a configuration struct in INI-format to a memory buffer. More... | |
This header file is part of the utilities library; it contains the configuration functions.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file config.h.
typedef void config_foreach_func_t(const char *section, const char *key, const char *value, void *data) |
The type of a function called by config_foreach() for each key in a configuration struct.
section | a pointer to the name of the section |
key | a pointer to the name of the key. |
value | a pointer to the value of the key. |
data | a pointer to user-specified data. |
anonymous enum |
config_t* config_create | ( | int | flags | ) |
Creates a new configuration struct with an unnamed empty root section.
flags | either 0 or CONFIG_CASE. |
void config_destroy | ( | config_t * | config | ) |
size_t config_get_sections | ( | const config_t * | config, |
size_t | n, | ||
const char ** | sections | ||
) |
Retrieves a list of section names from a configuration struct.
config | a pointer to a configuration struct. |
n | the maximum number of sections to return. |
sections | an array of at least n pointers (can be NULL). On success, *sections contains the pointers to the section names. |
size_t config_get_keys | ( | const config_t * | config, |
const char * | section, | ||
size_t | n, | ||
const char ** | keys | ||
) |
Retrieves a list of key names from a section in a configuration struct.
config | a pointer to a configuration struct. |
section | a pointer to the name of the section. If section is NULL or "", the root section is used instead. |
n | the maximum number of sections to return. |
keys | an array of at least n pointers (can be NULL). On success, *keys contains the pointers to the key names. |
const char* config_get | ( | const config_t * | config, |
const char * | section, | ||
const char * | key | ||
) |
Retrieves a key from a configuration struct.
config | a pointer to a configuration struct. |
section | a pointer to the name of the section. If section is NULL or "", the root section is used instead. |
key | a pointer to the name of the key. |
const char* config_set | ( | config_t * | config, |
const char * | section, | ||
const char * | key, | ||
const char * | value | ||
) |
Sets a key in or removes a key from a configuration struct.
config | a pointer to a configuration struct. |
section | a pointer to the name of the section. If section is NULL or "", the root section is used instead. |
key | a pointer to the name of the key. This name is duplicated on success, so the caller need not guarantee the lifetime of the string. |
value | a pointer to the new value of the key. If value is NULL, the key is removed. Like key, the string is duplicated on success. |
void config_foreach | ( | const config_t * | config, |
config_foreach_func_t * | func, | ||
void * | data | ||
) |
size_t config_parse_ini_file | ( | config_t * | config, |
const char * | filename | ||
) |
Parses an INI file and adds the keys to a configuration struct.
Definition at line 47 of file config_ini.c.
size_t config_parse_ini_text | ( | config_t * | config, |
const char * | begin, | ||
const char * | end, | ||
struct floc * | at | ||
) |
Parses a string in INI-format and adds the keys to a configuration struct.
config | a pointer to a configuration struct. |
begin | a pointer to the first character in the string. |
end | a pointer to one past the last character in the string (can be NULL if the string is null-terminated). |
at | an optional pointer to the file location of begin (used for diagnostic purposes). On exit, if at != NULL , *at points to one past the last character parsed. |
Definition at line 75 of file config_ini.c.
size_t config_print_ini_file | ( | const config_t * | config, |
const char * | filename | ||
) |
Prints a configuration struct to an INI file.
Definition at line 179 of file config_ini.c.
size_t config_print_ini_text | ( | const config_t * | config, |
char ** | pbegin, | ||
char * | end | ||
) |
Prints a configuration struct in INI-format to a memory buffer.
Note that the output is not null-terminated.
config | a pointer to a configuration struct. |
pbegin | the address of a pointer to the start of the buffer. If pbegin or *pbegin is NULL, nothing is written; Otherwise, on exit, *pbegin points to one past the last character written. |
end | a pointer to the end of the buffer. If end is not NULL, at most end - *pbegin characters are written, and the output may be truncated. |
Definition at line 213 of file config_ini.c.