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.
This commit is contained in:
Thierry Fournier 2016-04-13 18:27:51 +02:00 committed by Willy Tarreau
parent 5c3ed34529
commit 3610c39c8c
4 changed files with 9 additions and 8 deletions

View 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;
};
/*

View 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);

View 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 },
}
};

View 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 },
}
};