mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-09 16:47:18 +02:00
[MINOR] cfgparse: add support for warnings in external functions
Some parsers will need to report warnings in some cases. Let's use positive values for that.
This commit is contained in:
parent
10522fd113
commit
39f23b6c7e
@ -36,7 +36,8 @@
|
|||||||
struct cfg_keyword {
|
struct cfg_keyword {
|
||||||
int section; /* section type for this keyword */
|
int section; /* section type for this keyword */
|
||||||
const char *kw; /* the keyword itself */
|
const char *kw; /* the keyword itself */
|
||||||
int (*parse)(char **args, /* command line and arguments */
|
int (*parse)( /* 0=OK, <0=Alert, >0=Warning */
|
||||||
|
char **args, /* command line and arguments */
|
||||||
int section_type, /* current section CFG_{GLOBAL|LISTEN} */
|
int section_type, /* current section CFG_{GLOBAL|LISTEN} */
|
||||||
struct proxy *curpx, /* current proxy (NULL in GLOBAL) */
|
struct proxy *curpx, /* current proxy (NULL in GLOBAL) */
|
||||||
struct proxy *defpx, /* default proxy (NULL in GLOBAL) */
|
struct proxy *defpx, /* default proxy (NULL in GLOBAL) */
|
||||||
|
@ -501,6 +501,7 @@ int cfg_parse_global(const char *file, int linenum, char **args, int inv)
|
|||||||
else {
|
else {
|
||||||
struct cfg_kw_list *kwl;
|
struct cfg_kw_list *kwl;
|
||||||
int index;
|
int index;
|
||||||
|
int rc;
|
||||||
|
|
||||||
list_for_each_entry(kwl, &cfg_keywords.list, list) {
|
list_for_each_entry(kwl, &cfg_keywords.list, list) {
|
||||||
for (index = 0; kwl->kw[index].kw != NULL; index++) {
|
for (index = 0; kwl->kw[index].kw != NULL; index++) {
|
||||||
@ -510,10 +511,15 @@ int cfg_parse_global(const char *file, int linenum, char **args, int inv)
|
|||||||
/* prepare error message just in case */
|
/* prepare error message just in case */
|
||||||
snprintf(trash, sizeof(trash),
|
snprintf(trash, sizeof(trash),
|
||||||
"error near '%s' in '%s' section", args[0], "global");
|
"error near '%s' in '%s' section", args[0], "global");
|
||||||
if (kwl->kw[index].parse(args, CFG_GLOBAL, NULL, NULL, trash, sizeof(trash)) < 0) {
|
rc = kwl->kw[index].parse(args, CFG_GLOBAL, NULL, NULL, trash, sizeof(trash));
|
||||||
|
if (rc < 0) {
|
||||||
Alert("parsing [%s:%d] : %s\n", file, linenum, trash);
|
Alert("parsing [%s:%d] : %s\n", file, linenum, trash);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else if (rc > 0) {
|
||||||
|
Warning("parsing [%s:%d] : %s\n", file, linenum, trash);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2680,10 +2686,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int inv)
|
|||||||
/* prepare error message just in case */
|
/* prepare error message just in case */
|
||||||
snprintf(trash, sizeof(trash),
|
snprintf(trash, sizeof(trash),
|
||||||
"error near '%s' in %s section", args[0], cursection);
|
"error near '%s' in %s section", args[0], cursection);
|
||||||
if (kwl->kw[index].parse(args, CFG_LISTEN, curproxy, &defproxy, trash, sizeof(trash)) < 0) {
|
rc = kwl->kw[index].parse(args, CFG_LISTEN, curproxy, &defproxy, trash, sizeof(trash));
|
||||||
|
if (rc < 0) {
|
||||||
Alert("parsing [%s:%d] : %s\n", file, linenum, trash);
|
Alert("parsing [%s:%d] : %s\n", file, linenum, trash);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
else if (rc > 0) {
|
||||||
|
Warning("parsing [%s:%d] : %s\n", file, linenum, trash);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user