MEDIUM: pattern: create pattern expression

This new structure contains the data needed for pattern matching. It's
the first step to the complete independance of the pattern matching.
diff --git a/include/proto/pattern.h b/include/proto/pattern.h
index 9898eb3..d085196 100644
--- a/include/proto/pattern.h
+++ b/include/proto/pattern.h
@@ -35,14 +35,14 @@
  * fails, with <err> message filled. It returns -2 in "out of memory"
  * error case.
  */
-int acl_register_pattern(struct acl_expr *expr, char *text, struct sample_storage *smp, struct acl_pattern **pattern, int patflags, char **err);
+int acl_register_pattern(struct pattern_expr *expr, char *text, struct sample_storage *smp, struct acl_pattern **pattern, int patflags, char **err);
 
 /* This function executes a pattern match on a sample. It applies pattern <expr>
  * to sample <smp>. If <sample> is not NULL, a pointer to an optional sample
  * associated to the matching patterned will be put there. The function returns
  * ACL_PAT_FAIL, ACL_PAT_MISS or ACL_PAT_PASS.
  */
-inline int acl_exec_match(struct acl_expr *expr, struct sample *smp, struct sample_storage **sample);
+inline int acl_exec_match(struct pattern_expr *expr, struct sample *smp, struct sample_storage **sample);
 
 /*
  *
@@ -128,9 +128,9 @@
  */
 int acl_match_reg(struct sample *smp, struct acl_pattern *pattern);
 
-int acl_read_patterns_from_file(struct acl_expr *expr, const char *filename, int patflags, char **err);
+int acl_read_patterns_from_file(struct pattern_expr *expr, const char *filename, int patflags, char **err);
 void free_pattern(struct acl_pattern *pat);
-void free_pattern_list(struct list *head);
-void free_pattern_tree(struct eb_root *root);
+void prune_pattern_expr(struct pattern_expr *expr);
+void init_pattern_expr(struct pattern_expr *expr);
 
 #endif
diff --git a/include/types/acl.h b/include/types/acl.h
index e479f9b..50a89f3 100644
--- a/include/types/acl.h
+++ b/include/types/acl.h
@@ -105,17 +105,13 @@
 /*
  * Description of an ACL expression.
  * The expression is part of a list. It contains pointers to the keyword, the
- * parse and match functions which default to the keyword's, the sample fetch
- * descriptor which also defaults to the keyword's, and a list or tree of
- * patterns to test against. The structure is organized so that the hot parts
- * are grouped together in order to optimize caching.
+ * sample fetch descriptor which defaults to the keyword's, and the associated
+ * pattern matching. The structure is organized so that the hot parts are
+ * grouped together in order to optimize caching.
  */
 struct acl_expr {
-	int (*parse)(const char **text, struct acl_pattern *pattern, struct sample_storage *smp, int *opaque, char **err);
-	int (*match)(struct sample *smp, struct acl_pattern *pattern);
 	struct sample_expr *smp;      /* the sample expression we depend on */
-	struct list patterns;         /* list of acl_patterns */
-	struct eb_root pattern_tree;  /* may be used for lookup in large datasets */
+	struct pattern_expr pat;      /* the pattern matching expression */
 	struct list list;             /* chaining */
 	const char *kw;               /* points to the ACL kw's name or fetch's name (must not free) */
 };
diff --git a/include/types/pattern.h b/include/types/pattern.h
index 68ed462..2023b1a 100644
--- a/include/types/pattern.h
+++ b/include/types/pattern.h
@@ -121,6 +121,18 @@
 
 };
 
+/* Description of a pattern expression.
+ * It contains pointers to the parse and match functions, and a list or tree of
+ * patterns to test against. The structure is organized so that the hot parts
+ * are grouped together in order to optimize caching.
+ */
+struct pattern_expr {
+	int (*parse)(const char **text, struct acl_pattern *pattern, struct sample_storage *smp, int *opaque, char **err);
+	int (*match)(struct sample *smp, struct acl_pattern *pattern);
+	struct list patterns;         /* list of acl_patterns */
+	struct eb_root pattern_tree;  /* may be used for lookup in large datasets */
+};
+
 extern char *acl_match_names[ACL_MATCH_NUM];
 extern int (*acl_parse_fcts[ACL_MATCH_NUM])(const char **, struct acl_pattern *, struct sample_storage *, int *, char **);
 extern int (*acl_match_fcts[ACL_MATCH_NUM])(struct sample *, struct acl_pattern *);