]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] modularize the global "stats" keyword configuration parser
authorWilly Tarreau <w@1wt.eu>
Wed, 9 Jul 2008 18:12:41 +0000 (20:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 9 Jul 2008 18:12:41 +0000 (20:12 +0200)
The "stats" keyword already relied on an external parser, let's
make use of the new keyword registration mechanism.

include/proto/dumpstats.h
src/cfgparse.c
src/dumpstats.c

index 6cca84fd657504a8c7c5d3dde8acb7aeca11e979..ed2bf1e066a51eaa4d06230e1d8a4088cf53faa4 100644 (file)
@@ -3,7 +3,7 @@
   This file contains definitions of some primitives to dedicated to
   statistics output.
 
-  Copyright (C) 2000-2007 Willy Tarreau - w@1wt.eu
+  Copyright (C) 2000-2008 Willy Tarreau - w@1wt.eu
   
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -39,7 +39,6 @@
 #define STATS_TYPE_BE  1
 #define STATS_TYPE_SV  2
 
-int stats_parse_global(const char **args, char *err, int errlen);
 int stats_dump_raw(struct session *s, struct uri_auth *uri);
 int stats_dump_http(struct session *s, struct uri_auth *uri);
 int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri);
index b202923ed893b26e0d72ecf35a4eedbe3ff2b4b7..af29a47986f7c54968ac9edb9d76ab49da8998df 100644 (file)
@@ -295,13 +295,6 @@ int cfg_parse_global(const char *file, int linenum, char **args, int inv)
        else if (!strcmp(args[0], "quiet")) {
                global.mode |= MODE_QUIET;
        }
-       else if (!strcmp(args[0], "stats")) {
-               memcpy(trash, "error near 'stats'", 19);
-               if (stats_parse_global((const char **)args + 1, trash, sizeof(trash)) < 0) {
-                       Alert("parsing [%s:%d] : %s\n", file, linenum, trash);
-                       return -1;
-               }
-       }
        else if (!strcmp(args[0], "tune.maxpollevents")) {
                if (global.tune.maxpollevents != 0) {
                        Alert("parsing [%s:%d] : '%s' already specified. Continuing.\n", file, linenum, args[0]);
index 354d274551fc03735d074c06586427ab382f0b05..655cb4dfe2a42cc851a83863a5b7b288e452cb52 100644 (file)
@@ -23,6 +23,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+#include <common/cfgparse.h>
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/debug.h>
  * zero included. The trailing '\n' must not be written. The function must be
  * called with <args> pointing to the first word after "stats".
  */
-int stats_parse_global(const char **args, char *err, int errlen)
+static int stats_parse_global(char **args, int section_type, struct proxy *curpx,
+                             struct proxy *defpx, char *err, int errlen)
 {
+       args++;
        if (!strcmp(args[0], "socket")) {
                struct sockaddr_un su;
                int cur_arg;
@@ -1067,6 +1070,17 @@ int stats_dump_proxy(struct session *s, struct proxy *px, struct uri_auth *uri)
        }
 }
 
+static struct cfg_kw_list cfg_kws = {{ },{
+       { CFG_GLOBAL, "stats", stats_parse_global },
+       { 0, NULL, NULL },
+}};
+
+__attribute__((constructor))
+static void __dumpstats_module_init(void)
+{
+       cfg_register_keywords(&cfg_kws);
+}
+
 /*
  * Local variables:
  *  c-indent-level: 8