REORG: include: move stats.h to haproxy/stats{,-t}.h

Just some minor reordering, and the usual cleanup of call places for
those which didn't need it. We don't include the whole tools.h into
stats-t anymore but just tools-t.h.
diff --git a/contrib/prometheus-exporter/service-prometheus.c b/contrib/prometheus-exporter/service-prometheus.c
index f0b1adf..d64d8ae 100644
--- a/contrib/prometheus-exporter/service-prometheus.c
+++ b/contrib/prometheus-exporter/service-prometheus.c
@@ -33,7 +33,7 @@
 #include <haproxy/sample.h>
 #include <proto/server.h>
 #include <proto/ssl_sock.h>
-#include <proto/stats.h>
+#include <haproxy/stats.h>
 #include <proto/stream.h>
 #include <proto/stream_interface.h>
 #include <haproxy/task.h>
diff --git a/include/types/stats.h b/include/haproxy/stats-t.h
similarity index 97%
rename from include/types/stats.h
rename to include/haproxy/stats-t.h
index bc25a5c..6573008 100644
--- a/include/types/stats.h
+++ b/include/haproxy/stats-t.h
@@ -1,7 +1,9 @@
 /*
- * include/types/stats.h
+ * include/haproxy/stats-t.h
  * This file provides structures and types for stats.
  *
+ * Copyright (C) 2000-2020 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
  * License as published by the Free Software Foundation, version 2.1
@@ -17,8 +19,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef _TYPES_STATS_H
-#define _TYPES_STATS_H
+#ifndef _HAPROXY_STATS_T_H
+#define _HAPROXY_STATS_T_H
+
+#include <haproxy/api-t.h>
 
 /* Flags for applet.ctx.stats.flags */
 #define STAT_FMT_HTML   0x00000001      /* dump the stats in HTML format */
@@ -242,22 +246,6 @@
 	FS_MASK     = 0xFF000000,
 };
 
-/* Please consider updating stats_dump_fields_*(),
- * stats_dump_.*_info_fields() and stats_*_schema()
- * when modifying struct field or related enums.
- */
-struct field {
-	uint32_t type;
-	union {
-		int32_t     s32; /* FF_S32 */
-		uint32_t    u32; /* FF_U32 */
-		int64_t     s64; /* FF_S64 */
-		uint64_t    u64; /* FF_U64 */
-		double      flt; /* FF_FLT */
-		const char *str; /* FF_STR */
-	} u;
-};
-
 /* Show Info fields for CLI output. For any field added here, please add the text
  * representation in the info_field_names array below. Please only append at the end,
  * before the INF_TOTAL_FIELDS entry, and never insert anything in the middle
@@ -440,5 +428,21 @@
 	ST_F_TOTAL_FIELDS
 };
 
+/* Please consider updating stats_dump_fields_*(),
+ * stats_dump_.*_info_fields() and stats_*_schema()
+ * when modifying struct field or related enums.
+ */
+struct field {
+	uint32_t type;
+	union {
+		int32_t     s32; /* FF_S32 */
+		uint32_t    u32; /* FF_U32 */
+		int64_t     s64; /* FF_S64 */
+		uint64_t    u64; /* FF_U64 */
+		double      flt; /* FF_FLT */
+		const char *str; /* FF_STR */
+	} u;
+};
+
 
-#endif /* _TYPES_STATS_H */
+#endif /* _HAPROXY_STATS_T_H */
diff --git a/include/proto/stats.h b/include/haproxy/stats.h
similarity index 93%
rename from include/proto/stats.h
rename to include/haproxy/stats.h
index 84c64d0..7fb5775 100644
--- a/include/proto/stats.h
+++ b/include/haproxy/stats.h
@@ -1,9 +1,9 @@
 /*
- * include/proto/stats.h
+ * include/haproxy/stats.h
  * This file contains definitions of some primitives to dedicated to
  * statistics output.
  *
- * Copyright (C) 2000-2011 Willy Tarreau - w@1wt.eu
+ * Copyright (C) 2000-2020 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
@@ -20,16 +20,40 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef _PROTO_STATS_H
-#define _PROTO_STATS_H
+#ifndef _HAPROXY_STATS_H
+#define _HAPROXY_STATS_H
 
 #include <haproxy/applet-t.h>
-#include <haproxy/tools.h>
 #include <haproxy/api.h>
+#include <haproxy/stats-t.h>
+#include <haproxy/tools-t.h>
 #include <types/stream_interface.h>
-#include <types/stats.h>
 
 
+/* These two structs contains all field names and descriptions according to
+ * the the number of entries in "enum stat_field" and "enum info_field"
+ */
+extern const struct name_desc stat_fields[];
+extern const struct name_desc info_fields[];
+extern const char *stat_status_codes[];
+extern struct applet http_stats_applet;
+
+
+int stats_fill_info(struct field *info, int len);
+int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len);
+int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags,
+                        struct field *stats, int len);
+int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
+                        struct field *stats, int len);
+int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int len);
+
+void stats_io_handler(struct stream_interface *si);
+int stats_emit_raw_data_field(struct buffer *out, const struct field *f);
+int stats_emit_typed_data_field(struct buffer *out, const struct field *f);
+int stats_emit_field_tags(struct buffer *out, const struct field *f,
+			  char delim);
+
+
 static inline enum field_format field_format(const struct field *f, int e)
 {
 	return f[e].type & FF_MASK;
@@ -91,31 +115,7 @@
 	return f;
 }
 
-extern const char *stat_status_codes[];
-
-/* These two structs contains all field names and descriptions according to
- * the the number of entries in "enum stat_field" and "enum info_field"
- */
-extern const struct name_desc stat_fields[];
-extern const struct name_desc info_fields[];
-
-int stats_fill_info(struct field *info, int len);
-int stats_fill_fe_stats(struct proxy *px, struct field *stats, int len);
-int stats_fill_li_stats(struct proxy *px, struct listener *l, int flags,
-                        struct field *stats, int len);
-int stats_fill_sv_stats(struct proxy *px, struct server *sv, int flags,
-                        struct field *stats, int len);
-int stats_fill_be_stats(struct proxy *px, int flags, struct field *stats, int len);
-
-extern struct applet http_stats_applet;
-
-void stats_io_handler(struct stream_interface *si);
-int stats_emit_raw_data_field(struct buffer *out, const struct field *f);
-int stats_emit_typed_data_field(struct buffer *out, const struct field *f);
-int stats_emit_field_tags(struct buffer *out, const struct field *f,
-			  char delim);
-
-#endif /* _PROTO_STATS_H */
+#endif /* _HAPROXY_STATS_H */
 
 /*
  * Local variables:
diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c
index 44474fd..9ec25a3 100644
--- a/src/cfgparse-listen.c
+++ b/src/cfgparse-listen.c
@@ -24,7 +24,7 @@
 #include <haproxy/listener.h>
 #include <haproxy/peers.h>
 #include <haproxy/sample.h>
-#include <types/stats.h>
+#include <haproxy/stats-t.h>
 
 #include <haproxy/protocol.h>
 #include <proto/proxy.h>
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 5f27877..e3d33ed 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -56,6 +56,7 @@
 #include <haproxy/peers-t.h>
 #include <haproxy/pool.h>
 #include <haproxy/session.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/tools.h>
 #include <haproxy/time.h>
 #include <haproxy/uri_auth-t.h>
@@ -65,11 +66,9 @@
 
 #include <types/filters.h>
 #include <haproxy/global.h>
-#include <types/stats.h>
 
 #include <proto/backend.h>
 #include <proto/channel.h>
-#include <proto/stats.h>
 #include <proto/filters.h>
 #include <proto/lb_map.h>
 #include <proto/log.h>
diff --git a/src/check.c b/src/check.c
index dfa3098..6e8e238 100644
--- a/src/check.c
+++ b/src/check.c
@@ -47,15 +47,14 @@
 #include <haproxy/h1.h>
 #include <haproxy/htx.h>
 #include <haproxy/signal.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/vars.h>
 
 #include <haproxy/global.h>
-#include <types/stats.h>
 
 #include <haproxy/arg.h>
 #include <proto/backend.h>
-#include <proto/stats.h>
 #include <haproxy/fd.h>
 #include <proto/log.h>
 #include <proto/queue.h>
diff --git a/src/cli.c b/src/cli.c
index e3b914d..2a0f423 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -39,6 +39,7 @@
 #include <haproxy/peers.h>
 #include <haproxy/sample-t.h>
 #include <haproxy/session.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/tools.h>
 #include <haproxy/ticks.h>
@@ -47,14 +48,12 @@
 #include <haproxy/base64.h>
 
 #include <haproxy/global.h>
-#include <types/stats.h>
 
 #include <haproxy/activity.h>
 #include <proto/backend.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
 #include <haproxy/compression.h>
-#include <proto/stats.h>
 #include <haproxy/fd.h>
 #include <haproxy/freq_ctr.h>
 #include <proto/log.h>
diff --git a/src/dns.c b/src/dns.c
index 9fc767d..036d4af 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -27,6 +27,7 @@
 #include <haproxy/errors.h>
 #include <haproxy/http_rules.h>
 #include <haproxy/sample.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/tcp_rules.h>
 #include <haproxy/time.h>
@@ -36,7 +37,6 @@
 
 #include <types/cli.h>
 #include <haproxy/global.h>
-#include <types/stats.h>
 
 #include <proto/channel.h>
 #include <proto/cli.h>
diff --git a/src/hlua.c b/src/hlua.c
index 0d3a3e9..04319bc 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -42,6 +42,7 @@
 #include <haproxy/payload.h>
 #include <haproxy/sample.h>
 #include <haproxy/session.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/tcp_rules.h>
 #include <haproxy/tools.h>
@@ -49,12 +50,10 @@
 
 #include <types/cli.h>
 #include <types/proxy.h>
-#include <types/stats.h>
 
 #include <haproxy/arg.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
-#include <proto/stats.h>
 #include <proto/queue.h>
 #include <proto/http_ana.h>
 #include <proto/server.h>
diff --git a/src/hlua_fcn.c b/src/hlua_fcn.c
index f4ac3d5..c9ef840 100644
--- a/src/hlua_fcn.c
+++ b/src/hlua_fcn.c
@@ -22,15 +22,14 @@
 #include <haproxy/http.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/regex.h>
+#include <haproxy/stats.h>
 #include <haproxy/time.h>
 
 #include <types/cli.h>
 #include <types/proxy.h>
-#include <types/stats.h>
 
 #include <proto/proxy.h>
 #include <proto/server.h>
-#include <proto/stats.h>
 #include <haproxy/stick_table.h>
 
 /* Contains the class reference of the concat object. */
diff --git a/src/http_ana.c b/src/http_ana.c
index 37ae648..690640f 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -21,6 +21,7 @@
 #include <haproxy/htx.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/regex.h>
+#include <haproxy/stats.h>
 #include <haproxy/uri_auth-t.h>
 #include <haproxy/vars.h>
 
@@ -34,7 +35,6 @@
 #include <proto/server.h>
 #include <proto/stream.h>
 #include <proto/stream_interface.h>
-#include <proto/stats.h>
 
 #define TRACE_SOURCE &trace_strm
 
diff --git a/src/map.c b/src/map.c
index 77d687b..65fd1ed 100644
--- a/src/map.c
+++ b/src/map.c
@@ -17,10 +17,10 @@
 #include <haproxy/map.h>
 #include <haproxy/pattern.h>
 #include <haproxy/regex.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/tools.h>
 
 #include <types/cli.h>
-#include <types/stats.h>
 
 #include <haproxy/arg.h>
 #include <proto/cli.h>
diff --git a/src/peers.c b/src/peers.c
index 1d60e3f..c9d5735 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -30,12 +30,11 @@
 #include <haproxy/task.h>
 #include <haproxy/session-t.h>
 #include <haproxy/signal.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/time.h>
 #include <haproxy/tools.h>
 #include <haproxy/thread.h>
 
-#include <types/stats.h>
-
 #include <proto/channel.h>
 #include <proto/cli.h>
 #include <haproxy/fd.h>
diff --git a/src/pool.c b/src/pool.c
index 1e8e2f8..e8b96a0 100644
--- a/src/pool.c
+++ b/src/pool.c
@@ -15,12 +15,12 @@
 #include <haproxy/api.h>
 #include <types/cli.h>
 #include <haproxy/global.h>
-#include <types/stats.h>
 
 #include <common/cfgparse.h>
 #include <haproxy/thread.h>
 #include <haproxy/pool.h>
 #include <haproxy/list.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/tools.h>
 
 #include <haproxy/activity-t.h>
@@ -29,7 +29,6 @@
 #include <proto/channel.h>
 #include <proto/log.h>
 #include <proto/stream_interface.h>
-#include <proto/stats.h>
 
 #ifdef CONFIG_HAP_LOCAL_POOLS
 /* These are the most common pools, expected to be initialized first. These
diff --git a/src/proxy.c b/src/proxy.c
index b00ea01..8e0f03a 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -26,6 +26,7 @@
 #include <haproxy/obj_type-t.h>
 #include <haproxy/peers.h>
 #include <haproxy/pool.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/time.h>
 
@@ -34,7 +35,6 @@
 
 #include <haproxy/capture-t.h>
 #include <types/cli.h>
-#include <types/stats.h>
 
 #include <proto/cli.h>
 #include <proto/backend.h>
diff --git a/src/server.c b/src/server.c
index 2e2ada8..c4a453b 100644
--- a/src/server.c
+++ b/src/server.c
@@ -27,12 +27,12 @@
 #include <haproxy/global.h>
 #include <haproxy/namespace.h>
 #include <haproxy/sample.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/time.h>
 
 #include <types/cli.h>
 #include <types/cli.h>
-#include <types/stats.h>
 
 #include <proto/cli.h>
 #include <haproxy/port_range.h>
@@ -41,7 +41,6 @@
 #include <proto/server.h>
 #include <proto/stream.h>
 #include <proto/stream_interface.h>
-#include <proto/stats.h>
 #include <netinet/tcp.h>
 
 #include <import/ebsttree.h>
diff --git a/src/ssl_sock.c b/src/ssl_sock.c
index 308dbfa..aa983bd 100644
--- a/src/ssl_sock.c
+++ b/src/ssl_sock.c
@@ -57,6 +57,7 @@
 #include <haproxy/ssl_ckch.h>
 #include <haproxy/ssl_crtlist.h>
 #include <haproxy/ssl_utils.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/tools.h>
 #include <haproxy/ticks.h>
@@ -69,7 +70,6 @@
 
 #include <types/cli.h>
 #include <types/ssl_sock.h>
-#include <types/stats.h>
 
 #include <haproxy/arg.h>
 #include <proto/channel.h>
diff --git a/src/stats.c b/src/stats.c
index b527eaf..bc59066 100644
--- a/src/stats.c
+++ b/src/stats.c
@@ -42,6 +42,7 @@
 #include <haproxy/map-t.h>
 #include <haproxy/pattern-t.h>
 #include <haproxy/session.h>
+#include <haproxy/stats.h>
 #include <haproxy/task.h>
 #include <haproxy/tools.h>
 #include <haproxy/ticks.h>
@@ -51,12 +52,10 @@
 #include <haproxy/base64.h>
 
 #include <types/cli.h>
-#include <types/stats.h>
 
 #include <proto/backend.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
-#include <proto/stats.h>
 #include <haproxy/fd.h>
 #include <haproxy/freq_ctr.h>
 #include <proto/log.h>
diff --git a/src/stick_table.c b/src/stick_table.c
index ebb9033..a79defc 100644
--- a/src/stick_table.c
+++ b/src/stick_table.c
@@ -22,6 +22,7 @@
 #include <haproxy/list.h>
 #include <haproxy/net_helper.h>
 #include <haproxy/peers.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/tcp_rules.h>
 #include <haproxy/tools.h>
@@ -31,7 +32,6 @@
 #include <import/ebsttree.h>
 
 #include <types/cli.h>
-#include <types/stats.h>
 
 #include <haproxy/arg.h>
 #include <proto/cli.h>
diff --git a/src/stream.c b/src/stream.c
index 0dd4745..e6058c5 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -34,20 +34,19 @@
 #include <haproxy/htx.h>
 #include <haproxy/pool.h>
 #include <haproxy/session.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/task.h>
 #include <haproxy/tcp_rules.h>
 #include <haproxy/vars.h>
 
 #include <types/cli.h>
 #include <types/filters.h>
-#include <types/stats.h>
 
 #include <haproxy/activity.h>
 #include <haproxy/arg.h>
 #include <proto/backend.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
-#include <proto/stats.h>
 #include <haproxy/fd.h>
 #include <proto/filters.h>
 #include <haproxy/freq_ctr.h>
diff --git a/src/uri_auth.c b/src/uri_auth.c
index 236f578..2005bc8 100644
--- a/src/uri_auth.c
+++ b/src/uri_auth.c
@@ -15,9 +15,9 @@
 
 #include <haproxy/api.h>
 #include <haproxy/base64.h>
+#include <haproxy/stats-t.h>
 #include <haproxy/uri_auth.h>
 
-#include <types/stats.h>
 #include <proto/log.h>
 
 /*