PatchworkOS
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1#ifndef CONFIG_CONFIG_H
2#define CONFIG_CONFIG_H 1
3
4#include <errno.h>
5#include <stdbool.h>
6#include <stdint.h>
7
8#if defined(__cplusplus)
9extern "C"
10{
11#endif
12
31typedef struct config config_t;
32
37typedef struct config_array
38{
39 char** items;
42
54config_t* config_open(const char* prefix, const char* name);
55
61void config_close(config_t* config);
62
74const char* config_get_string(config_t* config, const char* section, const char* key, const char* fallback);
75
85int64_t config_get_int(config_t* config, const char* section, const char* key, int64_t fallback);
86
99bool config_get_bool(config_t* config, const char* section, const char* key, bool fallback);
100
111config_array_t* config_get_array(config_t* config, const char* section, const char* key);
112
119
122#if defined(__cplusplus)
123}
124#endif
125
126#endif
config_array_t * config_get_array(config_t *config, const char *section, const char *key)
Get an array of strings from a configuration file.
Definition config.c:300
config_t * config_open(const char *prefix, const char *name)
Open a configuration file.
Definition config.c:93
int64_t config_get_int(config_t *config, const char *section, const char *key, int64_t fallback)
Get an integer value from a configuration file.
Definition config.c:250
const char * config_get_string(config_t *config, const char *section, const char *key, const char *fallback)
Get a string value from a configuration file.
Definition config.c:228
void config_array_free(config_array_t *array)
Free a configuration array.
Definition config.c:388
bool config_get_bool(config_t *config, const char *section, const char *key, bool fallback)
Get a boolean value from a configuration file.
Definition config.c:273
void config_close(config_t *config)
Close a configuration file.
Definition config.c:202
__UINT64_TYPE__ uint64_t
Definition stdint.h:17
__INT64_TYPE__ int64_t
Definition stdint.h:16
Configuration array structure.
Definition config.h:38
char ** items
Definition config.h:39
uint64_t length
Definition config.h:40
Opaque configuration structure.
Definition config.c:28