ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/HostStatus/HostStatus.cpp
(Generate patch)

Comparing HostStatus/HostStatus.cpp (file contents):
Revision 27 by Douglas Thrift, 2003-11-14T11:38:42-08:00 vs.
Revision 29 by Douglas Thrift, 2003-11-14T12:44:58-08:00

# Line 15 | Line 15 | int main(int argc, char* argv[])
15  
16   HostStatus::HostStatus()
17   {
18 <        //
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   }

Comparing HostStatus/HostStatus.cpp (property svn:eol-style):
Revision 27 by Douglas Thrift, 2003-11-14T11:38:42-08:00 vs.
Revision 29 by Douglas Thrift, 2003-11-14T12:44:58-08:00

# Line 0 | Line 1
1 + native

Comparing HostStatus/HostStatus.cpp (property svn:keywords):
Revision 27 by Douglas Thrift, 2003-11-14T11:38:42-08:00 vs.
Revision 29 by Douglas Thrift, 2003-11-14T12:44:58-08:00

# Line 0 | Line 1
1 + Id

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines