--- HostStatus/HostStatus.cpp 2003/11/15 09:40:10 35 +++ HostStatus/HostStatus.cpp 2003/11/16 04:46:26 39 @@ -16,20 +16,17 @@ int main(int argc, char* argv[]) HostStatus::HostStatus() { +#ifndef __CYGWIN__ sputenv("TZ=:America/Los_Angeles"); +#else + sputenv("TZ= PST8PDT"); +#endif + tzset(); string method = sgetenv("REQUEST_METHOD"); parse(method); - - multimap::iterator itor = cgi.find("format"); - - if (itor != cgi.end()) - { - string format = itor->second; - - page = format != "t" ? true : false; - } + mode(); display(method); } @@ -63,6 +60,58 @@ void HostStatus::parse(const string& met while (input.good()); } +void HostStatus::mode() +{ + multimap::iterator itor = cgi.find("format"); + + if (itor != cgi.end()) + { + string format = itor->second; + + page = format != "t" ? true : false; + } + + if (!page) return; + + host = false, name = false, address = false, platform = false, since = + false; + + for (multimap::iterator itor = cgi.find("mode"); itor != + cgi.upper_bound("mode") && itor != cgi.end(); itor++) + { + string mode = itor->second; + + for (string::iterator itor = mode.begin(); itor != mode.end(); itor++) + { + char mode = *itor; + + switch (mode) + { + case 'h': + if (!host) host = true; + break; + case 'n': + if (!name) name = true; + break; + case 'a': + if (!address) address = true; + break; + case 'p': + if (!platform) platform = true; + break; + case 's': + if (!since) since = true; + break; + default: + break; + } + } + } + + if (!host && !name && !address && !platform && !since) host = true, name = + true, address = true, platform = true, since = true; +} + void HostStatus::display(const string& method) { cout << "Content-Type: text/html\n\n"; @@ -124,19 +173,32 @@ void HostStatus::display(const string& m void HostStatus::header() { - cout << "\n" + cout << "\n" + << "\n" << "\n" - << "\n" + << "\n" << "Host Status\n" << "\n" << "\n" << "

Host Status

\n" - << "\n"; + << "\n" + << "
\n" + << "\n"; + + if (host) cout << "\n"; + if (name) cout << "\n"; + if (address) cout << "\n"; + if (platform) cout << "\n"; + if (since) cout << "\n"; + + cout << "\n"; } void HostStatus::footer() { cout << "
HostNameAddressPlatformSince
\n" + << "\n" << "\n"; }