// Host Status // // Douglas Thrift // // $Id$ #include "HostStatus.hpp" int main(int argc, char* argv[]) { HostStatus status; return 0; } HostStatus::HostStatus() { string method = sgetenv("REQUEST_METHOD"); parse(method); multimap::iterator itor = cgi.find("format"); if (itor != cgi.end()) { string format = itor->second; if (format == "t") { this->format = table; } else { this->format = page; } } display(method); } void HostStatus::parse(const string& method) { string query; if (method == "POST") { getline(cin, query); } else { query = sgetenv("QUERY_STRING"); } if (query == "") return; istringstream input(query); do { string name, value; getline(input, name, '='); getline(input, value, '&'); cgi.insert(pair(name, value)); } while (input.good()); } void HostStatus::display(const string& method) { cout << "Content-Type: text/html\n\n"; if (method == "POST") sunsetenv("HTTP_USER_AGENT"); pstream hostupdate("./hostupdate.cgi"); if (method == "POST") { for (multimap::iterator itor = cgi.begin(); itor != cgi.end(); itor++) { hostupdate << itor->first << '=' << itor->second << '&'; } hostupdate << '\n'; } do { string line; getline(hostupdate, line); cout << line << '\n'; } while (hostupdate.good()); }