1 |
// Smersh |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#include "Smersh.hpp" |
8 |
#include "Matcher.hpp" |
9 |
|
10 |
int main(int argc, char* argv[]) |
11 |
{ |
12 |
Smersh smersh; |
13 |
|
14 |
return 0; |
15 |
} |
16 |
|
17 |
Smersh::Smersh(ostream& sout) |
18 |
{ |
19 |
string method = sgetenv("REQUEST_METHOD"); |
20 |
|
21 |
parse(method); |
22 |
|
23 |
sout << "Content-Type: text/plain\n\n" << (cgi.find("sn") != cgi.end() ? |
24 |
cgi.find("sn")->second : "Unknown") << '\n'; |
25 |
} |
26 |
|
27 |
void Smersh::parse(const string& method) |
28 |
{ |
29 |
string query(sgetenv("QUERY_STRING")); |
30 |
|
31 |
if (method == "POST") getline(cin, query); |
32 |
if (query == "") return; |
33 |
|
34 |
istringstream input(query); |
35 |
|
36 |
do |
37 |
{ |
38 |
string name, value; |
39 |
|
40 |
getline(input, name, '='); |
41 |
getline(input, value, '&'); |
42 |
|
43 |
cgi.insert(pair<string, string>(name, value)); |
44 |
} |
45 |
while (input.good()); |
46 |
} |