[MEDIUM] modularize the global "stats" keyword configuration parser

The "stats" keyword already relied on an external parser, let's
make use of the new keyword registration mechanism.
diff --git a/include/proto/dumpstats.h b/include/proto/dumpstats.h
index 6cca84f..ed2bf1e 100644
--- a/include/proto/dumpstats.h
+++ b/include/proto/dumpstats.h
@@ -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);
diff --git a/src/cfgparse.c b/src/cfgparse.c
index b202923..af29a47 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -295,13 +295,6 @@
 	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]);
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 354d274..655cb4d 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -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>
@@ -55,8 +56,10 @@
  * 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 @@
 	}
 }
 
+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