author | Michael 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) |
commit | f1eed2b661d43b7e39e1aea16d9453a538206564 (patch) (unidiff) | |
tree | 7f340d0294baecd1e8719026f16b71000ca4712d | |
parent | f4db51309c0333434d9ee96bc52593dacab04c69 (diff) | |
download | kingate-f1eed2b661d43b7e39e1aea16d9453a538206564.zip kingate-f1eed2b661d43b7e39e1aea16d9453a538206564.tar.gz kingate-f1eed2b661d43b7e39e1aea16d9453a538206564.tar.bz2 |
missing headers for gcc 4.3
-rw-r--r-- | src/fastcgi.cc | 1 | ||||
-rw-r--r-- | src/plaincgi.cc | 1 | ||||
-rw-r--r-- | src/util.cc | 2 |
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 @@ | |||
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 <fastcgi.h> | 5 | #include <fastcgi.h> |
5 | #include "kingate/fastcgi.h" | 6 | #include "kingate/fastcgi.h" |
6 | #include "kingate/exception.h" | 7 | #include "kingate/exception.h" |
7 | 8 | ||
8 | namespace kingate { | 9 | namespace kingate { |
9 | 10 | ||
10 | bool fcgi_socket::_initialized = false; | 11 | bool fcgi_socket::_initialized = false; |
11 | 12 | ||
12 | fcgi_socket::fcgi_socket(const char *s,int bl) | 13 | fcgi_socket::fcgi_socket(const char *s,int bl) |
13 | : sock(-1) { | 14 | : sock(-1) { |
14 | if(!_initialized) { | 15 | if(!_initialized) { |
15 | if( FCGX_Init() ) | 16 | if( FCGX_Init() ) |
16 | throw exception(CODEPOINT,"failed to FCGX_Init()"); | 17 | throw exception(CODEPOINT,"failed to FCGX_Init()"); |
17 | _initialized = true; | 18 | _initialized = true; |
18 | } | 19 | } |
19 | if(!s) { | 20 | if(!s) { |
20 | sock = FCGI_LISTENSOCK_FILENO; | 21 | sock = FCGI_LISTENSOCK_FILENO; |
21 | }else{ | 22 | }else{ |
22 | sock = FCGX_OpenSocket(s,bl); | 23 | sock = FCGX_OpenSocket(s,bl); |
23 | if(sock<0) | 24 | if(sock<0) |
24 | throw exception(CODEPOINT,"failed to FCGX_OpenSocket("); | 25 | throw exception(CODEPOINT,"failed to FCGX_OpenSocket("); |
25 | // TODO: check if there is a ':', not if it starts with ':' | 26 | // TODO: check if there is a ':', not if it starts with ':' |
26 | if(*s != ':') | 27 | if(*s != ':') |
27 | if(chmod(s,0777)) // XXX: configurable. | 28 | if(chmod(s,0777)) // XXX: configurable. |
28 | throw exception(CODEPOINT,"failed to chmod()"); | 29 | throw exception(CODEPOINT,"failed to chmod()"); |
29 | } | 30 | } |
30 | } | 31 | } |
31 | fcgi_socket::fcgi_socket(int s) | 32 | fcgi_socket::fcgi_socket(int s) |
32 | : sock(0) { | 33 | : sock(0) { |
33 | if(!_initialized) { | 34 | if(!_initialized) { |
34 | if( FCGX_Init() ) | 35 | if( FCGX_Init() ) |
35 | throw exception(CODEPOINT,"failed to FCGX_Init()"); | 36 | throw exception(CODEPOINT,"failed to FCGX_Init()"); |
36 | _initialized = true; | 37 | _initialized = true; |
37 | } | 38 | } |
38 | } | 39 | } |
39 | fcgi_socket::~fcgi_socket() { | 40 | fcgi_socket::~fcgi_socket() { |
40 | if(sock>=0) | 41 | if(sock>=0) |
41 | close(sock); | 42 | close(sock); |
42 | } | 43 | } |
43 | 44 | ||
44 | fcgi_interface::fcgi_interface(fcgi_socket& s,int f) | 45 | fcgi_interface::fcgi_interface(fcgi_socket& s,int f) |
45 | : sbin(buf_sbin,sizeof(buf_sbin)), | 46 | : sbin(buf_sbin,sizeof(buf_sbin)), |
46 | sbout(buf_sbout,sizeof(buf_sbout)), | 47 | sbout(buf_sbout,sizeof(buf_sbout)), |
47 | sberr(buf_sberr,sizeof(buf_sberr)), | 48 | sberr(buf_sberr,sizeof(buf_sberr)), |
48 | sin(&sbin), sout(&sbout), serr(&sberr) { | 49 | sin(&sbin), sout(&sbout), serr(&sberr) { |
49 | if( FCGX_InitRequest(&request,s.sock,f) ) | 50 | if( FCGX_InitRequest(&request,s.sock,f) ) |
50 | throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); | 51 | throw exception(CODEPOINT,"failed to FCGX_InitRequest()"); |
51 | if( FCGX_Accept_r(&request) ) | 52 | 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 @@ | |||
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 |
9 | extern char **environ; | 10 | extern char **environ; |
10 | #endif /* HAVE_DECL_ENVIRON */ | 11 | #endif /* HAVE_DECL_ENVIRON */ |
11 | 12 | ||
12 | namespace kingate { | 13 | namespace 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() { |
28 | cout.flush(); | 29 | cout.flush(); |
29 | cerr.flush(); | 30 | cerr.flush(); |
30 | } | 31 | } |
31 | 32 | ||
32 | } | 33 | } |
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 @@ | |||
1 | #include <cstdlib> | ||
2 | #include <cstring> | ||
1 | #include "kingate/util.h" | 3 | #include "kingate/util.h" |
2 | #include "kingate/exception.h" | 4 | #include "kingate/exception.h" |
3 | 5 | ||
4 | namespace kingate { | 6 | namespace kingate { |
5 | 7 | ||
6 | static const char *safeChars = | 8 | static const char *safeChars = |
7 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | 9 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
8 | "abcdefghijklmnopqrstuvwxyz" | 10 | "abcdefghijklmnopqrstuvwxyz" |
9 | "0123456789" | 11 | "0123456789" |
10 | "_-" ; | 12 | "_-" ; |
11 | 13 | ||
12 | string url_encode(const string& str) { | 14 | string url_encode(const string& str) { |
13 | string rv = str; | 15 | string rv = str; |
14 | string::size_type screwed = 0; | 16 | string::size_type screwed = 0; |
15 | for(;;) { | 17 | for(;;) { |
16 | screwed = rv.find_first_not_of(safeChars,screwed); | 18 | screwed = rv.find_first_not_of(safeChars,screwed); |
17 | if(screwed == string::npos) | 19 | if(screwed == string::npos) |
18 | break; | 20 | break; |
19 | while(screwed<rv.length() && !strchr(safeChars,rv.at(screwed))) { | 21 | while(screwed<rv.length() && !strchr(safeChars,rv.at(screwed))) { |
20 | char danger = rv.at(screwed); | 22 | char danger = rv.at(screwed); |
21 | if(danger==' ') { | 23 | if(danger==' ') { |
22 | rv.replace(screwed++,1,1,'+'); | 24 | rv.replace(screwed++,1,1,'+'); |
23 | }else{ | 25 | }else{ |
24 | static char tmp[4] = {'%',0,0,0}; | 26 | static char tmp[4] = {'%',0,0,0}; |
25 | snprintf(&tmp[1],3,"%02X",0xFF&(int)danger); | 27 | snprintf(&tmp[1],3,"%02X",0xFF&(int)danger); |
26 | rv.replace(screwed,1,tmp,3); | 28 | rv.replace(screwed,1,tmp,3); |
27 | screwed+=3; | 29 | screwed+=3; |
28 | } | 30 | } |
29 | } | 31 | } |
30 | } | 32 | } |
31 | return rv; | 33 | return rv; |
32 | } | 34 | } |
33 | string url_decode(const string& str) { | 35 | string url_decode(const string& str) { |
34 | string rv = str; | 36 | string rv = str; |
35 | string::size_type unscrewed = 0; | 37 | string::size_type unscrewed = 0; |
36 | for(;;) { | 38 | for(;;) { |
37 | unscrewed = rv.find_first_of("%+",unscrewed); | 39 | unscrewed = rv.find_first_of("%+",unscrewed); |
38 | if(unscrewed == string::npos) | 40 | if(unscrewed == string::npos) |
39 | break; | 41 | break; |
40 | if(rv.at(unscrewed)=='+') { | 42 | if(rv.at(unscrewed)=='+') { |
41 | rv.replace(unscrewed++,1,1,' '); | 43 | rv.replace(unscrewed++,1,1,' '); |
42 | }else{ | 44 | }else{ |
43 | if((rv.length()-unscrewed)<3) | 45 | if((rv.length()-unscrewed)<3) |
44 | throw exception(CODEPOINT,"incorrectly escaped string"); | 46 | throw exception(CODEPOINT,"incorrectly escaped string"); |
45 | // XXX: ensure it's hex? | 47 | // XXX: ensure it's hex? |
46 | int danger = strtol(rv.substr(unscrewed+1,2).c_str(),NULL,16); | 48 | int danger = strtol(rv.substr(unscrewed+1,2).c_str(),NULL,16); |
47 | rv.replace(unscrewed,3,1,danger); | 49 | rv.replace(unscrewed,3,1,danger); |
48 | unscrewed++; | 50 | unscrewed++; |