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 30 by Douglas Thrift, 2003-11-14T19:31:53-08:00 vs.
Revision 35 by Douglas Thrift, 2003-11-15T01:40:10-08:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include "HostStatus.hpp"
8 + #include "Host.hpp"
9  
10   int main(int argc, char* argv[])
11   {
# Line 15 | Line 16 | int main(int argc, char* argv[])
16  
17   HostStatus::HostStatus()
18   {
19 +        sputenv("TZ=:America/Los_Angeles");
20 +
21          string method = sgetenv("REQUEST_METHOD");
22  
23          parse(method);
# Line 25 | Line 28 | HostStatus::HostStatus()
28          {
29                  string format = itor->second;
30  
31 <                if (format == "t")
29 <                {
30 <                        this->format = table;
31 <                }
32 <                else
33 <                {
34 <                        this->format = page;
35 <                }
31 >                page = format != "t" ? true : false;
32          }
33  
34          display(method);
# Line 86 | Line 82 | void HostStatus::display(const string& m
82                  hostupdate << '\n' << flush;
83          }
84  
85 +        hostupdate.ignore(26);
86 +
87 +        list<Host> hosts;
88 +        bool done = false;
89 +
90          do
91          {
92 <                string line;
92 >                Host host;
93 >
94 >                hostupdate >> host;
95 >
96 >                hosts.push_back(host);
97 >
98 >                switch (hostupdate.peek())
99 >                {
100 >                case 'h':
101 >                case 'n':
102 >                case 'a':
103 >                case 'p':
104 >                case 's':
105 >                        break;
106 >                default:
107 >                        done = true;
108 >                        break;
109 >                }
110 >        }
111 >        while (!done && hostupdate.good());
112 >
113 >        if (page) header();
114  
115 <                getline(hostupdate, line);
115 >        for (list<Host>::iterator itor = hosts.begin(); itor != hosts.end(); itor++)
116 >        {
117 >                Host host = *itor;
118  
119 <                cout << line << '\n';
119 >                cout << host << flush;
120          }
121 <        while (hostupdate.good());
121 >
122 >        if (page) footer();
123 > }
124 >
125 > void HostStatus::header()
126 > {
127 >        cout << "<html>\n"
128 >                << "<head>\n"
129 >                << "<link rel=\"StyleSheet\" href=\"../stylesheets/regular.css\" type\""
130 >                << "text/css\">\n"
131 >                << "<title>Host Status</title>\n"
132 >                << "</head>\n"
133 >                << "<body>\n"
134 >                << "<h1 id=\"title\" class=\"center\">Host Status</h1>\n"
135 >                << "<table class=\"center\">\n";
136 > }
137 >
138 > void HostStatus::footer()
139 > {
140 >        cout << "</table>\n"
141 >                << "</html>\n";
142   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines