From ae52f06da388bf400e14c56f60f9a764a4cf1aae Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 26 Apr 2012 12:13:35 +0200 Subject: [PATCH] MINOR: acl: add a val_args field to keywords This will make it possible to delegate argument validating to functions shared with smp_fetch_*. --- include/types/acl.h | 1 + src/acl.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/types/acl.h b/include/types/acl.h index cff3ae2c7..00dfa0c6c 100644 --- a/include/types/acl.h +++ b/include/types/acl.h @@ -235,6 +235,7 @@ struct acl_keyword { int (*match)(struct sample *smp, struct acl_pattern *pattern); unsigned int requires; /* bit mask of all ACL_USE_* required to evaluate this keyword */ int arg_mask; /* mask describing up to 7 arg types */ + int (*val_args)(struct arg *arg_p, char **err_msg); /* argument validation function */ /* must be after the config params */ int use_cnt; }; diff --git a/src/acl.c b/src/acl.c index 8f76286ed..433a2667e 100644 --- a/src/acl.c +++ b/src/acl.c @@ -1271,6 +1271,9 @@ struct acl_expr *parse_acl_expr(const char **args) NULL, NULL, NULL); if (nbargs < 0) goto out_free_expr; + + if (aclkw->val_args && !aclkw->val_args(expr->args, NULL)) + goto out_free_expr; /* invalid keyword argument */ } else if (ARGM(aclkw->arg_mask) == 1) { int type = (aclkw->arg_mask >> 4) & 15;