author | Michael Krelin <hacker@klever.net> | 2005-02-13 14:02:29 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2005-02-13 14:02:29 (UTC) |
commit | 4fa4a0071ef9a04c02f8934b2e1d3b7628a65c80 (patch) (side-by-side diff) | |
tree | 47f2e6866ab812985ae9e6adbcea8bb785fa0403 | |
parent | ff4b919683537625f693eedf53006364d0f8444d (diff) | |
download | kingate-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
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile.am | 22 | ||||
-rw-r--r-- | configure.ac | 25 | ||||
-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, 121 insertions, 25 deletions
@@ -1,23 +1,24 @@ configure Makefile.in kingate.pc Doxyfile config.log depcomp kingate-fcgi.pc config.guess config.h ltmain.sh config.sub INSTALL Makefile config.status stamp-h1 config.h.in libtool autom4te.cache missing aclocal.m4 install-sh NEWS doxydox +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 @@ SUBDIRS=include src EXTRA_DIST= NEWS NEWS.xml NEWS.xsl DISTCHECK_CONFIGURE_FLAGS=--with-pkgconfigdir=$${dc_install_base}/lib/pkgconfig if HAVE_PKGCONFIG pkgconfigdir=@PKGCONFIG_DIR@ -pkgconfig_DATA=kingate.pc kingate-fcgi.pc +pkgconfig_DATA=kingate.pc kingate-plaincgi.pc +if HAVE_FCGI +pkgconfig_DATA += kingate-fcgi.pc +endif endif -LOCAL_TARGETS= +all-local: NEWS if HAVE_DOXYGEN -LOCAL_TARGETS+=doxygen +clean-local: + rm -rf doxydox endif -all-local: NEWS $(addprefix all-lota-,${LOCAL_TARGETS}) -clean-local: $(addprefix clean-lota-,${LOCAL_TARGETS}) - NEWS: NEWS.xsl NEWS.xml ${XSLTPROC} -o $@ NEWS.xsl NEWS.xml -all-lota-doxygen: doxydox/built -doxydox/built: $(wildcard ${top_srcdir}/include/kingate/*.h) +if HAVE_DOXYGEN +dox: ${DOXYGEN} - touch $@ - -clean-lota-doxygen: - rm -rf doxydox +endif diff --git a/configure.ac b/configure.ac index 109eddf..5ae7b27 100644 --- a/configure.ac +++ b/configure.ac @@ -1,62 +1,67 @@ -AC_INIT([kingate], [0.0], [kingate-bugs@klever.net]) +AC_INIT([kingate], [0.0.1], [kingate-bugs@klever.net]) AC_CONFIG_SRCDIR([include/kingate/cgi_gateway.h]) AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE([dist-bzip2]) AC_PROG_INSTALL AC_PROG_AWK AC_PROG_CXX AC_PROG_CC AC_PROG_LIBTOOL AC_HEADER_STDC AC_CHECK_HEADERS([sys/types.h sys/stat.h]) +HAVE_FCGI=false AC_LANG_PUSH(C++) -AC_CHECK_HEADERS([fcgio.h],,[ - exit 1 -]) -AC_CHECK_LIB(fcgi,FCGX_Init,,[ - exit 1 -]) -AC_CHECK_LIB([fcgi++],[main],,[ - exit 1 +AC_CHECK_HEADERS([fcgio.h],[ + AC_CHECK_LIB(fcgi,FCGX_Init,[ + LIBS="-lfcgi ${LIBS}" + AC_CHECK_LIB([fcgi++],[main],[ + LIBS="-lfcgi++ ${LIBS}" + HAVE_FCGI=true + ]) + ]) ]) AC_LANG_POP(C++) +if ! ${HAVE_FCGI} ; then + AC_MSG_NOTICE([no FastCGI development kit found. It is highly recommnded that you get one. Meanwhile we will proceed without FastCGI support]) +fi +AM_CONDITIONAL([HAVE_FCGI],[${HAVE_FCGI}]) AC_C_CONST AC_FUNC_MALLOC AC_FUNC_REALLOC AC_PATH_PROG([XSLTPROC],[xsltproc],[true]) AC_WITH_PKGCONFIG PKG_CHECK_MODULES([KONFORKA],[konforka],,[ AC_MSG_ERROR([no konforka library found. get one from http://kin.klever.net/konforka/]) ]) WANT_DOXYGEN="yes" AC_ARG_ENABLE([doxygen], AC_HELP_STRING([--disable-doxygen],[do not generate documentation]), [ test "${enableval}" = "no" && WANT_DOXYGEN="no" ] ) if test "${WANT_DOXYGEN}" = "yes" ; then AC_WITH_DOXYGEN AC_WITH_DOT else AM_CONDITIONAL([HAVE_DOXYGEN],[false]) AM_CONDITIONAL([HAVE_DOT],[false]) fi AC_CONFIG_FILES([ Makefile - kingate.pc kingate-fcgi.pc + kingate.pc kingate-fcgi.pc kingate-plaincgi.pc Doxyfile include/Makefile src/Makefile ]) 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 @@ nobase_include_HEADERS = \ kingate/cgi_gateway.h \ kingate/cgi_interface.h \ kingate/fastcgi.h \ kingate/exception.h \ - kingate/util.h + kingate/util.h \ + 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 @@ +#ifndef __KINGATE_PLAINCGI_H +#define __KINGATE_PLAINCGI_H + +#include <iostream> +#include "kingate/cgi_interface.h" + +/** + * @file + * @brief the "plain" cgi specific implementation. + */ + +namespace kingate { + + /** + * The implementation of the interface to the regular CGI. + */ + class plaincgi_interface : public cgi_interface { + public: + + /** + */ + plaincgi_interface(); + virtual ~plaincgi_interface(); + + /** + * @overload cgi_interface::in() + */ + istream& in() { return cin; } + /** + * @overload cgi_interface::out() + */ + ostream& out() { return cout; } + /** + * @overload cgi_interface::out() + */ + ostream& err() { return cerr; } + }; + +} + +#endif /* __KINGATE_PLAINCGI_H */ +/* + * vim:set ft=cpp: + */ 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 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +includedir=@includedir@ + +Name: kingate-plaincgi +Description: plain cgi implementation of kingate interface +Version: @VERSION@ +Requires: kingate = @VERSION@ +Libs: -L${libdir} -lkingate-plaincgi +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 @@ -lib_LTLIBRARIES = libkingate.la libkingate-fcgi.la +lib_LTLIBRARIES = libkingate.la libkingate-plaincgi.la + +if HAVE_FCGI +lib_LTLIBRARIES += libkingate-fcgi.la +endif INCLUDES = -I${top_srcdir}/include AM_CXXFLAGS = ${KONFORKA_CFLAGS} LDADD = ${KONFORKA_LIBS} libkingate_la_SOURCES = \ cgi_gateway.cc \ cgi_interface.cc \ util.cc libkingate_la_LDFLAGS = -version-info 1:0:0 libkingate_fcgi_la_SOURCES = \ fastcgi.cc libkingate_fcgi_la_LDFLAGS = -version-info 1:0:0 + +libkingate_plaincgi_la_SOURCES = \ + plaincgi.cc +libkingate_plaincgi_la_LDFLAGS = -version-info 1:0:0 + +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 @@ -1,67 +1,66 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include "kingate/fastcgi.h" #include "kingate/exception.h" namespace kingate { bool fcgi_socket::_initialized = false; fcgi_socket::fcgi_socket(const char *s,int bl) : sock(-1) { if(!_initialized) { if( FCGX_Init() ) throw exception(CODEPOINT,"failed to FCGX_Init()"); _initialized = true; } sock = FCGX_OpenSocket(s,bl); if(sock<0) throw exception(CODEPOINT,"failed to FCGX_OpenSocket("); // TODO: check if there is a ':', not if it starts with ':' if(*s != ':') if(chmod(s,0777)) // XXX: configurable. throw exception(CODEPOINT,"failed to chmod()"); } fcgi_socket::fcgi_socket(int s) : sock(0) { if(!_initialized) { if( FCGX_Init() ) throw exception(CODEPOINT,"failed to FCGX_Init()"); _initialized = true; } } fcgi_socket::~fcgi_socket() { if(sock>=0) close(sock); } fcgi_interface::fcgi_interface(fcgi_socket& s,int f) : sin(&sbin), sout(&sbout), serr(&sberr) { if( FCGX_InitRequest(&request,s.sock,f) ) throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); if( FCGX_Accept_r(&request) ) throw exception(CODEPOINT,"failed to FCGX_Accept_r()"); sbin.attach(request.in); sbout.attach(request.out); sberr.attach(request.err); - metavars.clear(); // XXX: redundant. for(char **p = request.envp; *p; p++) { const char *e = strchr(*p,'='); if(!e){ // XXX: check if we have it already? metavars[*p] = string(0); }else{ int l = e-*p; e++; // XXX: check if we have it already? metavars[string(*p,l)]=e; } } } fcgi_interface::~fcgi_interface() { sout.flush(); serr.flush(); FCGX_Finish_r(&request); } } 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 @@ +#include <unistd.h> +#include <sys/types.h> +#include <sys/stat.h> +#include "kingate/plaincgi.h" +#include "kingate/exception.h" + +namespace kingate { + + plaincgi_interface::plaincgi_interface() { + for(char **p = environ; *p; p++) { + const char *e = strchr(*p,'='); + if(!e){ + // XXX: check if we have it already? + metavars[*p] = string(0); + }else{ + int l = e-*p; e++; + // XXX: check if we have it already? + metavars[string(*p,l)]=e; + } + } + } + plaincgi_interface::~plaincgi_interface() { + cout.flush(); + cerr.flush(); + } + +} |