-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 22 | ||||
-rw-r--r-- | configure.ac | 21 | ||||
-rw-r--r-- | include/Makefile.am | 3 | ||||
-rw-r--r-- | include/kingate/plaincgi.h | 44 | ||||
-rw-r--r-- | kingate-plaincgi.pc.in | 11 | ||||
-rw-r--r-- | src/Makefile.am | 12 | ||||
-rw-r--r-- | src/fastcgi.cc | 1 | ||||
-rw-r--r-- | src/plaincgi.cc | 27 |
9 files changed, 119 insertions, 23 deletions
@@ -16,8 +16,9 @@ stamp-h1 | |||
16 | config.h.in | 16 | config.h.in |
17 | libtool | 17 | libtool |
18 | autom4te.cache | 18 | autom4te.cache |
19 | missing | 19 | missing |
20 | aclocal.m4 | 20 | aclocal.m4 |
21 | install-sh | 21 | install-sh |
22 | NEWS | 22 | NEWS |
23 | doxydox | 23 | doxydox |
24 | kingate-plaincgi.pc | ||
diff --git a/Makefile.am b/Makefile.am index 9833732..3e9f0f1 100644 --- a/Makefile.am +++ b/Makefile.am | |||
@@ -1,27 +1,25 @@ | |||
1 | SUBDIRS=include src | 1 | SUBDIRS=include src |
2 | EXTRA_DIST= NEWS NEWS.xml NEWS.xsl | 2 | EXTRA_DIST= NEWS NEWS.xml NEWS.xsl |
3 | 3 | ||
4 | DISTCHECK_CONFIGURE_FLAGS=--with-pkgconfigdir=$${dc_install_base}/lib/pkgconfig | 4 | DISTCHECK_CONFIGURE_FLAGS=--with-pkgconfigdir=$${dc_install_base}/lib/pkgconfig |
5 | if HAVE_PKGCONFIG | 5 | if HAVE_PKGCONFIG |
6 | pkgconfigdir=@PKGCONFIG_DIR@ | 6 | pkgconfigdir=@PKGCONFIG_DIR@ |
7 | pkgconfig_DATA=kingate.pc kingate-fcgi.pc | 7 | pkgconfig_DATA=kingate.pc kingate-plaincgi.pc |
8 | if HAVE_FCGI | ||
9 | pkgconfig_DATA += kingate-fcgi.pc | ||
10 | endif | ||
8 | endif | 11 | endif |
9 | 12 | ||
10 | LOCAL_TARGETS= | 13 | all-local: NEWS |
11 | if HAVE_DOXYGEN | 14 | if HAVE_DOXYGEN |
12 | LOCAL_TARGETS+=doxygen | 15 | clean-local: |
16 | rm -rf doxydox | ||
13 | endif | 17 | endif |
14 | 18 | ||
15 | all-local: NEWS $(addprefix all-lota-,${LOCAL_TARGETS}) | ||
16 | clean-local: $(addprefix clean-lota-,${LOCAL_TARGETS}) | ||
17 | |||
18 | NEWS: NEWS.xsl NEWS.xml | 19 | NEWS: NEWS.xsl NEWS.xml |
19 | ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml | 20 | ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml |
20 | 21 | ||
21 | all-lota-doxygen: doxydox/built | 22 | if HAVE_DOXYGEN |
22 | doxydox/built: $(wildcard ${top_srcdir}/include/kingate/*.h) | 23 | dox: |
23 | ${DOXYGEN} | 24 | ${DOXYGEN} |
24 | touch $@ | 25 | endif |
25 | |||
26 | clean-lota-doxygen: | ||
27 | rm -rf doxydox | ||
diff --git a/configure.ac b/configure.ac index 109eddf..5ae7b27 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -1,33 +1,38 @@ | |||
1 | AC_INIT([kingate], [0.0], [kingate-bugs@klever.net]) | 1 | AC_INIT([kingate], [0.0.1], [kingate-bugs@klever.net]) |
2 | AC_CONFIG_SRCDIR([include/kingate/cgi_gateway.h]) | 2 | AC_CONFIG_SRCDIR([include/kingate/cgi_gateway.h]) |
3 | AC_CONFIG_HEADER([config.h]) | 3 | AC_CONFIG_HEADER([config.h]) |
4 | AM_INIT_AUTOMAKE([dist-bzip2]) | 4 | AM_INIT_AUTOMAKE([dist-bzip2]) |
5 | 5 | ||
6 | AC_PROG_INSTALL | 6 | AC_PROG_INSTALL |
7 | AC_PROG_AWK | 7 | AC_PROG_AWK |
8 | AC_PROG_CXX | 8 | AC_PROG_CXX |
9 | AC_PROG_CC | 9 | AC_PROG_CC |
10 | AC_PROG_LIBTOOL | 10 | AC_PROG_LIBTOOL |
11 | 11 | ||
12 | AC_HEADER_STDC | 12 | AC_HEADER_STDC |
13 | AC_CHECK_HEADERS([sys/types.h sys/stat.h]) | 13 | AC_CHECK_HEADERS([sys/types.h sys/stat.h]) |
14 | 14 | ||
15 | HAVE_FCGI=false | ||
15 | AC_LANG_PUSH(C++) | 16 | AC_LANG_PUSH(C++) |
16 | AC_CHECK_HEADERS([fcgio.h],,[ | 17 | AC_CHECK_HEADERS([fcgio.h],[ |
17 | exit 1 | 18 | AC_CHECK_LIB(fcgi,FCGX_Init,[ |
19 | LIBS="-lfcgi ${LIBS}" | ||
20 | AC_CHECK_LIB([fcgi++],[main],[ | ||
21 | LIBS="-lfcgi++ ${LIBS}" | ||
22 | HAVE_FCGI=true | ||
18 | ]) | 23 | ]) |
19 | AC_CHECK_LIB(fcgi,FCGX_Init,,[ | ||
20 | exit 1 | ||
21 | ]) | 24 | ]) |
22 | AC_CHECK_LIB([fcgi++],[main],,[ | ||
23 | exit 1 | ||
24 | ]) | 25 | ]) |
25 | AC_LANG_POP(C++) | 26 | AC_LANG_POP(C++) |
27 | if ! ${HAVE_FCGI} ; then | ||
28 | AC_MSG_NOTICE([no FastCGI development kit found. It is highly recommnded that you get one. Meanwhile we will proceed without FastCGI support]) | ||
29 | fi | ||
30 | AM_CONDITIONAL([HAVE_FCGI],[${HAVE_FCGI}]) | ||
26 | 31 | ||
27 | AC_C_CONST | 32 | AC_C_CONST |
28 | 33 | ||
29 | AC_FUNC_MALLOC | 34 | AC_FUNC_MALLOC |
30 | AC_FUNC_REALLOC | 35 | AC_FUNC_REALLOC |
31 | 36 | ||
32 | AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) | 37 | AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) |
33 | 38 | ||
@@ -49,14 +54,14 @@ if test "${WANT_DOXYGEN}" = "yes" ; then | |||
49 | AC_WITH_DOT | 54 | AC_WITH_DOT |
50 | else | 55 | else |
51 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) | 56 | AM_CONDITIONAL([HAVE_DOXYGEN],[false]) |
52 | AM_CONDITIONAL([HAVE_DOT],[false]) | 57 | AM_CONDITIONAL([HAVE_DOT],[false]) |
53 | fi | 58 | fi |
54 | 59 | ||
55 | AC_CONFIG_FILES([ | 60 | AC_CONFIG_FILES([ |
56 | Makefile | 61 | Makefile |
57 | kingate.pc kingate-fcgi.pc | 62 | kingate.pc kingate-fcgi.pc kingate-plaincgi.pc |
58 | Doxyfile | 63 | Doxyfile |
59 | include/Makefile | 64 | include/Makefile |
60 | src/Makefile | 65 | src/Makefile |
61 | ]) | 66 | ]) |
62 | AC_OUTPUT | 67 | AC_OUTPUT |
diff --git a/include/Makefile.am b/include/Makefile.am index c1ec36e..e0b778b 100644 --- a/include/Makefile.am +++ b/include/Makefile.am | |||
@@ -1,6 +1,7 @@ | |||
1 | nobase_include_HEADERS = \ | 1 | nobase_include_HEADERS = \ |
2 | kingate/cgi_gateway.h \ | 2 | kingate/cgi_gateway.h \ |
3 | kingate/cgi_interface.h \ | 3 | kingate/cgi_interface.h \ |
4 | kingate/fastcgi.h \ | 4 | kingate/fastcgi.h \ |
5 | kingate/exception.h \ | 5 | kingate/exception.h \ |
6 | kingate/util.h | 6 | kingate/util.h \ |
7 | kingate/plaincgi.h | ||
diff --git a/include/kingate/plaincgi.h b/include/kingate/plaincgi.h new file mode 100644 index 0000000..745839e --- a/dev/null +++ b/include/kingate/plaincgi.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef __KINGATE_PLAINCGI_H | ||
2 | #define __KINGATE_PLAINCGI_H | ||
3 | |||
4 | #include <iostream> | ||
5 | #include "kingate/cgi_interface.h" | ||
6 | |||
7 | /** | ||
8 | * @file | ||
9 | * @brief the "plain" cgi specific implementation. | ||
10 | */ | ||
11 | |||
12 | namespace kingate { | ||
13 | |||
14 | /** | ||
15 | * The implementation of the interface to the regular CGI. | ||
16 | */ | ||
17 | class plaincgi_interface : public cgi_interface { | ||
18 | public: | ||
19 | |||
20 | /** | ||
21 | */ | ||
22 | plaincgi_interface(); | ||
23 | virtual ~plaincgi_interface(); | ||
24 | |||
25 | /** | ||
26 | * @overload cgi_interface::in() | ||
27 | */ | ||
28 | istream& in() { return cin; } | ||
29 | /** | ||
30 | * @overload cgi_interface::out() | ||
31 | */ | ||
32 | ostream& out() { return cout; } | ||
33 | /** | ||
34 | * @overload cgi_interface::out() | ||
35 | */ | ||
36 | ostream& err() { return cerr; } | ||
37 | }; | ||
38 | |||
39 | } | ||
40 | |||
41 | #endif /* __KINGATE_PLAINCGI_H */ | ||
42 | /* | ||
43 | * vim:set ft=cpp: | ||
44 | */ | ||
diff --git a/kingate-plaincgi.pc.in b/kingate-plaincgi.pc.in new file mode 100644 index 0000000..deb8e9d --- a/dev/null +++ b/kingate-plaincgi.pc.in | |||
@@ -0,0 +1,11 @@ | |||
1 | prefix=@prefix@ | ||
2 | exec_prefix=@exec_prefix@ | ||
3 | libdir=@libdir@ | ||
4 | includedir=@includedir@ | ||
5 | |||
6 | Name: kingate-plaincgi | ||
7 | Description: plain cgi implementation of kingate interface | ||
8 | Version: @VERSION@ | ||
9 | Requires: kingate = @VERSION@ | ||
10 | Libs: -L${libdir} -lkingate-plaincgi | ||
11 | Cflags: -I${includedir} | ||
diff --git a/src/Makefile.am b/src/Makefile.am index 8a5447b..e5c6778 100644 --- a/src/Makefile.am +++ b/src/Makefile.am | |||
@@ -1,15 +1,25 @@ | |||
1 | lib_LTLIBRARIES = libkingate.la libkingate-fcgi.la | 1 | lib_LTLIBRARIES = libkingate.la libkingate-plaincgi.la |
2 | |||
3 | if HAVE_FCGI | ||
4 | lib_LTLIBRARIES += libkingate-fcgi.la | ||
5 | endif | ||
2 | 6 | ||
3 | INCLUDES = -I${top_srcdir}/include | 7 | INCLUDES = -I${top_srcdir}/include |
4 | AM_CXXFLAGS = ${KONFORKA_CFLAGS} | 8 | AM_CXXFLAGS = ${KONFORKA_CFLAGS} |
5 | LDADD = ${KONFORKA_LIBS} | 9 | LDADD = ${KONFORKA_LIBS} |
6 | 10 | ||
7 | libkingate_la_SOURCES = \ | 11 | libkingate_la_SOURCES = \ |
8 | cgi_gateway.cc \ | 12 | cgi_gateway.cc \ |
9 | cgi_interface.cc \ | 13 | cgi_interface.cc \ |
10 | util.cc | 14 | util.cc |
11 | libkingate_la_LDFLAGS = -version-info 1:0:0 | 15 | libkingate_la_LDFLAGS = -version-info 1:0:0 |
12 | 16 | ||
13 | libkingate_fcgi_la_SOURCES = \ | 17 | libkingate_fcgi_la_SOURCES = \ |
14 | fastcgi.cc | 18 | fastcgi.cc |
15 | libkingate_fcgi_la_LDFLAGS = -version-info 1:0:0 | 19 | libkingate_fcgi_la_LDFLAGS = -version-info 1:0:0 |
20 | |||
21 | libkingate_plaincgi_la_SOURCES = \ | ||
22 | plaincgi.cc | ||
23 | libkingate_plaincgi_la_LDFLAGS = -version-info 1:0:0 | ||
24 | |||
25 | EXTRA_DIST = ${libkingate_fcgi_la_SOURCES} | ||
diff --git a/src/fastcgi.cc b/src/fastcgi.cc index 7484449..6285370 100644 --- a/src/fastcgi.cc +++ b/src/fastcgi.cc | |||
@@ -40,17 +40,16 @@ namespace kingate { | |||
40 | : sin(&sbin), sout(&sbout), serr(&sberr) { | 40 | : sin(&sbin), sout(&sbout), serr(&sberr) { |
41 | if( FCGX_InitRequest(&request,s.sock,f) ) | 41 | if( FCGX_InitRequest(&request,s.sock,f) ) |
42 | throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); | 42 | throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); |
43 | if( FCGX_Accept_r(&request) ) | 43 | if( FCGX_Accept_r(&request) ) |
44 | throw exception(CODEPOINT,"failed to FCGX_Accept_r()"); | 44 | throw exception(CODEPOINT,"failed to FCGX_Accept_r()"); |
45 | sbin.attach(request.in); | 45 | sbin.attach(request.in); |
46 | sbout.attach(request.out); | 46 | sbout.attach(request.out); |
47 | sberr.attach(request.err); | 47 | sberr.attach(request.err); |
48 | metavars.clear(); // XXX: redundant. | ||
49 | for(char **p = request.envp; *p; p++) { | 48 | for(char **p = request.envp; *p; p++) { |
50 | const char *e = strchr(*p,'='); | 49 | const char *e = strchr(*p,'='); |
51 | if(!e){ | 50 | if(!e){ |
52 | // XXX: check if we have it already? | 51 | // XXX: check if we have it already? |
53 | metavars[*p] = string(0); | 52 | metavars[*p] = string(0); |
54 | }else{ | 53 | }else{ |
55 | int l = e-*p; e++; | 54 | int l = e-*p; e++; |
56 | // XXX: check if we have it already? | 55 | // XXX: check if we have it already? |
diff --git a/src/plaincgi.cc b/src/plaincgi.cc new file mode 100644 index 0000000..6934748 --- a/dev/null +++ b/src/plaincgi.cc | |||
@@ -0,0 +1,27 @@ | |||
1 | #include <unistd.h> | ||
2 | #include <sys/types.h> | ||
3 | #include <sys/stat.h> | ||
4 | #include "kingate/plaincgi.h" | ||
5 | #include "kingate/exception.h" | ||
6 | |||
7 | namespace kingate { | ||
8 | |||
9 | plaincgi_interface::plaincgi_interface() { | ||
10 | for(char **p = environ; *p; p++) { | ||
11 | const char *e = strchr(*p,'='); | ||
12 | if(!e){ | ||
13 | // XXX: check if we have it already? | ||
14 | metavars[*p] = string(0); | ||
15 | }else{ | ||
16 | int l = e-*p; e++; | ||
17 | // XXX: check if we have it already? | ||
18 | metavars[string(*p,l)]=e; | ||
19 | } | ||
20 | } | ||
21 | } | ||
22 | plaincgi_interface::~plaincgi_interface() { | ||
23 | cout.flush(); | ||
24 | cerr.flush(); | ||
25 | } | ||
26 | |||
27 | } | ||