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/include/types/acl.h b/include/types/acl.h
index 564c4bb..cff3ae2 100644
--- a/include/types/acl.h
+++ b/include/types/acl.h
@@ -71,14 +71,6 @@
 	ACL_COND_UNLESS,	/* negative condition (after 'unless') */
 };
 
-/* ACLs can be evaluated on requests and on responses, and on partial or complete data */
-enum {
-	ACL_DIR_REQ = 0,        /* ACL evaluated on request */
-	ACL_DIR_RTR = (1 << 0), /* ACL evaluated on response */
-	ACL_DIR_MASK = (ACL_DIR_REQ | ACL_DIR_RTR),
-	ACL_PARTIAL = (1 << 1), /* partial data, return MISS if data are missing */
-};
-
 /* possible flags for expressions or patterns */
 enum {
 	ACL_PAT_F_IGNORE_CASE = 1 << 0,       /* ignore case */
@@ -238,7 +230,7 @@
 struct acl_keyword {
 	const char *kw;
 	int (*parse)(const char **text, struct acl_pattern *pattern, int *opaque);
-	int (*fetch)(struct proxy *px, struct session *l4, void *l7, int dir,
+	int (*fetch)(struct proxy *px, struct session *l4, void *l7, unsigned int opt,
 	             const struct arg *args, struct sample *smp);
 	int (*match)(struct sample *smp, struct acl_pattern *pattern);
 	unsigned int requires;   /* bit mask of all ACL_USE_* required to evaluate this keyword */
diff --git a/include/types/pattern.h b/include/types/pattern.h
index d4d3838..3ee18cb 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -41,6 +41,26 @@
 	SMP_TYPES        /* number of types, must always be last */
 };
 
+/* Sample fetch capabilities are used to declare keywords. Right now only
+ * the supportd fetch directions are specified.
+ */
+enum {
+	SMP_CAP_REQ = 1 << 0, /* fetch supported on request */
+	SMP_CAP_RES = 1 << 1, /* fetch supported on response */
+};
+
+/* Sample fetch options are passed to sample fetch functions to add precision
+ * about what is desired :
+ *   - fetch direction (req/resp)
+ *   - intermediary / final fetch
+ */
+enum {
+	SMP_OPT_DIR_REQ = 0,    /* direction = request */
+	SMP_OPT_DIR_RES = 1,    /* direction = response */
+	SMP_OPT_DIR     = (SMP_OPT_DIR_REQ|SMP_OPT_DIR_RES), /* mask to get direction */
+	SMP_OPT_FINAL   = 2,    /* final fetch, contents won't change anymore */
+};
+
 /* Flags used to describe fetched samples. MAY_CHANGE indicates that the result
  * of the fetch might still evolve, for instance because of more data expected,
  * even if the fetch has failed. VOL_* indicates how long a result may be cached.
@@ -56,11 +76,6 @@
 	SMP_F_VOLATILE   = (1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6), /* any volatility condition */
 };
 
-/* pattern fetch direction */
-#define PATTERN_FETCH_REQ	1
-#define PATTERN_FETCH_RTR	2
-
-
 /* 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
@@ -115,13 +130,14 @@
 	int (*process)(struct proxy *px,
 	               struct session *l4,
 	               void *l7,
-	               int dir, const struct arg *arg_p,
+		       unsigned int opt,          /* fetch options (SMP_OPT_*) */
+		       const struct arg *arg_p,
 	               struct sample *smp);       /* fetch processing function */
 	unsigned int arg_mask;                    /* arguments (ARG*()) */
 	int (*val_args)(struct arg *arg_p,
 			char **err_msg);          /* argument validation function */
 	unsigned long out_type;                   /* output pattern type */
-	int dir;                                  /* usable directions */
+	unsigned int cap;                         /* fetch capabilities (SMP_CAP_*) */
 };
 
 /* pattern expression */