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.
This commit is contained in:
Willy Tarreau 2012-04-23 21:35:11 +02:00
parent 21e5b0e3cb
commit b4a88f0672
4 changed files with 9 additions and 15 deletions

View 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

View 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

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

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