rblcconfig 9.0
Loading...
Searching...
No Matches
libconfig_modified.h
Go to the documentation of this file.
1/* ----------------------------------------------------------------------------
2 libconfig - A library for processing structured configuration files
3 Copyright (C) 2005-2018 Mark A Lindner
4
5 This file is part of libconfig.
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public License
9 as published by the Free Software Foundation; either version 2.1 of
10 the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public
18 License along with this library; if not, see
19 <http://www.gnu.org/licenses/>.
20 ----------------------------------------------------------------------------
21*/
22
23#ifndef __libconfig_h
24#define __libconfig_h
25
26#ifdef __cplusplus
27extern "C" {
28#endif /* __cplusplus */
29
30#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
31#if defined(LIBCONFIG_STATIC)
32#define LIBCONFIG_API
33#elif defined(LIBCONFIG_EXPORTS)
34#define LIBCONFIG_API __declspec(dllexport)
35#else /* ! LIBCONFIG_EXPORTS */
36#define LIBCONFIG_API __declspec(dllimport)
37#endif /* LIBCONFIG_STATIC */
38#else /* ! WIN32 */
39#define LIBCONFIG_API
40#endif /* WIN32 */
41
42#define LIBCONFIG_VER_MAJOR 1
43#define LIBCONFIG_VER_MINOR 7
44#define LIBCONFIG_VER_REVISION 0
45
46#ifndef PARSE_C_HEADER_TO_META
47#include <stdio.h>
48#endif
49
50#define CONFIG_TYPE_NONE 0
51#define CONFIG_TYPE_GROUP 1
52#define CONFIG_TYPE_INT 2
53#define CONFIG_TYPE_INT64 3
54#define CONFIG_TYPE_FLOAT 4
55#define CONFIG_TYPE_STRING 5
56#define CONFIG_TYPE_BOOL 6
57#define CONFIG_TYPE_ARRAY 7
58#define CONFIG_TYPE_LIST 8
59
60#define CONFIG_FORMAT_DEFAULT 0
61#define CONFIG_FORMAT_HEX 1
62
63#define CONFIG_OPTION_AUTOCONVERT 0x01
64#define CONFIG_OPTION_SEMICOLON_SEPARATORS 0x02
65#define CONFIG_OPTION_COLON_ASSIGNMENT_FOR_GROUPS 0x04
66#define CONFIG_OPTION_COLON_ASSIGNMENT_FOR_NON_GROUPS 0x08
67#define CONFIG_OPTION_OPEN_BRACE_ON_SEPARATE_LINE 0x10
68#define CONFIG_OPTION_ALLOW_SCIENTIFIC_NOTATION 0x20
69#define CONFIG_OPTION_FSYNC 0x40
70#define CONFIG_OPTION_ALLOW_OVERRIDES 0x80
71
72#define CONFIG_TRUE (1)
73#define CONFIG_FALSE (0)
74
75typedef union config_value_t
76{
77 int ival;
78 long long llval;
79 double fval;
80 char *sval;
83
84typedef struct config_setting_t
85{
86 char *name;
87 short type;
88 short format;
92 void *hook;
93 unsigned int line;
94 const char *file;
96
103
109
110typedef const char ** (*config_include_fn_t)(struct config_t *,
111 const char *,
112 const char *,
113 const char **);
114
115typedef struct config_t
116{
118 void (*destructor)(void *);
120 unsigned short tab_width;
121 unsigned short float_precision;
122 unsigned short default_format;
123 const char *include_dir;
125 const char *error_text;
126 const char *error_file;
129 const char **filenames;
130 void *hook;
132
133extern LIBCONFIG_API int config_read(config_t *config, FILE *stream);
134extern LIBCONFIG_API void config_write(const config_t *config, FILE *stream);
135
137 short format);
138
139extern LIBCONFIG_API void config_set_options(config_t *config, int options);
140extern LIBCONFIG_API int config_get_options(const config_t *config);
141
142extern LIBCONFIG_API void config_set_option(config_t *config, int option,
143 int flag);
144extern LIBCONFIG_API int config_get_option(const config_t *config, int option);
145
146extern LIBCONFIG_API int config_read_string(config_t *config, const char *str);
147
149 const char *filename);
151 const char *filename);
152
154 void (*destructor)(void *));
156 const char *include_dir);
159
161 unsigned short digits);
163 const config_t *config);
164
166 unsigned short width);
168 const config_t *config);
169
170extern LIBCONFIG_API void config_set_hook(config_t *config, void *hook);
171
172#define config_get_hook(C) ((C)->hook)
173
174extern LIBCONFIG_API void config_init(config_t *config);
177
179 const config_setting_t *setting);
181 const config_setting_t *setting);
183 const config_setting_t *setting);
185 const config_setting_t *setting);
187 const config_setting_t *setting);
188
190 const config_setting_t *setting, const char *name, int *value);
192 const config_setting_t *setting, const char *name, long long *value);
194 const config_setting_t *setting, const char *name, double *value);
196 const config_setting_t *setting, const char *name, int *value);
198 const config_setting_t *setting, const char *name, const char **value);
199
201 int value);
203 long long value);
205 double value);
207 int value);
209 const char *value);
210
212 short format);
214 const config_setting_t *setting);
215
217 const config_setting_t *setting, int idx);
219 const config_setting_t *setting, int idx);
221 const config_setting_t *setting, int idx);
223 const config_setting_t *setting, int idx);
225 const config_setting_t *setting, int idx);
226
228 config_setting_t *setting, int idx, int value);
230 config_setting_t *setting, int idx, long long value);
232 config_setting_t *setting, int idx, double value);
234 config_setting_t *setting, int idx, int value);
236 config_setting_t *setting, int idx, const char *value);
237
239 config_t *config, const char *include_dir, const char *path,
240 const char **error);
241
243 const config_setting_t *setting);
244
246 const config_setting_t *setting);
247
248#ifndef PARSE_C_HEADER_TO_META
249
250#define /* const char * */ config_get_include_dir(/* const config_t * */ C) \
251 ((C)->include_dir)
252
253#define /* void */ config_set_auto_convert(/* config_t * */ C, F) \
254 config_set_option((C), CONFIG_OPTION_AUTOCONVERT, (F))
255#define /* int */ config_get_auto_convert(/* const config_t * */ C) \
256 config_get_option((C), CONFIG_OPTION_AUTOCONVERT)
257
258#define /* int */ config_setting_type(/* const config_setting_t * */ S) \
259 ((S)->type)
260
261#define /* int */ config_setting_is_group(/* const config_setting_t * */ S) \
262 ((S)->type == CONFIG_TYPE_GROUP)
263#define /* int */ config_setting_is_array(/* const config_setting_t * */ S) \
264 ((S)->type == CONFIG_TYPE_ARRAY)
265#define /* int */ config_setting_is_list(/* const config_setting_t * */ S) \
266 ((S)->type == CONFIG_TYPE_LIST)
267
268#define /* int */ config_setting_is_number(/* const config_setting_t * */ S) \
269 (((S)->type == CONFIG_TYPE_INT) \
270 || ((S)->type == CONFIG_TYPE_INT64) \
271 || ((S)->type == CONFIG_TYPE_FLOAT))
272
273#define /* const char * */ config_setting_name( \
274 /* const config_setting_t * */ S) \
275 ((S)->name)
276
277#define /* config_setting_t * */ config_setting_parent( \
278 /* const config_setting_t * */ S) \
279 ((S)->parent)
280
281#define /* int */ config_setting_is_root( \
282 /* const config_setting_t * */ S) \
283 ((S)->parent ? CONFIG_FALSE : CONFIG_TRUE)
284
285#endif // PARSE_C_HEADER_TO_META
286
288
290 const config_setting_t *setting);
292 const config_setting_t *setting, unsigned int idx);
293
295 const config_setting_t *setting, const char *name);
296
298 config_setting_t *parent, const char *name, int __type);
300 const char *name);
302 unsigned int idx);
304 void *hook);
305
306#ifndef PARSE_C_HEADER_TO_META
307#define config_setting_get_hook(S) ((S)->hook)
308#endif
309
311 const char *path);
313 config_setting_t *setting, const char *path);
314
315extern LIBCONFIG_API int config_lookup_int(const config_t *config,
316 const char *path, int *value);
318 const char *path,
319 long long *value);
321 const char *path, double *value);
323 const char *path, int *value);
325 const char *path,
326 const char **value);
327
328#ifndef PARSE_C_HEADER_TO_META
329
330#define /* config_setting_t * */ config_root_setting( \
331 /* const config_t * */ C) \
332 ((C)->root)
333
334#define /* void */ config_set_default_format(/* config_t * */ C, \
335 /* short */ F) \
336 (C)->default_format = (F)
337
338#define /* short */ config_get_default_format(/* config_t * */ C) \
339 ((C)->default_format)
340
341#define /* unsigned short */ config_setting_source_line( \
342 /* const config_setting_t * */ S) \
343 ((S)->line)
344
345#define /* const char */ config_setting_source_file( \
346 /* const config_setting_t * */ S) \
347 ((S)->file)
348
349#define /* const char * */ config_error_text(/* const config_t * */ C) \
350 ((C)->error_text)
351
352#define /* const char * */ config_error_file(/* const config_t * */ C) \
353 ((C)->error_file)
354
355#define /* int */ config_error_line(/* const config_t * */ C) \
356 ((C)->error_line)
357
358#define /* config_error_t */ config_error_type(/* const config_t * */ C) \
359 ((C)->error_type)
360
361#endif // PARSE_C_HEADER_TO_META
362
363#ifdef __cplusplus
364}
365#endif /* __cplusplus */
366
367#endif /* __libconfig_h */
LIBCONFIG_API int config_setting_get_bool(const config_setting_t *setting)
LIBCONFIG_API int config_read_file(config_t *config, const char *filename)
LIBCONFIG_API void config_set_float_precision(config_t *config, unsigned short digits)
LIBCONFIG_API config_setting_t * config_lookup(const config_t *config, const char *path)
LIBCONFIG_API int config_setting_set_int(config_setting_t *setting, int value)
LIBCONFIG_API config_setting_t * config_setting_set_string_elem(config_setting_t *setting, int idx, const char *value)
LIBCONFIG_API void config_set_include_dir(config_t *config, const char *include_dir)
LIBCONFIG_API int config_setting_lookup_int64(const config_setting_t *setting, const char *name, long long *value)
LIBCONFIG_API int config_setting_remove_elem(config_setting_t *parent, unsigned int idx)
LIBCONFIG_API unsigned short config_get_tab_width(const config_t *config)
LIBCONFIG_API config_setting_t * config_setting_set_float_elem(config_setting_t *setting, int idx, double value)
LIBCONFIG_API const char * config_setting_get_string_elem(const config_setting_t *setting, int idx)
LIBCONFIG_API config_setting_t * config_setting_get_member(const config_setting_t *setting, const char *name)
LIBCONFIG_API int config_setting_lookup_int(const config_setting_t *setting, const char *name, int *value)
LIBCONFIG_API config_setting_t * config_setting_add(config_setting_t *parent, const char *name, int __type)
LIBCONFIG_API const char * config_setting_get_string(const config_setting_t *setting)
LIBCONFIG_API const char ** config_default_include_func(config_t *config, const char *include_dir, const char *path, const char **error)
LIBCONFIG_API int config_setting_index(const config_setting_t *setting)
LIBCONFIG_API config_setting_t * config_setting_lookup(config_setting_t *setting, const char *path)
LIBCONFIG_API int config_setting_set_float(config_setting_t *setting, double value)
LIBCONFIG_API int config_setting_set_int64(config_setting_t *setting, long long value)
LIBCONFIG_API void config_set_include_func(config_t *config, config_include_fn_t func)
LIBCONFIG_API double config_setting_get_float(const config_setting_t *setting)
LIBCONFIG_API void config_set_tab_width(config_t *config, unsigned short width)
LIBCONFIG_API int config_setting_set_string(config_setting_t *setting, const char *value)
LIBCONFIG_API config_setting_t * config_setting_get_elem(const config_setting_t *setting, unsigned int idx)
LIBCONFIG_API int config_setting_set_format(config_setting_t *setting, short format)
LIBCONFIG_API void config_set_options(config_t *config, int options)
LIBCONFIG_API void config_setting_set_hook(config_setting_t *setting, void *hook)
LIBCONFIG_API int config_setting_lookup_string(const config_setting_t *setting, const char *name, const char **value)
LIBCONFIG_API int config_lookup_string(const config_t *config, const char *path, const char **value)
const char **(* config_include_fn_t)(struct config_t *, const char *, const char *, const char **)
LIBCONFIG_API int config_setting_lookup_float(const config_setting_t *setting, const char *name, double *value)
LIBCONFIG_API void config_destroy(config_t *config)
#define config_set_default_format(C, F)
LIBCONFIG_API unsigned short config_get_float_precision(const config_t *config)
LIBCONFIG_API int config_lookup_bool(const config_t *config, const char *path, int *value)
LIBCONFIG_API int config_lookup_float(const config_t *config, const char *path, double *value)
LIBCONFIG_API short config_setting_get_format(const config_setting_t *setting)
LIBCONFIG_API int config_lookup_int(const config_t *config, const char *path, int *value)
LIBCONFIG_API void config_init(config_t *config)
LIBCONFIG_API int config_setting_remove(config_setting_t *parent, const char *name)
LIBCONFIG_API int config_setting_get_bool_elem(const config_setting_t *setting, int idx)
LIBCONFIG_API int config_get_options(const config_t *config)
LIBCONFIG_API void config_set_hook(config_t *config, void *hook)
LIBCONFIG_API int config_setting_get_int(const config_setting_t *setting)
LIBCONFIG_API int config_setting_length(const config_setting_t *setting)
LIBCONFIG_API int config_setting_set_bool(config_setting_t *setting, int value)
config_error_t
@ CONFIG_ERR_PARSE
@ CONFIG_ERR_NONE
@ CONFIG_ERR_FILE_IO
LIBCONFIG_API int config_setting_lookup_bool(const config_setting_t *setting, const char *name, int *value)
LIBCONFIG_API void config_set_option(config_t *config, int option, int flag)
LIBCONFIG_API config_setting_t * config_setting_set_int_elem(config_setting_t *setting, int idx, int value)
LIBCONFIG_API int config_write_file(config_t *config, const char *filename)
LIBCONFIG_API int config_get_option(const config_t *config, int option)
LIBCONFIG_API int config_setting_is_scalar(const config_setting_t *setting)
LIBCONFIG_API double config_setting_get_float_elem(const config_setting_t *setting, int idx)
#define LIBCONFIG_API
LIBCONFIG_API int config_lookup_int64(const config_t *config, const char *path, long long *value)
LIBCONFIG_API config_setting_t * config_setting_set_bool_elem(config_setting_t *setting, int idx, int value)
LIBCONFIG_API int config_setting_get_int_elem(const config_setting_t *setting, int idx)
LIBCONFIG_API void config_clear(config_t *config)
LIBCONFIG_API int config_read(config_t *config, FILE *stream)
LIBCONFIG_API long long config_setting_get_int64_elem(const config_setting_t *setting, int idx)
LIBCONFIG_API void config_write(const config_t *config, FILE *stream)
LIBCONFIG_API config_setting_t * config_setting_set_int64_elem(config_setting_t *setting, int idx, long long value)
LIBCONFIG_API void config_set_destructor(config_t *config, void(*destructor)(void *))
LIBCONFIG_API int config_setting_is_aggregate(const config_setting_t *setting)
LIBCONFIG_API int config_read_string(config_t *config, const char *str)
LIBCONFIG_API long long config_setting_get_int64(const config_setting_t *setting)
unsigned int length
config_setting_t ** elements
config_value_t value
struct config_setting_t * parent
struct config_t * config
const char ** filenames
const char * error_file
config_include_fn_t include_fn
config_setting_t * root
config_error_t error_type
const char * include_dir
unsigned short tab_width
const char * error_text
unsigned short float_precision
void(* destructor)(void *)
unsigned short default_format
struct config_list_t * list