📄 confuse.h.3
字号:
Set a value of a boolean option. .PP\fBParameters:\fP.RS 4\fIopt\fP The option structure (eg, as returned from \fBcfg_getopt()\fP) .br\fIvalue\fP The value to set. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_opt_setnfloat (\fBcfg_opt_t\fP * opt, double value, unsigned int index)".PPSet a value of a floating point option. .PP\fBParameters:\fP.RS 4\fIopt\fP The option structure (eg, as returned from \fBcfg_getopt()\fP) .br\fIvalue\fP The value to set. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_opt_setnint (\fBcfg_opt_t\fP * opt, long int value, unsigned int index)".PPSet a value of an integer option. .PP\fBParameters:\fP.RS 4\fIopt\fP The option structure (eg, as returned from \fBcfg_getopt()\fP) .br\fIvalue\fP The value to set. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_opt_setnstr (\fBcfg_opt_t\fP * opt, const char * value, unsigned int index)".PPSet a value of a string option. .PP\fBParameters:\fP.RS 4\fIopt\fP The option structure (eg, as returned from \fBcfg_getopt()\fP) .br\fIvalue\fP The value to set. Memory for the string is allocated and the value is copied. Any previous string value is freed. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT unsigned int __export cfg_opt_size (\fBcfg_opt_t\fP * opt)".PPReturn the number of values this option has. .PPIf 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). .PP\fBParameters:\fP.RS 4\fIopt\fP The option structure (eg, as returned from \fBcfg_getopt()\fP) .RE.PP.PP\fBExamples: \fP.in +1c\fBftpconf.c\fP..SS "DLLIMPORT int __export cfg_parse (\fBcfg_t\fP * cfg, const char * filename)".PPParse a configuration file. .PPTilde expansion is performed on the filename before it is opened. After a configuration file has been initialized (with \fBcfg_init()\fP) and parsed (with \fBcfg_parse()\fP), the values can be read with the cfg_getXXX functions..PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context as returned from \fBcfg_init()\fP. .br\fIfilename\fP The name of the file to parse..RE.PP\fBReturns:\fP.RS 4On 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 \fBcfg_error()\fP was called with a descriptive error message. .RE.PP.PP\fBExamples: \fP.in +1c\fBftpconf.c\fP, \fBreread.c\fP, and \fBsimple.c\fP..SS "DLLIMPORT int __export cfg_parse_boolean (const char * s)".PPParse a boolean option string. .PPAccepted 'true' values are 'true', 'on' and 'yes', and accepted 'false' values are 'false', 'off' and 'no'..PP\fBReturns:\fP.RS 4Returns 1 or 0 (true/false) if the string was parsed correctly, or -1 if an error occurred. .RE.PP.SS "DLLIMPORT int __export cfg_parse_buf (\fBcfg_t\fP * cfg, const char * buf)".PPSame as \fBcfg_parse()\fP above, but takes a character buffer as argument. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context as returned from \fBcfg_init()\fP. .br\fIbuf\fP A zero-terminated string with configuration directives..RE.PP\fBSee also:\fP.RS 4\fBcfg_parse()\fP .RE.PP.PP\fBExamples: \fP.in +1c\fBreread.c\fP..SS "DLLIMPORT int __export cfg_parse_fp (\fBcfg_t\fP * cfg, FILE * fp)".PPSame as \fBcfg_parse()\fP above, but takes an already opened file as argument. .PPReading begins at the current position. After parsing, the position is not reset. The caller is responsible for closing the file..PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context as returned from \fBcfg_init()\fP. .br\fIfp\fP An open file stream..RE.PP\fBSee also:\fP.RS 4\fBcfg_parse()\fP .RE.PP.SS "DLLIMPORT void __export cfg_print (\fBcfg_t\fP * cfg, FILE * fp)".PPPrint the options and values to a file. .PPNote 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..PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIfp\fP File stream to print to, use stdout to print to the screen..RE.PP\fBSee also:\fP.RS 4\fBcfg_print_func_t\fP, \fBcfg_set_print_func\fP .RE.PP.PP\fBExamples: \fP.in +1c\fBsimple.c\fP..SS "DLLIMPORT void __export cfg_print_indent (\fBcfg_t\fP * cfg, FILE * fp, int indent)".PPPrint the options and values to a file. .PPSame as cfg_print, but with the indentation level specified. .PP\fBSee also:\fP.RS 4\fBcfg_print\fP .RE.PP.SS "DLLIMPORT \fBcfg_errfunc_t\fP __export cfg_set_error_function (\fBcfg_t\fP * cfg, \fBcfg_errfunc_t\fP errfunc)".PPInstall a user-defined error reporting function. .PP\fBReturns:\fP.RS 4The old error reporting function is returned. .RE.PP.SS "DLLIMPORT \fBcfg_print_func_t\fP __export cfg_set_print_func (\fBcfg_t\fP * cfg, const char * name, \fBcfg_print_func_t\fP pf)".PPSet a print callback function for an option given its name. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIpf\fP The print callback function..RE.PP\fBSee also:\fP.RS 4\fBcfg_print_func_t\fP .RE.PP.SS "DLLIMPORT \fBcfg_validate_callback_t\fP __export cfg_set_validate_func (\fBcfg_t\fP * cfg, const char * name, \fBcfg_validate_callback_t\fP vf)".PPRegister a validating callback function for an option. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvf\fP The validating callback function..RE.PP\fBSee also:\fP.RS 4\fBcfg_validate_callback_t\fP .RE.PP.PP\fBExamples: \fP.in +1c\fBftpconf.c\fP..SS "DLLIMPORT void __export cfg_setbool (\fBcfg_t\fP * cfg, const char * name, \fBcfg_bool_t\fP value)".PPSet the value of a boolean option given its name. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setfloat (\fBcfg_t\fP * cfg, const char * name, double value)".PPSet the value of a floating point option given its name. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setint (\fBcfg_t\fP * cfg, const char * name, long int value)".PPSet the value of an integer option given its name. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setlist (\fBcfg_t\fP * cfg, const char * name, unsigned int nvalues, ...)".PPSet values for a list option. .PPAll existing values are replaced with the new ones..PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fInvalues\fP Number of values to set. .br\fI...\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setnbool (\fBcfg_t\fP * cfg, const char * name, \fBcfg_bool_t\fP value, unsigned int index)".PPSet a value of a boolean option given its name and index. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP The value to set. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setnfloat (\fBcfg_t\fP * cfg, const char * name, double value, unsigned int index)".PPSet a value of a floating point option given its name and index. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP The value to set. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setnint (\fBcfg_t\fP * cfg, const char * name, long int value, unsigned int index)".PPSet a value of an integer option given its name and index. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP The value to set. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setnstr (\fBcfg_t\fP * cfg, const char * name, const char * value, unsigned int index)".PPSet a value of a boolean option given its name and index. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP The value to set. Memory for the string is allocated and the value is copied. Any privious string value is freed. .br\fIindex\fP 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. .RE.PP.SS "DLLIMPORT void __export cfg_setstr (\fBcfg_t\fP * cfg, const char * name, const char * value)".PPSet the value of a string option given its name. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .br\fIvalue\fP The value to set. Memory for the string is allocated and the value is copied. Any previous string value is freed. If the option is a list (the CFGF_LIST flag is set), only the first value (with index 0) is set. .RE.PP.PP\fBExamples: \fP.in +1c\fBsimple.c\fP..SS "DLLIMPORT unsigned int __export cfg_size (\fBcfg_t\fP * cfg, const char * name)".PPReturn the number of values this option has. .PPIf 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)..PPNote that there is no way to *not* specify a default value for integers, floats and booleans. Ie, they always have default values (since 0 or NULL is a valid integer/float/boolean value). Only strings and lists may have no default value..PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .br\fIname\fP The name of the option. .RE.PP.PP\fBExamples: \fP.in +1c\fBftpconf.c\fP, and \fBreread.c\fP..SS "DLLIMPORT char* __export cfg_tilde_expand (const char * filename)".PPDoes tilde expansion (~ -> $HOME) on the filename. .PP\fBReturns:\fP.RS 4The expanded filename is returned. If a ~user was not found, the original filename is returned. In any case, a dynamically allocated string is returned, which should be free()'d by the caller. .RE.PP.SS "DLLIMPORT const char* __export cfg_title (\fBcfg_t\fP * cfg)".PPReturn the title of a section. .PP\fBParameters:\fP.RS 4\fIcfg\fP The configuration file context. .RE.PP\fBReturns:\fP.RS 4Returns the title, or 0 if there is no title. This string should not be modified. .RE.PP.SH "Author".PP Generated automatically by Doxygen for confuse from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -