From b4a88f067228cdaddfb7eb96a935a9117672911d Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 23 Apr 2012 21:35:11 +0200 Subject: [PATCH] MINOR: pattern: replace struct pattern with struct sample This change is pretty minor. Struct pattern is only used for pattern_process() now so changing it to use the common type is quite obvious. It's worth noting that the last argument of pattern_process() is never used so the function is self-sufficient. Note that pattern_process() does not initialize the pattern at all before calling fetch->process(), and that minimal initialization will be required when we later change the argument for the sample. --- include/proto/pattern.h | 6 +++--- include/types/pattern.h | 6 ------ src/pattern.c | 10 +++++----- src/stick_table.c | 2 +- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/include/proto/pattern.h b/include/proto/pattern.h index 8a896ff55..5a9f9444a 100644 --- a/include/proto/pattern.h +++ b/include/proto/pattern.h @@ -26,9 +26,9 @@ #include struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err_size); -struct pattern *pattern_process(struct proxy *px, struct session *l4, - void *l7, int dir, struct pattern_expr *expr, - struct pattern *p); +struct sample *pattern_process(struct proxy *px, struct session *l4, + void *l7, int dir, struct pattern_expr *expr, + struct sample *p); void pattern_register_fetches(struct pattern_fetch_kw_list *psl); void pattern_register_convs(struct pattern_conv_kw_list *psl); #endif diff --git a/include/types/pattern.h b/include/types/pattern.h index c710b207c..1ac1cc368 100644 --- a/include/types/pattern.h +++ b/include/types/pattern.h @@ -70,12 +70,6 @@ union pattern_data { struct chunk str; /* used for char strings or buffers */ }; -/* pattern result */ -struct pattern { - int type; /* current type of data */ - union pattern_data data; /* data */ -}; - /* a sample context might be used by any sample fetch function in order to * store information needed across multiple calls (eg: restart point for a * next occurrence). By definition it may store up to 8 pointers, or any diff --git a/src/pattern.c b/src/pattern.c index 4665be3d8..10e136560 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -18,8 +18,8 @@ #include #include -/* static structure used on pattern_process if

is NULL */ -static struct pattern temp_pattern; +/* static sample used in pattern_process() when

is NULL */ +static struct sample temp_smp; /* trash chunk used for pattern conversions */ static struct chunk trash_chunk; @@ -467,13 +467,13 @@ out_error: * If

is not null, function returns results in structure pointed by

. * If

is null, functions returns a pointer on a static pattern structure. */ -struct pattern *pattern_process(struct proxy *px, struct session *l4, void *l7, int dir, - struct pattern_expr *expr, struct pattern *p) +struct sample *pattern_process(struct proxy *px, struct session *l4, void *l7, int dir, + struct pattern_expr *expr, struct sample *p) { struct pattern_conv_expr *conv_expr; if (p == NULL) - p = &temp_pattern; + p = &temp_smp; if (!expr->fetch->process(px, l4, l7, dir, expr->arg_p, &p->data)) return NULL; diff --git a/src/stick_table.c b/src/stick_table.c index 433d7d3ec..6574f0e55 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -593,7 +593,7 @@ static pattern_to_key_fct pattern_to_key[SMP_TYPES][STKTABLE_TYPES] = { struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, struct session *l4, void *l7, int dir, struct pattern_expr *expr) { - struct pattern *ptrn; + struct sample *ptrn; ptrn = pattern_process(px, l4, l7, dir, expr, NULL); if (!ptrn)