mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 14:51:27 +02:00
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:
parent
21e5b0e3cb
commit
b4a88f0672
@ -26,9 +26,9 @@
|
|||||||
#include <types/stick_table.h>
|
#include <types/stick_table.h>
|
||||||
|
|
||||||
struct pattern_expr *pattern_parse_expr(char **str, int *idx, char *err, int err_size);
|
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,
|
struct sample *pattern_process(struct proxy *px, struct session *l4,
|
||||||
void *l7, int dir, struct pattern_expr *expr,
|
void *l7, int dir, struct pattern_expr *expr,
|
||||||
struct pattern *p);
|
struct sample *p);
|
||||||
void pattern_register_fetches(struct pattern_fetch_kw_list *psl);
|
void pattern_register_fetches(struct pattern_fetch_kw_list *psl);
|
||||||
void pattern_register_convs(struct pattern_conv_kw_list *psl);
|
void pattern_register_convs(struct pattern_conv_kw_list *psl);
|
||||||
#endif
|
#endif
|
||||||
|
@ -70,12 +70,6 @@ union pattern_data {
|
|||||||
struct chunk str; /* used for char strings or buffers */
|
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
|
/* 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
|
* store information needed across multiple calls (eg: restart point for a
|
||||||
* next occurrence). By definition it may store up to 8 pointers, or any
|
* next occurrence). By definition it may store up to 8 pointers, or any
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
#include <proto/buffers.h>
|
#include <proto/buffers.h>
|
||||||
#include <common/standard.h>
|
#include <common/standard.h>
|
||||||
|
|
||||||
/* static structure used on pattern_process if <p> is NULL */
|
/* static sample used in pattern_process() when <p> is NULL */
|
||||||
static struct pattern temp_pattern;
|
static struct sample temp_smp;
|
||||||
|
|
||||||
/* trash chunk used for pattern conversions */
|
/* trash chunk used for pattern conversions */
|
||||||
static struct chunk trash_chunk;
|
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 not null, function returns results in structure pointed by <p>.
|
||||||
* If <p> is null, functions returns a pointer on a static pattern structure.
|
* 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 sample *pattern_process(struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
struct pattern_expr *expr, struct pattern *p)
|
struct pattern_expr *expr, struct sample *p)
|
||||||
{
|
{
|
||||||
struct pattern_conv_expr *conv_expr;
|
struct pattern_conv_expr *conv_expr;
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
p = &temp_pattern;
|
p = &temp_smp;
|
||||||
|
|
||||||
if (!expr->fetch->process(px, l4, l7, dir, expr->arg_p, &p->data))
|
if (!expr->fetch->process(px, l4, l7, dir, expr->arg_p, &p->data))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -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 stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, struct session *l4, void *l7, int dir,
|
||||||
struct pattern_expr *expr)
|
struct pattern_expr *expr)
|
||||||
{
|
{
|
||||||
struct pattern *ptrn;
|
struct sample *ptrn;
|
||||||
|
|
||||||
ptrn = pattern_process(px, l4, l7, dir, expr, NULL);
|
ptrn = pattern_process(px, l4, l7, dir, expr, NULL);
|
||||||
if (!ptrn)
|
if (!ptrn)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user