]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: pattern: replace struct pattern with struct sample
authorWilly Tarreau <w@1wt.eu>
Mon, 23 Apr 2012 19:35:11 +0000 (21:35 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 18:57:15 +0000 (20:57 +0200)
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
include/types/pattern.h
src/pattern.c
src/stick_table.c

index 8a896ff55bb866ebcaad30f37e887570ae06aada..5a9f9444aa085b21b6b86539d11b310ea45226e5 100644 (file)
@@ -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
index c710b207c28c01f31335663059b233728acd4174..1ac1cc368ccce480df03b2fd8fa61ef73a2a3bda 100644 (file)
@@ -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
index 4665be3d8fc24bb3259e0a29467aeb4015c2799b..10e136560a1ca86522870659bfbc97e37a9166d9 100644 (file)
@@ -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 @@ out_error:
  *  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;
index 433d7d3ec221cb9efd1131e0c9a58cd58ee2ea08..6574f0e55e0f906dd45b1be894780a92aaa1dbd3 100644 (file)
@@ -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)