[REORG] session: move the data_ctx struct to the stream interface's applet

This is in fact where those parts belong to. The old data_state was replaced
by applet.state and is now initialized when the applet is registered. It's
worth noting that the applet does not need to know the session nor the
buffer anymore since everything is brought by the stream interface.

It is possible that having a separate applet struct would simplify the
code but that's not a big deal.
diff --git a/include/proto/dumpstats.h b/include/proto/dumpstats.h
index 3f89116..89e656e 100644
--- a/include/proto/dumpstats.h
+++ b/include/proto/dumpstats.h
@@ -27,7 +27,7 @@
 #include <types/buffers.h>
 #include <types/session.h>
 
-/* Flags for session->data_ctx.stats.flags */
+/* Flags for applet.ctx.stats.flags */
 #define STAT_FMT_CSV    0x00000001	/* dump the stats in CSV format instead of HTML */
 #define STAT_SHOW_STAT  0x00000002	/* dump the stats part */
 #define STAT_SHOW_INFO  0x00000004	/* dump the info part */
diff --git a/include/proto/proto_http.h b/include/proto/proto_http.h
index 417d5e6..a2d91ff 100644
--- a/include/proto/proto_http.h
+++ b/include/proto/proto_http.h
@@ -81,7 +81,7 @@
 void manage_client_side_cookies(struct session *t, struct buffer *req);
 void manage_server_side_cookies(struct session *t, struct buffer *rtr);
 void check_response_for_cacheability(struct session *t, struct buffer *rtr);
-int stats_check_uri(struct session *s, struct proxy *backend);
+int stats_check_uri(struct stream_interface *si, struct http_txn *txn, struct proxy *backend);
 void init_proto_http();
 int http_find_header2(const char *name, int len,
 		      char *sol, struct hdr_idx *idx,
diff --git a/include/types/proto_http.h b/include/types/proto_http.h
index cdd0a61..421bb98 100644
--- a/include/types/proto_http.h
+++ b/include/types/proto_http.h
@@ -186,28 +186,6 @@
 #define HTTP_MSG_CLOSED       35 // shutdown_w done, all bytes sent
 #define HTTP_MSG_TUNNEL       36 // tunneled data after DONE
 
-/* data transmission states for the stats responses */
-enum {
-	DATA_ST_INIT = 0,
-	DATA_ST_HEAD,
-	DATA_ST_INFO,
-	DATA_ST_LIST,
-	DATA_ST_END,
-	DATA_ST_FIN,
-};
-
-/* data transmission states for the stats responses inside a proxy */
-enum {
-	DATA_ST_PX_INIT = 0,
-	DATA_ST_PX_TH,
-	DATA_ST_PX_FE,
-	DATA_ST_PX_LI,
-	DATA_ST_PX_SV,
-	DATA_ST_PX_BE,
-	DATA_ST_PX_END,
-	DATA_ST_PX_FIN,
-};
-
 /* Redirect flags */
 enum {
 	REDIRECT_FLAG_NONE = 0,
diff --git a/include/types/session.h b/include/types/session.h
index 019eea2..0a001be 100644
--- a/include/types/session.h
+++ b/include/types/session.h
@@ -203,44 +203,6 @@
 	void (*do_log)(struct session *s);	/* the function to call in order to log (or NULL) */
 	void (*srv_error)(struct session *s,	/* the function to call upon unrecoverable server errors (or NULL) */
 			  struct stream_interface *si);
-	short int data_state;			/* where to get the data we generate ourselves */
-	union {
-		struct {
-			struct proxy *px;
-			struct server *sv;
-			struct listener *l;
-			short px_st, sv_st;	/* DATA_ST_INIT or DATA_ST_DATA */
-			unsigned int flags;	/* STAT_* */
-			int iid, type, sid;	/* proxy id, type and service id if bounding of stats is enabled */
-			const char *st_code;	/* pointer to the status code returned by an action */
-		} stats;
-		struct {
-			struct bref bref;	/* back-reference from the session being dumped */
-			void *target;		/* session we want to dump, or NULL for all */
-			unsigned int uid;	/* if non-null, the uniq_id of the session being dumped */
-			int section;		/* section of the session being dumped */
-			int pos;		/* last position of the current session's buffer */
-		} sess;
-		struct {
-			int iid;		/* if >= 0, ID of the proxy to filter on */
-			struct proxy *px;	/* current proxy being dumped, NULL = not started yet. */
-			unsigned int buf;	/* buffer being dumped, 0 = req, 1 = rep */
-			unsigned int sid;	/* session ID of error being dumped */
-			int ptr;		/* <0: headers, >=0 : text pointer to restart from */
-			int bol;		/* pointer to beginning of current line */
-		} errors;
-		struct {
-			void *target;		/* table we want to dump, or NULL for all */
-			struct proxy *proxy;	/* table being currently dumped (first if NULL) */
-			struct stksess *entry;	/* last entry we were trying to dump (or first if NULL) */
-			long long value;	/* value to compare against */
-			signed char data_type;	/* type of data to compare, or -1 if none */
-			signed char data_op;	/* operator (STD_OP_*) when data_type set */
-		} table;
-		struct {
-			const char *msg;	/* pointer to a persistent message to be returned in PRINT state */
-		} cli;
-	} data_ctx;				/* used by stats I/O handlers to dump the stats */
 	unsigned int uniq_id;			/* unique ID used for the traces */
 };
 
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index 1c1e6a6..39caf8f 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -136,8 +136,46 @@
 	int conn_retries;	/* number of connect retries left */
 	int fd;                 /* file descriptor for a stream driver when known */
 	struct {
+		int state;                 /* applet state, initialized to zero */
 		void *private;             /* may be used by any function above */
 		unsigned int st0, st1;     /* may be used by any function above */
+		union {
+			struct {
+				struct proxy *px;
+				struct server *sv;
+				struct listener *l;
+				int px_st;		/* STAT_PX_ST* */
+				unsigned int flags;	/* STAT_* */
+				int iid, type, sid;	/* proxy id, type and service id if bounding of stats is enabled */
+				const char *st_code;	/* pointer to the status code returned by an action */
+			} stats;
+			struct {
+				struct bref bref;	/* back-reference from the session being dumped */
+				void *target;		/* session we want to dump, or NULL for all */
+				unsigned int uid;	/* if non-null, the uniq_id of the session being dumped */
+				int section;		/* section of the session being dumped */
+				int pos;		/* last position of the current session's buffer */
+			} sess;
+			struct {
+				int iid;		/* if >= 0, ID of the proxy to filter on */
+				struct proxy *px;	/* current proxy being dumped, NULL = not started yet. */
+				unsigned int buf;	/* buffer being dumped, 0 = req, 1 = rep */
+				unsigned int sid;	/* session ID of error being dumped */
+				int ptr;		/* <0: headers, >=0 : text pointer to restart from */
+				int bol;		/* pointer to beginning of current line */
+			} errors;
+			struct {
+				void *target;		/* table we want to dump, or NULL for all */
+				struct proxy *proxy;	/* table being currently dumped (first if NULL) */
+				struct stksess *entry;	/* last entry we were trying to dump (or first if NULL) */
+				long long value;	/* value to compare against */
+				signed char data_type;	/* type of data to compare, or -1 if none */
+				signed char data_op;	/* operator (STD_OP_*) when data_type set */
+			} table;
+			struct {
+				const char *msg;	/* pointer to a persistent message to be returned in PRINT state */
+			} cli;
+		} ctx;					/* used by stats I/O handlers to dump the stats */
 	} applet;
 	union {
 		struct {