summaryrefslogtreecommitdiffabout
authorMichael Krelin @devel <hacker@klever.net>2009-03-11 20:05:54 (UTC)
committer Michael Krelin @devel <hacker@klever.net>2009-03-11 20:05:54 (UTC)
commitf1eed2b661d43b7e39e1aea16d9453a538206564 (patch) (side-by-side diff)
tree7f340d0294baecd1e8719026f16b71000ca4712d
parentf4db51309c0333434d9ee96bc52593dacab04c69 (diff)
downloadkingate-f1eed2b661d43b7e39e1aea16d9453a538206564.zip
kingate-f1eed2b661d43b7e39e1aea16d9453a538206564.tar.gz
kingate-f1eed2b661d43b7e39e1aea16d9453a538206564.tar.bz2
missing headers for gcc 4.3
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/fastcgi.cc1
-rw-r--r--src/plaincgi.cc1
-rw-r--r--src/util.cc2
3 files changed, 4 insertions, 0 deletions
diff --git a/src/fastcgi.cc b/src/fastcgi.cc
index 63b59f8..641ae46 100644
--- a/src/fastcgi.cc
+++ b/src/fastcgi.cc
@@ -1,51 +1,52 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <cstring>
#include <fastcgi.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;
}
if(!s) {
sock = FCGI_LISTENSOCK_FILENO;
}else{
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)
: sbin(buf_sbin,sizeof(buf_sbin)),
sbout(buf_sbout,sizeof(buf_sbout)),
sberr(buf_sberr,sizeof(buf_sberr)),
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) )
diff --git a/src/plaincgi.cc b/src/plaincgi.cc
index 1cb7dc6..3a82d33 100644
--- a/src/plaincgi.cc
+++ b/src/plaincgi.cc
@@ -1,32 +1,33 @@
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <cstring>
#include "kingate/plaincgi.h"
#include "kingate/exception.h"
#include "config.h"
#if !HAVE_DECL_ENVIRON
extern char **environ;
#endif /* HAVE_DECL_ENVIRON */
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();
}
}
diff --git a/src/util.cc b/src/util.cc
index 48e486a..82a4a0a 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -1,48 +1,50 @@
+#include <cstdlib>
+#include <cstring>
#include "kingate/util.h"
#include "kingate/exception.h"
namespace kingate {
static const char *safeChars =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789"
"_-" ;
string url_encode(const string& str) {
string rv = str;
string::size_type screwed = 0;
for(;;) {
screwed = rv.find_first_not_of(safeChars,screwed);
if(screwed == string::npos)
break;
while(screwed<rv.length() && !strchr(safeChars,rv.at(screwed))) {
char danger = rv.at(screwed);
if(danger==' ') {
rv.replace(screwed++,1,1,'+');
}else{
static char tmp[4] = {'%',0,0,0};
snprintf(&tmp[1],3,"%02X",0xFF&(int)danger);
rv.replace(screwed,1,tmp,3);
screwed+=3;
}
}
}
return rv;
}
string url_decode(const string& str) {
string rv = str;
string::size_type unscrewed = 0;
for(;;) {
unscrewed = rv.find_first_of("%+",unscrewed);
if(unscrewed == string::npos)
break;
if(rv.at(unscrewed)=='+') {
rv.replace(unscrewed++,1,1,' ');
}else{
if((rv.length()-unscrewed)<3)
throw exception(CODEPOINT,"incorrectly escaped string");
// XXX: ensure it's hex?
int danger = strtol(rv.substr(unscrewed+1,2).c_str(),NULL,16);
rv.replace(unscrewed,3,1,danger);
unscrewed++;