version 1.1.1.1, 2017/01/24 14:48:56
|
version 1.1.1.2, 2021/03/17 00:49:17
|
Line 7
|
Line 7
|
|
|
#include "check_confuse.h" |
#include "check_confuse.h" |
|
|
cfg_opt_t opts[] = | cfg_opt_t opts[] = { |
{ | |
CFG_STR("parameter", NULL, CFGF_NONE), |
CFG_STR("parameter", NULL, CFGF_NONE), |
CFG_END() |
CFG_END() |
}; |
}; |
|
|
int | int main(void) |
main(void) | |
{ |
{ |
|
FILE *fp; |
|
char *param; |
cfg_t *cfg = cfg_init(opts, CFGF_NONE); |
cfg_t *cfg = cfg_init(opts, CFGF_NONE); |
|
|
fail_unless(cfg); |
fail_unless(cfg); |
|
|
/* set a string parameter to a string including a quote character |
/* set a string parameter to a string including a quote character |
Line 25 main(void)
|
Line 26 main(void)
|
|
|
/* print the config to a temporary file |
/* print the config to a temporary file |
*/ |
*/ |
FILE *fp = tmpfile(); | fp = tmpfile(); |
fail_unless(fp); |
fail_unless(fp); |
cfg_print(cfg, fp); |
cfg_print(cfg, fp); |
cfg_free(cfg); |
cfg_free(cfg); |
Line 38 main(void)
|
Line 39 main(void)
|
fail_unless(cfg_parse_fp(cfg, fp) == CFG_SUCCESS); |
fail_unless(cfg_parse_fp(cfg, fp) == CFG_SUCCESS); |
fail_unless(fclose(fp) == 0); |
fail_unless(fclose(fp) == 0); |
|
|
char *param = cfg_getstr(cfg, "parameter"); | param = cfg_getstr(cfg, "parameter"); |
fail_unless(param); |
fail_unless(param); |
|
|
fail_unless(strcmp(param, "text \" with quotes and \\") == 0); |
fail_unless(strcmp(param, "text \" with quotes and \\") == 0); |
Line 46 main(void)
|
Line 47 main(void)
|
|
|
return 0; |
return 0; |
} |
} |
|
|