From: Thierry Fournier Date: Wed, 13 Apr 2016 16:27:51 +0000 (+0200) Subject: MINOR: filters: add opaque data X-Git-Tag: v1.7-dev3~19 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3610c39c8c67797fbd7cb589c694cc70386627db;p=thirdparty%2Fhaproxy.git MINOR: filters: add opaque data 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. --- diff --git a/include/types/filters.h b/include/types/filters.h index 0e4d99ab52..34818cf05c 100644 --- a/include/types/filters.h +++ b/include/types/filters.h @@ -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; }; /* diff --git a/src/filters.c b/src/filters.c index cceca50cd2..e96af31a71 100644 --- a/src/filters.c +++ b/src/filters.c @@ -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); diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index ee8f13bf15..fb431c13ca 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -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 }, } }; diff --git a/src/flt_trace.c b/src/flt_trace.c index a45f4a089f..8b47651ed9 100644 --- a/src/flt_trace.c +++ b/src/flt_trace.c @@ -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 }, } };