summaryrefslogtreecommitdiffabout
path: root/src
Unidiff
Diffstat (limited to 'src') (more/less context) (ignore whitespace changes)
-rw-r--r--src/Makefile.am12
-rw-r--r--src/fastcgi.cc1
-rw-r--r--src/plaincgi.cc27
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 @@
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
@@ -36,25 +36,24 @@ namespace kingate {
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 }
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}