summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/cgi_gateway.cc1
-rw-r--r--src/fastcgi.cc1
-rw-r--r--src/plaincgi.cc1
-rw-r--r--src/util.cc1
4 files changed, 4 insertions, 0 deletions
diff --git a/src/cgi_gateway.cc b/src/cgi_gateway.cc
index a2681aa..3763654 100644
--- a/src/cgi_gateway.cc
+++ b/src/cgi_gateway.cc
@@ -1,27 +1,28 @@
1#include <errno.h> 1#include <errno.h>
2#include <ctype.h> 2#include <ctype.h>
3#include <sstream> 3#include <sstream>
4#include <cstring>
4#include "kingate/cgi_gateway.h" 5#include "kingate/cgi_gateway.h"
5#include "kingate/util.h" 6#include "kingate/util.h"
6#include "kingate/exception.h" 7#include "kingate/exception.h"
7#include "config.h" 8#include "config.h"
8#ifdef HAVE_MIMETIC 9#ifdef HAVE_MIMETIC
9# include <mimetic/mimeentity.h> 10# include <mimetic/mimeentity.h>
10# include <mimetic/parser/itparser.h> 11# include <mimetic/parser/itparser.h>
11#endif /* HAVE_MIMETIC */ 12#endif /* HAVE_MIMETIC */
12 13
13namespace kingate { 14namespace kingate {
14 15
15#ifdef HAVE_MIMETIC 16#ifdef HAVE_MIMETIC
16 using mimetic::MimeEntity; 17 using mimetic::MimeEntity;
17 18
18 struct TornMimeEntity : public MimeEntity { 19 struct TornMimeEntity : public MimeEntity {
19 typedef istreambuf_iterator<char> it_type; 20 typedef istreambuf_iterator<char> it_type;
20 typedef it_type::iterator_category it_cat; 21 typedef it_type::iterator_category it_cat;
21 struct IParser : public mimetic::IteratorParser<it_type,it_cat> { 22 struct IParser : public mimetic::IteratorParser<it_type,it_cat> {
22 typedef mimetic::IteratorParser<it_type,it_cat> BT; 23 typedef mimetic::IteratorParser<it_type,it_cat> BT;
23 IParser(MimeEntity& me) 24 IParser(MimeEntity& me)
24 : BT::IteratorParser<it_type,it_cat>(me) { } 25 : BT::IteratorParser<it_type,it_cat>(me) { }
25 void loadHeader(it_type bit,it_type eit) { 26 void loadHeader(it_type bit,it_type eit) {
26 m_bit = bit; m_eit = eit; 27 m_bit = bit; m_eit = eit;
27 BT::loadHeader(); 28 BT::loadHeader();
diff --git a/src/fastcgi.cc b/src/fastcgi.cc
index 8b7668c..5a6c081 100644
--- a/src/fastcgi.cc
+++ b/src/fastcgi.cc
@@ -1,27 +1,28 @@
1#include <unistd.h> 1#include <unistd.h>
2#include <sys/types.h> 2#include <sys/types.h>
3#include <sys/stat.h> 3#include <sys/stat.h>
4#include <cstring>
4#include "kingate/fastcgi.h" 5#include "kingate/fastcgi.h"
5#include "kingate/exception.h" 6#include "kingate/exception.h"
6 7
7namespace kingate { 8namespace kingate {
8 9
9 bool fcgi_socket::_initialized = false; 10 bool fcgi_socket::_initialized = false;
10 11
11 fcgi_socket::fcgi_socket(const char *s,int bl) 12 fcgi_socket::fcgi_socket(const char *s,int bl)
12 : sock(-1) { 13 : sock(-1) {
13 if(!_initialized) { 14 if(!_initialized) {
14 if( FCGX_Init() ) 15 if( FCGX_Init() )
15 throw exception(CODEPOINT,"failed to FCGX_Init()"); 16 throw exception(CODEPOINT,"failed to FCGX_Init()");
16 _initialized = true; 17 _initialized = true;
17 } 18 }
18 sock = FCGX_OpenSocket(s,bl); 19 sock = FCGX_OpenSocket(s,bl);
19 if(sock<0) 20 if(sock<0)
20 throw exception(CODEPOINT,"failed to FCGX_OpenSocket("); 21 throw exception(CODEPOINT,"failed to FCGX_OpenSocket(");
21 // TODO: check if there is a ':', not if it starts with ':' 22 // TODO: check if there is a ':', not if it starts with ':'
22 if(*s != ':') 23 if(*s != ':')
23 if(chmod(s,0777)) // XXX: configurable. 24 if(chmod(s,0777)) // XXX: configurable.
24 throw exception(CODEPOINT,"failed to chmod()"); 25 throw exception(CODEPOINT,"failed to chmod()");
25 } 26 }
26 fcgi_socket::fcgi_socket(int s) 27 fcgi_socket::fcgi_socket(int s)
27 : sock(0) { 28 : sock(0) {
diff --git a/src/plaincgi.cc b/src/plaincgi.cc
index 1cb7dc6..3a82d33 100644
--- a/src/plaincgi.cc
+++ b/src/plaincgi.cc
@@ -1,27 +1,28 @@
1#include <unistd.h> 1#include <unistd.h>
2#include <sys/types.h> 2#include <sys/types.h>
3#include <sys/stat.h> 3#include <sys/stat.h>
4#include <cstring>
4#include "kingate/plaincgi.h" 5#include "kingate/plaincgi.h"
5#include "kingate/exception.h" 6#include "kingate/exception.h"
6#include "config.h" 7#include "config.h"
7 8
8#if !HAVE_DECL_ENVIRON 9#if !HAVE_DECL_ENVIRON
9extern char **environ; 10extern char **environ;
10#endif /* HAVE_DECL_ENVIRON */ 11#endif /* HAVE_DECL_ENVIRON */
11 12
12namespace kingate { 13namespace kingate {
13 14
14 plaincgi_interface::plaincgi_interface() { 15 plaincgi_interface::plaincgi_interface() {
15 for(char **p = environ; *p; p++) { 16 for(char **p = environ; *p; p++) {
16 const char *e = strchr(*p,'='); 17 const char *e = strchr(*p,'=');
17 if(!e){ 18 if(!e){
18 // XXX: check if we have it already? 19 // XXX: check if we have it already?
19 metavars[*p] = string(0); 20 metavars[*p] = string(0);
20 }else{ 21 }else{
21 int l = e-*p; e++; 22 int l = e-*p; e++;
22 // XXX: check if we have it already? 23 // XXX: check if we have it already?
23 metavars[string(*p,l)]=e; 24 metavars[string(*p,l)]=e;
24 } 25 }
25 } 26 }
26 } 27 }
27 plaincgi_interface::~plaincgi_interface() { 28 plaincgi_interface::~plaincgi_interface() {
diff --git a/src/util.cc b/src/util.cc
index 48e486a..76e684f 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -1,24 +1,25 @@
1#include <cstring>
1#include "kingate/util.h" 2#include "kingate/util.h"
2#include "kingate/exception.h" 3#include "kingate/exception.h"
3 4
4namespace kingate { 5namespace kingate {
5 6
6 static const char *safeChars = 7 static const char *safeChars =
7 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 8 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
8 "abcdefghijklmnopqrstuvwxyz" 9 "abcdefghijklmnopqrstuvwxyz"
9 "0123456789" 10 "0123456789"
10 "_-" ; 11 "_-" ;
11 12
12 string url_encode(const string& str) { 13 string url_encode(const string& str) {
13 string rv = str; 14 string rv = str;
14 string::size_type screwed = 0; 15 string::size_type screwed = 0;
15 for(;;) { 16 for(;;) {
16 screwed = rv.find_first_not_of(safeChars,screwed); 17 screwed = rv.find_first_not_of(safeChars,screwed);
17 if(screwed == string::npos) 18 if(screwed == string::npos)
18 break; 19 break;
19 while(screwed<rv.length() && !strchr(safeChars,rv.at(screwed))) { 20 while(screwed<rv.length() && !strchr(safeChars,rv.at(screwed))) {
20 char danger = rv.at(screwed); 21 char danger = rv.at(screwed);
21 if(danger==' ') { 22 if(danger==' ') {
22 rv.replace(screwed++,1,1,'+'); 23 rv.replace(screwed++,1,1,'+');
23 }else{ 24 }else{
24 static char tmp[4] = {'%',0,0,0}; 25 static char tmp[4] = {'%',0,0,0};