forked from UnixJunkie/pharmer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cgi.h
112 lines (89 loc) · 2.77 KB
/
cgi.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
Pharmer: Efficient and Exact 3D Pharmacophore Search
Copyright (C) 2011 David Ryan Koes and the University of Pittsburgh
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*
* cgi.h
*
* Created on: Mar 11, 2010
* Author: dkoes
*/
#ifndef CGI_H_
#define CGI_H_
/*! \file FCgiIO.h
* \brief Class that implements input and output through a FastCGI request.
*
* This class provides access to the input byte-stream and environment
* variable interfaces of a FastCGI request. It is fully compatible with the
* Cgicc input API.
*
* It also provides access to the request's output and error streams, using a
* similar interface.
*/
#include <ostream>
#include <string>
#include <map>
#include "fcgio.h"
#include "cgicc/CgiInput.h"
#include "cgicc/Cgicc.h"
using namespace std;
namespace cgicc
{
//dkoes - return true if there is data with name
bool cgiTagExists(Cgicc& cgi, const string& name);
//get an integer value, 0 is returned if there's a problem
long cgiGetInt(Cgicc& cgi, const string& name);
//empty string is returned if problems
string cgiGetString(Cgicc& cgi, const string& name);
//get a double value, 0 is returned if there's a problem
double cgiGetDouble(Cgicc& cgi, const string& name);
//dump the cgi request for debugging
string cgiDump(Cgicc& cgi);
/*
* This class provides access to the input byte-stream and environment
* variable interfaces of a FastCGI request. It is fully compatible with the
* Cgicc input API.
*
* It also provides access to the request's output and error streams, using a
* similar interface.
*/
class FastCgiIO : public cgicc::CgiInput, public std::ostream
{
public:
FastCgiIO(FCGX_Request& request);
FastCgiIO(const FastCgiIO& io);
virtual inline ~FastCgiIO()
{}
virtual inline size_t read(char *data, size_t length)
{
return FCGX_GetStr(data, length, fRequest.in);
}
virtual inline std::string getenv(const char *varName)
{
return fEnv[varName];
}
inline std::ostream& err(void)
{
return fErr;
}
//@}
protected:
FCGX_Request& fRequest;
fcgi_streambuf fOutBuf;
fcgi_streambuf fErrBuf;
std::ostream fErr;
std::map<std::string, std::string> fEnv;
};
} // namespace cgicc
#endif /* CGI_H_ */