ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/HostStatus/HostStatus.cpp
Revision: 29
Committed: 2003-11-14T12:44:58-08:00 (21 years, 7 months ago) by Douglas Thrift
File size: 1373 byte(s)
Log Message:
Suicide! PStreams is having trouble.

File Contents

# Content
1 // Host Status
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #include "HostStatus.hpp"
8
9 int main(int argc, char* argv[])
10 {
11 HostStatus status;
12
13 return 0;
14 }
15
16 HostStatus::HostStatus()
17 {
18 string method = sgetenv("REQUEST_METHOD");
19
20 parse(method);
21
22 multimap<string, string>::iterator itor = cgi.find("format");
23
24 if (itor != cgi.end())
25 {
26 string format = itor->second;
27
28 if (format == "t")
29 {
30 this->format = table;
31 }
32 else
33 {
34 this->format = page;
35 }
36 }
37
38 display(method);
39 }
40
41 void HostStatus::parse(const string& method)
42 {
43 string query;
44
45 if (method == "POST")
46 {
47 getline(cin, query);
48 }
49 else
50 {
51 query = sgetenv("QUERY_STRING");
52 }
53
54 if (query == "") return;
55
56 istringstream input(query);
57
58 do
59 {
60 string name, value;
61
62 getline(input, name, '=');
63 getline(input, value, '&');
64
65 cgi.insert(pair<string, string>(name, value));
66 }
67 while (input.good());
68 }
69
70 void HostStatus::display(const string& method)
71 {
72 cout << "Content-Type: text/html\n\n";
73
74 if (method == "POST") sunsetenv("HTTP_USER_AGENT");
75
76 pstream hostupdate("./hostupdate.cgi");
77
78 if (method == "POST")
79 {
80 for (multimap<string, string>::iterator itor = cgi.begin(); itor !=
81 cgi.end(); itor++)
82 {
83 hostupdate << itor->first << '=' << itor->second << '&';
84 }
85
86 hostupdate << '\n';
87 }
88
89 do
90 {
91 string line;
92
93 getline(hostupdate, line);
94
95 cout << line << '\n';
96 }
97 while (hostupdate.good());
98 }

Properties

Name Value
svn:eol-style native
svn:keywords Id