-rw-r--r-- | src/Makefile.am | 12 | ||||
-rw-r--r-- | src/fastcgi.cc | 1 | ||||
-rw-r--r-- | src/plaincgi.cc | 27 |
3 files changed, 38 insertions, 2 deletions
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 @@ -24,44 +24,43 @@ namespace kingate { 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(); + } + +} |