ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/HostStatus/HostStatus.cpp
Revision: 31
Committed: 2003-11-14T20:11:01-08:00 (21 years, 7 months ago) by Douglas Thrift
File size: 1402 byte(s)
Log Message:
The world smile on you!

File Contents

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

Properties

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