MEDIUM: pattern: add indexation function.
Before this patch, the indexation function check the declared patttern
matching function and index the data according with this function. This
is not useful to add some indexation mode.
This commit adds dedicated indexation function. Each struct pattern is
associated with one indexation function. This function permit to index
data according with the type of pattern and with the type of match.
diff --git a/src/dumpstats.c b/src/dumpstats.c
index ba0a7a5..0eb5639 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -1920,7 +1920,6 @@
}
else if (strcmp(args[0], "add") == 0) {
if (strcmp(args[1], "map") == 0) {
- struct pattern_list *pat;
struct map_entry *ent;
struct sample_storage *smp;
@@ -1993,23 +1992,7 @@
continue;
}
- /* If the value can be indexed, get the first pattern. If
- * the return entry is not the indexed entry, new 'pattern' is
- * created by the function pattern_register(). If the 'pattern'
- * is NULL, new entry is created. This is ugly because the
- * following code interfers with the own code of the function
- * pattern_register().
- */
- if (appctx->ctx.map.desc->pat->match == pat_match_str ||
- appctx->ctx.map.desc->pat->match == pat_match_ip) {
- pat = LIST_NEXT(&appctx->ctx.map.desc->pat->patterns, struct pattern_list *, list);
- if (&pat->list == &appctx->ctx.map.desc->pat->patterns)
- pat = NULL;
- }
- else
- pat = NULL;
-
- if (!pattern_register(appctx->ctx.map.desc->pat, args[3], smp, &pat, 0, NULL)) {
+ if (!pattern_register(appctx->ctx.map.desc->pat, args[3], smp, 0, NULL)) {
free(smp);
continue;
}