summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2005-02-13 14:02:29 (UTC)
committer Michael Krelin <hacker@klever.net>2005-02-13 14:02:29 (UTC)
commit4fa4a0071ef9a04c02f8934b2e1d3b7628a65c80 (patch) (unidiff)
tree47f2e6866ab812985ae9e6adbcea8bb785fa0403
parentff4b919683537625f693eedf53006364d0f8444d (diff)
downloadkingate-4fa4a0071ef9a04c02f8934b2e1d3b7628a65c80.zip
kingate-4fa4a0071ef9a04c02f8934b2e1d3b7628a65c80.tar.gz
kingate-4fa4a0071ef9a04c02f8934b2e1d3b7628a65c80.tar.bz2
1. Support for 'plain' CGI
2. Made fastcgi support optional 3. bumped version to 0.0.1 4. doxygen documentation target 'dox' is not built for 'all' now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am22
-rw-r--r--configure.ac25
-rw-r--r--include/Makefile.am3
-rw-r--r--include/kingate/plaincgi.h44
-rw-r--r--kingate-plaincgi.pc.in11
-rw-r--r--src/Makefile.am12
-rw-r--r--src/fastcgi.cc1
-rw-r--r--src/plaincgi.cc27
9 files changed, 121 insertions, 25 deletions
diff --git a/.gitignore b/.gitignore
index 02145e3..1997933 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,23 +1,24 @@
1configure 1configure
2Makefile.in 2Makefile.in
3kingate.pc 3kingate.pc
4Doxyfile 4Doxyfile
5config.log 5config.log
6depcomp 6depcomp
7kingate-fcgi.pc 7kingate-fcgi.pc
8config.guess 8config.guess
9config.h 9config.h
10ltmain.sh 10ltmain.sh
11config.sub 11config.sub
12INSTALL 12INSTALL
13Makefile 13Makefile
14config.status 14config.status
15stamp-h1 15stamp-h1
16config.h.in 16config.h.in
17libtool 17libtool
18autom4te.cache 18autom4te.cache
19missing 19missing
20aclocal.m4 20aclocal.m4
21install-sh 21install-sh
22NEWS 22NEWS
23doxydox 23doxydox
24kingate-plaincgi.pc
diff --git a/Makefile.am b/Makefile.am
index 9833732..3e9f0f1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,27 +1,25 @@
1SUBDIRS=include src 1SUBDIRS=include src
2EXTRA_DIST= NEWS NEWS.xml NEWS.xsl 2EXTRA_DIST= NEWS NEWS.xml NEWS.xsl
3 3
4DISTCHECK_CONFIGURE_FLAGS=--with-pkgconfigdir=$${dc_install_base}/lib/pkgconfig 4DISTCHECK_CONFIGURE_FLAGS=--with-pkgconfigdir=$${dc_install_base}/lib/pkgconfig
5if HAVE_PKGCONFIG 5if HAVE_PKGCONFIG
6pkgconfigdir=@PKGCONFIG_DIR@ 6pkgconfigdir=@PKGCONFIG_DIR@
7pkgconfig_DATA=kingate.pc kingate-fcgi.pc 7pkgconfig_DATA=kingate.pc kingate-plaincgi.pc
8if HAVE_FCGI
9pkgconfig_DATA += kingate-fcgi.pc
10endif
8endif 11endif
9 12
10LOCAL_TARGETS= 13all-local: NEWS
11if HAVE_DOXYGEN 14if HAVE_DOXYGEN
12LOCAL_TARGETS+=doxygen 15clean-local:
16 rm -rf doxydox
13endif 17endif
14 18
15all-local: NEWS $(addprefix all-lota-,${LOCAL_TARGETS})
16clean-local: $(addprefix clean-lota-,${LOCAL_TARGETS})
17
18NEWS: NEWS.xsl NEWS.xml 19NEWS: NEWS.xsl NEWS.xml
19 ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml 20 ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml
20 21
21all-lota-doxygen: doxydox/built 22if HAVE_DOXYGEN
22doxydox/built: $(wildcard ${top_srcdir}/include/kingate/*.h) 23dox:
23 ${DOXYGEN} 24 ${DOXYGEN}
24 touch $@ 25endif
25
26clean-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,62 +1,67 @@
1AC_INIT([kingate], [0.0], [kingate-bugs@klever.net]) 1AC_INIT([kingate], [0.0.1], [kingate-bugs@klever.net])
2AC_CONFIG_SRCDIR([include/kingate/cgi_gateway.h]) 2AC_CONFIG_SRCDIR([include/kingate/cgi_gateway.h])
3AC_CONFIG_HEADER([config.h]) 3AC_CONFIG_HEADER([config.h])
4AM_INIT_AUTOMAKE([dist-bzip2]) 4AM_INIT_AUTOMAKE([dist-bzip2])
5 5
6AC_PROG_INSTALL 6AC_PROG_INSTALL
7AC_PROG_AWK 7AC_PROG_AWK
8AC_PROG_CXX 8AC_PROG_CXX
9AC_PROG_CC 9AC_PROG_CC
10AC_PROG_LIBTOOL 10AC_PROG_LIBTOOL
11 11
12AC_HEADER_STDC 12AC_HEADER_STDC
13AC_CHECK_HEADERS([sys/types.h sys/stat.h]) 13AC_CHECK_HEADERS([sys/types.h sys/stat.h])
14 14
15HAVE_FCGI=false
15AC_LANG_PUSH(C++) 16AC_LANG_PUSH(C++)
16AC_CHECK_HEADERS([fcgio.h],,[ 17AC_CHECK_HEADERS([fcgio.h],[
17 exit 1 18 AC_CHECK_LIB(fcgi,FCGX_Init,[
18]) 19 LIBS="-lfcgi ${LIBS}"
19AC_CHECK_LIB(fcgi,FCGX_Init,,[ 20 AC_CHECK_LIB([fcgi++],[main],[
20 exit 1 21 LIBS="-lfcgi++ ${LIBS}"
21]) 22 HAVE_FCGI=true
22AC_CHECK_LIB([fcgi++],[main],,[ 23 ])
23 exit 1 24 ])
24]) 25])
25AC_LANG_POP(C++) 26AC_LANG_POP(C++)
27if ! ${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])
29fi
30AM_CONDITIONAL([HAVE_FCGI],[${HAVE_FCGI}])
26 31
27AC_C_CONST 32AC_C_CONST
28 33
29AC_FUNC_MALLOC 34AC_FUNC_MALLOC
30AC_FUNC_REALLOC 35AC_FUNC_REALLOC
31 36
32AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) 37AC_PATH_PROG([XSLTPROC],[xsltproc],[true])
33 38
34AC_WITH_PKGCONFIG 39AC_WITH_PKGCONFIG
35 40
36PKG_CHECK_MODULES([KONFORKA],[konforka],,[ 41PKG_CHECK_MODULES([KONFORKA],[konforka],,[
37 AC_MSG_ERROR([no konforka library found. get one from http://kin.klever.net/konforka/]) 42 AC_MSG_ERROR([no konforka library found. get one from http://kin.klever.net/konforka/])
38]) 43])
39 44
40WANT_DOXYGEN="yes" 45WANT_DOXYGEN="yes"
41AC_ARG_ENABLE([doxygen], 46AC_ARG_ENABLE([doxygen],
42 AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), 47 AC_HELP_STRING([--disable-doxygen],[do not generate documentation]),
43 [ 48 [
44 test "${enableval}" = "no" && WANT_DOXYGEN="no" 49 test "${enableval}" = "no" && WANT_DOXYGEN="no"
45 ] 50 ]
46) 51)
47if test "${WANT_DOXYGEN}" = "yes" ; then 52if test "${WANT_DOXYGEN}" = "yes" ; then
48 AC_WITH_DOXYGEN 53 AC_WITH_DOXYGEN
49 AC_WITH_DOT 54 AC_WITH_DOT
50else 55else
51 AM_CONDITIONAL([HAVE_DOXYGEN],[false]) 56 AM_CONDITIONAL([HAVE_DOXYGEN],[false])
52 AM_CONDITIONAL([HAVE_DOT],[false]) 57 AM_CONDITIONAL([HAVE_DOT],[false])
53fi 58fi
54 59
55AC_CONFIG_FILES([ 60AC_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])
62AC_OUTPUT 67AC_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 @@
1nobase_include_HEADERS = \ 1nobase_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
12namespace 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 @@
1prefix=@prefix@
2exec_prefix=@exec_prefix@
3libdir=@libdir@
4includedir=@includedir@
5
6Name: kingate-plaincgi
7Description: plain cgi implementation of kingate interface
8Version: @VERSION@
9Requires: kingate = @VERSION@
10Libs: -L${libdir} -lkingate-plaincgi
11Cflags: -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 @@
1lib_LTLIBRARIES = libkingate.la libkingate-fcgi.la 1lib_LTLIBRARIES = libkingate.la libkingate-plaincgi.la
2
3if HAVE_FCGI
4lib_LTLIBRARIES += libkingate-fcgi.la
5endif
2 6
3INCLUDES = -I${top_srcdir}/include 7INCLUDES = -I${top_srcdir}/include
4AM_CXXFLAGS = ${KONFORKA_CFLAGS} 8AM_CXXFLAGS = ${KONFORKA_CFLAGS}
5LDADD = ${KONFORKA_LIBS} 9LDADD = ${KONFORKA_LIBS}
6 10
7libkingate_la_SOURCES = \ 11libkingate_la_SOURCES = \
8 cgi_gateway.cc \ 12 cgi_gateway.cc \
9 cgi_interface.cc \ 13 cgi_interface.cc \
10 util.cc 14 util.cc
11libkingate_la_LDFLAGS = -version-info 1:0:0 15libkingate_la_LDFLAGS = -version-info 1:0:0
12 16
13libkingate_fcgi_la_SOURCES = \ 17libkingate_fcgi_la_SOURCES = \
14 fastcgi.cc 18 fastcgi.cc
15libkingate_fcgi_la_LDFLAGS = -version-info 1:0:0 19libkingate_fcgi_la_LDFLAGS = -version-info 1:0:0
20
21libkingate_plaincgi_la_SOURCES = \
22 plaincgi.cc
23libkingate_plaincgi_la_LDFLAGS = -version-info 1:0:0
24
25EXTRA_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
@@ -24,44 +24,43 @@ namespace kingate {
24 throw exception(CODEPOINT,"failed to chmod()"); 24 throw exception(CODEPOINT,"failed to chmod()");
25 } 25 }
26 fcgi_socket::fcgi_socket(int s) 26 fcgi_socket::fcgi_socket(int s)
27 : sock(0) { 27 : sock(0) {
28 if(!_initialized) { 28 if(!_initialized) {
29 if( FCGX_Init() ) 29 if( FCGX_Init() )
30 throw exception(CODEPOINT,"failed to FCGX_Init()"); 30 throw exception(CODEPOINT,"failed to FCGX_Init()");
31 _initialized = true; 31 _initialized = true;
32 } 32 }
33 } 33 }
34 fcgi_socket::~fcgi_socket() { 34 fcgi_socket::~fcgi_socket() {
35 if(sock>=0) 35 if(sock>=0)
36 close(sock); 36 close(sock);
37 } 37 }
38 38
39 fcgi_interface::fcgi_interface(fcgi_socket& s,int f) 39 fcgi_interface::fcgi_interface(fcgi_socket& s,int f)
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?
57 metavars[string(*p,l)]=e; 56 metavars[string(*p,l)]=e;
58 } 57 }
59 } 58 }
60 } 59 }
61 fcgi_interface::~fcgi_interface() { 60 fcgi_interface::~fcgi_interface() {
62 sout.flush(); 61 sout.flush();
63 serr.flush(); 62 serr.flush();
64 FCGX_Finish_r(&request); 63 FCGX_Finish_r(&request);
65 } 64 }
66 65
67} 66}
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
7namespace 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}