REORG: applet: move the applet definitions out of stream_interface

We're tidying the definitions so that appctx lives on its own. A new
set of applet.h files has been added for this purpose.
diff --git a/include/proto/applet.h b/include/proto/applet.h
new file mode 100644
index 0000000..61bca02
--- /dev/null
+++ b/include/proto/applet.h
@@ -0,0 +1,73 @@
+/*
+ * include/proto/applet.h
+ * This file contains applet function prototypes
+ *
+ * Copyright (C) 2000-2015 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
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _PROTO_APPLET_H
+#define _PROTO_APPLET_H
+
+#include <stdlib.h>
+
+#include <common/config.h>
+#include <types/applet.h>
+#include <proto/connection.h>
+
+/* Initializes all required fields for a new appctx. Note that it does the
+ * minimum acceptable initialization for an appctx. This means only the
+ * 3 integer states st0, st1, st2 are zeroed.
+ */
+static inline void appctx_init(struct appctx *appctx)
+{
+	appctx->st0 = appctx->st1 = appctx->st2 = 0;
+}
+
+/* Tries to allocate a new appctx and initialize its main fields. The appctx
+ * is returned on success, NULL on failure. The appctx must be released using
+ * pool_free2(connection) or appctx_free(), since it's allocated from the
+ * connection pool. <applet> is assigned as the applet, but it can be NULL.
+ */
+static inline struct appctx *appctx_new(struct si_applet *applet)
+{
+	struct appctx *appctx;
+
+	appctx = pool_alloc2(pool2_connection);
+	if (likely(appctx != NULL)) {
+		appctx->obj_type = OBJ_TYPE_APPCTX;
+		appctx->applet = applet;
+		appctx_init(appctx);
+	}
+	return appctx;
+}
+
+/* Releases an appctx previously allocated by appctx_new(). Note that
+ * we share the connection pool.
+ */
+static inline void appctx_free(struct appctx *appctx)
+{
+	pool_free2(pool2_connection, appctx);
+}
+
+#endif /* _PROTO_APPLET_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
diff --git a/include/proto/dumpstats.h b/include/proto/dumpstats.h
index 61e39bf..cbbb802 100644
--- a/include/proto/dumpstats.h
+++ b/include/proto/dumpstats.h
@@ -24,6 +24,7 @@
 #define _PROTO_DUMPSTATS_H
 
 #include <common/config.h>
+#include <types/applet.h>
 #include <types/stream_interface.h>
 
 /* Flags for applet.ctx.stats.flags */
diff --git a/include/proto/obj_type.h b/include/proto/obj_type.h
index a02e1d6..6d6577c 100644
--- a/include/proto/obj_type.h
+++ b/include/proto/obj_type.h
@@ -24,6 +24,7 @@
 
 #include <common/config.h>
 #include <common/memory.h>
+#include <types/applet.h>
 #include <types/connection.h>
 #include <types/listener.h>
 #include <types/obj_type.h>
diff --git a/include/proto/stream_interface.h b/include/proto/stream_interface.h
index ec52f1e..2645961 100644
--- a/include/proto/stream_interface.h
+++ b/include/proto/stream_interface.h
@@ -27,6 +27,7 @@
 #include <common/config.h>
 #include <types/stream.h>
 #include <types/stream_interface.h>
+#include <proto/applet.h>
 #include <proto/channel.h>
 #include <proto/connection.h>
 
@@ -103,41 +104,6 @@
 		return &LIST_ELEM(si, struct stream *, si[0])->si[1];
 }
 
-/* Initializes all required fields for a new appctx. Note that it does the
- * minimum acceptable initialization for an appctx. This means only the
- * 3 integer states st0, st1, st2 are zeroed.
- */
-static inline void appctx_init(struct appctx *appctx)
-{
-	appctx->st0 = appctx->st1 = appctx->st2 = 0;
-}
-
-/* Tries to allocate a new appctx and initialize its main fields. The appctx
- * is returned on success, NULL on failure. The appctx must be released using
- * pool_free2(connection) or appctx_free(), since it's allocated from the
- * connection pool. <applet> is assigned as the applet, but it can be NULL.
- */
-static inline struct appctx *appctx_new(struct si_applet *applet)
-{
-	struct appctx *appctx;
-
-	appctx = pool_alloc2(pool2_connection);
-	if (likely(appctx != NULL)) {
-		appctx->obj_type = OBJ_TYPE_APPCTX;
-		appctx->applet = applet;
-		appctx_init(appctx);
-	}
-	return appctx;
-}
-
-/* Releases an appctx previously allocated by appctx_new(). Note that
- * we share the connection pool.
- */
-static inline void appctx_free(struct appctx *appctx)
-{
-	pool_free2(pool2_connection, appctx);
-}
-
 /* initializes a stream interface in the SI_ST_INI state. It's detached from
  * any endpoint and only keeps its side which is expected to have already been
  * set.
diff --git a/include/types/applet.h b/include/types/applet.h
new file mode 100644
index 0000000..9146ee4
--- /dev/null
+++ b/include/types/applet.h
@@ -0,0 +1,117 @@
+/*
+ * include/types/applet.h
+ * This file describes the applet struct and associated constants.
+ *
+ * Copyright (C) 2000-2015 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
+ * exclusively.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef _TYPES_APPLET_H
+#define _TYPES_APPLET_H
+
+#include <types/hlua.h>
+#include <types/obj_type.h>
+#include <common/chunk.h>
+#include <common/config.h>
+
+struct appctx;
+
+/* Applet descriptor */
+struct si_applet {
+	enum obj_type obj_type;            /* object type = OBJ_TYPE_APPLET */
+	/* 3 unused bytes here */
+	char *name;                        /* applet's name to report in logs */
+	void (*fct)(struct appctx *);      /* internal I/O handler, may never be NULL */
+	void (*release)(struct appctx *);  /* callback to release resources, may be NULL */
+};
+
+/* Context of a running applet. */
+struct appctx {
+	enum obj_type obj_type;    /* OBJ_TYPE_APPCTX */
+	/* 3 unused bytes here */
+	unsigned int st0;          /* CLI state for stats, session state for peers */
+	unsigned int st1;          /* prompt for stats, session error for peers */
+	unsigned int st2;          /* output state for stats, unused by peers  */
+	struct si_applet *applet;  /* applet this context refers to */
+	void *owner;               /* pointer to upper layer's entity (eg: stream interface) */
+
+	union {
+		struct {
+			struct proxy *px;
+			struct server *sv;
+			void *l;
+			int scope_str;		/* limit scope to a frontend/backend substring */
+			int scope_len;		/* length of the string above in the buffer */
+			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 */
+			int st_code;		/* 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 */
+			char *err;        /* pointer to a 'must free' message to be returned in PRINT_FREE state */
+		} cli;
+		struct {
+			void *ptr;              /* multi-purpose pointer for peers */
+		} peers;
+		struct {
+			unsigned int display_flags;
+			struct pat_ref *ref;
+			struct pat_ref_elt *elt;
+			struct map_descriptor *desc;
+			struct pattern_expr *expr;
+			struct chunk chunk;
+		} map;
+		struct {
+			int connected;
+			struct hlua_socket *socket;
+			struct list wake_on_read;
+			struct list wake_on_write;
+		} hlua;
+	} ctx;					/* used by stats I/O handlers to dump the stats */
+};
+
+#endif /* _TYPES_APPLET_H */
+
+/*
+ * Local variables:
+ *  c-indent-level: 8
+ *  c-basic-offset: 8
+ * End:
+ */
diff --git a/include/types/stream_interface.h b/include/types/stream_interface.h
index 7e688cf..9b228e5 100644
--- a/include/types/stream_interface.h
+++ b/include/types/stream_interface.h
@@ -22,10 +22,6 @@
 #ifndef _TYPES_STREAM_INTERFACE_H
 #define _TYPES_STREAM_INTERFACE_H
 
-#include <stdlib.h>
-#include <sys/socket.h>
-
-#include <types/hlua.h>
 #include <types/obj_type.h>
 #include <common/config.h>
 
@@ -103,17 +99,6 @@
 	int conn_retries;	/* number of connect retries left */
 };
 
-struct appctx;
-
-/* An applet designed to run in a stream interface */
-struct si_applet {
-	enum obj_type obj_type;                      /* object type = OBJ_TYPE_APPLET */
-	/* 3 unused bytes here */
-	char *name;                                  /* applet's name to report in logs */
-	void (*fct)(struct appctx *);      /* internal I/O handler, may never be NULL */
-	void (*release)(struct appctx *);  /* callback to release resources, may be NULL */
-};
-
 /* operations available on a stream-interface */
 struct si_ops {
 	void (*update)(struct stream_interface *);  /* I/O update function */
@@ -123,75 +108,6 @@
 	void (*shutw)(struct stream_interface *);   /* shut write function */
 };
 
-/* Context of a running applet. */
-struct appctx {
-	enum obj_type obj_type;    /* OBJ_TYPE_APPCTX */
-	/* 3 unused bytes here */
-	unsigned int st0;          /* CLI state for stats, session state for peers */
-	unsigned int st1;          /* prompt for stats, session error for peers */
-	unsigned int st2;          /* output state for stats, unused by peers  */
-	struct si_applet *applet;  /* applet this context refers to */
-	void *owner;               /* pointer to upper layer's entity (eg: stream interface) */
-
-	union {
-		struct {
-			struct proxy *px;
-			struct server *sv;
-			void *l;
-			int scope_str;		/* limit scope to a frontend/backend substring */
-			int scope_len;		/* length of the string above in the buffer */
-			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 */
-			int st_code;		/* 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 */
-			char *err;        /* pointer to a 'must free' message to be returned in PRINT_FREE state */
-		} cli;
-		struct {
-			void *ptr;              /* multi-purpose pointer for peers */
-		} peers;
-		struct {
-			unsigned int display_flags;
-			struct pat_ref *ref;
-			struct pat_ref_elt *elt;
-			struct map_descriptor *desc;
-			struct pattern_expr *expr;
-			struct chunk chunk;
-		} map;
-		struct {
-			int connected;
-			struct hlua_socket *socket;
-			struct list wake_on_read;
-			struct list wake_on_write;
-		} hlua;
-	} ctx;					/* used by stats I/O handlers to dump the stats */
-};
-
 #endif /* _TYPES_STREAM_INTERFACE_H */
 
 /*
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 4375bec..d416ad0 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -37,6 +37,7 @@
 #include <common/version.h>
 #include <common/base64.h>
 
+#include <types/applet.h>
 #include <types/global.h>
 
 #include <proto/backend.h>
diff --git a/src/hlua.c b/src/hlua.c
index d1531be..4bc32e7 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -20,6 +20,7 @@
 #include <types/proxy.h>
 
 #include <proto/arg.h>
+#include <proto/applet.h>
 #include <proto/channel.h>
 #include <proto/hdr_idx.h>
 #include <proto/hlua.h>
diff --git a/src/peers.c b/src/peers.c
index 6af565f..7683150 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -30,6 +30,7 @@
 #include <types/peers.h>
 
 #include <proto/acl.h>
+#include <proto/applet.h>
 #include <proto/channel.h>
 #include <proto/fd.h>
 #include <proto/frontend.h>
diff --git a/src/stream.c b/src/stream.c
index e9a4b0d..ed97e48 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -19,6 +19,7 @@
 #include <common/debug.h>
 #include <common/memory.h>
 
+#include <types/applet.h>
 #include <types/capture.h>
 #include <types/global.h>
 
diff --git a/src/stream_interface.c b/src/stream_interface.c
index 8df5008..ad865ca 100644
--- a/src/stream_interface.c
+++ b/src/stream_interface.c
@@ -27,6 +27,7 @@
 #include <common/ticks.h>
 #include <common/time.h>
 
+#include <proto/applet.h>
 #include <proto/channel.h>
 #include <proto/connection.h>
 #include <proto/pipe.h>