enum | cfg_type_t { ,
- CFGT_INT,
-CFGT_FLOAT,
-CFGT_STR,
-CFGT_BOOL,
-
- CFGT_SEC,
-CFGT_FUNC,
-CFGT_PTR
-
+A configuration file parser library.
+More...
+#include <stdio.h>
+#include <stdarg.h>
+
+Go to the source code of this file.
+
+ |
+struct | cfg_t |
+ | Data structure holding information about a "section". More...
|
+ |
+union | cfg_value_t |
+ | Data structure holding the value of a fundamental option value. More...
|
+ |
+union | cfg_simple_t |
+ | Data structure holding the pointer to a user provided variable defined with CFG_SIMPLE_*. More...
|
+ |
+struct | cfg_defvalue_t |
+ | Data structure holding the default value given by the initialization macros. More...
|
+ |
+struct | cfg_opt_t |
+ | Data structure holding information about an option. More...
|
+ |
+
+ |
+#define | CFGF_NONE (0) |
+ | Flags. More...
|
+ |
+
+#define | CFGF_MULTI (1 << 0) |
+ | option may be specified multiple times (only applies to sections)
|
+ |
+
+#define | CFGF_LIST (1 << 1) |
+ | option is a list
|
+ |
+
+#define | CFGF_NOCASE (1 << 2) |
+ | configuration file is case insensitive
|
+ |
+
+#define | CFGF_TITLE (1 << 3) |
+ | option has a title (only applies to sections)
|
+ |
+
+#define | CFGF_NODEFAULT (1 << 4) |
+ | option has no default value
|
+ |
+
+#define | CFGF_NO_TITLE_DUPES (1 << 5) |
+ | multiple section titles must be unique (duplicates raises an error, only applies to sections)
|
+ |
+
+#define | CFGF_IGNORE_UNKNOWN (1 << 8) |
+ | ignore unknown options in configuration files
|
+ |
+#define | CFGF_DEPRECATED (1 << 9) |
+ | option is deprecated and should be ignored. More...
|
+ |
+
+#define | CFGF_DROP (1 << 10) |
+ | option should be dropped after parsing
|
+ |
+
+#define | CFGF_COMMENTS (1 << 11) |
+ | Enable option annotation/comments support.
|
+ |
+
+#define | CFGF_MODIFIED (1 << 12) |
+ | option has been changed from its default value
|
+ |
+
+#define | CFGF_KEYSTRVAL (1 << 13) |
+ | section has free-form key=value string options created when parsing file
|
+ |
+#define | CFG_SUCCESS 0 |
+ | Return codes from cfg_parse(), cfg_parse_boolean(), and cfg_set*() functions. More...
|
+ |
+
+#define | CFG_STR(name, def, flags) __CFG_STR(name, def, flags, 0, 0) |
+ | Initialize a string option.
|
+ |
+
+#define | CFG_STR_LIST(name, def, flags) __CFG_STR_LIST(name, def, flags, 0, 0) |
+ | Initialize a string list option.
|
+ |
+
+#define | CFG_STR_CB(name, def, flags, cb) __CFG_STR(name, def, flags, 0, cb) |
+ | Initialize a string option with a value parsing callback.
|
+ |
+
+#define | CFG_STR_LIST_CB(name, def, flags, cb) __CFG_STR_LIST(name, def, flags, 0, cb) |
+ | Initialize a string list option with a value parsing callback.
|
+ |
+#define | CFG_SIMPLE_STR(name, svalue) __CFG_STR(name, 0, CFGF_NONE, svalue, 0) |
+ | Initialize a "simple" string option. More...
|
+ |
+
+#define | CFG_INT(name, def, flags) __CFG_INT(name, def, flags, 0, 0) |
+ | Initialize an integer option.
|
+ |
+
+#define | CFG_INT_LIST(name, def, flags) __CFG_INT_LIST(name, def, flags, 0, 0) |
+ | Initialize an integer list option.
|
+ |
+
+#define | CFG_INT_CB(name, def, flags, cb) __CFG_INT(name, def, flags, 0, cb) |
+ | Initialize an integer option with a value parsing callback.
|
+ |
+
+#define | CFG_INT_LIST_CB(name, def, flags, cb) __CFG_INT_LIST(name, def, flags, 0, cb) |
+ | Initialize an integer list option with a value parsing callback.
|
+ |
+#define | CFG_SIMPLE_INT(name, svalue) __CFG_INT(name, 0, CFGF_NONE, svalue, 0) |
+ | Initialize a "simple" integer option (see documentation for CFG_SIMPLE_STR for more information). More...
|
+ |
+
+#define | CFG_FLOAT(name, def, flags) __CFG_FLOAT(name, def, flags, 0, 0) |
+ | Initialize a floating point option.
|
+ |
+
+#define | CFG_FLOAT_LIST(name, def, flags) __CFG_FLOAT_LIST(name, def, flags, 0, 0) |
+ | Initialize a floating point list option.
|
+ |
+
+#define | CFG_FLOAT_CB(name, def, flags, cb) __CFG_FLOAT(name, def, flags, 0, cb) |
+ | Initialize a floating point option with a value parsing callback.
|
+ |
+
+#define | CFG_FLOAT_LIST_CB(name, def, flags, cb) __CFG_FLOAT_LIST(name, def, flags, 0, cb) |
+ | Initialize a floating point list option with a value parsing callback.
|
+ |
+
+#define | CFG_SIMPLE_FLOAT(name, svalue) __CFG_FLOAT(name, 0, CFGF_NONE, svalue, 0) |
+ | Initialize a "simple" floating point option (see documentation for CFG_SIMPLE_STR for more information).
|
+ |
+
+#define | CFG_BOOL(name, def, flags) __CFG_BOOL(name, def, flags, 0, 0) |
+ | Initialize a boolean option.
|
+ |
+
+#define | CFG_BOOL_LIST(name, def, flags) __CFG_BOOL_LIST(name, def, flags, 0, 0) |
+ | Initialize a boolean list option.
|
+ |
+
+#define | CFG_BOOL_CB(name, def, flags, cb) __CFG_BOOL(name, def, flags, 0, cb) |
+ | Initialize a boolean option with a value parsing callback.
|
+ |
+
+#define | CFG_BOOL_LIST_CB(name, def, flags, cb) __CFG_BOOL_LIST(name, def, flags, 0, cb) |
+ | Initialize a boolean list option with a value parsing callback.
|
+ |
+
+#define | CFG_SIMPLE_BOOL(name, svalue) __CFG_BOOL(name, cfg_false, CFGF_NONE, svalue, 0) |
+ | Initialize a "simple" boolean option (see documentation for CFG_SIMPLE_STR for more information).
|
+ |
+#define | CFG_SEC(name, opts, flags) {name,0,CFGT_SEC,0,0,flags,opts,{0,0,cfg_false,0,0},0,{0},0,0,0,0,0} |
+ | Initialize a section. More...
|
+ |
+#define | CFG_FUNC(name, func) {name,0,CFGT_FUNC,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},func,{0},0,0,0,0,0} |
+ | Initialize a function. More...
|
+ |
+#define | CFG_PTR_CB(name, def, flags, parsecb, freecb) __CFG_PTR(name, def, flags, 0, parsecb, freecb) |
+ | Initialize a user-defined option. More...
|
+ |
+
+#define | CFG_PTR_LIST_CB(name, def, flags, parsecb, freecb) __CFG_PTR(name, def, flags | CFGF_LIST, 0, parsecb, freecb) |
+ | Initialize a list of user-defined options.
|
+ |
+#define | CFG_END() {0,0,CFGT_NONE,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},0,{0},0,0,0,0,0} |
+ | Terminate list of options. More...
|
+ |
+
+ |
+typedef int(* | cfg_func_t) (cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv) |
+ | Function prototype used by CFGT_FUNC options. More...
|
+ |
+typedef void(* | cfg_print_func_t) (cfg_opt_t *opt, unsigned int index, FILE *fp) |
+ | Function prototype used by the cfg_print_ functions. More...
|
+ |
+typedef int(* | cfg_callback_t) (cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result) |
+ | Value parsing callback prototype. More...
|
+ |
+typedef int(* | cfg_validate_callback_t) (cfg_t *cfg, cfg_opt_t *opt) |
+ | Validating callback prototype. More...
|
+ |
+typedef int(* | cfg_validate_callback2_t) (cfg_t *cfg, cfg_opt_t *opt, void *value) |
+ | Validating callback2 prototype. More...
|
+ |
+typedef void(* | cfg_free_func_t) (void *value) |
+ | User-defined memory release function for CFG_PTR values. More...
|
+ |
+typedef void(* | cfg_errfunc_t) (cfg_t *cfg, const char *fmt, va_list ap) |
+ | Error reporting function. More...
|
+ |
+typedef int(* | cfg_print_filter_func_t) (cfg_t *cfg, cfg_opt_t *opt) |
+ | Print filter function. More...
|
+ |
+
+ |
+enum | cfg_type_t { ,
+ CFGT_INT,
+CFGT_FLOAT,
+CFGT_STR,
+CFGT_BOOL,
+
+ CFGT_SEC,
+CFGT_FUNC,
+CFGT_PTR,
+CFGT_COMMENT
+
} |
-
- | Fundamental option types. More...
|
-enum | cfg_bool_t |
-
- | Boolean values. More...
|
-
Functions |
-DLLIMPORT cfg_t *__export | cfg_init (cfg_opt_t *opts, cfg_flag_t flags) |
-
- | Create and initialize a cfg_t structure.
|
-DLLIMPORT int __export | cfg_parse (cfg_t *cfg, const char *filename) |
-
- | Parse a configuration file.
|
-DLLIMPORT int __export | cfg_parse_fp (cfg_t *cfg, FILE *fp) |
-
- | Same as cfg_parse() above, but takes an already opened file as argument.
|
-DLLIMPORT int __export | cfg_parse_buf (cfg_t *cfg, const char *buf) |
-
- | Same as cfg_parse() above, but takes a character buffer as argument.
|
-DLLIMPORT void __export | cfg_free_value (cfg_opt_t *opt) |
-
- | Free the memory allocated for the values of a given option.
|
-DLLIMPORT void __export | cfg_free (cfg_t *cfg) |
-
- | Free a cfg_t context.
|
-DLLIMPORT cfg_errfunc_t __export | cfg_set_error_function (cfg_t *cfg, cfg_errfunc_t errfunc) |
-
- | Install a user-defined error reporting function.
|
-DLLIMPORT void __export | cfg_error (cfg_t *cfg, const char *fmt,...) |
-
- | Show a parser error.
|
-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.
|
-DLLIMPORT long int __export | cfg_getnint (cfg_t *cfg, const char *name, unsigned int index) |
-
- | Indexed version of cfg_getint(), used for lists.
|
-DLLIMPORT long int __export | cfg_getint (cfg_t *cfg, const char *name) |
-
- | Returns the value of an integer option.
|
-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.
|
-DLLIMPORT double __export | cfg_getnfloat (cfg_t *cfg, const char *name, unsigned int index) |
-
- | Indexed version of cfg_getfloat(), used for lists.
|
-DLLIMPORT double __export | cfg_getfloat (cfg_t *cfg, const char *name) |
-
- | Returns the value of a floating point option.
|
-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.
|
-DLLIMPORT char *__export | cfg_getnstr (cfg_t *cfg, const char *name, unsigned int index) |
-
- | Indexed version of cfg_getstr(), used for lists.
|
-DLLIMPORT char *__export | cfg_getstr (cfg_t *cfg, const char *name) |
-
- | Returns the value of a string option.
|
-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.
|
-DLLIMPORT cfg_bool_t __export | cfg_getnbool (cfg_t *cfg, const char *name, unsigned int index) |
-
- | Indexed version of cfg_getbool(), used for lists.
|
-DLLIMPORT cfg_bool_t __export | cfg_getbool (cfg_t *cfg, const char *name) |
-
- | Returns the value of a boolean option.
|
-DLLIMPORT void *__export | cfg_getptr (cfg_t *cfg, const char *name) |
-
- | Returns the value of a user-defined option (void pointer).
|
-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.
|
-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.
|
-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.
|
-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.
|
-DLLIMPORT cfg_t *__export | cfg_getsec (cfg_t *cfg, const char *name) |
-
- | Returns the value of a section option.
|
-DLLIMPORT unsigned int __export | cfg_opt_size (cfg_opt_t *opt) |
-
- | Return the number of values this option has.
|
-DLLIMPORT unsigned int __export | cfg_size (cfg_t *cfg, const char *name) |
-
- | Return the number of values this option has.
|
-DLLIMPORT const char *__export | cfg_title (cfg_t *cfg) |
-
- | Return the title of a section.
|
-DLLIMPORT const char *__export | cfg_name (cfg_t *cfg) |
-
- | Return the name of a section.
|
-DLLIMPORT const char *__export | cfg_opt_name (cfg_opt_t *opt) |
-
- | Return the name of an option.
|
-DLLIMPORT int __export | cfg_include (cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv) |
-
- | Predefined include-function.
|
-DLLIMPORT char *__export | cfg_tilde_expand (const char *filename) |
-
- | Does tilde expansion (~ -> $HOME) on the filename.
|
-DLLIMPORT int __export | cfg_parse_boolean (const char *s) |
-
- | Parse a boolean option string.
|
-DLLIMPORT cfg_opt_t *__export | cfg_getopt (cfg_t *cfg, const char *name) |
-
- | Return an option given it's name.
|
-DLLIMPORT cfg_value_t * | cfg_setopt (cfg_t *cfg, cfg_opt_t *opt, char *value) |
-
- | Set an option (create an instance of an option).
|
-DLLIMPORT void __export | cfg_opt_setnint (cfg_opt_t *opt, long int value, unsigned int index) |
-
- | Set a value of an integer option.
|
-DLLIMPORT void __export | cfg_setint (cfg_t *cfg, const char *name, long int value) |
-
- | Set the value of an integer option given its name.
|
-DLLIMPORT void __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.
|
-DLLIMPORT void __export | cfg_opt_setnfloat (cfg_opt_t *opt, double value, unsigned int index) |
-
- | Set a value of a floating point option.
|
-DLLIMPORT void __export | cfg_setfloat (cfg_t *cfg, const char *name, double value) |
-
- | Set the value of a floating point option given its name.
|
-DLLIMPORT void __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.
|
-DLLIMPORT void __export | cfg_opt_setnbool (cfg_opt_t *opt, cfg_bool_t value, unsigned int index) |
-
- | Set a value of a boolean option.
|
-DLLIMPORT void __export | cfg_setbool (cfg_t *cfg, const char *name, cfg_bool_t value) |
-
- | Set the value of a boolean option given its name.
|
-DLLIMPORT void __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.
|
-DLLIMPORT void __export | cfg_opt_setnstr (cfg_opt_t *opt, const char *value, unsigned int index) |
-
- | Set a value of a string option.
|
-DLLIMPORT void __export | cfg_setstr (cfg_t *cfg, const char *name, const char *value) |
-
- | Set the value of a string option given its name.
|
-DLLIMPORT void __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.
|
-DLLIMPORT void __export | cfg_setlist (cfg_t *cfg, const char *name, unsigned int nvalues,...) |
-
- | Set values for a list option.
|
-DLLIMPORT void __export | cfg_addlist (cfg_t *cfg, const char *name, unsigned int nvalues,...) |
-
- | Add values for a list option.
|
-DLLIMPORT void __export | cfg_opt_nprint_var (cfg_opt_t *opt, unsigned int index, FILE *fp) |
-
- | Default value print function.
|
-DLLIMPORT void __export | cfg_opt_print_indent (cfg_opt_t *opt, FILE *fp, int indent) |
-
- | Print an option and its value to a file.
|
-DLLIMPORT void __export | cfg_opt_print (cfg_opt_t *opt, FILE *fp) |
-
- | Print an option and its value to a file.
|
-DLLIMPORT void __export | cfg_print_indent (cfg_t *cfg, FILE *fp, int indent) |
-
- | Print the options and values to a file.
|
-DLLIMPORT void __export | cfg_print (cfg_t *cfg, FILE *fp) |
-
- | Print the options and values to a file.
|
-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.
|
-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.
|
-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.
|
+ | Fundamental option types. More...
|
+ |
+enum | cfg_bool_t |
+ | Boolean values. More...
|
+ |
+
+ |
+DLLIMPORT cfg_t *__export | cfg_init (cfg_opt_t *opts, cfg_flag_t flags) |
+ | Create and initialize a cfg_t structure. More...
|
+ |
+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 and then freed as part of the usual context takedown. More...
|
+ |
+DLLIMPORT char *__export | cfg_searchpath (cfg_searchpath_t *path, const char *file) |
+ | Search the linked-list of cfg_searchpath_t for the specified file. More...
|
+ |
+DLLIMPORT int __export | cfg_parse (cfg_t *cfg, const char *filename) |
+ | Parse a configuration file. More...
|
+ |
+DLLIMPORT int __export | cfg_parse_fp (cfg_t *cfg, FILE *fp) |
+ | Same as cfg_parse() above, but takes an already opened file as argument. More...
|
+ |
+DLLIMPORT int __export | cfg_parse_buf (cfg_t *cfg, const char *buf) |
+ | Same as cfg_parse() above, but takes a character buffer as argument. More...
|
+ |
+DLLIMPORT int __export | cfg_free_value (cfg_opt_t *opt) |
+ | Free the memory allocated for the values of a given option. More...
|
+ |
+DLLIMPORT int __export | cfg_free (cfg_t *cfg) |
+ | Free a cfg_t context. More...
|
+ |
+DLLIMPORT cfg_errfunc_t __export | cfg_set_error_function (cfg_t *cfg, cfg_errfunc_t errfunc) |
+ | Install a user-defined error reporting function. More...
|
+ |
+DLLIMPORT void __export | cfg_error (cfg_t *cfg, const char *fmt,...) |
+ | Show a parser error. More...
|
+ |
+DLLIMPORT char *__export | cfg_opt_getcomment (cfg_opt_t *opt) |
+ | Returns the option comment. More...
|
+ |
+DLLIMPORT char *__export | cfg_getcomment (cfg_t *cfg, const char *name) |
+ | Returns the option comment. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT long int __export | cfg_getnint (cfg_t *cfg, const char *name, unsigned int index) |
+ | Indexed version of cfg_getint(), used for lists. More...
|
+ |
+DLLIMPORT long int __export | cfg_getint (cfg_t *cfg, const char *name) |
+ | Returns the value of an integer option. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT double __export | cfg_getnfloat (cfg_t *cfg, const char *name, unsigned int index) |
+ | Indexed version of cfg_getfloat(), used for lists. More...
|
+ |
+DLLIMPORT double __export | cfg_getfloat (cfg_t *cfg, const char *name) |
+ | Returns the value of a floating point option. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT char *__export | cfg_getnstr (cfg_t *cfg, const char *name, unsigned int index) |
+ | Indexed version of cfg_getstr(), used for lists. More...
|
+ |
+DLLIMPORT char *__export | cfg_getstr (cfg_t *cfg, const char *name) |
+ | Returns the value of a string option. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT cfg_bool_t __export | cfg_getnbool (cfg_t *cfg, const char *name, unsigned int index) |
+ | Indexed version of cfg_getbool(), used for lists. More...
|
+ |
+DLLIMPORT cfg_bool_t __export | cfg_getbool (cfg_t *cfg, const char *name) |
+ | Returns the value of a boolean option. More...
|
+ |
+DLLIMPORT void *__export | cfg_getptr (cfg_t *cfg, const char *name) |
+ | Returns the value of a user-defined option (void pointer). More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT cfg_t *__export | cfg_getsec (cfg_t *cfg, const char *name) |
+ | Returns the value of a section option. More...
|
+ |
+DLLIMPORT unsigned int __export | cfg_opt_size (cfg_opt_t *opt) |
+ | Return the number of values this option has. More...
|
+ |
+DLLIMPORT unsigned int __export | cfg_size (cfg_t *cfg, const char *name) |
+ | Return the number of values this option has. More...
|
+ |
+const DLLIMPORT char *__export | cfg_title (cfg_t *cfg) |
+ | Return the title of a section. More...
|
+ |
+const DLLIMPORT char *__export | cfg_name (cfg_t *cfg) |
+ | Return the name of a section. More...
|
+ |
+const DLLIMPORT char *__export | cfg_opt_name (cfg_opt_t *opt) |
+ | Return the name of an option. More...
|
+ |
+const DLLIMPORT char * | cfg_opt_getstr (cfg_opt_t *opt) |
+ | Return the string value of a key=value pair. More...
|
+ |
+DLLIMPORT int __export | cfg_include (cfg_t *cfg, cfg_opt_t *opt, int argc, const char **argv) |
+ | Predefined include-function. More...
|
+ |
+DLLIMPORT char *__export | cfg_tilde_expand (const char *filename) |
+ | Does tilde expansion (~ -> $HOME) on the filename. More...
|
+ |
+DLLIMPORT int __export | cfg_parse_boolean (const char *s) |
+ | Parse a boolean option string. More...
|
+ |
+DLLIMPORT cfg_opt_t * | cfg_getnopt (cfg_t *cfg, unsigned int index) |
+ | Return the nth option in a file or section. More...
|
+ |
+DLLIMPORT cfg_opt_t *__export | cfg_getopt (cfg_t *cfg, const char *name) |
+ | Return an option given it's name. More...
|
+ |
+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). More...
|
+ |
+DLLIMPORT int __export | cfg_opt_setcomment (cfg_opt_t *opt, char *comment) |
+ | Annotate an option. More...
|
+ |
+DLLIMPORT int __export | cfg_setcomment (cfg_t *cfg, const char *name, char *comment) |
+ | Annotate an option given its name. More...
|
+ |
+DLLIMPORT int __export | cfg_opt_setnint (cfg_opt_t *opt, long int value, unsigned int index) |
+ | Set a value of an integer option. More...
|
+ |
+DLLIMPORT int __export | cfg_setint (cfg_t *cfg, const char *name, long int value) |
+ | Set the value of an integer option given its name. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT int __export | cfg_opt_setnfloat (cfg_opt_t *opt, double value, unsigned int index) |
+ | Set a value of a floating point option. More...
|
+ |
+DLLIMPORT int __export | cfg_setfloat (cfg_t *cfg, const char *name, double value) |
+ | Set the value of a floating point option given its name. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT int __export | cfg_opt_setnbool (cfg_opt_t *opt, cfg_bool_t value, unsigned int index) |
+ | Set a value of a boolean option. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT int __export | cfg_opt_setnstr (cfg_opt_t *opt, const char *value, unsigned int index) |
+ | Set a value of a string option. More...
|
+ |
+DLLIMPORT int __export | cfg_setstr (cfg_t *cfg, const char *name, const char *value) |
+ | Set the value of a string option given its name. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT int __export | cfg_setlist (cfg_t *cfg, const char *name, unsigned int nvalues,...) |
+ | Set values for a list option. More...
|
+ |
+DLLIMPORT unsigned int __export | cfg_num (cfg_t *cfg) |
+ | Return number of options in a file or section. More...
|
+ |
+DLLIMPORT int __export | cfg_addlist (cfg_t *cfg, const char *name, unsigned int nvalues,...) |
+ | Add values for a list option. More...
|
+ |
+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). More...
|
+ |
+DLLIMPORT int | cfg_setmulti (cfg_t *cfg, const char *name, unsigned int nvalues, char **values) |
+ | Set an option (create an instance of an option). More...
|
+ |
+DLLIMPORT cfg_t * | cfg_addtsec (cfg_t *cfg, const char *name, const char *title) |
+ | Create a new titled config section. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT int __export | cfg_rmnsec (cfg_t *cfg, const char *name, unsigned int index) |
+ | Indexed version of cfg_rmsec(), used for CFGF_MULTI sections. More...
|
+ |
+DLLIMPORT int __export | cfg_rmsec (cfg_t *cfg, const char *name) |
+ | Removes and frees a config section. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+DLLIMPORT int __export | cfg_opt_nprint_var (cfg_opt_t *opt, unsigned int index, FILE *fp) |
+ | Default value print function. More...
|
+ |
+DLLIMPORT int __export | cfg_opt_print_indent (cfg_opt_t *opt, FILE *fp, int indent) |
+ | Print an option and its value to a file. More...
|
+ |
+DLLIMPORT int __export | cfg_opt_print (cfg_opt_t *opt, FILE *fp) |
+ | Print an option and its value to a file. More...
|
+ |
+DLLIMPORT int __export | cfg_print_indent (cfg_t *cfg, FILE *fp, int indent) |
+ | Print the options and values to a file. More...
|
+ |
+DLLIMPORT int __export | cfg_print (cfg_t *cfg, FILE *fp) |
+ | Print the options and values to a file. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
+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. More...
|
+ |
-
Detailed Description
-A configuration file parser library.
-
-
Define Documentation
-
+
+A configuration file parser library.
+
+
+◆ CFG_END
+
- #define CFG_END |
+ #define CFG_END |
( |
-
- |
- ) |
- {0,CFGT_NONE,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},0,0,0,0,0,0} |
+ | ) |
+ {0,0,CFGT_NONE,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},0,{0},0,0,0,0,0} |
-
-
+
-
-Terminate list of options.
-
-This must be the last initializer in the option list. - Examples:
-
-ftpconf.c, reread.c, and simple.c.
+ Terminate list of options.
+ This must be the last initializer in the option list.
+ - Examples
- ftpconf.c, reread.c, and simple.c.
+
+
-
-
+
+
+ ◆ CFG_FUNC
+
- #define CFG_FUNC |
+ #define CFG_FUNC |
( |
- name, |
+ |
+ name, |
+
+
|
|
- func |
- |
- ) |
- {name,CFGT_FUNC,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},func,0,0,0,0,0} |
+ |
+ func |
+
+ |
+ ) |
+ | {name,0,CFGT_FUNC,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},func,{0},0,0,0,0,0} |
+
-
-
+
-
-Initialize a function.
-
- - Parameters:
-
-
- | name | The name of the option |
- | func | The callback function. |
+Initialize a function.
+- Parameters
-
+
+ name | The name of the option |
+ func | The callback function. |
+
-- See also:
- cfg_func_t
-- Examples:
-
-ftpconf.c.
+- See also
- cfg_func_t
+- Examples
- ftpconf.c.
+
+
-
-
+
+
+ ◆ CFG_PTR_CB
+
- #define CFG_PTR_CB |
+ #define CFG_PTR_CB |
( |
- name, |
+ |
+ name, |
+
+
|
|
- def, |
+ |
+ def, |
+
+
|
|
- flags, |
+ |
+ flags, |
+
+
|
|
- parsecb, |
+ |
+ parsecb, |
+
+
|
|
- freecb |
- |
- ) |
- __CFG_PTR(name, def, flags, 0, parsecb, freecb) |
+ |
+ freecb |
+
+ |
+ ) |
+ | __CFG_PTR(name, def, flags, 0, parsecb, freecb) |
+
-
-
+
-
-Initialize a user-defined option.
-
-CFG_PTR options can only be used together with a value parsing callback.
- - Parameters:
-
-
- | name | The name of the option |
- | def | Default value |
- | flags | Flags |
- | parsecb | Value parsing callback |
- | freecb | Memory release function |
+Initialize a user-defined option.
+CFG_PTR options can only be used together with a value parsing callback.
+- Parameters
-
+
+ name | The name of the option |
+ def | Default value |
+ flags | Flags |
+ parsecb | Value parsing callback |
+ freecb | Memory release function |
+
-- See also:
- cfg_callback_t, cfg_free_func_t
+- See also
- cfg_callback_t, cfg_free_func_t
-
-
+
+
+ ◆ CFG_SEC
+
- #define CFG_SEC |
+ #define CFG_SEC |
( |
- name, |
+ |
+ name, |
+
+
|
|
- opts, |
+ |
+ opts, |
+
+
|
|
- flags |
- |
- ) |
- {name,CFGT_SEC,0,0,flags,opts,{0,0,cfg_false,0,0},0,0,0,0,0,0} |
+ |
+ flags |
+
+ |
+ ) |
+ | {name,0,CFGT_SEC,0,0,flags,opts,{0,0,cfg_false,0,0},0,{0},0,0,0,0,0} |
+
-
-
+
-
-Initialize a section.
-
- - Parameters:
-
-
- | name | The name of the option |
- | opts | Array of options that are valid within this section |
- | flags | Flags, specify CFGF_MULTI if it should be possible to have multiples of the same section, and CFGF_TITLE if the section(s) must have a title (which can be used in the cfg_gettsec() function) |
+Initialize a section.
+- Parameters
-
+
+ name | The name of the option |
+ opts | Array of options that are valid within this section |
+ flags | Flags, specify CFGF_MULTI if it should be possible to have multiples of the same section, and CFGF_TITLE if the section(s) must have a title (which can be used in the cfg_gettsec() function) |
+
-- Examples:
-
-ftpconf.c, and reread.c.
+- Examples
- ftpconf.c, and reread.c.
+
+
-
-
+
+
+ ◆ CFG_SIMPLE_INT
+
- #define CFG_SIMPLE_STR |
+ #define CFG_SIMPLE_INT |
( |
- name, |
+ |
+ name, |
+
+
|
|
- svalue |
- |
- ) |
- __CFG_STR(name, 0, CFGF_NONE, svalue, 0) |
+ |
+ svalue |
+
+ |
+ ) |
+ | __CFG_INT(name, 0, CFGF_NONE, svalue, 0) |
+
+
+
+ Initialize a "simple" integer option (see documentation for CFG_SIMPLE_STR for more information).
+ Note that confuse uses long integers, so make sure that any pointer you provide for svalue points to a long int rather than a normal int. Otherwise, you will have strange problems on 64-bit architectures.
+ - Examples
- simple.c.
+
+
-
+
+
+ ◆ CFG_SIMPLE_STR
-
-Initialize a "simple" string option.
-
-"Simple" options (in lack of a better expression) does not support lists of values or multiple sections. LibConfuse will store the value of a simple option in the user-defined location specified by the value parameter in the initializer. Simple options are not stored in the cfg_t context, only a pointer. Sections can not be initialized as a "simple" option.
-As of version 2.2, libConfuse can now return the values of simple options with the cfg_get functions. This allows using the new cfg_print function with simple options.
-libConfuse doesn't support handling default values for "simple" options. They are assumed to be set by the calling application before cfg_parse is called.
- - Parameters:
-
-
- | name | name of the option |
- | svalue | pointer to a character pointer (a char **). This value must be initalized either to NULL or to a malloc()'ed string. You can't use
- char *user = "joe";
- ...
- cfg_opt_t opts[] = {
+
+
+
+
+ #define CFG_SIMPLE_STR |
+ ( |
+ |
+ name, |
+
+
+ |
+ |
+ |
+ svalue |
+
+
+ |
+ ) |
+ | __CFG_STR(name, 0, CFGF_NONE, svalue, 0) |
+
+
+
+
+ Initialize a "simple" string option.
+ "Simple" options (in lack of a better expression) does not support lists of values or multiple sections. LibConfuse will store the value of a simple option in the user-defined location specified by the value parameter in the initializer. Simple options are not stored in the cfg_t context, only a pointer. Sections can not be initialized as a "simple" option.
+ As of version 2.2, libConfuse can now return the values of simple options with the cfg_get functions. This allows using the new cfg_print function with simple options.
+ libConfuse doesn't support handling default values for "simple" options. They are assumed to be set by the calling application before cfg_parse is called.
+ - Parameters
-
+
+ name | name of the option |
+ svalue | pointer to a character pointer (a char **). This value must be initalized either to NULL or to a malloc()'ed string. You can't use
+char *user = "joe";
+...
+cfg_opt_t opts[] = {
+ CFG_SIMPLE_STR("user", &user),
+...
+ since libConfuse will try to free the static string "joe" (which is an error) when a "user" option is found. Rather, use the following code snippet:
+char *user = strdup("joe");
+...
+cfg_opt_t opts[] = {
CFG_SIMPLE_STR("user", &user),
- ...
- since libConfuse will try to free the static string "joe" (which is an error) when a "user" option is found. Rather, use the following code snippet:
- char *user = strdup("joe");
- ...
- cfg_opt_t opts[] = {
- CFG_SIMPLE_STR("user", &user),
- ...
- Alternatively, the default value can be set after the opts struct is defined, as in:
- char *user = 0;
- ...
- cfg_opt_t opts[] = {
- CFG_SIMPLE_STR("user", &user),
- ...
- user = strdup("joe");
- cfg = cfg_init(opts, 0);
- cfg_parse(cfg, filename);
- |
+...
+ Alternatively, the default value can be set after the opts struct is defined, as in:
+char *user = 0;
+...
+cfg_opt_t opts[] = {
+ CFG_SIMPLE_STR("user", &user),
+...
+user = strdup("joe");
+cfg = cfg_init(opts, 0);
+cfg_parse(cfg, filename);
+
+
- - Examples:
-
-simple.c.
+ - Examples
- simple.c.
+
+
-
-
+
+
+ ◆ CFG_SUCCESS
+
- #define CFG_SUCCESS 0 |
+ #define CFG_SUCCESS 0 |
-
-
+
-
-
+
+
+ ◆ CFGF_DEPRECATED
+
- #define CFGF_NONE 0 |
+ #define CFGF_DEPRECATED (1 << 9) |
-
-
+
-
-Flags.
-
- - Examples:
-
-ftpconf.c, and reread.c.
+ option is deprecated and should be ignored.
+
-
-
Typedef Documentation
-
+
+
+◆ CFGF_NONE
+
-
+
+
+
+ ◆ cfg_callback_t
-
-Value parsing callback prototype.
-
-This is a callback function (different from the one registered with the CFG_FUNC initializer) used to parse a value. This can be used to override the internal parsing of a value.
-Suppose you want an integer option that only can have certain values, for example 1, 2 and 3, and these should be written in the configuration file as "yes", "no" and "maybe". The callback function would be called with the found value ("yes", "no" or "maybe") as a string, and the result should be stored in the result parameter.
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | opt | The option. |
- | value | The value found in the configuration file. |
- | result | Pointer to storage for the result, cast to a void pointer. |
+
+
+
+
+ typedef int(* cfg_callback_t) (cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result) |
+
+
+
+
+ Value parsing callback prototype.
+ This is a callback function (different from the one registered with the CFG_FUNC initializer) used to parse a value. This can be used to override the internal parsing of a value.
+ Suppose you want an integer option that only can have certain values, for example 1, 2 and 3, and these should be written in the configuration file as "yes", "no" and "maybe". The callback function would be called with the found value ("yes", "no" or "maybe") as a string, and the result should be stored in the result parameter.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ opt | The option. |
+ value | The value found in the configuration file. |
+ result | Pointer to storage for the result, cast to a void pointer. |
+
- - Returns:
- On success, 0 should be returned. All other values indicates an error, and the parsing is aborted. The callback function should notify the error itself, for example by calling cfg_error().
+ - Returns
- On success, 0 should be returned. All other values indicates an error, and the parsing is aborted. The callback function should notify the error itself, for example by calling cfg_error().
-
-
+
+
+ ◆ cfg_errfunc_t
+
- typedef void(* cfg_errfunc_t)(cfg_t *cfg, const char *fmt, va_list ap) |
+ typedef void(* cfg_errfunc_t) (cfg_t *cfg, const char *fmt, va_list ap) |
-
-
+
-
-Error reporting function.
-
+ Error reporting function.
-
-
+
+
+ ◆ cfg_free_func_t
+
- typedef void(* cfg_free_func_t)(void *value) |
+ typedef void(* cfg_free_func_t) (void *value) |
-
-
+
-
-User-defined memory release function for CFG_PTR values.
-
-This callback is used to free memory allocated in a value parsing callback function. Especially useful for CFG_PTR options, since libConfuse will not itself release such values. If the values are simply allocated with a malloc(3), one can use the standard free(3) function here.
+ User-defined memory release function for CFG_PTR values.
+ This callback is used to free memory allocated in a value parsing callback function. Especially useful for CFG_PTR options, since libConfuse will not itself release such values. If the values are simply allocated with a malloc(3), one can use the standard free(3) function here.
+
-
-
+
+
+ ◆ cfg_func_t
+
-
+
-
-Function prototype used by CFGT_FUNC options.
-
-This is a callback function, registered with the CFG_FUNC initializer. Each time libConfuse finds a function, the registered callback function is called (parameters are passed as strings, any conversion to other types should be made in the callback function). libConfuse does not support any storage of the data found; these are passed as parameters to the callback, and it's the responsibility of the callback function to do whatever it should do with the data.
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | opt | The option. |
- | argc | Number of arguments passed. The callback function is responsible for checking that the correct number of arguments are passed. |
- | argv | Arguments as an array of character strings. |
+Function prototype used by CFGT_FUNC options.
+This is a callback function, registered with the CFG_FUNC initializer. Each time libConfuse finds a function, the registered callback function is called (parameters are passed as strings, any conversion to other types should be made in the callback function). libConfuse does not support any storage of the data found; these are passed as parameters to the callback, and it's the responsibility of the callback function to do whatever it should do with the data.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ opt | The option. |
+ argc | Number of arguments passed. The callback function is responsible for checking that the correct number of arguments are passed. |
+ argv | Arguments as an array of character strings. |
+
-- Returns:
- On success, 0 should be returned. All other values indicates an error, and the parsing is aborted. The callback function should notify the error itself, for example by calling cfg_error().
-- See also:
- CFG_FUNC
+- Returns
- On success, 0 should be returned. All other values indicates an error, and the parsing is aborted. The callback function should notify the error itself, for example by calling cfg_error().
+- See also
- CFG_FUNC
-
-
+
+
+ ◆ cfg_print_filter_func_t
+
-
+
-
-Function prototype used by the cfg_print_ functions.
-
-This callback function is used to print option values. For options with a value parsing callback, this is often required, especially if a string is mapped to an integer by the callback. This print callback must then map the integer back to the appropriate string.
-Except for functions, the print callback function should only print the value of the option, not the name and the equal sign (that is handled by the cfg_opt_print function). For function options however, the name and the parenthesis must be printed by this function. The value to print can be accessed with the cfg_opt_get functions.
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | index | Index of the value to get. Zero based. |
- | fp | File stream to print to, use stdout to print to the screen. |
+Print filter function.
+- Parameters
-
+
+ cfg | The configuration file context that opt belongs to. |
+ opt | The configuration option that is about to be printed, or not. |
+
-- See also:
- cfg_print, cfg_set_print_func
+- Returns
- Zero if opt should be printed, non-zero if it should be filtered out.
+- See also
- cfg_set_print_filter_func()
-
-
+
+
+ ◆ cfg_print_func_t
+
-
+
-
-Validating callback prototype.
-
-This callback function is called after an option has been parsed and set. The function is called for both fundamental values (strings, integers etc) as well as lists and sections. This can for example be used to validate that all required options in a section has been set to sane values.
- - Returns:
- On success, 0 should be returned. All other values indicates an error, and the parsing is aborted. The callback function should notify the error itself, for example by calling cfg_error().
- - See also:
- cfg_set_validate_func
+ Function prototype used by the cfg_print_ functions.
+ This callback function is used to print option values. For options with a value parsing callback, this is often required, especially if a string is mapped to an integer by the callback. This print callback must then map the integer back to the appropriate string.
+ Except for functions, the print callback function should only print the value of the option, not the name and the equal sign (that is handled by the cfg_opt_print function). For function options however, the name and the parenthesis must be printed by this function. The value to print can be accessed with the cfg_opt_get functions.
+ - Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | Index of the value to get. Zero based. |
+ fp | File stream to print to, use stdout to print to the screen. |
+
+
+
+ - See also
- cfg_print, cfg_set_print_func
-
-
Enumeration Type Documentation
-
+
+
+◆ cfg_validate_callback2_t
+
+
+ Validating callback2 prototype.
+ This callback function is called before an option is set using the cfg_set*() APIs. The function is called only for strings, integers, and floats. Compared to the regular callback function this takes a value pointer argument which must be casted before use, but can also be used to correct a value before it is set, e.g. when a too large value is set this can be used to set the MAX.
+ - Returns
- On success, 0 should be returned. All other values indicates an error, and the cfg_set*() function will return without setting the value.
+ - See also
- cfg_set_validate_func2()
+
-
+
+
+ ◆ cfg_validate_callback_t
-
-Boolean values.
-
+
+
+
+
+ typedef int(* cfg_validate_callback_t) (cfg_t *cfg, cfg_opt_t *opt) |
+
+
+
+ Validating callback prototype.
+ This callback function is called after an option has been parsed and set. The function is called for both fundamental values (strings, integers etc) as well as lists and sections. This can for example be used to validate that all required options in a section has been set to sane values.
+ - Returns
- On success, 0 should be returned. All other values indicates an error, and the parsing is aborted. The callback function should notify the error itself, for example by calling cfg_error().
+ - See also
- cfg_set_validate_func
+
-
-
+
+
+
+◆ cfg_bool_t
+
-
+
+
+ ◆ cfg_type_t
-
-Fundamental option types.
-
- - Enumerator:
-
-
-CFGT_INT |
-integer |
-CFGT_FLOAT |
-floating point number |
-CFGT_STR |
-string |
-CFGT_BOOL |
-boolean value |
-CFGT_SEC |
-section |
-CFGT_FUNC |
-function |
-CFGT_PTR |
-pointer to user-defined value |
+
+
+
+ Fundamental option types.
+
+Enumerator |
---|
CFGT_INT | integer
+ |
+CFGT_FLOAT | floating point number
+ |
+CFGT_STR | string
+ |
+CFGT_BOOL | boolean value
+ |
+CFGT_SEC | section
+ |
+CFGT_FUNC | function
+ |
+CFGT_PTR | pointer to user-defined value
+ |
+CFGT_COMMENT | comment/annotation
+ |
+
+
+
+
+
+◆ cfg_add_searchpath()
+
+
+
+
+
+ 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 and then freed as part of the usual context takedown.
+ All directories added to the context in this manner will be searched for the file specified in cfg_parse(), and for those included. All directories added with this function will be "tilde expanded". Note that the current directory is not added to the searchpath by default.
+ - Parameters
-
+
+ cfg | The configuration file context as returned from cfg_init(). |
+ dir | Directory to be added to the search path. |
+
+
+ - Returns
- On success, CFG_SUCCESS, on failure (which can only be caused by a failed malloc()), CFG_PARSE_ERROR.
-
-
Function Documentation
-
+
+
+◆ cfg_addlist()
+
- DLLIMPORT void __export cfg_addlist |
+ DLLIMPORT int __export cfg_addlist |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- unsigned int |
- nvalues, |
+ unsigned int |
+ nvalues, |
|
|
- |
- ... | |
+ |
+ ... |
|
) |
- | | |
+ | |
-
-
+
-
-Add values for a list option.
-
-The new values are appended to any current values in the list.
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | nvalues | Number of values to add. |
- | ... | The values to add, the type must match the type of the option and the number of values must be equal to the nvalues parameter. |
+Add values for a list option.
+The new values are appended to any current values in the list.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ nvalues | Number of values to add. |
+ ... | The values to add, the type must match the type of the option and the number of values must be equal to the nvalues parameter. |
+
+- Returns
- POSIX OK(0), or non-zero on failure.
-References CFGF_LIST, and cfg_opt_t::flags.
-
-
-
+
+
+ ◆ cfg_addtsec()
+
- DLLIMPORT void __export cfg_error |
+ DLLIMPORT cfg_t* cfg_addtsec |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- fmt, |
+ const char * |
+ name, |
|
|
- |
- ... | |
+ const char * |
+ title |
|
) |
- | | |
+ | |
-
-
+
-
-Show a parser error.
-
-Any user-defined error reporting function is called. - See also:
- cfg_set_error_function
- - Examples:
-
-ftpconf.c.
- References cfg_t::errfunc, cfg_t::filename, and cfg_t::line.
+ Create a new titled config section.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ title | The title of this section. |
+
+
+
+ - Returns
- A pointer to the created section or if the section already exists a pointer to that section is returned. If the section could not be created or found, 0 is returned.
-
-
+
+
+ ◆ cfg_error()
+
- DLLIMPORT void __export cfg_free |
+ DLLIMPORT void __export cfg_error |
( |
- cfg_t * |
- cfg |
- ) |
+ cfg_t * |
+ cfg, |
+
+
+ |
|
+ const char * |
+ fmt, |
+
+ |
+ |
+ |
+ ... |
+
+
+ |
+ ) |
+ | |
+
-
-
+
-
-
+
+
+ ◆ cfg_free()
+
- DLLIMPORT void __export cfg_free_value |
+ DLLIMPORT int __export cfg_free |
( |
- cfg_opt_t * |
- opt |
- ) |
+ cfg_t * |
+ cfg | ) |
|
+
+
+ Free a cfg_t context.
+ All memory allocated by the cfg_t context structure are freed, and can't be used in any further cfg_* calls.
+ - Returns
- POSIX OK(0), or non-zero on failure.
+ - Examples
- ftpconf.c, reread.c, and simple.c.
+
+
-
+
+
+ ◆ cfg_free_value()
-
-Free the memory allocated for the values of a given option.
-
-Only the values are freed, not the option itself (it is freed by cfg_free()).
- - See also:
- cfg_free()
+
+
+
+
+ DLLIMPORT int __export cfg_free_value |
+ ( |
+ cfg_opt_t * |
+ opt | ) |
+ |
+
+
+
- References CFGT_PTR, CFGT_SEC, CFGT_STR, cfg_opt_t::freecb, cfg_opt_t::nvalues, cfg_value_t::ptr, cfg_value_t::section, cfg_value_t::string, cfg_opt_t::type, and cfg_opt_t::values.
+ Free the memory allocated for the values of a given option.
+ Only the values are freed, not the option itself (it is freed by cfg_free()).
+ - See also
- cfg_free()
+ - Returns
- POSIX OK(0), or non-zero on failure.
-
-
+
+
+◆ cfg_getbool()
+
- DLLIMPORT cfg_bool_t __export cfg_getbool |
+ DLLIMPORT cfg_bool_t __export cfg_getbool |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name | |
+ const char * |
+ name |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a boolean option.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
+Returns the value of a boolean option.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
-- Returns:
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
-- Examples:
-
-ftpconf.c.
+- Returns
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
+- Examples
- ftpconf.c.
+
+
-
-
+
+
+ ◆ cfg_getcomment()
+
- DLLIMPORT double __export cfg_getfloat |
+ DLLIMPORT char* __export cfg_getcomment |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name | |
+ const char * |
+ name |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a floating point option.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
+Returns the option comment.
+This function can be used to extract option annotations from a config file. Only comments preceding the option are read by cfg_parse().
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
-- Returns:
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
+- See also
- cfg_setcomment
+- Returns
- The comment for this option, or NULL if unset
-
-
+
+
+ ◆ cfg_getfloat()
+
- DLLIMPORT long int __export cfg_getint |
+ DLLIMPORT double __export cfg_getfloat |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name | |
+ const char * |
+ name |
|
) |
- | | |
+ | |
+
+
+ Returns the value of a floating point option.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
+
+
+ - Returns
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
+
-
+
+
+ ◆ cfg_getint()
-
-Returns the value of an integer option.
-
-This is the same as calling cfg_getnint with index 0. - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
+
+
+
+
+ DLLIMPORT long int __export cfg_getint |
+ ( |
+ cfg_t * |
+ cfg, |
+
+
+ |
+ |
+ const char * |
+ name |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Returns the value of an integer option.
+ This is the same as calling cfg_getnint with index 0. - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
- - Returns:
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
- - Examples:
-
-ftpconf.c, and reread.c.
+ - Returns
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
+ - Examples
- ftpconf.c, and reread.c.
+
+
-
-
+
+
+ ◆ cfg_getnbool()
+
- DLLIMPORT cfg_bool_t __export cfg_getnbool |
+ DLLIMPORT cfg_bool_t __export cfg_getnbool |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Indexed version of cfg_getbool(), used for lists.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | index | Index of the value to get. Zero based. |
+Indexed version of cfg_getbool(), used for lists.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getbool
+- See also
- cfg_getbool
-
-
+
+
+ ◆ cfg_getnfloat()
+
- DLLIMPORT double __export cfg_getnfloat |
+ DLLIMPORT double __export cfg_getnfloat |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Indexed version of cfg_getfloat(), used for lists.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | index | Index of the value to get. Zero based. |
+Indexed version of cfg_getfloat(), used for lists.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getfloat
+- See also
- cfg_getfloat
-
-
+
+
+ ◆ cfg_getnint()
+
- DLLIMPORT long int __export cfg_getnint |
+ DLLIMPORT long int __export cfg_getnint |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
+
+
+ Indexed version of cfg_getint(), used for lists.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ index | Index of the value to get. Zero based. |
+
+
+
+ - See also
- cfg_getint
+
-
+
+
+ ◆ cfg_getnopt()
-
-Indexed version of cfg_getint(), used for lists.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | index | Index of the value to get. Zero based. |
+
+
+
+
+ DLLIMPORT cfg_opt_t* cfg_getnopt |
+ ( |
+ cfg_t * |
+ cfg, |
+
+
+ |
+ |
+ unsigned int |
+ index |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Return the nth option in a file or section.
+ - Parameters
-
+
+ cfg | The configuration file or section context |
+ index | Option index |
+
- - See also:
- cfg_getint
+ - See also
- cfg_num
-
-
+
+
+ ◆ cfg_getnsec()
+
- DLLIMPORT cfg_t* __export cfg_getnsec |
+ DLLIMPORT cfg_t* __export cfg_getnsec |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Indexed version of cfg_getsec(), used for sections with the CFGF_MULTI flag set.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | index | Index of the section to get. Zero based. |
+Indexed version of cfg_getsec(), used for sections with the CFGF_MULTI flag set.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ index | Index of the section to get. Zero based. |
+
-- See also:
- cfg_getsec
-- Examples:
-
-ftpconf.c, and reread.c.
+- See also
- cfg_getsec
+- Examples
- ftpconf.c, and reread.c.
+
+
-
-
+
+
+ ◆ cfg_getnstr()
+
- DLLIMPORT char* __export cfg_getnstr |
+ DLLIMPORT char* __export cfg_getnstr |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Indexed version of cfg_getstr(), used for lists.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | index | Index of the value to get. Zero based. |
+Indexed version of cfg_getstr(), used for lists.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getstr
-- Examples:
-
-ftpconf.c.
+- See also
- cfg_getstr
+- Examples
- ftpconf.c.
+
+
-
-
+
+
+ ◆ cfg_getopt()
+
- DLLIMPORT cfg_opt_t* __export cfg_getopt |
+ DLLIMPORT cfg_opt_t* __export cfg_getopt |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name | |
+ const char * |
+ name |
|
) |
- | | |
+ | |
-
-
+
-
-Return an option given it's name.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
+Return an option given it's name.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
-- Returns:
- Returns a pointer to the option. If the option isn't declared, libConfuse will print an error message and return 0.
+- Returns
- Returns a pointer to the option. If the option isn't declared, libConfuse will print an error message and return 0.
-References CFGF_NOCASE, cfg_t::flags, cfg_opt_t::name, cfg_t::name, and cfg_t::opts.
-
-
-
+
+
+ ◆ cfg_getptr()
+
- DLLIMPORT void* __export cfg_getptr |
+ DLLIMPORT void* __export cfg_getptr |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name | |
+ const char * |
+ name |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a user-defined option (void pointer).
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
+Returns the value of a user-defined option (void pointer).
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
-- Returns:
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
+- Returns
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
-
-
+
+
+ ◆ cfg_getsec()
+
- DLLIMPORT cfg_t* __export cfg_getsec |
+ DLLIMPORT cfg_t* __export cfg_getsec |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name | |
+ const char * |
+ name |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a section option.
-
-The returned value is another cfg_t structure that can be used in following calls to cfg_getint, cfg_getstr or other get-functions. - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
+Returns the value of a section option.
+The returned value is another cfg_t structure that can be used in following calls to cfg_getint, cfg_getstr or other get-functions. - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
-- Returns:
- The requested section is returned. If no section is found with that name, 0 is returned. There can only be default values for section without the CFGF_MULTI flag set. It is an error to try to get a section that isn't declared.
+- Returns
- The requested section is returned. If no section is found with that name, 0 is returned. There can only be default values for section without the CFGF_MULTI flag set. It is an error to try to get a section that isn't declared.
-
-
+
+
+ ◆ cfg_getstr()
+
- DLLIMPORT char* __export cfg_getstr |
+ DLLIMPORT char* __export cfg_getstr |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name | |
+ const char * |
+ name |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a string option.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
+Returns the value of a string option.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+
-- Returns:
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
-- Examples:
-
-ftpconf.c, and reread.c.
+- Returns
- The requested value is returned. If the option was not set in the configuration file, the default value given in the corresponding cfg_opt_t structure is returned. It is an error to try to get an option that isn't declared.
+- Examples
- ftpconf.c, and reread.c.
+
+
-
-
+
+
+ ◆ cfg_gettsec()
+
- DLLIMPORT cfg_t* __export cfg_gettsec |
+ DLLIMPORT cfg_t* __export cfg_gettsec |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- const char * |
- title | |
+ const char * |
+ title |
|
) |
- | | |
+ | |
-
-
+
-
-Return a section given the title, used for section with the CFGF_TITLE flag set.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | title | The title of this section. The CFGF_TITLE flag must have been set for this option. |
+Return a section given the title, used for section with the CFGF_TITLE flag set.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ title | The title of this section. The CFGF_TITLE flag must have been set for this option. |
+
-- See also:
- cfg_getsec
+- See also
- cfg_getsec
-
-
+
+
+ ◆ cfg_include()
+
- DLLIMPORT int __export cfg_include |
+ DLLIMPORT int __export cfg_include |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- int |
- argc, |
+ int |
+ argc, |
|
|
- const char ** |
- argv | |
+ const char ** |
+ argv |
|
) |
- | | |
+ | |
-
-
+
-
-Predefined include-function.
-
-This function can be used in the options passed to cfg_init() to specify a function for including other configuration files in the parsing. For example: CFG_FUNC("include", &cfg_include) - Examples:
-
-ftpconf.c.
+ Predefined include-function.
+ This function can be used in the options passed to cfg_init() to specify a function for including other configuration files in the parsing. For example: CFG_FUNC("include", &cfg_include)
+ - Examples
- ftpconf.c.
+
+
-
-
+
+
+ ◆ cfg_init()
+
- DLLIMPORT cfg_t* __export cfg_init |
+ DLLIMPORT cfg_t* __export cfg_init |
( |
- cfg_opt_t * |
- opts, |
+ cfg_opt_t * |
+ opts, |
|
|
- cfg_flag_t |
- flags | |
+ cfg_flag_t |
+ flags |
|
) |
- | | |
+ | |
+
+
+ Create and initialize a cfg_t structure.
+ This should be the first function called when setting up the parsing of a configuration file. The options passed in the first parameter is initialized using the CFG_* initializers. The last option in the option array must be CFG_END(), unless you like segmentation faults.
+ The options must no longer be defined in the same scope as where the cfg_xxx functions are used (since version 2.3).
+ CFGF_IGNORE_UNKNOWN can be specified to use the "__unknown" option whenever an unknown option is parsed. Be sure to define an "__unknown" option in each scope that unknown parameters are allowed.
+ Call setlocale() before calling this function to localize handling of types, LC_CTYPE, and messages, LC_MESSAGES, since version 2.9:
+ setlocale(LC_MESSAGES, "");
+ setlocale(LC_CTYPE, "");
+ - Parameters
-
+
+ opts | An arrary of options |
+ flags | One or more flags (bitwise or'ed together). Currently only CFGF_NOCASE and CFGF_IGNORE_UNKNOWN are available. Use 0 if no flags are needed. |
+
+
+
+ - Returns
- A configuration context structure. This pointer is passed to almost all other functions as the first parameter.
+ - Examples
- ftpconf.c, reread.c, and simple.c.
+
+
-
+
+
+ ◆ cfg_name()
-
-Create and initialize a cfg_t structure.
-
-This should be the first function called when setting up the parsing of a configuration file. The options passed in the first parameter is initialized using the CFG_* initializers. The last option in the option array must be CFG_END(), unless you like segmentation faults.
-The options must no longer be defined in the same scope as where the cfg_xxx functions are used (since version 2.3).
- - Parameters:
-
-
- | opts | An arrary of options |
- | flags | One or more flags (bitwise or'ed together). Currently only CFGF_NOCASE is available. Use 0 if no flags are needed. |
+
+
+
+
+ const DLLIMPORT char* __export cfg_name |
+ ( |
+ cfg_t * |
+ cfg | ) |
+ |
+
+
+
-
-
+
+
+ ◆ cfg_num()
+
- DLLIMPORT const char* __export cfg_name |
+ DLLIMPORT unsigned int __export cfg_num |
( |
- cfg_t * |
- cfg |
- ) |
+ cfg_t * |
+ cfg | ) |
|
+
+
+ Return number of options in a file or section.
+ - Parameters
-
+
+ cfg | The configuration file or section context |
+
+
+
+ When a file has been parsed this function returns the number of options/settings the file, or a sub-section, has.
+ - Returns
- Number of options in a config file or section.
+
-
+
+
+ ◆ cfg_opt_getcomment()
-
-Return the name of a section.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
+
+
+
+
+ DLLIMPORT char* __export cfg_opt_getcomment |
+ ( |
+ cfg_opt_t * |
+ opt | ) |
+ |
+
+
+
+
+ Returns the option comment.
+ - Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+
- - Returns:
- Returns the title, or 0 if there is no title. This string should not be modified.
- - Examples:
-
-ftpconf.c.
- References cfg_t::name.
+ - See also
- cfg_getcomment
-
-
+
+
+ ◆ cfg_opt_getnbool()
+
- DLLIMPORT cfg_bool_t __export cfg_opt_getnbool |
+ DLLIMPORT cfg_bool_t __export cfg_opt_getnbool |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a boolean option, given a cfg_opt_t pointer.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | index | Index of the value to get. Zero based. |
+Returns the value of a boolean option, given a cfg_opt_t pointer.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getnbool
+- See also
- cfg_getnbool
-References cfg_value_t::boolean, CFGT_BOOL, cfg_opt_t::simple_value, cfg_opt_t::type, and cfg_opt_t::values.
-
-
-
+
+
+ ◆ cfg_opt_getnfloat()
+
- DLLIMPORT double __export cfg_opt_getnfloat |
+ DLLIMPORT double __export cfg_opt_getnfloat |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a floating point option, given a cfg_opt_t pointer.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | index | Index of the value to get. Zero based. |
+Returns the value of a floating point option, given a cfg_opt_t pointer.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getnfloat
+- See also
- cfg_getnfloat
-References CFGT_FLOAT, cfg_value_t::fpnumber, cfg_opt_t::simple_value, cfg_opt_t::type, and cfg_opt_t::values.
-
-
-
+
+
+ ◆ cfg_opt_getnint()
+
- DLLIMPORT signed long __export cfg_opt_getnint |
+ DLLIMPORT signed long __export cfg_opt_getnint |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of an integer option, given a cfg_opt_t pointer.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | index | Index of the value to get. Zero based. |
+Returns the value of an integer option, given a cfg_opt_t pointer.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getnint
-- Examples:
-
-ftpconf.c.
-References CFGT_INT, cfg_value_t::number, cfg_opt_t::simple_value, cfg_opt_t::type, and cfg_opt_t::values.
+- See also
- cfg_getnint
+- Examples
- ftpconf.c.
+
-
-
+
+
+ ◆ cfg_opt_getnsec()
+
- DLLIMPORT cfg_t* __export cfg_opt_getnsec |
+ DLLIMPORT cfg_t* __export cfg_opt_getnsec |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a section option, given a cfg_opt_t pointer.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | index | Index of the value to get. Zero based. |
+Returns the value of a section option, given a cfg_opt_t pointer.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getnsec
-- Examples:
-
-ftpconf.c.
-References CFGT_SEC, cfg_value_t::section, cfg_opt_t::type, and cfg_opt_t::values.
+- See also
- cfg_getnsec
+- Examples
- ftpconf.c.
+
-
-
+
+
+ ◆ cfg_opt_getnstr()
+
- DLLIMPORT char* __export cfg_opt_getnstr |
+ DLLIMPORT char* __export cfg_opt_getnstr |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a string option, given a cfg_opt_t pointer.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | index | Index of the value to get. Zero based. |
+Returns the value of a string option, given a cfg_opt_t pointer.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | Index of the value to get. Zero based. |
+
-- See also:
- cfg_getnstr
+- See also
- cfg_getnstr
-References CFGT_STR, cfg_opt_t::simple_value, cfg_value_t::string, cfg_opt_t::type, and cfg_opt_t::values.
+
+
+
+◆ cfg_opt_getstr()
+
+
+
+
+ const DLLIMPORT char* cfg_opt_getstr |
+ ( |
+ cfg_opt_t * |
+ opt | ) |
+ |
+
+
+
+
+ Return the string value of a key=value pair.
+ - Parameters
-
+
+
+
+ - See also
- cfg_opt_name
+ - Returns
- The string value for the option, or NULL if it's not a string. This string must not be modified!
+
-
-
+
+
+ ◆ cfg_opt_gettsec()
+
- DLLIMPORT cfg_t* __export cfg_opt_gettsec |
+ DLLIMPORT cfg_t* __export cfg_opt_gettsec |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- const char * |
- title | |
+ const char * |
+ title |
|
) |
- | | |
+ | |
-
-
+
-
-Returns the value of a section option, given a cfg_opt_t pointer and the title.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | title | The title of this section. The CFGF_TITLE flag must have been set for this option. |
+Returns the value of a section option, given a cfg_opt_t pointer and the title.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ title | The title of this section. The CFGF_TITLE flag must have been set for this option. |
+
-- See also:
- cfg_gettsec
+- See also
- cfg_gettsec
-References CFGF_NOCASE, CFGF_TITLE, cfg_opt_t::flags, and cfg_t::title.
-
-
-
+
+
+ ◆ cfg_opt_name()
+
- DLLIMPORT const char* __export cfg_opt_name |
+ const DLLIMPORT char* __export cfg_opt_name |
( |
- cfg_opt_t * |
- opt |
- ) |
+ cfg_opt_t * |
+ opt | ) |
|
-
-
+
-
-Return the name of an option.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
+Return the name of an option.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+
-- Returns:
- Returns the title, or 0 if there is no title. This string should not be modified.
-- Examples:
-
-ftpconf.c.
-References cfg_opt_t::name.
+- Returns
- Returns the title, or 0 if there is no title. This string should not be modified.
+- Examples
- ftpconf.c.
+
-
-
+
+
+ ◆ cfg_opt_nprint_var()
+
- DLLIMPORT void __export cfg_opt_nprint_var |
+ DLLIMPORT int __export cfg_opt_nprint_var |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- unsigned int |
- index, |
+ unsigned int |
+ index, |
|
|
- FILE * |
- fp | |
+ FILE * |
+ fp |
|
) |
- | | |
+ | |
-
-
+
-
-Default value print function.
-
-Print only the value of a given option. Does not handle sections or functions. Use cfg_opt_print to print the whole assignment ("option = value"), or cfg_print to print the whole config file.
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | index | The index in the option value array that should be printed |
- | fp | File stream to print to. |
+Default value print function.
+Print only the value of a given option. Does not handle sections or functions. Use cfg_opt_print to print the whole assignment ("option
+= value"), or cfg_print to print the whole config file.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | The index in the option value array that should be printed |
+ fp | File stream to print to. |
+
-- See also:
- cfg_print, cfg_opt_print
+- See also
- cfg_print, cfg_opt_print
+- Returns
- POSIX OK(0), or non-zero on failure.
-References CFGT_BOOL, CFGT_FLOAT, CFGT_FUNC, CFGT_INT, CFGT_PTR, CFGT_SEC, CFGT_STR, and cfg_opt_t::type.
-
-
-
+
+
+ ◆ cfg_opt_print()
+
- DLLIMPORT void __export cfg_opt_print |
+ DLLIMPORT int __export cfg_opt_print |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- FILE * |
- fp | |
+ FILE * |
+ fp |
|
) |
- | | |
+ | |
-
-
+
-
-Print an option and its value to a file.
-
-If a print callback function is specified for the option, it is used instead of cfg_opt_nprint_var.
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | fp | File stream to print to. |
+Print an option and its value to a file.
+If a print callback function is specified for the option, it is used instead of cfg_opt_nprint_var.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ fp | File stream to print to. |
+
-- See also:
- cfg_print_func_t
+- See also
- cfg_print_func_t
+- Returns
- POSIX OK(0), or non-zero on failure.
-
-
+
+
+ ◆ cfg_opt_print_indent()
+
- DLLIMPORT void __export cfg_opt_print_indent |
+ DLLIMPORT int __export cfg_opt_print_indent |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- FILE * |
- fp, |
+ FILE * |
+ fp, |
|
|
- int |
- indent | |
+ int |
+ indent |
|
) |
- | | |
+ | |
+
+
+ Print an option and its value to a file.
+ Same as cfg_opt_print, but with the indentation level specified. - See also
- cfg_opt_print
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_opt_rmnsec()
-
-Print an option and its value to a file.
-
-Same as cfg_opt_print, but with the indentation level specified. - See also:
- cfg_opt_print
+
+
+
+
+ DLLIMPORT int __export cfg_opt_rmnsec |
+ ( |
+ cfg_opt_t * |
+ opt, |
+
+
+ |
+ |
+ unsigned int |
+ index |
+
+
+ |
+ ) |
+ | |
+
+
+
- References CFGF_LIST, CFGF_TITLE, CFGT_FUNC, CFGT_SEC, CFGT_STR, cfg_opt_t::flags, cfg_opt_t::name, cfg_opt_t::nvalues, cfg_opt_t::pf, cfg_opt_t::simple_value, cfg_value_t::string, cfg_opt_t::type, and cfg_opt_t::values.
+ Removes and frees a config section, given a cfg_opt_t pointer.
+ - Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ index | Index of the section to remove. Zero based. |
+
+
+
+ - See also
- cfg_rmnsec
+ - Returns
- POSIX OK(0), or non-zero on failure.
-
-
+
+
+◆ cfg_opt_rmtsec()
+
+
+ Removes and frees a config section, given a cfg_opt_t pointer and the title.
+ - Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ title | The title of this section. The CFGF_TITLE flag must have been set for this option. |
+
+
+
+ - See also
- cfg_rmtsec
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_opt_set_print_func()
-
-Set a print callback function for an option.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | pf | The print function callback. |
+
+
+◆ cfg_opt_setcomment()
+
+
+
+
+ DLLIMPORT int __export cfg_opt_setcomment |
+ ( |
+ cfg_opt_t * |
+ opt, |
+
+
+ |
+ |
+ char * |
+ comment |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Annotate an option.
+ - Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ comment | The annotation |
+
+
+
+ - See also
- cfg_setcomment
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
-
+
+
+ ◆ cfg_opt_setmulti()
+
- DLLIMPORT void __export cfg_opt_setnbool |
+ DLLIMPORT int cfg_opt_setmulti |
( |
- cfg_opt_t * |
- opt, |
+ cfg_t * |
+ cfg, |
|
|
- cfg_bool_t |
- value, |
+ cfg_opt_t * |
+ opt, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ nvalues, |
+ |
|
+ char ** |
+ values |
+
+
+ |
) |
- | | |
+ | |
-
-
+
-
-Set a value of a boolean option.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | value | The value to set. |
- | index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+Set an option (create an instance of an option).
+- Parameters
-
+
+ cfg | The configuration file context. |
+ opt | The option definition. |
+ nvalues | The number of values to set for the option. |
+ values | The value(s) for the option. |
+
+- Returns
- POSIX OK(0), or non-zero on failure.
-References cfg_value_t::boolean, CFGT_BOOL, and cfg_opt_t::type.
-
-
-
+
+
+ ◆ cfg_opt_setnbool()
+
- DLLIMPORT void __export cfg_opt_setnfloat |
+ DLLIMPORT int __export cfg_opt_setnbool |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- double |
- value, |
+ cfg_bool_t |
+ value, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Set a value of a floating point option.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | value | The value to set. |
- | index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+Set a value of a boolean option.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ value | The value to set. |
+ index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+
+- Returns
- POSIX OK(0), or non-zero on failure.
-References CFGT_FLOAT, cfg_value_t::fpnumber, and cfg_opt_t::type.
-
-
-
+
+
+ ◆ cfg_opt_setnfloat()
+
- DLLIMPORT void __export cfg_opt_setnint |
+ DLLIMPORT int __export cfg_opt_setnfloat |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- long int |
- value, |
+ double |
+ value, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Set a value of an integer option.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | value | The value to set. |
- | index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+Set a value of a floating point option.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ value | The value to set. |
+ index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+
+- Returns
- POSIX OK(0), or non-zero on failure.
-References CFGT_INT, cfg_value_t::number, and cfg_opt_t::type.
-
-
-
+
+
+ ◆ cfg_opt_setnint()
+
- DLLIMPORT void __export cfg_opt_setnstr |
+ DLLIMPORT int __export cfg_opt_setnint |
( |
- cfg_opt_t * |
- opt, |
+ cfg_opt_t * |
+ opt, |
|
|
- const char * |
- value, |
+ long int |
+ value, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Set a value of a string option.
-
- - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
- | value | The value to set. Memory for the string is allocated and the value is copied. Any previous string value is freed. |
- | index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+Set a value of an integer option.
+- Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ value | The value to set. |
+ index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+
+- Returns
- POSIX OK(0), or non-zero on failure.
-References CFGT_STR, cfg_value_t::string, and cfg_opt_t::type.
-
-
-
+
+
+ ◆ cfg_opt_setnstr()
+
- DLLIMPORT unsigned int __export cfg_opt_size |
+ DLLIMPORT int __export cfg_opt_setnstr |
( |
- cfg_opt_t * |
- opt |
- ) |
+ cfg_opt_t * |
+ opt, |
+
+
+ |
|
+ const char * |
+ value, |
+
+ |
+ |
+ unsigned int |
+ index |
+
+
+ |
+ ) |
+ | |
+
+
+
+ Set a value of a string option.
+ - Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+ value | The value to set. Memory for the string is allocated and the value is copied. Any previous string value is freed. |
+ index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+
+
+
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_opt_size()
-
-Return the number of values this option has.
-
-If no default value is given for the option and no value was found in the config file, 0 will be returned (ie, the option value is not set at all). - Parameters:
-
-
- | opt | The option structure (eg, as returned from cfg_getopt()) |
+
+
+
+
+ DLLIMPORT unsigned int __export cfg_opt_size |
+ ( |
+ cfg_opt_t * |
+ opt | ) |
+ |
+
+
+
+
+ Return the number of values this option has.
+ If no default value is given for the option and no value was found in the config file, 0 will be returned (ie, the option value is not set at all). - Parameters
-
+
+ opt | The option structure (eg, as returned from cfg_getopt()) |
+
- - Examples:
-
-ftpconf.c.
- References cfg_opt_t::nvalues.
+ - Examples
- ftpconf.c.
+
-
-
+
+
+ ◆ cfg_parse()
+
- DLLIMPORT int __export cfg_parse |
+ DLLIMPORT int __export cfg_parse |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- filename | |
+ const char * |
+ filename |
|
) |
- | | |
+ | |
-
-
+
-
-Parse a configuration file.
-
-Tilde expansion is performed on the filename before it is opened. After a configuration file has been initialized (with cfg_init()) and parsed (with cfg_parse()), the values can be read with the cfg_getXXX functions.
- - Parameters:
-
-
- | cfg | The configuration file context as returned from cfg_init(). |
- | filename | The name of the file to parse. |
+Parse a configuration file.
+Tilde expansion is performed on the filename before it is opened. After a configuration file has been initialized (with cfg_init()) and parsed (with cfg_parse()), the values can be read with the cfg_getXXX functions.
+- Parameters
-
+
+ cfg | The configuration file context as returned from cfg_init(). |
+ filename | The name of the file to parse. |
+
-- Returns:
- On success, CFG_SUCCESS is returned. If the file couldn't be opened for reading, CFG_FILE_ERROR is returned. On all other errors, CFG_PARSE_ERROR is returned and cfg_error() was called with a descriptive error message.
-- Examples:
-
-ftpconf.c, reread.c, and simple.c.
-References cfg_t::filename.
+- Returns
- On success, CFG_SUCCESS is returned. If the file couldn't be opened for reading, CFG_FILE_ERROR is returned. On all other errors, CFG_PARSE_ERROR is returned and cfg_error() was called with a descriptive error message.
+- Examples
- ftpconf.c, reread.c, and simple.c.
+
-
-
+
+
+ ◆ cfg_parse_boolean()
+
- DLLIMPORT int __export cfg_parse_boolean |
+ DLLIMPORT int __export cfg_parse_boolean |
( |
- const char * |
- s |
- ) |
+ const char * |
+ s | ) |
|
-
-
+
-
-Parse a boolean option string.
-
-Accepted "true" values are "true", "on" and "yes", and accepted "false" values are "false", "off" and "no".
- - Returns:
- Returns 1 or 0 (true/false) if the string was parsed correctly, or -1 if an error occurred.
+ Parse a boolean option string.
+ Accepted "true" values are "true", "on" and "yes", and accepted "false" values are "false", "off" and "no".
+ - Returns
- Returns 1 or 0 (true/false) if the string was parsed correctly, or -1 if an error occurred.
-
-
+
+
+ ◆ cfg_parse_buf()
+
- DLLIMPORT int __export cfg_parse_buf |
+ DLLIMPORT int __export cfg_parse_buf |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- buf | |
+ const char * |
+ buf |
|
) |
- | | |
+ | |
-
-
+
-
-Same as cfg_parse() above, but takes a character buffer as argument.
-
- - Parameters:
-
-
- | cfg | The configuration file context as returned from cfg_init(). |
- | buf | A zero-terminated string with configuration directives. |
+Same as cfg_parse() above, but takes a character buffer as argument.
+- Parameters
-
+
+ cfg | The configuration file context as returned from cfg_init(). |
+ buf | A zero-terminated string with configuration directives. |
+
-- See also:
- cfg_parse()
-- Examples:
-
-reread.c.
-References CFG_SUCCESS, cfg_t::filename, and cfg_t::line.
+- See also
- cfg_parse()
+- Returns
- POSIX OK(0), or non-zero on failure.
+- Examples
- reread.c.
+
-
-
+
+
+ ◆ cfg_parse_fp()
+
- DLLIMPORT int __export cfg_parse_fp |
+ DLLIMPORT int __export cfg_parse_fp |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- FILE * |
- fp | |
+ FILE * |
+ fp |
|
) |
- | | |
+ | |
+
+
+ Same as cfg_parse() above, but takes an already opened file as argument.
+ Reading begins at the current position. After parsing, the position is not reset. The caller is responsible for closing the file.
+ - Parameters
-
+
+ cfg | The configuration file context as returned from cfg_init(). |
+ fp | An open file stream. |
+
+
+
+ - See also
- cfg_parse()
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_print()
-
-Same as cfg_parse() above, but takes an already opened file as argument.
-
-Reading begins at the current position. After parsing, the position is not reset. The caller is responsible for closing the file.
- - Parameters:
-
-
- | cfg | The configuration file context as returned from cfg_init(). |
- | fp | An open file stream. |
+
+
+
+
+ DLLIMPORT int __export cfg_print |
+ ( |
+ cfg_t * |
+ cfg, |
+
+
+ |
+ |
+ FILE * |
+ fp |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Print the options and values to a file.
+ Note that options in any included file are expanded and printed directly to the file. Option values given with environment variables in the parsed input are also printed expanded. This means that if you parse a configuration file you can't expect that the output from this function is identical to the initial file.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ fp | File stream to print to, use stdout to print to the screen. |
+
- - See also:
- cfg_parse()
+ - See also
- cfg_print_func_t, cfg_set_print_func
+ - Returns
- POSIX OK(0), or non-zero on failure.
+ - Examples
- simple.c.
+
- References CFG_SUCCESS, cfg_t::filename, and cfg_t::line.
+
+
+
+◆ cfg_print_indent()
+
+
+
+
+ DLLIMPORT int __export cfg_print_indent |
+ ( |
+ cfg_t * |
+ cfg, |
+
+
+ |
+ |
+ FILE * |
+ fp, |
+
+
+ |
+ |
+ int |
+ indent |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Print the options and values to a file.
+ Same as cfg_print, but with the indentation level specified. - See also
- cfg_print
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
-
+
+
+ ◆ cfg_rmnsec()
+
- DLLIMPORT void __export cfg_print |
+ DLLIMPORT int __export cfg_rmnsec |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- FILE * |
- fp | |
+ const char * |
+ name, |
+ |
|
+ unsigned int |
+ index |
+
+
+ |
) |
- | | |
+ | |
+
+
+ Indexed version of cfg_rmsec(), used for CFGF_MULTI sections.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the section. |
+ index | Index of the section to remove. Zero based. |
+
+
+
+ - See also
- cfg_rmsec
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_rmsec()
-
-Print the options and values to a file.
-
-Note that options in any included file are expanded and printed directly to the file. Option values given with environment variables in the parsed input are also printed expanded. This means that if you parse a configuration file you can't expect that the output from this function is identical to the initial file.
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | fp | File stream to print to, use stdout to print to the screen. |
+
+
+
+
+ DLLIMPORT int __export cfg_rmsec |
+ ( |
+ cfg_t * |
+ cfg, |
+
+
+ |
+ |
+ const char * |
+ name |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Removes and frees a config section.
+ This is the same as calling cfg_rmnsec with index 0. - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the section. |
+
- - See also:
- cfg_print_func_t, cfg_set_print_func
- - Examples:
-
-simple.c.
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
-
+
+
+ ◆ cfg_rmtsec()
+
- DLLIMPORT void __export cfg_print_indent |
+ DLLIMPORT int __export cfg_rmtsec |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- FILE * |
- fp, |
+ const char * |
+ name, |
|
|
- int |
- indent | |
+ const char * |
+ title |
|
) |
- | | |
+ | |
+
+
+ Removes and frees a section given the title, used for section with the CFGF_TITLE flag set.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the section. |
+ title | The title of this section. The CFGF_TITLE flag must have been set for this option. |
+
+
+
+ - See also
- cfg_rmsec
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_searchpath()
-
-Print the options and values to a file.
-
-Same as cfg_print, but with the indentation level specified. - See also:
- cfg_print
+
+
+
+
+ DLLIMPORT char* __export cfg_searchpath |
+ ( |
+ cfg_searchpath_t * |
+ path, |
+
+
+ |
+ |
+ const char * |
+ file |
+
+
+ |
+ ) |
+ | |
+
+
+
- References cfg_opt_t::name, and cfg_t::opts.
+ Search the linked-list of cfg_searchpath_t for the specified file.
+ If not NULL, the return value is freshly allocated and and should be freed by the caller.
+ - Parameters
-
+
+ path | The linked list of cfg_searchpath_t structs, each containg a directory to be searched |
+ file | The file for which to search |
+
+
+
+ - Returns
- If the file is found on the searchpath then the full path to the file is returned. If not found, NULL is returned.
-
-
+
+
+◆ cfg_set_error_function()
+
+
+ Install a user-defined error reporting function.
+ - Returns
- The old error reporting function is returned.
+
-
+
+
+ ◆ cfg_set_print_filter_func()
-
-Install a user-defined error reporting function.
-
- - Returns:
- The old error reporting function is returned.
+
+
- References cfg_t::errfunc.
+ Install a user-defined print filter function.
+ This callback is called for each option when printing cfg, or something above cfg if cfg is a section in some parent cfg. When cfg (or something above cfg) is printed, this filter is also inherited to child sections unless the child section has its own print filter.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ pff | The print filter callback function. |
+
+
+
+ - Returns
- The old print filter function is returned.
+ - See also
- cfg_print_filter_func_t
-
-
+
+
+◆ cfg_set_print_func()
+
-
+
-
-Set a print callback function for an option given its name.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | pf | The print callback function. |
+Set a print callback function for an option given its name.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ pf | The print callback function. |
+
-- See also:
- cfg_print_func_t
+- See also
- cfg_print_func_t
-
-
+
+
+ ◆ cfg_set_validate_func()
+
-
+
-
-Register a validating callback function for an option.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | vf | The validating callback function. |
+Register a validating callback function for an option.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ vf | The validating callback function. |
+
-- See also:
- cfg_validate_callback_t
-- Examples:
-
-ftpconf.c.
-References cfg_t::flags, cfg_t::opts, and cfg_opt_t::validcb.
+- See also
- cfg_validate_callback_t
+- Examples
- ftpconf.c.
+
-
-
+
+
+ ◆ cfg_set_validate_func2()
+
-
+
-
-Set the value of a boolean option given its name.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | value | The value to set. If the option is a list (the CFGF_LIST flag is set), only the first value (with index 0) is set. |
+Register a validating callback function for an option.
+This callback is called for all cfg_set*() functions, although not cfg_opt_set*(), and can be used to check and modify a value/string *before* it is actually set. The regular callbacks are run after the fact and are only called when parsing a buffer or file.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ vf | The validating callback function. |
+
+- See also
- cfg_validate_callback2_t
-
-
+
+
+ ◆ cfg_setbool()
+
- DLLIMPORT void __export cfg_setfloat |
+ DLLIMPORT int __export cfg_setbool |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- double |
- value | |
+ cfg_bool_t |
+ value |
|
) |
- | | |
+ | |
+
+
+ Set the value of a boolean option given its name.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ value | The value to set. If the option is a list (the CFGF_LIST flag is set), only the first value (with index 0) is set. |
+
+
+
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_setcomment()
-
-Set the value of a floating point option given its name.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | value | The value to set. If the option is a list (the CFGF_LIST flag is set), only the first value (with index 0) is set. |
+
+
+
+
+ DLLIMPORT int __export cfg_setcomment |
+ ( |
+ cfg_t * |
+ cfg, |
+
+
+ |
+ |
+ const char * |
+ name, |
+
+
+ |
+ |
+ char * |
+ comment |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Annotate an option given its name.
+ All options can be annotated as long as the CFGF_COMMENTS flag is given to cfg_init().
+ When calling cfg_print(), annotations are saved as a C style one-liner comment before each option.
+ When calling cfg_parse(), only one-liner comments preceding an option are read and used to annotate the option.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ comment | The annotation |
+
+ - Returns
- POSIX OK(0), or non-zero on failure. This function will fail if memory for the new comment cannot be allocated.
-
-
+
+
+ ◆ cfg_setfloat()
+
- DLLIMPORT void __export cfg_setint |
+ DLLIMPORT int __export cfg_setfloat |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- long int |
- value | |
+ double |
+ value |
|
) |
- | | |
+ | |
+
+
+ Set the value of a floating point option given its name.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ value | The value to set. If the option is a list (the CFGF_LIST flag is set), only the first value (with index 0) is set. |
+
+
+
+ - Returns
- POSIX OK(0), or non-zero on failure.
+
-
+
+
+ ◆ cfg_setint()
-
-Set the value of an integer option given its name.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | value | The value to set. If the option is a list (the CFGF_LIST flag is set), only the first value (with index 0) is set. |
+
+
+
+
+ DLLIMPORT int __export cfg_setint |
+ ( |
+ cfg_t * |
+ cfg, |
+
+
+ |
+ |
+ const char * |
+ name, |
+
+
+ |
+ |
+ long int |
+ value |
+
+
+ |
+ ) |
+ | |
+
+
+
+
+ Set the value of an integer option given its name.
+ - Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ value | The value to set. If the option is a list (the CFGF_LIST flag is set), only the first value (with index 0) is set. |
+
+ - Returns
- POSIX OK(0), or non-zero on failure.
-
-
+
+
+ ◆ cfg_setlist()
+
- DLLIMPORT void __export cfg_setlist |
+ DLLIMPORT int __export cfg_setlist |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- unsigned int |
- nvalues, |
+ unsigned int |
+ nvalues, |
|
|
- |
- ... | |
+ |
+ ... |
|
) |
- | | |
+ | |
-
-
+
-
-Set values for a list option.
-
-All existing values are replaced with the new ones.
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | nvalues | Number of values to set. |
- | ... | The values to set, the type must match the type of the option and the number of values must be equal to the nvalues parameter. |
+Set values for a list option.
+All existing values are replaced with the new ones.
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ nvalues | Number of values to set. |
+ ... | The values to set, the type must match the type of the option and the number of values must be equal to the nvalues parameter. |
+
+- Returns
- POSIX OK(0), or non-zero on failure.
-References CFGF_LIST, and cfg_opt_t::flags.
-
-
-
+
+
+ ◆ cfg_setmulti()
+
- DLLIMPORT void __export cfg_setnbool |
+ DLLIMPORT int cfg_setmulti |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- cfg_bool_t |
- value, |
+ unsigned int |
+ nvalues, |
|
|
- unsigned int |
- index | |
+ char ** |
+ values |
|
) |
- | | |
+ | |
-
-
+
-
-Set a value of a boolean option given its name and index.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | value | The value to set. |
- | index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+Set an option (create an instance of an option).
+- Parameters
-
+
+ cfg | The configuration file context. |
+ name | The name of the option. |
+ nvalues | The number of values to set for the option. |
+ values | The value(s) for the option. |
+
+- Returns
- POSIX OK(0), or non-zero on failure.
-
-
+
+
+ ◆ cfg_setnbool()
+
- DLLIMPORT void __export cfg_setnfloat |
+ DLLIMPORT int __export cfg_setnbool |
( |
- cfg_t * |
- cfg, |
+ cfg_t * |
+ cfg, |
|
|
- const char * |
- name, |
+ const char * |
+ name, |
|
|
- double |
- value, |
+ cfg_bool_t |
+ value, |
|
|
- unsigned int |
- index | |
+ unsigned int |
+ index |
|
) |
- | | |
+ | |
-
-
+
-
-Set a value of a floating point option given its name and index.
-
- - Parameters:
-
-
- | cfg | The configuration file context. |
- | name | The name of the option. |
- | value | The value to set. |
- | index | The index in the option value array that should be modified. It is an error to set values with indices larger than 0 for options without the CFGF_LIST flag set. |
+Set a value of a boolean option given its name and index.
+- Parameters
-
+
|
|