MEDIUM: acl/pattern: use the same direction scheme
Patterns were using a bitmask to indicate if request or response was desired
in fetch functions and keywords. ACLs were using a bitmask in fetch keywords
and a single bit in fetch functions. ACLs were also using an ACL_PARTIAL bit
in fetch functions indicating that a non-final fetch was performed, which was
an abuse of the existing direction flag.
The change now consists in using :
- a capabilities field for fetch keywords => SMP_CAP_REQ/RES to indicate
if a keyword supports requests, responses, both, etc...
- an option field for fetch functions to indicate what the caller expects
(request/response, final/non-final)
The ACL_PARTIAL bit was reversed to get SMP_OPT_FINAL as it's more explicit
to know we're working on a final buffer than on a non-final one.
ACL_DIR_* were removed, as well as PATTERN_FETCH_*. L4 fetches were improved
to support being called on responses too since they're still available.
The <dir> field of all fetch functions was changed to <opt> which is now
unsigned.
The patch is large but mostly made of cosmetic changes to accomodate this, as
almost no logic change happened.
diff --git a/src/pattern.c b/src/pattern.c
index 9787ecc..f6afb97 100644
--- a/src/pattern.c
+++ b/src/pattern.c
@@ -463,7 +463,7 @@
/*
* Process a fetch + format conversion of defined by the pattern expression <expr>
- * on request or response considering the <dir> parameter.
+ * on request or response considering the <opt> parameter.
* Returns a pointer on a typed pattern structure containing the result or NULL if
* pattern is not found or when format conversion failed.
* If <p> is not null, function returns results in structure pointed by <p>.
@@ -473,7 +473,8 @@
* conversion functions must do so too. However the cast functions do not need
* to since they're made to cast mutiple types according to what is required.
*/
-struct sample *pattern_process(struct proxy *px, struct session *l4, void *l7, int dir,
+struct sample *pattern_process(struct proxy *px, struct session *l4, void *l7,
+ unsigned int opt,
struct pattern_expr *expr, struct sample *p)
{
struct pattern_conv_expr *conv_expr;
@@ -482,7 +483,7 @@
p = &temp_smp;
p->flags = 0;
- if (!expr->fetch->process(px, l4, l7, dir, expr->arg_p, p))
+ if (!expr->fetch->process(px, l4, l7, opt, expr->arg_p, p))
return NULL;
list_for_each_entry(conv_expr, &expr->conv_exprs, list) {