From 94580c9f52d0d68159aaf98fed5d90be97114e44 Mon Sep 17 00:00:00 2001 From: Thierry FOURNIER Date: Tue, 11 Feb 2014 14:36:45 +0100 Subject: [PATCH] MINOR: dumpstat/conf: display all the configuration lines that using pattern reference --- include/proto/pattern.h | 2 +- src/acl.c | 6 +----- src/map.c | 6 +----- src/pattern.c | 20 +++++++++++++++++--- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/include/proto/pattern.h b/include/proto/pattern.h index 4b5afe120..57294d8ab 100644 --- a/include/proto/pattern.h +++ b/include/proto/pattern.h @@ -186,7 +186,7 @@ int pat_ref_load(struct pat_ref *ref, struct pattern_expr *expr, int patflags, i */ void pattern_init_head(struct pattern_head *head); void pattern_prune(struct pattern_head *head); -int pattern_read_from_file(struct pattern_head *head, unsigned int refflags, const char *filename, int patflags, int load_smp, char **err, const char *display, const char *file, int line); +int pattern_read_from_file(struct pattern_head *head, unsigned int refflags, const char *filename, int patflags, int load_smp, char **err, const char *file, int line); /* * pattern_expr manipulation. diff --git a/src/acl.c b/src/acl.c index 2a7435dab..ca2a5fcf2 100644 --- a/src/acl.c +++ b/src/acl.c @@ -449,11 +449,7 @@ struct acl_expr *parse_acl_expr(const char **args, char **err, struct arg_list * goto out_free_expr; } - /* Create displayed reference */ - snprintf(trash.str, trash.size, "acl(s) loaded from file '%s'", args[1]); - trash.str[trash.size - 1] = '\0'; - - if (!pattern_read_from_file(&expr->pat, PAT_REF_ACL, args[1], patflags | PAT_F_FROM_FILE, load_as_map, err, trash.str, file, line)) + if (!pattern_read_from_file(&expr->pat, PAT_REF_ACL, args[1], patflags | PAT_F_FROM_FILE, load_as_map, err, file, line)) goto out_free_expr; is_loaded = 1; args++; diff --git a/src/map.c b/src/map.c index 16f86bb21..597907de9 100644 --- a/src/map.c +++ b/src/map.c @@ -152,13 +152,9 @@ static int sample_load_map(struct arg *arg, struct sample_conv *conv, return 0; } - /* Build displayed message. */ - snprintf(trash.str, trash.size, "map(s) loaded from file '%s'", arg[0].data.str.str); - trash.str[trash.size - 1] = '\0'; - /* Load map. */ if (!pattern_read_from_file(&desc->pat, PAT_REF_MAP, arg[0].data.str.str, 0, - 1, err, trash.str, file, line)) + 1, err, file, line)) return 0; /* The second argument is the default value */ diff --git a/src/pattern.c b/src/pattern.c index da79c9fd0..dad2472de 100644 --- a/src/pattern.c +++ b/src/pattern.c @@ -1972,8 +1972,7 @@ int pat_ref_read_from_file(struct pat_ref *ref, const char *filename, char **err int pattern_read_from_file(struct pattern_head *head, unsigned int refflags, const char *filename, int patflags, int load_smp, - char **err, const char *display, const char *file, - int line) + char **err, const char *file, int line) { struct pat_ref *ref; struct pattern_expr *expr; @@ -1984,7 +1983,11 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags, /* If the reference doesn't exists, create it and load associated file. */ if (!ref) { - ref = pat_ref_new(filename, display, refflags); + chunk_printf(&trash, + "pattern loaded from file '%s' used by %s at file '%s' line %d", + filename, refflags & PAT_REF_MAP ? "map" : "acl", file, line); + + ref = pat_ref_new(filename, trash.str, refflags); if (!ref) { memprintf(err, "out of memory"); return 0; @@ -2026,6 +2029,17 @@ int pattern_read_from_file(struct pattern_head *head, unsigned int refflags, } } + /* Extends display */ + chunk_printf(&trash, "%s", ref->display); + chunk_appendf(&trash, ", by %s at file '%s' line %d", + refflags & PAT_REF_MAP ? "map" : "acl", file, line); + free(ref->display); + ref->display = strdup(trash.str); + if (!ref->display) { + memprintf(err, "out of memory"); + return 0; + } + /* Merge flags. */ ref->flags |= refflags; }