]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: dumpstat/conf: display all the configuration lines that using pattern reference
authorThierry FOURNIER <tfournier@exceliance.fr>
Tue, 11 Feb 2014 13:36:45 +0000 (14:36 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 17 Mar 2014 17:06:08 +0000 (18:06 +0100)
include/proto/pattern.h
src/acl.c
src/map.c
src/pattern.c

index 4b5afe1207dcb2f1a1079b800044cd7eb04beae2..57294d8abedbb092e0a1c8019f80d559118f650d 100644 (file)
@@ -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.
index 2a7435dab801a21e60ee505775d089e4bcebe932..ca2a5fcf2af6b4ed4d91ff93d545a510bd468102 100644 (file)
--- 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++;
index 16f86bb21c30a3202d98972bf0b3d2fd44e3577d..597907de94efc48002bc4f4c17fa98a61d7c869b 100644 (file)
--- 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 */
index da79c9fd00d43c81da67ef7682dac75468d07f09..dad2472de1d7036cf715511926afe2202d1a64ec 100644 (file)
@@ -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;
        }