summaryrefslogtreecommitdiffabout
path: root/include/kingate/fastcgi.h
Side-by-side diff
Diffstat (limited to 'include/kingate/fastcgi.h') (more/less context) (ignore whitespace changes)
-rw-r--r--include/kingate/fastcgi.h98
1 files changed, 98 insertions, 0 deletions
diff --git a/include/kingate/fastcgi.h b/include/kingate/fastcgi.h
new file mode 100644
index 0000000..fd293b9
--- a/dev/null
+++ b/include/kingate/fastcgi.h
@@ -0,0 +1,98 @@
+#ifndef __KINGATE_FASTCGI_H
+#define __KINGATE_FASTCGI_H
+
+#include "kingate/cgi_interface.h"
+#include <fcgio.h>
+
+/**
+ * @file
+ * @brief the fastcgi-specific implementation.
+ */
+
+namespace kingate {
+
+ /**
+ * The fcgi listening socket.
+ */
+ class fcgi_socket {
+ static bool _initialized;
+ public:
+ /**
+ * socket file descriptor.
+ */
+ int sock;
+
+ /**
+ * @param s the socket name. (if the socket starts with a colon,
+ * then it is interpreted as a tcp port number.
+ * @param bl backlog listen queue depth.
+ */
+ fcgi_socket(const char* s,int bl);
+ /**
+ * @param s the file descriptor of preopened socket.
+ */
+ fcgi_socket(int s);
+ ~fcgi_socket();
+ };
+
+ /**
+ * The implementation of the interface to the FastCGI.
+ */
+ class fcgi_interface : public cgi_interface {
+ public:
+ /**
+ * stdin fcgi streambuf.
+ */
+ fcgi_streambuf sbin;
+ /**
+ * stdout fcgi streambuf.
+ */
+ fcgi_streambuf sbout;
+ /**
+ * stderr fcgi streambuf.
+ */
+ fcgi_streambuf sberr;
+ /**
+ * stdin istream.
+ */
+ istream sin;
+ /**
+ * stdout ostream.
+ */
+ ostream sout;
+ /**
+ * stderr ostream.
+ */
+ ostream serr;
+ /**
+ * The FCGI request.
+ */
+ FCGX_Request request;
+
+ /**
+ * @param s the socked used for interfacing with the server.
+ * @param f the request flags (e.g. FCGI_FAIL_ON_INTR).
+ */
+ fcgi_interface(fcgi_socket& s,int f=0);
+ virtual ~fcgi_interface();
+
+ /**
+ * @overload cgi_interface::in()
+ */
+ istream& in() { return sin; }
+ /**
+ * @overload cgi_interface::out()
+ */
+ ostream& out() { return sout; }
+ /**
+ * @overload cgi_interface::out()
+ */
+ ostream& err() { return serr; }
+ };
+
+}
+
+#endif /* __KINGATE_FASTCGI_H */
+/*
+ * vim:set ft=cpp:
+ */