libConfuse 3.4
Small configuration file parser library for C
Loading...
Searching...
No Matches
confuse.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2002-2017 Martin Hedenfalk <martin@bzero.se>
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
22#ifndef CONFUSE_H_
23#define CONFUSE_H_
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29#include <stdio.h>
30#include <stdarg.h>
31#include <stdint.h>
32
33#if defined(_WIN32) && !defined(__GNUC__)
34# ifdef HAVE__FILENO
35# define fileno _fileno
36# endif
37# include <io.h>
38# ifdef HAVE__ISATTY
39# define isatty _isatty
40# endif
41# ifdef BUILDING_STATIC
42# define DLLIMPORT
43# else /* ! BUILDING_STATIC */
44# ifdef BUILDING_DLL
45# define DLLIMPORT __declspec (dllexport)
46# else /* ! BUILDING_DLL */
47# define DLLIMPORT __declspec (dllimport)
48# endif /* BUILDING_DLL */
49# endif /* BUILDING_STATIC */
50#else /* ! _WIN32 || __GNUC__ */
51# define DLLIMPORT
52#endif /* _WIN32 */
53
54#ifndef __BORLANDC__
55# define __export
56#endif
57
79typedef enum cfg_type_t cfg_type_t;
82#define CFGF_NONE (0)
83#define CFGF_MULTI (1 << 0)
84#define CFGF_LIST (1 << 1)
85#define CFGF_NOCASE (1 << 2)
86#define CFGF_TITLE (1 << 3)
87#define CFGF_NODEFAULT (1 << 4)
88#define CFGF_NO_TITLE_DUPES (1 << 5)
91#define CFGF_RESET (1 << 6)
92#define CFGF_DEFINIT (1 << 7)
93#define CFGF_IGNORE_UNKNOWN (1 << 8)
94#define CFGF_DEPRECATED (1 << 9)
95#define CFGF_DROP (1 << 10)
96#define CFGF_COMMENTS (1 << 11)
97#define CFGF_MODIFIED (1 << 12)
98#define CFGF_KEYSTRVAL (1 << 13)
99#define CFGF_USE_INCLUDE_FUNCTION (1 << 14)
100#define CFGF_JSON_LISTS (1 << 15)
102/* Return codes from cfg_parse(), cfg_parse_boolean(), and cfg_set*() functions. */
103#define CFG_SUCCESS 0
104#define CFG_FAIL -1
105#define CFG_FILE_ERROR -1
106#define CFG_PARSE_ERROR 1
110typedef struct cfg_opt_t cfg_opt_t;
111typedef struct cfg_t cfg_t;
113typedef int cfg_flag_t;
141typedef int (*cfg_func_t)(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv);
142
163typedef void (*cfg_print_func_t)(cfg_opt_t *opt, unsigned int index, FILE *fp);
164
186typedef int (*cfg_callback_t)(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result);
187
201typedef int (*cfg_validate_callback_t)(cfg_t *cfg, cfg_opt_t *opt);
202
217typedef int (*cfg_validate_callback2_t)(cfg_t *cfg, cfg_opt_t *opt, void *value);
218
227typedef void (*cfg_free_func_t)(void *value);
228
230typedef enum { cfg_false, cfg_true } cfg_bool_t;
231
233typedef void (*cfg_errfunc_t)(cfg_t *cfg, const char *fmt, va_list ap);
234
244typedef int (*cfg_print_filter_func_t)(cfg_t *cfg, cfg_opt_t *opt);
245
268
272 long int number;
273 int8_t i8;
274 int16_t i16;
275 int32_t i32;
276 int64_t i64;
277 uint8_t u8;
278 uint16_t u16;
279 uint32_t u32;
280 uint64_t u64;
281 double fpnumber;
283 char *string;
285 void *ptr;
286};
287
292 long int *number;
293 int8_t *i8;
294 int16_t *i16;
295 int32_t *i32;
296 int64_t *i64;
297 uint8_t *u8;
298 uint16_t *u16;
299 uint32_t *u32;
300 uint64_t *u64;
301 double *fpnumber;
303 char **string;
304 void **ptr;
305};
306
311 long int number;
312 double fpnumber;
314 const char *string;
315 char *parsed;
318};
319
343
344extern const char __export confuse_copyright[];
345extern const char __export confuse_version[];
346extern const char __export confuse_author[];
348#define __CFG_STR(_name, _def, _flags, _svalue, _cb) { \
349 .name = _name, \
350 .type = CFGT_STR, \
351 .flags = _flags, \
352 .def = { .string = _def, }, \
353 .simple_value = { .string = _svalue, }, \
354 .parsecb = _cb, \
355}
356#define __CFG_STR_LIST(_name, _def, _flags, _svalue, _cb) { \
357 .name = _name, \
358 .type = CFGT_STR, \
359 .flags = _flags | CFGF_LIST, \
360 .def = { .parsed = _def, }, \
361 .simple_value = { .string = _svalue, }, \
362 .parsecb = _cb, \
363}
364
367#define CFG_STR(name, def, flags) \
368 __CFG_STR(name, def, flags, NULL, NULL)
369
372#define CFG_RAWSEC(_name, _flags) { \
373 .name = _name, \
374 .type = CFGT_RAWSEC, \
375 .flags = _flags, \
376 .subopts = NULL, \
377}
378
381#define CFG_STR_LIST(name, def, flags) \
382 __CFG_STR_LIST(name, def, flags, NULL, NULL)
383
386#define CFG_STR_CB(name, def, flags, cb) \
387 __CFG_STR(name, def, flags, NULL, cb)
388
391#define CFG_STR_LIST_CB(name, def, flags, cb) \
392 __CFG_STR_LIST(name, def, flags, NULL, cb)
393
446#define CFG_SIMPLE_STR(name, svalue) \
447 __CFG_STR(name, NULL, CFGF_NONE, svalue, NULL)
448
449
450#define __CFG_INT(_name, _def, _flags, _svalue, _cb) { \
451 .name = _name, \
452 .type = CFGT_INT, \
453 .flags = _flags, \
454 .def = { .number = _def, }, \
455 .simple_value = { .number = _svalue, }, \
456 .parsecb = _cb, \
457}
458#define __CFG_INT_LIST(_name, _def, _flags, _svalue, _cb) { \
459 .name = _name, \
460 .type = CFGT_INT, \
461 .flags = _flags | CFGF_LIST, \
462 .def = { .parsed = _def, }, \
463 .simple_value = { .number = _svalue, }, \
464 .parsecb = _cb, \
465}
466
473#define CFG_INT(name, def, flags) \
474 __CFG_INT(name, def, flags, NULL, NULL)
475
478#define CFG_INT_LIST(name, def, flags) \
479 __CFG_INT_LIST(name, def, flags, NULL, NULL)
480
483#define CFG_INT_CB(name, def, flags, cb) \
484 __CFG_INT(name, def, flags, NULL, cb)
485
488#define CFG_INT_LIST_CB(name, def, flags, cb) \
489 __CFG_INT_LIST(name, def, flags, NULL, cb)
490
497#define CFG_SIMPLE_INT(name, svalue) \
498 __CFG_INT(name, 0, CFGF_NONE, svalue, NULL)
499
500
501/*
502 * Fixed-width and unsigned integer types. Unlike CFG_INT, which is a
503 * platform `long int` (32-bit on ILP32), these have a defined width on
504 * every platform, and out-of-range values are rejected on parse. A
505 * compile-time default set with CFG_INT64() et al. is still limited to
506 * `long int` range on ILP32; use the config file or cfg_setint64() for
507 * larger defaults.
508 */
509#define __CFG_INT64(_name, _def, _flags, _svalue, _cb) { \
510 .name = _name, \
511 .type = CFGT_INT64, \
512 .flags = _flags, \
513 .def = { .number = _def, }, \
514 .simple_value = { .i64 = _svalue, }, \
515 .parsecb = _cb, \
516}
517#define __CFG_INT64_LIST(_name, _def, _flags, _svalue, _cb) { \
518 .name = _name, \
519 .type = CFGT_INT64, \
520 .flags = _flags | CFGF_LIST, \
521 .def = { .parsed = _def, }, \
522 .simple_value = { .i64 = _svalue, }, \
523 .parsecb = _cb, \
524}
525#define __CFG_UINT32(_name, _def, _flags, _svalue, _cb) { \
526 .name = _name, \
527 .type = CFGT_UINT32, \
528 .flags = _flags, \
529 .def = { .number = _def, }, \
530 .simple_value = { .u32 = _svalue, }, \
531 .parsecb = _cb, \
532}
533#define __CFG_UINT32_LIST(_name, _def, _flags, _svalue, _cb) { \
534 .name = _name, \
535 .type = CFGT_UINT32, \
536 .flags = _flags | CFGF_LIST, \
537 .def = { .parsed = _def, }, \
538 .simple_value = { .u32 = _svalue, }, \
539 .parsecb = _cb, \
540}
541#define __CFG_UINT64(_name, _def, _flags, _svalue, _cb) { \
542 .name = _name, \
543 .type = CFGT_UINT64, \
544 .flags = _flags, \
545 .def = { .number = _def, }, \
546 .simple_value = { .u64 = _svalue, }, \
547 .parsecb = _cb, \
548}
549#define __CFG_UINT64_LIST(_name, _def, _flags, _svalue, _cb) { \
550 .name = _name, \
551 .type = CFGT_UINT64, \
552 .flags = _flags | CFGF_LIST, \
553 .def = { .parsed = _def, }, \
554 .simple_value = { .u64 = _svalue, }, \
555 .parsecb = _cb, \
556}
557
559#define CFG_INT64(name, def, flags) __CFG_INT64(name, def, flags, NULL, NULL)
561#define CFG_INT64_LIST(name, def, flags) __CFG_INT64_LIST(name, def, flags, NULL, NULL)
563#define CFG_INT64_CB(name, def, flags, cb) __CFG_INT64(name, def, flags, NULL, cb)
565#define CFG_INT64_LIST_CB(name, def, flags, cb) __CFG_INT64_LIST(name, def, flags, NULL, cb)
567#define CFG_SIMPLE_INT64(name, svalue) __CFG_INT64(name, 0, CFGF_NONE, svalue, NULL)
568
570#define CFG_UINT32(name, def, flags) __CFG_UINT32(name, def, flags, NULL, NULL)
572#define CFG_UINT32_LIST(name, def, flags) __CFG_UINT32_LIST(name, def, flags, NULL, NULL)
574#define CFG_UINT32_CB(name, def, flags, cb) __CFG_UINT32(name, def, flags, NULL, cb)
576#define CFG_UINT32_LIST_CB(name, def, flags, cb) __CFG_UINT32_LIST(name, def, flags, NULL, cb)
578#define CFG_SIMPLE_UINT32(name, svalue) __CFG_UINT32(name, 0, CFGF_NONE, svalue, NULL)
579
581#define CFG_UINT64(name, def, flags) __CFG_UINT64(name, def, flags, NULL, NULL)
583#define CFG_UINT64_LIST(name, def, flags) __CFG_UINT64_LIST(name, def, flags, NULL, NULL)
585#define CFG_UINT64_CB(name, def, flags, cb) __CFG_UINT64(name, def, flags, NULL, cb)
587#define CFG_UINT64_LIST_CB(name, def, flags, cb) __CFG_UINT64_LIST(name, def, flags, NULL, cb)
589#define CFG_SIMPLE_UINT64(name, svalue) __CFG_UINT64(name, 0, CFGF_NONE, svalue, NULL)
590
591#define __CFG_INT8(_name, _def, _flags, _svalue, _cb) { \
592 .name = _name, .type = CFGT_INT8, .flags = _flags, \
593 .def = { .number = _def, }, .simple_value = { .i8 = _svalue, }, .parsecb = _cb, \
594}
595#define __CFG_INT8_LIST(_name, _def, _flags, _svalue, _cb) { \
596 .name = _name, .type = CFGT_INT8, .flags = _flags | CFGF_LIST, \
597 .def = { .parsed = _def, }, .simple_value = { .i8 = _svalue, }, .parsecb = _cb, \
598}
599#define __CFG_INT16(_name, _def, _flags, _svalue, _cb) { \
600 .name = _name, .type = CFGT_INT16, .flags = _flags, \
601 .def = { .number = _def, }, .simple_value = { .i16 = _svalue, }, .parsecb = _cb, \
602}
603#define __CFG_INT16_LIST(_name, _def, _flags, _svalue, _cb) { \
604 .name = _name, .type = CFGT_INT16, .flags = _flags | CFGF_LIST, \
605 .def = { .parsed = _def, }, .simple_value = { .i16 = _svalue, }, .parsecb = _cb, \
606}
607#define __CFG_INT32(_name, _def, _flags, _svalue, _cb) { \
608 .name = _name, .type = CFGT_INT32, .flags = _flags, \
609 .def = { .number = _def, }, .simple_value = { .i32 = _svalue, }, .parsecb = _cb, \
610}
611#define __CFG_INT32_LIST(_name, _def, _flags, _svalue, _cb) { \
612 .name = _name, .type = CFGT_INT32, .flags = _flags | CFGF_LIST, \
613 .def = { .parsed = _def, }, .simple_value = { .i32 = _svalue, }, .parsecb = _cb, \
614}
615#define __CFG_UINT8(_name, _def, _flags, _svalue, _cb) { \
616 .name = _name, .type = CFGT_UINT8, .flags = _flags, \
617 .def = { .number = _def, }, .simple_value = { .u8 = _svalue, }, .parsecb = _cb, \
618}
619#define __CFG_UINT8_LIST(_name, _def, _flags, _svalue, _cb) { \
620 .name = _name, .type = CFGT_UINT8, .flags = _flags | CFGF_LIST, \
621 .def = { .parsed = _def, }, .simple_value = { .u8 = _svalue, }, .parsecb = _cb, \
622}
623#define __CFG_UINT16(_name, _def, _flags, _svalue, _cb) { \
624 .name = _name, .type = CFGT_UINT16, .flags = _flags, \
625 .def = { .number = _def, }, .simple_value = { .u16 = _svalue, }, .parsecb = _cb, \
626}
627#define __CFG_UINT16_LIST(_name, _def, _flags, _svalue, _cb) { \
628 .name = _name, .type = CFGT_UINT16, .flags = _flags | CFGF_LIST, \
629 .def = { .parsed = _def, }, .simple_value = { .u16 = _svalue, }, .parsecb = _cb, \
630}
631
633#define CFG_INT8(name, def, flags) __CFG_INT8(name, def, flags, NULL, NULL)
635#define CFG_INT8_LIST(name, def, flags) __CFG_INT8_LIST(name, def, flags, NULL, NULL)
637#define CFG_INT8_CB(name, def, flags, cb) __CFG_INT8(name, def, flags, NULL, cb)
639#define CFG_INT8_LIST_CB(name, def, flags, cb) __CFG_INT8_LIST(name, def, flags, NULL, cb)
641#define CFG_SIMPLE_INT8(name, svalue) __CFG_INT8(name, 0, CFGF_NONE, svalue, NULL)
642
644#define CFG_INT16(name, def, flags) __CFG_INT16(name, def, flags, NULL, NULL)
646#define CFG_INT16_LIST(name, def, flags) __CFG_INT16_LIST(name, def, flags, NULL, NULL)
648#define CFG_INT16_CB(name, def, flags, cb) __CFG_INT16(name, def, flags, NULL, cb)
650#define CFG_INT16_LIST_CB(name, def, flags, cb) __CFG_INT16_LIST(name, def, flags, NULL, cb)
652#define CFG_SIMPLE_INT16(name, svalue) __CFG_INT16(name, 0, CFGF_NONE, svalue, NULL)
653
655#define CFG_INT32(name, def, flags) __CFG_INT32(name, def, flags, NULL, NULL)
657#define CFG_INT32_LIST(name, def, flags) __CFG_INT32_LIST(name, def, flags, NULL, NULL)
659#define CFG_INT32_CB(name, def, flags, cb) __CFG_INT32(name, def, flags, NULL, cb)
661#define CFG_INT32_LIST_CB(name, def, flags, cb) __CFG_INT32_LIST(name, def, flags, NULL, cb)
663#define CFG_SIMPLE_INT32(name, svalue) __CFG_INT32(name, 0, CFGF_NONE, svalue, NULL)
664
666#define CFG_UINT8(name, def, flags) __CFG_UINT8(name, def, flags, NULL, NULL)
668#define CFG_UINT8_LIST(name, def, flags) __CFG_UINT8_LIST(name, def, flags, NULL, NULL)
670#define CFG_UINT8_CB(name, def, flags, cb) __CFG_UINT8(name, def, flags, NULL, cb)
672#define CFG_UINT8_LIST_CB(name, def, flags, cb) __CFG_UINT8_LIST(name, def, flags, NULL, cb)
674#define CFG_SIMPLE_UINT8(name, svalue) __CFG_UINT8(name, 0, CFGF_NONE, svalue, NULL)
675
677#define CFG_UINT16(name, def, flags) __CFG_UINT16(name, def, flags, NULL, NULL)
679#define CFG_UINT16_LIST(name, def, flags) __CFG_UINT16_LIST(name, def, flags, NULL, NULL)
681#define CFG_UINT16_CB(name, def, flags, cb) __CFG_UINT16(name, def, flags, NULL, cb)
683#define CFG_UINT16_LIST_CB(name, def, flags, cb) __CFG_UINT16_LIST(name, def, flags, NULL, cb)
685#define CFG_SIMPLE_UINT16(name, svalue) __CFG_UINT16(name, 0, CFGF_NONE, svalue, NULL)
686
687
688
689#define __CFG_FLOAT(_name, _def, _flags, _svalue, _cb) { \
690 .name = _name, \
691 .type = CFGT_FLOAT, \
692 .flags = _flags, \
693 .def = { .fpnumber = _def, }, \
694 .simple_value = { .fpnumber = _svalue, }, \
695 .parsecb = _cb, \
696}
697#define __CFG_FLOAT_LIST(_name, _def, _flags, _svalue, _cb) { \
698 .name = _name, \
699 .type = CFGT_FLOAT, \
700 .flags = _flags | CFGF_LIST, \
701 .def = { .parsed = _def, }, \
702 .simple_value = { .fpnumber = _svalue, }, \
703 .parsecb = _cb, \
704}
705
708#define CFG_FLOAT(name, def, flags) \
709 __CFG_FLOAT(name, def, flags, NULL, NULL)
710
713#define CFG_FLOAT_LIST(name, def, flags) \
714 __CFG_FLOAT_LIST(name, def, flags, NULL, NULL)
715
718#define CFG_FLOAT_CB(name, def, flags, cb) \
719 __CFG_FLOAT(name, def, flags, NULL, cb)
720
723#define CFG_FLOAT_LIST_CB(name, def, flags, cb) \
724 __CFG_FLOAT_LIST(name, def, flags, NULL, cb)
725
729#define CFG_SIMPLE_FLOAT(name, svalue) \
730 __CFG_FLOAT(name, 0, CFGF_NONE, svalue, NULL)
731
732
733
734#define __CFG_BOOL(_name, _def, _flags, _svalue, _cb) { \
735 .name = _name, \
736 .type = CFGT_BOOL, \
737 .flags = _flags, \
738 .def = { .boolean = _def, }, \
739 .simple_value = { .boolean = _svalue, }, \
740 .parsecb = _cb, \
741}
742#define __CFG_BOOL_LIST(_name, _def, _flags, _svalue, _cb) { \
743 .name = _name, \
744 .type = CFGT_BOOL, \
745 .flags = _flags | CFGF_LIST, \
746 .def = { .parsed = _def, }, \
747 .simple_value = { .boolean = _svalue, }, \
748 .parsecb = _cb, \
749}
750
753#define CFG_BOOL(name, def, flags) \
754 __CFG_BOOL(name, def, flags, NULL, NULL)
755
758#define CFG_BOOL_LIST(name, def, flags) \
759 __CFG_BOOL_LIST(name, def, flags, NULL, NULL)
760
763#define CFG_BOOL_CB(name, def, flags, cb) \
764 __CFG_BOOL(name, def, flags, NULL, cb)
765
768#define CFG_BOOL_LIST_CB(name, def, flags, cb) \
769 __CFG_BOOL_LIST(name, def, flags, NULL, cb)
770
774#define CFG_SIMPLE_BOOL(name, svalue) \
775 __CFG_BOOL(name, cfg_false, CFGF_NONE, svalue, NULL)
776
777
778
790#define CFG_SEC(_name, _opts, _flags) { \
791 .name = _name, \
792 .type = CFGT_SEC, \
793 .flags = _flags, \
794 .subopts = _opts, \
795}
796
797
798
805#define CFG_FUNC(_name, _func) { \
806 .name = _name, \
807 .type = CFGT_FUNC, \
808 .func = _func, \
809}
810
811
812#define __CFG_PTR(_name, _def, _flags, _svalue, _parsecb, _freecb) { \
813 .name = _name, \
814 .type = CFGT_PTR, \
815 .flags = _flags, \
816 .def = { .parsed = _def, }, \
817 .simple_value = { .ptr = _svalue, }, \
818 .parsecb = _parsecb, \
819 .freecb = _freecb, \
820}
821#define __CFG_PTR_LIST(name, def, flags, svalue, parsecb, freecb) { \
822 .name = _name, \
823 .type = CFGT_PTR, \
824 .flags = _flags | CFGF_LIST, \
825 .def = { .parsed = _def, }, \
826 .simple_value = { .ptr = _svalue, }, \
827 .parsecb = _parsecb, \
828 .freecb = _freecb, \
829}
830
843#define CFG_PTR_CB(name, def, flags, parsecb, freecb) \
844 __CFG_PTR(name, def, flags, NULL, parsecb, freecb)
845
848#define CFG_PTR_LIST_CB(name, def, flags, parsecb, freecb) \
849 __CFG_PTR(name, def, flags | CFGF_LIST, NULL, parsecb, freecb)
850
851/*#define CFG_SIMPLE_PTR(name, svalue, cb) \
852 __CFG_PTR(name, 0, 0, svalue, cb)*/
853
854
858#define CFG_END() \
859 { .type = CFGT_NONE, }
860
861
862
890DLLIMPORT cfg_t *__export cfg_init(cfg_opt_t *opts, cfg_flag_t flags);
891
908DLLIMPORT int __export cfg_add_searchpath(cfg_t *cfg, const char *dir);
909
921DLLIMPORT char *__export cfg_searchpath(cfg_searchpath_t *path, const char *file);
922
936DLLIMPORT int __export cfg_parse(cfg_t *cfg, const char *filename);
937
955DLLIMPORT int __export cfg_parse_fp(cfg_t *cfg, FILE *fp);
956
973DLLIMPORT int __export cfg_parse_buf(cfg_t *cfg, const char *buf);
974
982DLLIMPORT int __export cfg_free_value(cfg_opt_t *opt);
983
989DLLIMPORT int __export cfg_free(cfg_t *cfg);
990
994DLLIMPORT cfg_errfunc_t __export cfg_set_error_function(cfg_t *cfg, cfg_errfunc_t errfunc);
995
999#ifdef __GNUC__
1000__attribute__((__format__(__printf__, 2, 3)))
1001#endif
1002DLLIMPORT void __export cfg_error(cfg_t *cfg, const char *fmt, ...);
1003
1008DLLIMPORT char * __export cfg_opt_getcomment(cfg_opt_t *opt);
1009
1020DLLIMPORT char * __export cfg_getcomment(cfg_t *cfg, const char *name);
1021
1027DLLIMPORT signed long __export cfg_opt_getnint(cfg_opt_t *opt, unsigned int index);
1028
1035DLLIMPORT long int __export cfg_getnint(cfg_t *cfg, const char *name, unsigned int index);
1036
1046DLLIMPORT long int __export cfg_getint(cfg_t *cfg, const char *name);
1047
1054DLLIMPORT int64_t __export cfg_opt_getnint64(cfg_opt_t *opt, unsigned int index);
1061DLLIMPORT int64_t __export cfg_getnint64(cfg_t *cfg, const char *name, unsigned int index);
1067DLLIMPORT int64_t __export cfg_getint64(cfg_t *cfg, const char *name);
1068
1075DLLIMPORT uint32_t __export cfg_opt_getnuint32(cfg_opt_t *opt, unsigned int index);
1082DLLIMPORT uint32_t __export cfg_getnuint32(cfg_t *cfg, const char *name, unsigned int index);
1088DLLIMPORT uint32_t __export cfg_getuint32(cfg_t *cfg, const char *name);
1089
1096DLLIMPORT uint64_t __export cfg_opt_getnuint64(cfg_opt_t *opt, unsigned int index);
1103DLLIMPORT uint64_t __export cfg_getnuint64(cfg_t *cfg, const char *name, unsigned int index);
1109DLLIMPORT uint64_t __export cfg_getuint64(cfg_t *cfg, const char *name);
1110
1117DLLIMPORT int8_t __export cfg_opt_getnint8(cfg_opt_t *opt, unsigned int index);
1124DLLIMPORT int8_t __export cfg_getnint8(cfg_t *cfg, const char *name, unsigned int index);
1130DLLIMPORT int8_t __export cfg_getint8(cfg_t *cfg, const char *name);
1131
1138DLLIMPORT int16_t __export cfg_opt_getnint16(cfg_opt_t *opt, unsigned int index);
1145DLLIMPORT int16_t __export cfg_getnint16(cfg_t *cfg, const char *name, unsigned int index);
1151DLLIMPORT int16_t __export cfg_getint16(cfg_t *cfg, const char *name);
1152
1159DLLIMPORT int32_t __export cfg_opt_getnint32(cfg_opt_t *opt, unsigned int index);
1166DLLIMPORT int32_t __export cfg_getnint32(cfg_t *cfg, const char *name, unsigned int index);
1172DLLIMPORT int32_t __export cfg_getint32(cfg_t *cfg, const char *name);
1173
1180DLLIMPORT uint8_t __export cfg_opt_getnuint8(cfg_opt_t *opt, unsigned int index);
1187DLLIMPORT uint8_t __export cfg_getnuint8(cfg_t *cfg, const char *name, unsigned int index);
1193DLLIMPORT uint8_t __export cfg_getuint8(cfg_t *cfg, const char *name);
1194
1201DLLIMPORT uint16_t __export cfg_opt_getnuint16(cfg_opt_t *opt, unsigned int index);
1208DLLIMPORT uint16_t __export cfg_getnuint16(cfg_t *cfg, const char *name, unsigned int index);
1214DLLIMPORT uint16_t __export cfg_getuint16(cfg_t *cfg, const char *name);
1215
1221DLLIMPORT double __export cfg_opt_getnfloat(cfg_opt_t *opt, unsigned int index);
1222
1229DLLIMPORT double __export cfg_getnfloat(cfg_t *cfg, const char *name, unsigned int index);
1230
1239DLLIMPORT double __export cfg_getfloat(cfg_t *cfg, const char *name);
1240
1246DLLIMPORT char *__export cfg_opt_getnstr(cfg_opt_t *opt, unsigned int index);
1247
1254DLLIMPORT char *__export cfg_getnstr(cfg_t *cfg, const char *name, unsigned int index);
1255
1264DLLIMPORT char *__export cfg_getstr(cfg_t *cfg, const char *name);
1265
1271DLLIMPORT cfg_bool_t __export cfg_opt_getnbool(cfg_opt_t *opt, unsigned int index);
1272
1280DLLIMPORT cfg_bool_t __export cfg_getnbool(cfg_t *cfg, const char *name, unsigned int index);
1281
1290DLLIMPORT cfg_bool_t __export cfg_getbool(cfg_t *cfg, const char *name);
1291
1292
1299DLLIMPORT void *__export cfg_opt_getnptr(cfg_opt_t *opt, unsigned int index);
1306DLLIMPORT void *__export cfg_getnptr(cfg_t *cfg, const char *name, unsigned int index);
1307
1316DLLIMPORT void *__export cfg_getptr(cfg_t *cfg, const char *name);
1317
1318
1324DLLIMPORT cfg_t *__export cfg_opt_getnsec(cfg_opt_t *opt, unsigned int index);
1325
1334DLLIMPORT cfg_t *__export cfg_getnsec(cfg_t *cfg, const char *name, unsigned int index);
1335
1343DLLIMPORT cfg_t *__export cfg_opt_gettsec(cfg_opt_t *opt, const char *title);
1344
1354DLLIMPORT cfg_t *__export cfg_gettsec(cfg_t *cfg, const char *name, const char *title);
1355
1366DLLIMPORT cfg_t *__export cfg_getsec(cfg_t *cfg, const char *name);
1367
1373DLLIMPORT unsigned int __export cfg_opt_size(cfg_opt_t *opt);
1374
1387DLLIMPORT unsigned int __export cfg_size(cfg_t *cfg, const char *name);
1388
1395DLLIMPORT const char *__export cfg_title(cfg_t *cfg);
1396
1402DLLIMPORT const char *__export cfg_getraw(cfg_t *cfg);
1403
1410DLLIMPORT const char *__export cfg_name(cfg_t *cfg);
1411
1418DLLIMPORT const char *__export cfg_opt_name(cfg_opt_t *opt);
1419
1427DLLIMPORT const char *cfg_opt_getstr(cfg_opt_t *opt);
1428
1434DLLIMPORT int __export cfg_include(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv);
1435
1442DLLIMPORT char *__export cfg_tilde_expand(const char *filename);
1443
1451DLLIMPORT int __export cfg_parse_boolean(const char *s);
1452
1459DLLIMPORT cfg_opt_t *cfg_getnopt(cfg_t *cfg, unsigned int index);
1460
1469DLLIMPORT cfg_opt_t *__export cfg_getopt(cfg_t *cfg, const char *name);
1470
1479DLLIMPORT cfg_value_t *cfg_setopt(cfg_t *cfg, cfg_opt_t *opt, const char *value);
1480
1487DLLIMPORT int __export cfg_opt_setcomment(cfg_opt_t *opt, char *comment);
1488
1507DLLIMPORT int __export cfg_setcomment(cfg_t *cfg, const char *name, char *comment);
1508
1519DLLIMPORT int __export cfg_opt_setnint(cfg_opt_t *opt, long int value, unsigned int index);
1520
1530DLLIMPORT int __export cfg_setint(cfg_t *cfg, const char *name, long int value);
1531
1543DLLIMPORT int __export cfg_setnint(cfg_t *cfg, const char *name, long int value, unsigned int index);
1544
1551DLLIMPORT int __export cfg_opt_setnint64(cfg_opt_t *opt, int64_t value, unsigned int index);
1558DLLIMPORT int __export cfg_setint64(cfg_t *cfg, const char *name, int64_t value);
1566DLLIMPORT int __export cfg_setnint64(cfg_t *cfg, const char *name, int64_t value, unsigned int index);
1567
1574DLLIMPORT int __export cfg_opt_setnuint32(cfg_opt_t *opt, uint32_t value, unsigned int index);
1581DLLIMPORT int __export cfg_setuint32(cfg_t *cfg, const char *name, uint32_t value);
1589DLLIMPORT int __export cfg_setnuint32(cfg_t *cfg, const char *name, uint32_t value, unsigned int index);
1590
1597DLLIMPORT int __export cfg_opt_setnuint64(cfg_opt_t *opt, uint64_t value, unsigned int index);
1604DLLIMPORT int __export cfg_setuint64(cfg_t *cfg, const char *name, uint64_t value);
1612DLLIMPORT int __export cfg_setnuint64(cfg_t *cfg, const char *name, uint64_t value, unsigned int index);
1613
1620DLLIMPORT int __export cfg_opt_setnint8(cfg_opt_t *opt, int8_t value, unsigned int index);
1627DLLIMPORT int __export cfg_setint8(cfg_t *cfg, const char *name, int8_t value);
1635DLLIMPORT int __export cfg_setnint8(cfg_t *cfg, const char *name, int8_t value, unsigned int index);
1636
1643DLLIMPORT int __export cfg_opt_setnint16(cfg_opt_t *opt, int16_t value, unsigned int index);
1650DLLIMPORT int __export cfg_setint16(cfg_t *cfg, const char *name, int16_t value);
1658DLLIMPORT int __export cfg_setnint16(cfg_t *cfg, const char *name, int16_t value, unsigned int index);
1659
1666DLLIMPORT int __export cfg_opt_setnint32(cfg_opt_t *opt, int32_t value, unsigned int index);
1673DLLIMPORT int __export cfg_setint32(cfg_t *cfg, const char *name, int32_t value);
1681DLLIMPORT int __export cfg_setnint32(cfg_t *cfg, const char *name, int32_t value, unsigned int index);
1682
1689DLLIMPORT int __export cfg_opt_setnuint8(cfg_opt_t *opt, uint8_t value, unsigned int index);
1696DLLIMPORT int __export cfg_setuint8(cfg_t *cfg, const char *name, uint8_t value);
1704DLLIMPORT int __export cfg_setnuint8(cfg_t *cfg, const char *name, uint8_t value, unsigned int index);
1705
1712DLLIMPORT int __export cfg_opt_setnuint16(cfg_opt_t *opt, uint16_t value, unsigned int index);
1719DLLIMPORT int __export cfg_setuint16(cfg_t *cfg, const char *name, uint16_t value);
1727DLLIMPORT int __export cfg_setnuint16(cfg_t *cfg, const char *name, uint16_t value, unsigned int index);
1728
1739DLLIMPORT int __export cfg_opt_setnfloat(cfg_opt_t *opt, double value, unsigned int index);
1740
1750DLLIMPORT int __export cfg_setfloat(cfg_t *cfg, const char *name, double value);
1751
1763DLLIMPORT int __export cfg_setnfloat(cfg_t *cfg, const char *name, double value, unsigned int index);
1764
1775DLLIMPORT int __export cfg_opt_setnbool(cfg_opt_t *opt, cfg_bool_t value, unsigned int index);
1776
1786DLLIMPORT int __export cfg_setbool(cfg_t *cfg, const char *name, cfg_bool_t value);
1787
1799DLLIMPORT int __export cfg_setnbool(cfg_t *cfg, const char *name, cfg_bool_t value, unsigned int index);
1800
1812DLLIMPORT int __export cfg_opt_setnstr(cfg_opt_t *opt, const char *value, unsigned int index);
1813
1824DLLIMPORT int __export cfg_setstr(cfg_t *cfg, const char *name, const char *value);
1825
1838DLLIMPORT int __export cfg_setnstr(cfg_t *cfg, const char *name, const char *value, unsigned int index);
1839
1852DLLIMPORT int __export cfg_setlist(cfg_t *cfg, const char *name, unsigned int nvalues, ...);
1853
1858DLLIMPORT int __export cfg_numopts(cfg_opt_t *opts);
1859
1869DLLIMPORT unsigned int __export cfg_num(cfg_t *cfg);
1870
1883DLLIMPORT int __export cfg_addlist(cfg_t *cfg, const char *name, unsigned int nvalues, ...);
1884
1894DLLIMPORT int cfg_opt_setmulti(cfg_t *cfg, cfg_opt_t *opt, unsigned int nvalues, char **values);
1895
1905DLLIMPORT int cfg_setmulti(cfg_t *cfg, const char *name, unsigned int nvalues, char **values);
1906
1917DLLIMPORT cfg_t *cfg_addtsec(cfg_t *cfg, const char *name, const char *title);
1918
1926DLLIMPORT int __export cfg_opt_rmnsec(cfg_opt_t *opt, unsigned int index);
1927
1936DLLIMPORT int __export cfg_rmnsec(cfg_t *cfg, const char *name, unsigned int index);
1937
1945DLLIMPORT int __export cfg_rmsec(cfg_t *cfg, const char *name);
1946
1956DLLIMPORT int __export cfg_opt_rmtsec(cfg_opt_t *opt, const char *title);
1957
1969DLLIMPORT int __export cfg_rmtsec(cfg_t *cfg, const char *name, const char *title);
1970
1985DLLIMPORT int __export cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp);
1986
1993DLLIMPORT int __export cfg_opt_print_indent(cfg_opt_t *opt, FILE *fp, int indent);
1994
2007DLLIMPORT int __export cfg_opt_print(cfg_opt_t *opt, FILE *fp);
2008
2015DLLIMPORT int __export cfg_print_indent(cfg_t *cfg, FILE *fp, int indent);
2016
2032DLLIMPORT int __export cfg_print(cfg_t *cfg, FILE *fp);
2033
2042
2051DLLIMPORT cfg_print_func_t __export cfg_set_print_func(cfg_t *cfg, const char *name, cfg_print_func_t pf);
2052
2067
2076DLLIMPORT cfg_validate_callback_t __export cfg_set_validate_func(cfg_t *cfg, const char *name, cfg_validate_callback_t vf);
2077
2091DLLIMPORT cfg_validate_callback2_t __export cfg_set_validate_func2(cfg_t *cfg, const char *name, cfg_validate_callback2_t vf);
2092
2093#ifdef __cplusplus
2094}
2095#endif
2096#endif /* CONFUSE_H_ */
2097
DLLIMPORT int __export cfg_setfloat(cfg_t *cfg, const char *name, double value)
Set the value of a floating point option given its name.
Definition confuse.c:2967
DLLIMPORT cfg_print_func_t __export cfg_set_print_func(cfg_t *cfg, const char *name, cfg_print_func_t pf)
Set a print callback function for an option given its name.
Definition confuse.c:3482
DLLIMPORT int16_t __export cfg_getnint16(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getint16(), used for lists.
Definition confuse.c:586
DLLIMPORT int __export cfg_setuint32(cfg_t *cfg, const char *name, uint32_t value)
Set the value of a CFGT_UINT32 (32-bit unsigned) option.
Definition confuse.c:2722
DLLIMPORT int __export cfg_opt_setnuint16(cfg_opt_t *opt, uint16_t value, unsigned int index)
Set the value of a CFGT_UINT16 (16-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:2902
DLLIMPORT char *__export cfg_opt_getcomment(cfg_opt_t *opt)
Returns the option comment.
Definition confuse.c:433
DLLIMPORT char *__export cfg_getnstr(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getstr(), used for lists.
Definition confuse.c:736
DLLIMPORT int __export cfg_parse(cfg_t *cfg, const char *filename)
Parse a configuration file.
Definition confuse.c:2299
DLLIMPORT void *__export cfg_getnptr(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getptr(), used for lists of user-defined values.
Definition confuse.c:761
int cfg_flag_t
Option flags, a bitwise OR of CFGF_* values.
Definition confuse.h:113
DLLIMPORT uint32_t __export cfg_opt_getnuint32(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_UINT32 (32-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:496
DLLIMPORT unsigned int __export cfg_opt_size(cfg_opt_t *opt)
Return the number of values this option has.
Definition confuse.c:421
int(* cfg_validate_callback_t)(cfg_t *cfg, cfg_opt_t *opt)
Validating callback prototype.
Definition confuse.h:201
void(* cfg_free_func_t)(void *value)
User-defined memory release function for CFG_PTR values.
Definition confuse.h:227
DLLIMPORT int64_t __export cfg_getnint64(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getint64(), used for lists.
Definition confuse.c:486
DLLIMPORT const char *__export cfg_opt_name(cfg_opt_t *opt)
Return the name of an option.
Definition confuse.c:409
void(* cfg_print_func_t)(cfg_opt_t *opt, unsigned int index, FILE *fp)
Function prototype used by the cfg_print_ functions.
Definition confuse.h:163
DLLIMPORT int __export cfg_opt_print_indent(cfg_opt_t *opt, FILE *fp, int indent)
Print an option and its value to a file.
Definition confuse.c:3432
DLLIMPORT uint8_t __export cfg_getuint8(cfg_t *cfg, const char *name)
Returns the value of a CFGT_UINT8 (8-bit unsigned) option, same as cfg_getnuint8() with index 0.
Definition confuse.c:641
DLLIMPORT int cfg_setmulti(cfg_t *cfg, const char *name, unsigned int nvalues, char **values)
Set an option (create an instance of an option).
Definition confuse.c:1614
DLLIMPORT uint16_t __export cfg_getnuint16(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getuint16(), used for lists.
Definition confuse.c:661
void(* cfg_errfunc_t)(cfg_t *cfg, const char *fmt, va_list ap)
Error reporting function.
Definition confuse.h:233
DLLIMPORT cfg_t *__export cfg_gettsec(cfg_t *cfg, const char *name, const char *title)
Return a section given the title, used for section with the CFGF_TITLE flag set.
Definition confuse.c:812
DLLIMPORT int __export cfg_setint(cfg_t *cfg, const char *name, long int value)
Set the value of an integer option given its name.
Definition confuse.c:2652
DLLIMPORT cfg_opt_t *__export cfg_getopt(cfg_t *cfg, const char *name)
Return an option given it's name.
Definition confuse.c:383
DLLIMPORT int __export cfg_rmtsec(cfg_t *cfg, const char *name, const char *title)
Removes and frees a section given the title, used for section with the CFGF_TITLE flag set.
Definition confuse.c:3255
DLLIMPORT cfg_print_func_t __export cfg_opt_set_print_func(cfg_opt_t *opt, cfg_print_func_t pf)
Set a print callback function for an option.
Definition confuse.c:3467
DLLIMPORT int __export cfg_setnint16(cfg_t *cfg, const char *name, int16_t value, unsigned int index)
Set a value of a CFGT_INT16 (16-bit signed) option at a given list index.
Definition confuse.c:2816
DLLIMPORT int32_t __export cfg_getnint32(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getint32(), used for lists.
Definition confuse.c:611
DLLIMPORT int __export cfg_setint32(cfg_t *cfg, const char *name, int32_t value)
Set the value of a CFGT_INT32 (32-bit signed) option.
Definition confuse.c:2862
DLLIMPORT int __export cfg_opt_setnstr(cfg_opt_t *opt, const char *value, unsigned int index)
Set a value of a string option.
Definition confuse.c:3001
DLLIMPORT int __export cfg_rmnsec(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_rmsec(), used for CFGF_MULTI sections.
Definition confuse.c:3208
struct cfg_searchpath_t cfg_searchpath_t
An entry in the include search path.
Definition confuse.h:114
DLLIMPORT char *__export cfg_searchpath(cfg_searchpath_t *path, const char *file)
Search the linked-list of cfg_searchpath_t for the specified file.
Definition confuse.c:2260
DLLIMPORT int __export cfg_setnint(cfg_t *cfg, const char *name, long int value, unsigned int index)
Set a value of an integer option given its name and index.
Definition confuse.c:2641
DLLIMPORT void *__export cfg_getptr(cfg_t *cfg, const char *name)
Returns the value of a user-defined option (void pointer).
Definition confuse.c:766
DLLIMPORT double __export cfg_getfloat(cfg_t *cfg, const char *name)
Returns the value of a floating point option.
Definition confuse.c:691
DLLIMPORT int __export cfg_opt_setnfloat(cfg_opt_t *opt, double value, unsigned int index)
Set a value of a floating point option.
Definition confuse.c:2937
DLLIMPORT int __export cfg_free_value(cfg_opt_t *opt)
Free the memory allocated for the values of a given option.
Definition confuse.c:2450
DLLIMPORT uint32_t __export cfg_getnuint32(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getuint32(), used for lists.
Definition confuse.c:511
cfg_bool_t
Boolean values.
Definition confuse.h:230
DLLIMPORT char *__export cfg_getcomment(cfg_t *cfg, const char *name)
Returns the option comment.
Definition confuse.c:441
DLLIMPORT int __export cfg_addlist(cfg_t *cfg, const char *name, unsigned int nvalues,...)
Add values for a list option.
Definition confuse.c:3134
DLLIMPORT cfg_value_t * cfg_setopt(cfg_t *cfg, cfg_opt_t *opt, const char *value)
Set an option (create an instance of an option).
Definition confuse.c:1179
DLLIMPORT int __export cfg_setstr(cfg_t *cfg, const char *name, const char *value)
Set the value of a string option given its name.
Definition confuse.c:3045
DLLIMPORT int __export cfg_parse_boolean(const char *s)
Parse a boolean option string.
Definition confuse.c:944
int(* cfg_validate_callback2_t)(cfg_t *cfg, cfg_opt_t *opt, void *value)
Validating callback2 prototype.
Definition confuse.h:217
DLLIMPORT int __export cfg_setnuint64(cfg_t *cfg, const char *name, uint64_t value, unsigned int index)
Set a value of a CFGT_UINT64 (64-bit unsigned) option at a given list index.
Definition confuse.c:2746
DLLIMPORT int __export cfg_setnuint8(cfg_t *cfg, const char *name, uint8_t value, unsigned int index)
Set a value of a CFGT_UINT8 (8-bit unsigned) option at a given list index.
Definition confuse.c:2886
DLLIMPORT void __export cfg_error(cfg_t *cfg, const char *fmt,...)
Show a parser error.
Definition confuse.c:1697
DLLIMPORT cfg_opt_t * cfg_getnopt(cfg_t *cfg, unsigned int index)
Return the nth option in a file or section.
Definition confuse.c:368
DLLIMPORT cfg_t *__export cfg_getsec(cfg_t *cfg, const char *name)
Returns the value of a section option.
Definition confuse.c:817
DLLIMPORT int __export cfg_setint8(cfg_t *cfg, const char *name, int8_t value)
Set the value of a CFGT_INT8 (8-bit signed) option.
Definition confuse.c:2792
DLLIMPORT void *__export cfg_opt_getnptr(cfg_opt_t *opt, unsigned int index)
Returns the value of a user-defined (CFGT_PTR) option, given a cfg_opt_t pointer.
Definition confuse.c:746
DLLIMPORT int __export cfg_setnint64(cfg_t *cfg, const char *name, int64_t value, unsigned int index)
Set a value of a CFGT_INT64 (64-bit signed) option at a given list index.
Definition confuse.c:2676
DLLIMPORT int __export cfg_setnstr(cfg_t *cfg, const char *name, const char *value, unsigned int index)
Set a value of a boolean option given its name and index.
Definition confuse.c:3034
DLLIMPORT uint64_t __export cfg_getnuint64(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getuint64(), used for lists.
Definition confuse.c:536
DLLIMPORT int __export cfg_numopts(cfg_opt_t *opts)
Count the number of options in a cfg_opt_t array.
Definition confuse.c:869
DLLIMPORT cfg_print_filter_func_t __export cfg_set_print_filter_func(cfg_t *cfg, cfg_print_filter_func_t pff)
Install a user-defined print filter function.
Definition confuse.c:1682
DLLIMPORT int8_t __export cfg_opt_getnint8(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_INT8 (8-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:546
DLLIMPORT int __export cfg_add_searchpath(cfg_t *cfg, const char *dir)
Add a searchpath directory to the configuration context, the const char* argument will be duplicated ...
Definition confuse.c:1640
DLLIMPORT cfg_t *__export cfg_opt_getnsec(cfg_opt_t *opt, unsigned int index)
Returns the value of a section option, given a cfg_opt_t pointer.
Definition confuse.c:771
DLLIMPORT int __export cfg_setint16(cfg_t *cfg, const char *name, int16_t value)
Set the value of a CFGT_INT16 (16-bit signed) option.
Definition confuse.c:2827
DLLIMPORT int __export cfg_parse_buf(cfg_t *cfg, const char *buf)
Same as cfg_parse() above, but takes a character buffer as argument.
Definition confuse.c:2330
DLLIMPORT int __export cfg_setuint16(cfg_t *cfg, const char *name, uint16_t value)
Set the value of a CFGT_UINT16 (16-bit unsigned) option.
Definition confuse.c:2932
DLLIMPORT char *__export cfg_getstr(cfg_t *cfg, const char *name)
Returns the value of a string option.
Definition confuse.c:741
int(* cfg_callback_t)(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result)
Value parsing callback prototype.
Definition confuse.h:186
DLLIMPORT int __export cfg_opt_setnint64(cfg_opt_t *opt, int64_t value, unsigned int index)
Set the value of a CFGT_INT64 (64-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:2657
DLLIMPORT int __export cfg_include(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv)
Predefined include-function.
Definition confuse.c:2551
DLLIMPORT int cfg_opt_setmulti(cfg_t *cfg, cfg_opt_t *opt, unsigned int nvalues, char **values)
Set an option (create an instance of an option).
Definition confuse.c:1580
DLLIMPORT char *__export cfg_tilde_expand(const char *filename)
Does tilde expansion (~ -> $HOME) on the filename.
Definition confuse.c:2401
int(* cfg_func_t)(cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv)
Function prototype used by CFGT_FUNC options.
Definition confuse.h:141
DLLIMPORT int __export cfg_setnfloat(cfg_t *cfg, const char *name, double value, unsigned int index)
Set a value of a floating point option given its name and index.
Definition confuse.c:2956
DLLIMPORT int64_t __export cfg_opt_getnint64(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_INT64 (64-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:471
DLLIMPORT int16_t __export cfg_opt_getnint16(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_INT16 (16-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:571
DLLIMPORT int __export cfg_opt_setnbool(cfg_opt_t *opt, cfg_bool_t value, unsigned int index)
Set a value of a boolean option.
Definition confuse.c:2972
DLLIMPORT int __export cfg_parse_fp(cfg_t *cfg, FILE *fp)
Same as cfg_parse() above, but takes an already opened file as argument.
Definition confuse.c:2207
DLLIMPORT int __export cfg_opt_setnuint64(cfg_opt_t *opt, uint64_t value, unsigned int index)
Set the value of a CFGT_UINT64 (64-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:2727
DLLIMPORT cfg_t *__export cfg_init(cfg_opt_t *opts, cfg_flag_t flags)
Create and initialize a cfg_t structure.
Definition confuse.c:2366
DLLIMPORT cfg_bool_t __export cfg_getnbool(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getbool(), used for lists.
Definition confuse.c:711
DLLIMPORT int __export cfg_opt_rmnsec(cfg_opt_t *opt, unsigned int index)
Removes and frees a config section, given a cfg_opt_t pointer.
Definition confuse.c:3178
DLLIMPORT const char *__export cfg_title(cfg_t *cfg)
Return the title of a section.
Definition confuse.c:388
DLLIMPORT cfg_validate_callback_t __export cfg_set_validate_func(cfg_t *cfg, const char *name, cfg_validate_callback_t vf)
Register a validating callback function for an option.
Definition confuse.c:3551
DLLIMPORT int __export cfg_setlist(cfg_t *cfg, const char *name, unsigned int nvalues,...)
Set values for a list option.
Definition confuse.c:3116
DLLIMPORT cfg_validate_callback2_t __export cfg_set_validate_func2(cfg_t *cfg, const char *name, cfg_validate_callback2_t vf)
Register a validating callback function for an option.
Definition confuse.c:3566
DLLIMPORT int __export cfg_opt_nprint_var(cfg_opt_t *opt, unsigned int index, FILE *fp)
Default value print function.
Definition confuse.c:3260
const char __export confuse_copyright[]
libConfuse copyright string
Definition confuse.c:61
cfg_type_t
Fundamental option types.
Definition confuse.h:59
@ CFGT_UINT16
16-bit unsigned integer
Definition confuse.h:77
@ CFGT_PTR
pointer to user-defined value
Definition confuse.h:67
@ CFGT_UINT8
8-bit unsigned integer
Definition confuse.h:76
@ CFGT_COMMENT
comment/annotation
Definition confuse.h:68
@ CFGT_FUNC
function
Definition confuse.h:66
@ CFGT_UINT64
64-bit unsigned integer
Definition confuse.h:72
@ CFGT_INT32
32-bit signed integer
Definition confuse.h:75
@ CFGT_BOOL
boolean value
Definition confuse.h:64
@ CFGT_SEC
section
Definition confuse.h:65
@ CFGT_FLOAT
floating point number
Definition confuse.h:62
@ CFGT_STR
string
Definition confuse.h:63
@ CFGT_INT8
8-bit signed integer
Definition confuse.h:73
@ CFGT_INT64
64-bit signed integer
Definition confuse.h:70
@ CFGT_RAWSEC
section whose body is captured verbatim as a string
Definition confuse.h:69
@ CFGT_INT16
16-bit signed integer
Definition confuse.h:74
@ CFGT_INT
integer
Definition confuse.h:61
@ CFGT_UINT32
32-bit unsigned integer
Definition confuse.h:71
DLLIMPORT int __export cfg_rmsec(cfg_t *cfg, const char *name)
Removes and frees a config section.
Definition confuse.c:3213
const char __export confuse_version[]
libConfuse version string
Definition confuse.c:60
DLLIMPORT int __export cfg_opt_setnuint32(cfg_opt_t *opt, uint32_t value, unsigned int index)
Set the value of a CFGT_UINT32 (32-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:2692
DLLIMPORT int8_t __export cfg_getint8(cfg_t *cfg, const char *name)
Returns the value of a CFGT_INT8 (8-bit signed) option, same as cfg_getnint8() with index 0.
Definition confuse.c:566
DLLIMPORT uint8_t __export cfg_opt_getnuint8(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_UINT8 (8-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:621
DLLIMPORT unsigned int __export cfg_num(cfg_t *cfg)
Return number of options in a file or section.
Definition confuse.c:878
DLLIMPORT double __export cfg_opt_getnfloat(cfg_opt_t *opt, unsigned int index)
Returns the value of a floating point option, given a cfg_opt_t pointer.
Definition confuse.c:671
DLLIMPORT long int __export cfg_getint(cfg_t *cfg, const char *name)
Returns the value of an integer option.
Definition confuse.c:466
DLLIMPORT int __export cfg_setnint8(cfg_t *cfg, const char *name, int8_t value, unsigned int index)
Set a value of a CFGT_INT8 (8-bit signed) option at a given list index.
Definition confuse.c:2781
DLLIMPORT char *__export cfg_opt_getnstr(cfg_opt_t *opt, unsigned int index)
Returns the value of a string option, given a cfg_opt_t pointer.
Definition confuse.c:721
DLLIMPORT int __export cfg_print_indent(cfg_t *cfg, FILE *fp, int indent)
Print the options and values to a file.
Definition confuse.c:3457
DLLIMPORT int __export cfg_setuint64(cfg_t *cfg, const char *name, uint64_t value)
Set the value of a CFGT_UINT64 (64-bit unsigned) option.
Definition confuse.c:2757
DLLIMPORT cfg_t *__export cfg_opt_gettsec(cfg_opt_t *opt, const char *title)
Returns the value of a section option, given a cfg_opt_t pointer and the title.
Definition confuse.c:790
DLLIMPORT int __export cfg_free(cfg_t *cfg)
Free a cfg_t context.
Definition confuse.c:2514
DLLIMPORT double __export cfg_getnfloat(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getfloat(), used for lists.
Definition confuse.c:686
DLLIMPORT const char * cfg_opt_getstr(cfg_opt_t *opt)
Return the string value of a key=value pair.
Definition confuse.c:416
DLLIMPORT cfg_bool_t __export cfg_getbool(cfg_t *cfg, const char *name)
Returns the value of a boolean option.
Definition confuse.c:716
DLLIMPORT const char *__export cfg_getraw(cfg_t *cfg)
Return the verbatim body of a raw section (CFGT_RAWSEC).
Definition confuse.c:395
DLLIMPORT int __export cfg_opt_rmtsec(cfg_opt_t *opt, const char *title)
Removes and frees a config section, given a cfg_opt_t pointer and the title.
Definition confuse.c:3222
DLLIMPORT int __export cfg_setnbool(cfg_t *cfg, const char *name, cfg_bool_t value, unsigned int index)
Set a value of a boolean option given its name and index.
Definition confuse.c:2991
DLLIMPORT int __export cfg_setuint8(cfg_t *cfg, const char *name, uint8_t value)
Set the value of a CFGT_UINT8 (8-bit unsigned) option.
Definition confuse.c:2897
DLLIMPORT signed long __export cfg_opt_getnint(cfg_opt_t *opt, unsigned int index)
Returns the value of an integer option, given a cfg_opt_t pointer.
Definition confuse.c:446
DLLIMPORT int __export cfg_setcomment(cfg_t *cfg, const char *name, char *comment)
Annotate an option given its name.
Definition confuse.c:2617
int(* cfg_print_filter_func_t)(cfg_t *cfg, cfg_opt_t *opt)
Print filter function.
Definition confuse.h:244
DLLIMPORT int64_t __export cfg_getint64(cfg_t *cfg, const char *name)
Returns the value of a CFGT_INT64 (64-bit signed) option, same as cfg_getnint64() with index 0.
Definition confuse.c:491
DLLIMPORT const char *__export cfg_name(cfg_t *cfg)
Return the name of a section.
Definition confuse.c:402
DLLIMPORT int __export cfg_print(cfg_t *cfg, FILE *fp)
Print the options and values to a file.
Definition confuse.c:3462
DLLIMPORT int __export cfg_opt_setnint8(cfg_opt_t *opt, int8_t value, unsigned int index)
Set the value of a CFGT_INT8 (8-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:2762
DLLIMPORT int __export cfg_setbool(cfg_t *cfg, const char *name, cfg_bool_t value)
Set the value of a boolean option given its name.
Definition confuse.c:2996
DLLIMPORT int __export cfg_opt_print(cfg_opt_t *opt, FILE *fp)
Print an option and its value to a file.
Definition confuse.c:3437
DLLIMPORT unsigned int __export cfg_size(cfg_t *cfg, const char *name)
Return the number of values this option has.
Definition confuse.c:428
DLLIMPORT uint64_t __export cfg_getuint64(cfg_t *cfg, const char *name)
Returns the value of a CFGT_UINT64 (64-bit unsigned) option, same as cfg_getnuint64() with index 0.
Definition confuse.c:541
DLLIMPORT int8_t __export cfg_getnint8(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getint8(), used for lists.
Definition confuse.c:561
DLLIMPORT int __export cfg_setnuint32(cfg_t *cfg, const char *name, uint32_t value, unsigned int index)
Set a value of a CFGT_UINT32 (32-bit unsigned) option at a given list index.
Definition confuse.c:2711
DLLIMPORT uint16_t __export cfg_opt_getnuint16(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_UINT16 (16-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:646
DLLIMPORT int __export cfg_opt_setnint(cfg_opt_t *opt, long int value, unsigned int index)
Set a value of an integer option.
Definition confuse.c:2622
DLLIMPORT uint32_t __export cfg_getuint32(cfg_t *cfg, const char *name)
Returns the value of a CFGT_UINT32 (32-bit unsigned) option, same as cfg_getnuint32() with index 0.
Definition confuse.c:516
DLLIMPORT int __export cfg_opt_setnint16(cfg_opt_t *opt, int16_t value, unsigned int index)
Set the value of a CFGT_INT16 (16-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:2797
DLLIMPORT long int __export cfg_getnint(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getint(), used for lists.
Definition confuse.c:461
DLLIMPORT uint16_t __export cfg_getuint16(cfg_t *cfg, const char *name)
Returns the value of a CFGT_UINT16 (16-bit unsigned) option, same as cfg_getnuint16() with index 0.
Definition confuse.c:666
DLLIMPORT int __export cfg_opt_setnint32(cfg_opt_t *opt, int32_t value, unsigned int index)
Set the value of a CFGT_INT32 (32-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:2832
DLLIMPORT cfg_errfunc_t __export cfg_set_error_function(cfg_t *cfg, cfg_errfunc_t errfunc)
Install a user-defined error reporting function.
Definition confuse.c:1667
DLLIMPORT cfg_t *__export cfg_getnsec(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getsec(), used for sections with the CFGF_MULTI flag set.
Definition confuse.c:785
DLLIMPORT int32_t __export cfg_opt_getnint32(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_INT32 (32-bit signed) option, given a cfg_opt_t pointer.
Definition confuse.c:596
DLLIMPORT uint64_t __export cfg_opt_getnuint64(cfg_opt_t *opt, unsigned int index)
Returns the value of a CFGT_UINT64 (64-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:521
DLLIMPORT int32_t __export cfg_getint32(cfg_t *cfg, const char *name)
Returns the value of a CFGT_INT32 (32-bit signed) option, same as cfg_getnint32() with index 0.
Definition confuse.c:616
DLLIMPORT int __export cfg_opt_setcomment(cfg_opt_t *opt, char *comment)
Annotate an option.
Definition confuse.c:2594
DLLIMPORT int __export cfg_setnint32(cfg_t *cfg, const char *name, int32_t value, unsigned int index)
Set a value of a CFGT_INT32 (32-bit signed) option at a given list index.
Definition confuse.c:2851
DLLIMPORT cfg_bool_t __export cfg_opt_getnbool(cfg_opt_t *opt, unsigned int index)
Returns the value of a boolean option, given a cfg_opt_t pointer.
Definition confuse.c:696
DLLIMPORT cfg_t * cfg_addtsec(cfg_t *cfg, const char *name, const char *title)
Create a new titled config section.
Definition confuse.c:3152
DLLIMPORT int16_t __export cfg_getint16(cfg_t *cfg, const char *name)
Returns the value of a CFGT_INT16 (16-bit signed) option, same as cfg_getnint16() with index 0.
Definition confuse.c:591
const char __export confuse_author[]
libConfuse author string
Definition confuse.c:62
DLLIMPORT int __export cfg_setint64(cfg_t *cfg, const char *name, int64_t value)
Set the value of a CFGT_INT64 (64-bit signed) option.
Definition confuse.c:2687
DLLIMPORT uint8_t __export cfg_getnuint8(cfg_t *cfg, const char *name, unsigned int index)
Indexed version of cfg_getuint8(), used for lists.
Definition confuse.c:636
DLLIMPORT int __export cfg_setnuint16(cfg_t *cfg, const char *name, uint16_t value, unsigned int index)
Set a value of a CFGT_UINT16 (16-bit unsigned) option at a given list index.
Definition confuse.c:2921
DLLIMPORT int __export cfg_opt_setnuint8(cfg_opt_t *opt, uint8_t value, unsigned int index)
Set the value of a CFGT_UINT8 (8-bit unsigned) option, given a cfg_opt_t pointer.
Definition confuse.c:2867
Data structure holding the default value given by the initialization macros.
Definition confuse.h:310
long int number
default integer value
Definition confuse.h:311
const char * string
default string value
Definition confuse.h:314
char * parsed
default value that is parsed by libConfuse, used for lists and functions
Definition confuse.h:315
cfg_bool_t boolean
default boolean value
Definition confuse.h:313
double fpnumber
default floating point value
Definition confuse.h:312
Data structure holding information about an option.
Definition confuse.h:324
const char * name
The name of the option.
Definition confuse.h:325
cfg_type_t type
Type of option.
Definition confuse.h:327
cfg_defvalue_t def
Default value.
Definition confuse.h:332
cfg_callback_t parsecb
Value parsing callback function.
Definition confuse.h:337
cfg_simple_t simple_value
Pointer to user-specified variable to store simple values (created with the CFG_SIMPLE_* initializers...
Definition confuse.h:334
cfg_func_t func
Function callback for CFGT_FUNC options.
Definition confuse.h:333
cfg_free_func_t freecb
user-defined memory release function
Definition confuse.h:341
cfg_validate_callback2_t validcb2
Value validating set callback function.
Definition confuse.h:339
char * comment
Optional comment/annotation.
Definition confuse.h:326
cfg_validate_callback_t validcb
Value validating parsing callback function.
Definition confuse.h:338
cfg_opt_t * subopts
Suboptions (only applies to sections)
Definition confuse.h:331
cfg_print_func_t pf
print callback function
Definition confuse.h:340
cfg_flag_t flags
Flags.
Definition confuse.h:330
cfg_value_t ** values
Array of found values.
Definition confuse.h:329
unsigned int nvalues
Number of values parsed.
Definition confuse.h:328
Data structure holding information about a "section".
Definition confuse.h:250
cfg_opt_t * opts
Array of options.
Definition confuse.h:256
int line
Line number in the config file.
Definition confuse.h:260
cfg_errfunc_t errfunc
This function (if set with cfg_set_error_function) is called for any error message.
Definition confuse.h:261
char * name
The name of this section, the root section returned from cfg_init() is always named "root".
Definition confuse.h:252
char * title
Optional title for this section, only set if CFGF_TITLE flag is set.
Definition confuse.h:257
cfg_print_filter_func_t pff
Printing filter function.
Definition confuse.h:265
cfg_flag_t flags
Any flags passed to cfg_init()
Definition confuse.h:251
char * comment
Optional annotation/comment.
Definition confuse.h:255
char * raw
Verbatim body, set for CFGT_RAWSEC sections.
Definition confuse.h:266
char * filename
Name of the file being parsed.
Definition confuse.h:259
cfg_searchpath_t * path
Linked list of directories to search.
Definition confuse.h:264
Data structure holding the pointer to a user provided variable defined with CFG_SIMPLE_*.
Definition confuse.h:291
int64_t * i64
pointer to an int64_t, for CFG_SIMPLE_INT64
Definition confuse.h:296
uint8_t * u8
pointer to a uint8_t, for CFG_SIMPLE_UINT8
Definition confuse.h:297
int16_t * i16
pointer to an int16_t, for CFG_SIMPLE_INT16
Definition confuse.h:294
uint32_t * u32
pointer to a uint32_t, for CFG_SIMPLE_UINT32
Definition confuse.h:299
uint64_t * u64
pointer to a uint64_t, for CFG_SIMPLE_UINT64
Definition confuse.h:300
void ** ptr
pointer to a user value, for CFG_SIMPLE_PTR
Definition confuse.h:304
long int * number
pointer to a long int, for CFG_SIMPLE_INT
Definition confuse.h:292
char ** string
pointer to a char *, for CFG_SIMPLE_STR
Definition confuse.h:303
cfg_bool_t * boolean
pointer to a cfg_bool_t, for CFG_SIMPLE_BOOL
Definition confuse.h:302
uint16_t * u16
pointer to a uint16_t, for CFG_SIMPLE_UINT16
Definition confuse.h:298
int8_t * i8
pointer to an int8_t, for CFG_SIMPLE_INT8
Definition confuse.h:293
int32_t * i32
pointer to an int32_t, for CFG_SIMPLE_INT32
Definition confuse.h:295
double * fpnumber
pointer to a double, for CFG_SIMPLE_FLOAT
Definition confuse.h:301
Data structure holding the value of a fundamental option value.
Definition confuse.h:271
uint64_t u64
64-bit unsigned integer value
Definition confuse.h:280
void * ptr
user-defined value
Definition confuse.h:285
int64_t i64
64-bit signed integer value
Definition confuse.h:276
int32_t i32
32-bit signed integer value
Definition confuse.h:275
cfg_t * section
section value
Definition confuse.h:284
char * string
string value
Definition confuse.h:283
cfg_bool_t boolean
boolean value
Definition confuse.h:282
long int number
integer value
Definition confuse.h:272
uint32_t u32
32-bit unsigned integer value
Definition confuse.h:279
int16_t i16
16-bit signed integer value
Definition confuse.h:274
uint8_t u8
8-bit unsigned integer value
Definition confuse.h:277
double fpnumber
floating point value
Definition confuse.h:281
int8_t i8
8-bit signed integer value
Definition confuse.h:273
uint16_t u16
16-bit unsigned integer value
Definition confuse.h:278