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.
diff --git a/include/proto/pattern.h b/include/proto/pattern.h
index 8a896ff..5a9f944 100644
--- a/include/proto/pattern.h
+++ b/include/proto/pattern.h
@@ -26,9 +26,9 @@
#include <types/stick_table.h>
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 c710b20..1ac1cc3 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -70,12 +70,6 @@
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 4665be3..10e1365 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -18,8 +18,8 @@
#include <proto/buffers.h>
#include <common/standard.h>
-/* static structure used on pattern_process if <p> is NULL */
-static struct pattern temp_pattern;
+/* static sample used in pattern_process() when <p> is NULL */
+static struct sample temp_smp;
/* trash chunk used for pattern conversions */
static struct chunk trash_chunk;
@@ -467,13 +467,13 @@
* If <p> is not null, function returns results in structure pointed by <p>.
* If <p> 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 433d7d3..6574f0e 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -593,7 +593,7 @@
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)