]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: acl: add a val_args field to keywords
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Apr 2012 10:13:35 +0000 (12:13 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 18:57:19 +0000 (20:57 +0200)
This will make it possible to delegate argument validating to functions
shared with smp_fetch_*.

include/types/acl.h
src/acl.c

index cff3ae2c7a8c427a3bf5c79a5408a045c6baa026..00dfa0c6cc971cd68092f1ed10efcca9df69a7e9 100644 (file)
@@ -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;
 };
index 8f76286ed09b3667ad4d9f45b1203decd5a812d6..433a2667e972771f39b1d7a5411c32ecc0b96bc8 100644 (file)
--- 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;