]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: filters: add opaque data
authorThierry Fournier <tfournier@arpalert.org>
Wed, 13 Apr 2016 16:27:51 +0000 (18:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 27 Apr 2016 08:48:15 +0000 (10:48 +0200)
Add opaque data between the filter keyword registrering and the parsing
function. This opaque data allow to use the same parser with differents
registered keywords. The opaque data is used for giving data which mainly
makes difference between the two keywords.

It will be used with Lua keywords registering.

include/types/filters.h
src/filters.c
src/flt_http_comp.c
src/flt_trace.c

index 0e4d99ab52751fc375eaa63e29f57ff05c7d6e09..34818cf05ca8a8ff4402d63360f3796f1243084a 100644 (file)
@@ -38,7 +38,8 @@ struct filter;
 struct flt_kw {
        const char *kw;
        int (*parse)(char **args, int *cur_arg, struct proxy *px,
-                    struct flt_conf *fconf, char **err);
+                    struct flt_conf *fconf, char **err, void *private);
+       void *private;
 };
 
 /*
index cceca50cd2dcfd2db10b5918efbefb9a543f5bdd..e96af31a7195393aa3666f9b79e3c82d8eff8eb8 100644 (file)
@@ -206,7 +206,7 @@ parse_filter(char **args, int section_type, struct proxy *curpx,
                                          file, line, args[0], args[cur_arg]);
                                goto error;
                        }
-                       if (kw->parse(args, &cur_arg, curpx, fconf, err) != 0) {
+                       if (kw->parse(args, &cur_arg, curpx, fconf, err, kw->private) != 0) {
                                if (err && *err)
                                        memprintf(err, "'%s' : '%s'",
                                                  args[0], *err);
index ee8f13bf15a8c0aab558fa1694c58c6fbe260f8a..fb431c13cad6d7ae3f2276613aa8a60e35ad3d42 100644 (file)
@@ -830,7 +830,7 @@ parse_compression_options(char **args, int section, struct proxy *proxy,
 
 static int
 parse_http_comp_flt(char **args, int *cur_arg, struct proxy *px,
-                        struct flt_conf *fconf, char **err)
+                    struct flt_conf *fconf, char **err, void *private)
 {
        struct flt_conf *fc, *back;
 
@@ -939,8 +939,8 @@ static struct cfg_kw_list cfg_kws = {ILH, {
 
 /* Declare the filter parser for "compression" keyword */
 static struct flt_kw_list filter_kws = { "COMP", { }, {
-               { "compression", parse_http_comp_flt },
-               { NULL, NULL },
+               { "compression", parse_http_comp_flt, NULL },
+               { NULL, NULL, NULL },
        }
 };
 
index a45f4a089fdeb6b3ea61638917ee4a34de2cc1cc..8b47651ed92e93024507a4e488c66dc6dd95fc2d 100644 (file)
@@ -414,7 +414,7 @@ struct flt_ops trace_ops = {
 /* Return -1 on error, else 0 */
 static int
 parse_trace_flt(char **args, int *cur_arg, struct proxy *px,
-               struct flt_conf *fconf, char **err)
+                struct flt_conf *fconf, char **err, void *private)
 {
        struct trace_config *conf;
        int                  pos = *cur_arg;
@@ -467,8 +467,8 @@ parse_trace_flt(char **args, int *cur_arg, struct proxy *px,
 
 /* Declare the filter parser for "trace" keyword */
 static struct flt_kw_list flt_kws = { "TRACE", { }, {
-               { "trace", parse_trace_flt },
-               { NULL, NULL },
+               { "trace", parse_trace_flt, NULL },
+               { NULL, NULL, NULL },
        }
 };