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/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 *);