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

This one is particularly tricky to move because everyone uses it
and it depends on a lot of other types. For example it cannot include
arg-t.h and must absolutely only rely on forward declarations to avoid
dependency loops between vars -> sample_data -> arg. In order to address
this one, it would be nice to split the sample_data part out of sample.h.
diff --git a/include/haproxy/auth.h b/include/haproxy/auth.h
index 3eafa41..d7ec2f7 100644
--- a/include/haproxy/auth.h
+++ b/include/haproxy/auth.h
@@ -17,7 +17,7 @@
 #include <haproxy/auth-t.h>
 #include <haproxy/api.h>
 #include <haproxy/pattern-t.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 
 extern struct userlist *userlist;
 
diff --git a/include/haproxy/map-t.h b/include/haproxy/map-t.h
index 902b064..d6085ee 100644
--- a/include/haproxy/map-t.h
+++ b/include/haproxy/map-t.h
@@ -23,7 +23,7 @@
 #define _HAPROXY_MAP_T_H
 
 #include <haproxy/pattern-t.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 
 struct map_descriptor {
 	struct sample_conv *conv;      /* original converter descriptor */
diff --git a/include/haproxy/map.h b/include/haproxy/map.h
index 140148c..3ec3418 100644
--- a/include/haproxy/map.h
+++ b/include/haproxy/map.h
@@ -23,7 +23,7 @@
 #define _HAPROXY_MAP_H
 
 #include <haproxy/map-t.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 
 /* maps output sample parser */
 int map_parse_ip(const char *text, struct sample_data *data);
diff --git a/include/haproxy/pattern-t.h b/include/haproxy/pattern-t.h
index 7787ec3..a977527 100644
--- a/include/haproxy/pattern-t.h
+++ b/include/haproxy/pattern-t.h
@@ -29,7 +29,7 @@
 #include <haproxy/thread-t.h>
 #include <haproxy/api-t.h>
 
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 
 
 /* Pattern matching function result.
diff --git a/include/haproxy/payload.h b/include/haproxy/payload.h
index a99adf0..da5b4e1 100644
--- a/include/haproxy/payload.h
+++ b/include/haproxy/payload.h
@@ -23,7 +23,7 @@
 #define _HAPROXY_PAYLOAD_H
 
 #include <haproxy/api.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 #include <types/stream.h>
 
 int fetch_rdp_cookie_name(struct stream *s, struct sample *smp, const char *cname, int clen);
diff --git a/include/types/sample.h b/include/haproxy/sample-t.h
similarity index 98%
rename from include/types/sample.h
rename to include/haproxy/sample-t.h
index 0bec0c4..9403d7b 100644
--- a/include/types/sample.h
+++ b/include/haproxy/sample-t.h
@@ -1,5 +1,5 @@
 /*
- * include/types/sample.h
+ * include/haproxy/sample-t.h
  * Macros, variables and structures for sample management.
  *
  * Copyright (C) 2009-2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
@@ -20,18 +20,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef _TYPES_SAMPLE_H
-#define _TYPES_SAMPLE_H
+#ifndef _HAPROXY_SAMPLE_T_H
+#define _HAPROXY_SAMPLE_T_H
 
 #include <sys/socket.h>
 #include <netinet/in.h>
 
+#include <haproxy/api-t.h>
 #include <haproxy/buf-t.h>
 #include <haproxy/http-t.h>
 #include <haproxy/list-t.h>
 
-struct arg;
-
 /* input and output sample types */
 enum {
 	SMP_T_ANY = 0,   /* any type */
@@ -179,8 +178,6 @@
 	                     SMP_VAL_BE_CHK_RUL,
 };
 
-extern const unsigned int fetch_cap[SMP_SRC_ENTRIES];
-
 /* Sample fetch options are passed to sample fetch functions to add precision
  * about what is desired :
  *   - fetch direction (req/resp)
@@ -213,6 +210,7 @@
 /* needed below */
 struct session;
 struct stream;
+struct arg;
 
 /* a sample context might be used by any sample fetch function in order to
  * store information needed across multiple calls (eg: restart point for a
@@ -326,6 +324,5 @@
 };
 
 typedef int (*sample_cast_fct)(struct sample *smp);
-extern sample_cast_fct sample_casts[SMP_TYPES][SMP_TYPES];
 
-#endif /* _TYPES_SAMPLE_H */
+#endif /* _HAPROXY_SAMPLE_T_H */
diff --git a/include/proto/sample.h b/include/haproxy/sample.h
similarity index 94%
rename from include/proto/sample.h
rename to include/haproxy/sample.h
index b4d52c5..1c30fd4 100644
--- a/include/proto/sample.h
+++ b/include/haproxy/sample.h
@@ -1,5 +1,5 @@
 /*
- * include/proto/sample.h
+ * include/haproxy/sample.h
  * Functions for samples management.
  *
  * Copyright (C) 2009-2010 EXCELIANCE, Emeric Brun <ebrun@exceliance.fr>
@@ -20,12 +20,16 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
-#ifndef _PROTO_SAMPLE_H
-#define _PROTO_SAMPLE_H
+#ifndef _HAPROXY_SAMPLE_H
+#define _HAPROXY_SAMPLE_H
 
-#include <types/sample.h>
+#include <haproxy/arg-t.h>
+#include <haproxy/api.h>
+#include <haproxy/sample-t.h>
 #include <types/stick_table.h>
 
+extern sample_cast_fct sample_casts[SMP_TYPES][SMP_TYPES];
+extern const unsigned int fetch_cap[SMP_SRC_ENTRIES];
 extern const char *smp_to_type[SMP_TYPES];
 
 struct sample_expr *sample_parse_expr(char **str, int *idx, const char *file, int line, char **err, struct arg_list *al, char **endptr);
@@ -170,4 +174,4 @@
 	return smp && (smp_is_rw(smp) || smp_dup(smp));
 }
 
-#endif /* _PROTO_SAMPLE_H */
+#endif /* _HAPROXY_SAMPLE_H */
diff --git a/include/proto/acl.h b/include/proto/acl.h
index 28b49c4..56ae228 100644
--- a/include/proto/acl.h
+++ b/include/proto/acl.h
@@ -24,7 +24,6 @@
 
 #include <haproxy/api.h>
 #include <types/acl.h>
-#include <proto/sample.h>
 
 /*
  * FIXME: we need destructor functions too !
diff --git a/include/proto/http_fetch.h b/include/proto/http_fetch.h
index e631bc0..3a7261a 100644
--- a/include/proto/http_fetch.h
+++ b/include/proto/http_fetch.h
@@ -27,7 +27,7 @@
 #include <haproxy/arg-t.h>
 #include <types/channel.h>
 #include <types/checks.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 
 struct htx *smp_prefetch_htx(struct sample *smp, struct channel *chn, struct check *check, int vol);
 int val_hdr(struct arg *arg, char **err_msg);
diff --git a/include/proto/protocol_buffers.h b/include/proto/protocol_buffers.h
index 3e1571a..16ccee5 100644
--- a/include/proto/protocol_buffers.h
+++ b/include/proto/protocol_buffers.h
@@ -24,8 +24,8 @@
 
 #include <inttypes.h>
 #include <haproxy/arg-t.h>
+#include <haproxy/sample-t.h>
 #include <types/protocol_buffers.h>
-#include <proto/sample.h>
 
 #define PBUF_VARINT_DONT_STOP_BIT       7
 #define PBUF_VARINT_DONT_STOP_BITMASK  (1 << PBUF_VARINT_DONT_STOP_BIT)
diff --git a/include/proto/spoe.h b/include/proto/spoe.h
index 584b38a..d9e9098 100644
--- a/include/proto/spoe.h
+++ b/include/proto/spoe.h
@@ -23,11 +23,10 @@
 #define _PROTO_SPOE_H
 
 #include <haproxy/intops.h>
+#include <haproxy/sample-t.h>
 
 #include <types/spoe.h>
 
-#include <proto/sample.h>
-
 
 /* Encode a buffer. Its length <len> is encoded as a varint, followed by a copy
  * of <str>. It must have enough space in <*buf> to encode the buffer, else an
diff --git a/include/types/checks.h b/include/types/checks.h
index 80f6321..9b914d0 100644
--- a/include/types/checks.h
+++ b/include/types/checks.h
@@ -24,7 +24,7 @@
 
 #include <types/connection.h>
 #include <types/proxy.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 #include <types/server.h>
 #include <types/session.h>
 #include <types/task.h>
diff --git a/include/types/protocol_buffers.h b/include/types/protocol_buffers.h
index 8509b01..35e8444 100644
--- a/include/types/protocol_buffers.h
+++ b/include/types/protocol_buffers.h
@@ -68,6 +68,7 @@
 	size_t sz;
 };
 
+struct sample;
 struct protobuf_parser_def {
 	int (*skip)(unsigned char **pos, size_t *left, size_t vlen);
 	int (*smp_store)(struct sample *, int type,
diff --git a/include/types/proxy.h b/include/types/proxy.h
index af33021..a72232f 100644
--- a/include/types/proxy.h
+++ b/include/types/proxy.h
@@ -44,7 +44,7 @@
 #include <types/filters.h>
 #include <haproxy/freq_ctr-t.h>
 #include <types/log.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 #include <types/server.h>
 #include <types/stick_table.h>
 
diff --git a/include/types/spoe.h b/include/types/spoe.h
index f08b9ad..fdaba93 100644
--- a/include/types/spoe.h
+++ b/include/types/spoe.h
@@ -32,7 +32,7 @@
 #include <haproxy/freq_ctr-t.h>
 #include <types/log.h>
 #include <types/proxy.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 #include <types/stream.h>
 #include <types/task.h>
 
diff --git a/include/types/stick_table.h b/include/types/stick_table.h
index e345048..0ee7b95 100644
--- a/include/types/stick_table.h
+++ b/include/types/stick_table.h
@@ -33,7 +33,7 @@
 #include <haproxy/pool-t.h>
 #include <haproxy/freq_ctr-t.h>
 #include <types/peers.h>
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 
 /* The types of extra data we can store in a stick table */
 enum {
diff --git a/include/types/vars.h b/include/types/vars.h
index 62b944b..d8ec71c 100644
--- a/include/types/vars.h
+++ b/include/types/vars.h
@@ -4,7 +4,7 @@
 #include <haproxy/list-t.h>
 #include <haproxy/thread.h>
 
-#include <types/sample.h>
+#include <haproxy/sample-t.h>
 
 enum vars_scope {
 	SCOPE_SESS = 0,