📄 confuse.h.3
字号:
.TH "confuse.h" 3 "29 Dec 2007" "Version 2.6" "confuse" \" -*- nroff -*-.ad l.nh.SH NAMEconfuse.h \- A configuration file parser library. .SH SYNOPSIS.br.PP\fC#include <stdio.h>\fP.br\fC#include <stdarg.h>\fP.br.SS "Data Structures".in +1c.ti -1c.RI "struct \fBcfg_t\fP".br.RI "\fIData structure holding information about a 'section'. \fP".ti -1c.RI "union \fBcfg_value_t\fP".br.RI "\fIData structure holding the value of a fundamental option value. \fP".ti -1c.RI "struct \fBcfg_defvalue_t\fP".br.RI "\fIData structure holding the default value given by the initialization macros. \fP".ti -1c.RI "struct \fBcfg_opt_t\fP".br.RI "\fIData structure holding information about an option. \fP".in -1c.SS "Defines".in +1c.ti -1c.RI "#define \fBCFGF_NONE\fP 0".br.RI "\fIFlags. \fP".ti -1c.RI "#define \fBCFGF_MULTI\fP 1".br.RI "\fIoption may be specified multiple times (only applies to sections) \fP".ti -1c.RI "#define \fBCFGF_LIST\fP 2".br.RI "\fIoption is a list \fP".ti -1c.RI "#define \fBCFGF_NOCASE\fP 4".br.RI "\fIconfiguration file is case insensitive \fP".ti -1c.RI "#define \fBCFGF_TITLE\fP 8".br.RI "\fIoption has a title (only applies to sections) \fP".ti -1c.RI "#define \fBCFGF_NODEFAULT\fP 16".br.RI "\fIoption has no default value \fP".ti -1c.RI "#define \fBCFGF_NO_TITLE_DUPES\fP 32".br.RI "\fImultiple section titles must be unique (duplicates raises an error, only applies to sections) \fP".ti -1c.RI "#define \fBCFG_SUCCESS\fP 0".br.RI "\fIReturn codes from \fBcfg_parse()\fP. \fP".ti -1c.RI "#define \fBCFG_STR\fP(name, def, flags) __CFG_STR(name, def, flags, 0, 0)".br.RI "\fIInitialize a string option. \fP".ti -1c.RI "#define \fBCFG_STR_LIST\fP(name, def, flags) __CFG_STR_LIST(name, def, flags, 0, 0)".br.RI "\fIInitialize a string list option. \fP".ti -1c.RI "#define \fBCFG_STR_CB\fP(name, def, flags, cb) __CFG_STR(name, def, flags, 0, cb)".br.RI "\fIInitialize a string option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_STR_LIST_CB\fP(name, def, flags, cb) __CFG_STR_LIST(name, def, flags, 0, cb)".br.RI "\fIInitialize a string list option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_SIMPLE_STR\fP(name, svalue) __CFG_STR(name, 0, CFGF_NONE, svalue, 0)".br.RI "\fIInitialize a 'simple' string option. \fP".ti -1c.RI "#define \fBCFG_INT\fP(name, def, flags) __CFG_INT(name, def, flags, 0, 0)".br.RI "\fIInitialize an integer option. \fP".ti -1c.RI "#define \fBCFG_INT_LIST\fP(name, def, flags) __CFG_INT_LIST(name, def, flags, 0, 0)".br.RI "\fIInitialize an integer list option. \fP".ti -1c.RI "#define \fBCFG_INT_CB\fP(name, def, flags, cb) __CFG_INT(name, def, flags, 0, cb)".br.RI "\fIInitialize an integer option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_INT_LIST_CB\fP(name, def, flags, cb) __CFG_INT_LIST(name, def, flags, 0, cb)".br.RI "\fIInitialize an integer list option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_SIMPLE_INT\fP(name, svalue) __CFG_INT(name, 0, CFGF_NONE, svalue, 0)".br.RI "\fIInitialize a 'simple' integer option (see documentation for CFG_SIMPLE_STR for more information). \fP".ti -1c.RI "#define \fBCFG_FLOAT\fP(name, def, flags) __CFG_FLOAT(name, def, flags, 0, 0)".br.RI "\fIInitialize a floating point option. \fP".ti -1c.RI "#define \fBCFG_FLOAT_LIST\fP(name, def, flags) __CFG_FLOAT_LIST(name, def, flags, 0, 0)".br.RI "\fIInitialize a floating point list option. \fP".ti -1c.RI "#define \fBCFG_FLOAT_CB\fP(name, def, flags, cb) __CFG_FLOAT(name, def, flags, 0, cb)".br.RI "\fIInitialize a floating point option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_FLOAT_LIST_CB\fP(name, def, flags, cb) __CFG_FLOAT_LIST(name, def, flags, 0, cb)".br.RI "\fIInitialize a floating point list option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_SIMPLE_FLOAT\fP(name, svalue) __CFG_FLOAT(name, 0, CFGF_NONE, svalue, 0)".br.RI "\fIInitialize a 'simple' floating point option (see documentation for CFG_SIMPLE_STR for more information). \fP".ti -1c.RI "#define \fBCFG_BOOL\fP(name, def, flags) __CFG_BOOL(name, def, flags, 0, 0)".br.RI "\fIInitialize a boolean option. \fP".ti -1c.RI "#define \fBCFG_BOOL_LIST\fP(name, def, flags) __CFG_BOOL_LIST(name, def, flags, 0, 0)".br.RI "\fIInitialize a boolean list option. \fP".ti -1c.RI "#define \fBCFG_BOOL_CB\fP(name, def, flags, cb) __CFG_BOOL(name, def, flags, 0, cb)".br.RI "\fIInitialize a boolean option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_BOOL_LIST_CB\fP(name, def, flags, cb) __CFG_BOOL_LIST(name, def, flags, 0, cb)".br.RI "\fIInitialize a boolean list option with a value parsing callback. \fP".ti -1c.RI "#define \fBCFG_SIMPLE_BOOL\fP(name, svalue) __CFG_BOOL(name, cfg_false, CFGF_NONE, svalue, 0)".br.RI "\fIInitialize a 'simple' boolean option (see documentation for CFG_SIMPLE_STR for more information). \fP".ti -1c.RI "#define \fBCFG_SEC\fP(name, opts, flags) {name,CFGT_SEC,0,0,flags,opts,{0,0,cfg_false,0,0},0,0,0,0,0,0}".br.RI "\fIInitialize a section. \fP".ti -1c.RI "#define \fBCFG_FUNC\fP(name, func) {name,CFGT_FUNC,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},func,0,0,0,0,0}".br.RI "\fIInitialize a function. \fP".ti -1c.RI "#define \fBCFG_PTR_CB\fP(name, def, flags, parsecb, freecb) __CFG_PTR(name, def, flags, 0, parsecb, freecb)".br.RI "\fIInitialize a user-defined option. \fP".ti -1c.RI "#define \fBCFG_PTR_LIST_CB\fP(name, def, flags, parsecb, freecb) __CFG_PTR(name, def, flags | CFGF_LIST, 0, parsecb, freecb)".br.RI "\fIInitialize a list of user-defined options. \fP".ti -1c.RI "#define \fBCFG_END\fP() {0,CFGT_NONE,0,0,CFGF_NONE,0,{0,0,cfg_false,0,0},0,0,0,0,0,0}".br.RI "\fITerminate list of options. \fP".in -1c.SS "Typedefs".in +1c.ti -1c.RI "typedef int(*) \fBcfg_func_t\fP (\fBcfg_t\fP *cfg, \fBcfg_opt_t\fP *opt, int argc, const char **argv)".br.RI "\fIFunction prototype used by CFGT_FUNC options. \fP".ti -1c.RI "typedef void(*) \fBcfg_print_func_t\fP (\fBcfg_opt_t\fP *opt, unsigned int index, FILE *fp)".br.RI "\fIFunction prototype used by the cfg_print_ functions. \fP".ti -1c.RI "typedef int(*) \fBcfg_callback_t\fP (\fBcfg_t\fP *cfg, \fBcfg_opt_t\fP *opt, const char *value, void *result)".br.RI "\fIValue parsing callback prototype. \fP".ti -1c.RI "typedef int(*) \fBcfg_validate_callback_t\fP (\fBcfg_t\fP *cfg, \fBcfg_opt_t\fP *opt)".br.RI "\fIValidating callback prototype. \fP".ti -1c.RI "typedef void(*) \fBcfg_free_func_t\fP (void *value)".br.RI "\fIUser-defined memory release function for CFG_PTR values. \fP".ti -1c.RI "typedef void(*) \fBcfg_errfunc_t\fP (\fBcfg_t\fP *cfg, const char *fmt, va_list ap)".br.RI "\fIError reporting function. \fP".in -1c.SS "Enumerations".in +1c.ti -1c.RI "enum \fBcfg_type_t\fP { , \fBCFGT_INT\fP, \fBCFGT_FLOAT\fP, \fBCFGT_STR\fP, \fBCFGT_BOOL\fP, \fBCFGT_SEC\fP, \fBCFGT_FUNC\fP, \fBCFGT_PTR\fP }".br.RI "\fIFundamental option types. \fP".ti -1c.RI "enum \fBcfg_bool_t\fP ".br.RI "\fIBoolean values. \fP".in -1c.SS "Functions".in +1c.ti -1c.RI "DLLIMPORT \fBcfg_t\fP *__export \fBcfg_init\fP (\fBcfg_opt_t\fP *opts, cfg_flag_t flags)".br.RI "\fICreate and initialize a \fBcfg_t\fP structure. \fP".ti -1c.RI "DLLIMPORT int __export \fBcfg_parse\fP (\fBcfg_t\fP *cfg, const char *filename)".br.RI "\fIParse a configuration file. \fP".ti -1c.RI "DLLIMPORT int __export \fBcfg_parse_fp\fP (\fBcfg_t\fP *cfg, FILE *fp)".br.RI "\fISame as \fBcfg_parse()\fP above, but takes an already opened file as argument. \fP".ti -1c.RI "DLLIMPORT int __export \fBcfg_parse_buf\fP (\fBcfg_t\fP *cfg, const char *buf)".br.RI "\fISame as \fBcfg_parse()\fP above, but takes a character buffer as argument. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_free_value\fP (\fBcfg_opt_t\fP *opt)".br.RI "\fIFree the memory allocated for the values of a given option. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_free\fP (\fBcfg_t\fP *cfg)".br.RI "\fIFree a \fBcfg_t\fP context. \fP".ti -1c.RI "DLLIMPORT \fBcfg_errfunc_t\fP __export \fBcfg_set_error_function\fP (\fBcfg_t\fP *cfg, \fBcfg_errfunc_t\fP errfunc)".br.RI "\fIInstall a user-defined error reporting function. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_error\fP (\fBcfg_t\fP *cfg, const char *fmt,...)".br.RI "\fIShow a parser error. \fP".ti -1c.RI "DLLIMPORT signed long __export \fBcfg_opt_getnint\fP (\fBcfg_opt_t\fP *opt, unsigned int index)".br.RI "\fIReturns the value of an integer option, given a \fBcfg_opt_t\fP pointer. \fP".ti -1c.RI "DLLIMPORT long int __export \fBcfg_getnint\fP (\fBcfg_t\fP *cfg, const char *name, unsigned int index)".br.RI "\fIIndexed version of \fBcfg_getint()\fP, used for lists. \fP".ti -1c.RI "DLLIMPORT long int __export \fBcfg_getint\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturns the value of an integer option. \fP".ti -1c.RI "DLLIMPORT double __export \fBcfg_opt_getnfloat\fP (\fBcfg_opt_t\fP *opt, unsigned int index)".br.RI "\fIReturns the value of a floating point option, given a \fBcfg_opt_t\fP pointer. \fP".ti -1c.RI "DLLIMPORT double __export \fBcfg_getnfloat\fP (\fBcfg_t\fP *cfg, const char *name, unsigned int index)".br.RI "\fIIndexed version of \fBcfg_getfloat()\fP, used for lists. \fP".ti -1c.RI "DLLIMPORT double __export \fBcfg_getfloat\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturns the value of a floating point option. \fP".ti -1c.RI "DLLIMPORT char *__export \fBcfg_opt_getnstr\fP (\fBcfg_opt_t\fP *opt, unsigned int index)".br.RI "\fIReturns the value of a string option, given a \fBcfg_opt_t\fP pointer. \fP".ti -1c.RI "DLLIMPORT char *__export \fBcfg_getnstr\fP (\fBcfg_t\fP *cfg, const char *name, unsigned int index)".br.RI "\fIIndexed version of \fBcfg_getstr()\fP, used for lists. \fP".ti -1c.RI "DLLIMPORT char *__export \fBcfg_getstr\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturns the value of a string option. \fP".ti -1c.RI "DLLIMPORT \fBcfg_bool_t\fP __export \fBcfg_opt_getnbool\fP (\fBcfg_opt_t\fP *opt, unsigned int index)".br.RI "\fIReturns the value of a boolean option, given a \fBcfg_opt_t\fP pointer. \fP".ti -1c.RI "DLLIMPORT \fBcfg_bool_t\fP __export \fBcfg_getnbool\fP (\fBcfg_t\fP *cfg, const char *name, unsigned int index)".br.RI "\fIIndexed version of \fBcfg_getbool()\fP, used for lists. \fP".ti -1c.RI "DLLIMPORT \fBcfg_bool_t\fP __export \fBcfg_getbool\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturns the value of a boolean option. \fP".ti -1c.RI "DLLIMPORT void *__export \fBcfg_getptr\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturns the value of a user-defined option (void pointer). \fP".ti -1c.RI "DLLIMPORT \fBcfg_t\fP *__export \fBcfg_opt_getnsec\fP (\fBcfg_opt_t\fP *opt, unsigned int index)".br.RI "\fIReturns the value of a section option, given a \fBcfg_opt_t\fP pointer. \fP".ti -1c.RI "DLLIMPORT \fBcfg_t\fP *__export \fBcfg_getnsec\fP (\fBcfg_t\fP *cfg, const char *name, unsigned int index)".br.RI "\fIIndexed version of \fBcfg_getsec()\fP, used for sections with the CFGF_MULTI flag set. \fP".ti -1c.RI "DLLIMPORT \fBcfg_t\fP *__export \fBcfg_opt_gettsec\fP (\fBcfg_opt_t\fP *opt, const char *title)".br.RI "\fIReturns the value of a section option, given a \fBcfg_opt_t\fP pointer and the title. \fP".ti -1c.RI "DLLIMPORT \fBcfg_t\fP *__export \fBcfg_gettsec\fP (\fBcfg_t\fP *cfg, const char *name, const char *title)".br.RI "\fIReturn a section given the title, used for section with the CFGF_TITLE flag set. \fP".ti -1c.RI "DLLIMPORT \fBcfg_t\fP *__export \fBcfg_getsec\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturns the value of a section option. \fP".ti -1c.RI "DLLIMPORT unsigned int __export \fBcfg_opt_size\fP (\fBcfg_opt_t\fP *opt)".br.RI "\fIReturn the number of values this option has. \fP".ti -1c.RI "DLLIMPORT unsigned int __export \fBcfg_size\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturn the number of values this option has. \fP".ti -1c.RI "DLLIMPORT const char *__export \fBcfg_title\fP (\fBcfg_t\fP *cfg)".br.RI "\fIReturn the title of a section. \fP".ti -1c.RI "DLLIMPORT const char *__export \fBcfg_name\fP (\fBcfg_t\fP *cfg)".br.RI "\fIReturn the name of a section. \fP".ti -1c.RI "DLLIMPORT const char *__export \fBcfg_opt_name\fP (\fBcfg_opt_t\fP *opt)".br.RI "\fIReturn the name of an option. \fP".ti -1c.RI "DLLIMPORT int __export \fBcfg_include\fP (\fBcfg_t\fP *cfg, \fBcfg_opt_t\fP *opt, int argc, const char **argv)".br.RI "\fIPredefined include-function. \fP".ti -1c.RI "DLLIMPORT char *__export \fBcfg_tilde_expand\fP (const char *filename)".br.RI "\fIDoes tilde expansion (~ -> $HOME) on the filename. \fP".ti -1c.RI "DLLIMPORT int __export \fBcfg_parse_boolean\fP (const char *s)".br.RI "\fIParse a boolean option string. \fP".ti -1c.RI "DLLIMPORT \fBcfg_opt_t\fP *__export \fBcfg_getopt\fP (\fBcfg_t\fP *cfg, const char *name)".br.RI "\fIReturn an option given it's name. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_opt_setnint\fP (\fBcfg_opt_t\fP *opt, long int value, unsigned int index)".br.RI "\fISet a value of an integer option. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setint\fP (\fBcfg_t\fP *cfg, const char *name, long int value)".br.RI "\fISet the value of an integer option given its name. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setnint\fP (\fBcfg_t\fP *cfg, const char *name, long int value, unsigned int index)".br.RI "\fISet a value of an integer option given its name and index. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_opt_setnfloat\fP (\fBcfg_opt_t\fP *opt, double value, unsigned int index)".br.RI "\fISet a value of a floating point option. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setfloat\fP (\fBcfg_t\fP *cfg, const char *name, double value)".br.RI "\fISet the value of a floating point option given its name. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setnfloat\fP (\fBcfg_t\fP *cfg, const char *name, double value, unsigned int index)".br.RI "\fISet a value of a floating point option given its name and index. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_opt_setnbool\fP (\fBcfg_opt_t\fP *opt, \fBcfg_bool_t\fP value, unsigned int index)".br.RI "\fISet a value of a boolean option. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setbool\fP (\fBcfg_t\fP *cfg, const char *name, \fBcfg_bool_t\fP value)".br.RI "\fISet the value of a boolean option given its name. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setnbool\fP (\fBcfg_t\fP *cfg, const char *name, \fBcfg_bool_t\fP value, unsigned int index)".br.RI "\fISet a value of a boolean option given its name and index. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_opt_setnstr\fP (\fBcfg_opt_t\fP *opt, const char *value, unsigned int index)".br.RI "\fISet a value of a string option. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setstr\fP (\fBcfg_t\fP *cfg, const char *name, const char *value)".br.RI "\fISet the value of a string option given its name. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setnstr\fP (\fBcfg_t\fP *cfg, const char *name, const char *value, unsigned int index)".br.RI "\fISet a value of a boolean option given its name and index. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_setlist\fP (\fBcfg_t\fP *cfg, const char *name, unsigned int nvalues,...)".br.RI "\fISet values for a list option. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_addlist\fP (\fBcfg_t\fP *cfg, const char *name, unsigned int nvalues,...)".br.RI "\fIAdd values for a list option. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_opt_nprint_var\fP (\fBcfg_opt_t\fP *opt, unsigned int index, FILE *fp)".br.RI "\fIDefault value print function. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_opt_print_indent\fP (\fBcfg_opt_t\fP *opt, FILE *fp, int indent)".br.RI "\fIPrint an option and its value to a file. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_opt_print\fP (\fBcfg_opt_t\fP *opt, FILE *fp)".br.RI "\fIPrint an option and its value to a file. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_print_indent\fP (\fBcfg_t\fP *cfg, FILE *fp, int indent)".br.RI "\fIPrint the options and values to a file. \fP".ti -1c.RI "DLLIMPORT void __export \fBcfg_print\fP (\fBcfg_t\fP *cfg, FILE *fp)"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -