Lely core libraries 2.3.4
|
This file is part of the utilities library; it contains the implementation of the configuration functions. More...
#include "util.h"
#include <lely/util/cmp.h>
#include <lely/util/config.h>
#include <lely/util/errnum.h>
#include <lely/util/rbtree.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Data Structures | |
struct | __config |
A configuration struct. More... | |
struct | config_section |
A section in a configuration struct. More... | |
struct | config_entry |
An entry in a configuration section. More... | |
Functions | |
config_t * | config_create (int flags) |
Creates a new configuration struct with an unnamed empty root section. | |
void | config_destroy (config_t *config) |
Destroys a configuration struct. | |
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. | |
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. | |
const char * | config_get (const config_t *config, const char *section, const char *key) |
Retrieves a key from a configuration struct. | |
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. | |
void | config_foreach (const config_t *config, config_foreach_func_t *func, void *data) |
Invokes a function for each key in a configuration struct. | |
This file is part of the utilities library; it contains the implementation of 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.c.
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 | ||
) |