--- HostStatus/HostStatus.cpp 2003/11/15 03:31:53 30 +++ HostStatus/HostStatus.cpp 2003/11/15 23:12:56 37 @@ -5,6 +5,7 @@ // $Id$ #include "HostStatus.hpp" +#include "Host.hpp" int main(int argc, char* argv[]) { @@ -15,6 +16,8 @@ int main(int argc, char* argv[]) HostStatus::HostStatus() { + sputenv("TZ=:America/Los_Angeles"); + string method = sgetenv("REQUEST_METHOD"); parse(method); @@ -25,14 +28,7 @@ HostStatus::HostStatus() { string format = itor->second; - if (format == "t") - { - this->format = table; - } - else - { - this->format = page; - } + page = format != "t" ? true : false; } display(method); @@ -86,13 +82,78 @@ void HostStatus::display(const string& m hostupdate << '\n' << flush; } + hostupdate.ignore(26); + + list hosts; + bool done = false; + + do + { + Host host; + + hostupdate >> host; + + hosts.push_back(host); + + switch (hostupdate.peek()) + { + case 'h': + case 'n': + case 'a': + case 'p': + case 's': + break; + default: + done = true; + break; + } + } + while (!done && hostupdate.good()); + + if (page) header(); + + for (list::iterator itor = hosts.begin(); itor != hosts.end(); itor++) + { + Host host = *itor; + + cout << host << flush; + } + + if (page) footer(); +} + +void HostStatus::header() +{ + cout << "\n" + << "\n" + << "\n" + << "\n" + << "Host Status\n" + << "\n" + << "\n" + << "

Host Status

\n" + << "\n"; +} + +void HostStatus::footer() +{ + cout << "
\n" +/* << "
" << flush;
+
+	ipstream env("env");
+
 	do
 	{
 		string line;
 
-		getline(hostupdate, line);
+		getline(env, line);
 
 		cout << line << '\n';
 	}
-	while (hostupdate.good());
+	while (env.good());
+
+	cout << "
\n"*/ + << "\n"; }