MEDIUM: acl: use the fetch syntax 'fetch(args),conv(),conv()' into the ACL keyword
If the acl keyword is a "fetch", the dedicated parsing function
"sample_parse_expr()" is used. Otherwise, the acl parsing function
"parse_acl_expr()" is extended to understand the syntax of a series
of converters placed after the "fetch" keyword.
Before this patch, each acl uses a "struct sample_fetch" and executes
it with the "<fetch>->process()" function. Now, the dedicated function
"sample_process()" is called.
These syntax are now avalaible:
acl bad req.hdr(host),lower -m str www
http-request redirect prefix /go-away if bad
acl bad hdr_beg(host),lower www
http-request redirect prefix /go-away if bad
diff --git a/src/sample.c b/src/sample.c
index 72412c9..ac0e52a 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -266,6 +266,23 @@
[SMP_CKP_FE_LOG_END] = "logs",
};
+/* This function returns the type of the data returned by the sample_expr.
+ * It assumes that the <expr> and all of its converters are properly
+ * initialized.
+ */
+inline
+int smp_expr_output_type(struct sample_expr *expr)
+{
+ struct sample_conv_expr *smp_expr;
+
+ if (!LIST_ISEMPTY(&expr->conv_exprs)) {
+ smp_expr = LIST_PREV(&expr->conv_exprs, struct sample_conv_expr *, list);
+ return smp_expr->conv->out_type;
+ }
+ return expr->fetch->out_type;
+}
+
+
/* fill the trash with a comma-delimited list of source names for the <use> bit
* field which must be composed of a non-null set of SMP_USE_* flags. The return
* value is the pointer to the string in the trash buffer.