5 |
|
// $Id$ |
6 |
|
|
7 |
|
#include "HostStatus.hpp" |
8 |
+ |
#include "Host.hpp" |
9 |
|
|
10 |
|
int main(int argc, char* argv[]) |
11 |
|
{ |
16 |
|
|
17 |
|
HostStatus::HostStatus() |
18 |
|
{ |
19 |
+ |
#ifndef __CYGWIN__ |
20 |
+ |
sputenv("TZ=:America/Los_Angeles"); |
21 |
+ |
#else |
22 |
+ |
sputenv("TZ= PST8PDT"); |
23 |
+ |
#endif |
24 |
+ |
tzset(); |
25 |
+ |
|
26 |
|
string method = sgetenv("REQUEST_METHOD"); |
27 |
|
|
28 |
|
parse(method); |
33 |
|
{ |
34 |
|
string format = itor->second; |
35 |
|
|
36 |
< |
if (format == "t") |
29 |
< |
{ |
30 |
< |
this->format = table; |
31 |
< |
} |
32 |
< |
else |
33 |
< |
{ |
34 |
< |
this->format = page; |
35 |
< |
} |
36 |
> |
page = format != "t" ? true : false; |
37 |
|
} |
38 |
|
|
39 |
|
display(method); |
84 |
|
hostupdate << itor->first << '=' << itor->second << '&'; |
85 |
|
} |
86 |
|
|
87 |
< |
hostupdate << '\n'; |
87 |
> |
hostupdate << '\n' << flush; |
88 |
> |
} |
89 |
> |
|
90 |
> |
hostupdate.ignore(26); |
91 |
> |
|
92 |
> |
list<Host> hosts; |
93 |
> |
bool done = false; |
94 |
> |
|
95 |
> |
do |
96 |
> |
{ |
97 |
> |
Host host; |
98 |
> |
|
99 |
> |
hostupdate >> host; |
100 |
> |
|
101 |
> |
hosts.push_back(host); |
102 |
> |
|
103 |
> |
switch (hostupdate.peek()) |
104 |
> |
{ |
105 |
> |
case 'h': |
106 |
> |
case 'n': |
107 |
> |
case 'a': |
108 |
> |
case 'p': |
109 |
> |
case 's': |
110 |
> |
break; |
111 |
> |
default: |
112 |
> |
done = true; |
113 |
> |
break; |
114 |
> |
} |
115 |
> |
} |
116 |
> |
while (!done && hostupdate.good()); |
117 |
> |
|
118 |
> |
if (page) header(); |
119 |
> |
|
120 |
> |
for (list<Host>::iterator itor = hosts.begin(); itor != hosts.end(); itor++) |
121 |
> |
{ |
122 |
> |
Host host = *itor; |
123 |
> |
|
124 |
> |
cout << host << flush; |
125 |
|
} |
126 |
|
|
127 |
+ |
if (page) footer(); |
128 |
+ |
} |
129 |
+ |
|
130 |
+ |
void HostStatus::header() |
131 |
+ |
{ |
132 |
+ |
cout << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\"\n" |
133 |
+ |
<< "\t\"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" |
134 |
+ |
<< "<html>\n" |
135 |
+ |
<< "<head>\n" |
136 |
+ |
<< "<link rel=\"StyleSheet\" href=\"../stylesheets/regular.css\" type=" |
137 |
+ |
<< "\"text/css\">\n" |
138 |
+ |
<< "<title>Host Status</title>\n" |
139 |
+ |
<< "</head>\n" |
140 |
+ |
<< "<body>\n" |
141 |
+ |
<< "<h1 id=\"title\" class=\"center\">Host Status</h1>\n" |
142 |
+ |
<< "<table class=\"center\">\n"; |
143 |
+ |
} |
144 |
+ |
|
145 |
+ |
void HostStatus::footer() |
146 |
+ |
{ |
147 |
+ |
cout << "</table>\n" |
148 |
+ |
/* << "<pre>" << flush; |
149 |
+ |
|
150 |
+ |
ipstream env("env"); |
151 |
+ |
|
152 |
|
do |
153 |
|
{ |
154 |
|
string line; |
155 |
|
|
156 |
< |
getline(hostupdate, line); |
156 |
> |
getline(env, line); |
157 |
|
|
158 |
|
cout << line << '\n'; |
159 |
|
} |
160 |
< |
while (hostupdate.good()); |
160 |
> |
while (env.good()); |
161 |
> |
|
162 |
> |
cout << "</pre>\n"*/ |
163 |
> |
<< "</html>\n"; |
164 |
|
} |