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 38 by Douglas Thrift, 2003-11-15T20:23:23-08:00 vs.
Revision 39 by Douglas Thrift, 2003-11-15T20:46:26-08:00

# Line 26 | Line 26 | HostStatus::HostStatus()
26          string method = sgetenv("REQUEST_METHOD");
27  
28          parse(method);
29 <
30 <        multimap<string, string>::iterator itor = cgi.find("format");
31 <
32 <        if (itor != cgi.end())
33 <        {
34 <                string format = itor->second;
35 <
36 <                page = format != "t" ? true : false;
37 <        }
29 >        mode();
30  
31          display(method);
32   }
# Line 68 | Line 60 | void HostStatus::parse(const string& met
60          while (input.good());
61   }
62  
63 + void HostStatus::mode()
64 + {
65 +        multimap<string, string>::iterator itor = cgi.find("format");
66 +
67 +        if (itor != cgi.end())
68 +        {
69 +                string format = itor->second;
70 +
71 +                page = format != "t" ? true : false;
72 +        }
73 +
74 +        if (!page) return;
75 +
76 +        host = false, name = false, address = false, platform = false, since =
77 +                false;
78 +
79 +        for (multimap<string, string>::iterator itor = cgi.find("mode"); itor !=
80 +                cgi.upper_bound("mode") && itor != cgi.end(); itor++)
81 +        {
82 +                string mode = itor->second;
83 +
84 +                for (string::iterator itor = mode.begin(); itor != mode.end(); itor++)
85 +                {
86 +                        char mode = *itor;
87 +
88 +                        switch (mode)
89 +                        {
90 +                        case 'h':
91 +                                if (!host) host = true;
92 +                                break;
93 +                        case 'n':
94 +                                if (!name) name = true;
95 +                                break;
96 +                        case 'a':
97 +                                if (!address) address = true;
98 +                                break;
99 +                        case 'p':
100 +                                if (!platform) platform = true;
101 +                                break;
102 +                        case 's':
103 +                                if (!since) since = true;
104 +                                break;
105 +                        default:
106 +                                break;
107 +                        }
108 +                }
109 +        }
110 +
111 +        if (!host && !name && !address && !platform && !since) host = true, name =
112 +                true, address = true, platform = true, since = true;
113 + }
114 +
115   void HostStatus::display(const string& method)
116   {
117          cout << "Content-Type: text/html\n\n";
# Line 139 | Line 183 | void HostStatus::header()
183                  << "</head>\n"
184                  << "<body>\n"
185                  << "<h1 id=\"title\" class=\"center\">Host Status</h1>\n"
186 <                << "<table class=\"center\">\n";
186 >                << "<form action=\"hoststatus.cgi\" method=\"POST\">\n"
187 >                << "<table class=\"center\">\n"
188 >                << "<tr>\n";
189 >
190 >        if (host) cout << "<th>Host</th>\n";
191 >        if (name) cout << "<th>Name</th>\n";
192 >        if (address) cout << "<th>Address</th>\n";
193 >        if (platform) cout << "<th>Platform</th>\n";
194 >        if (since) cout << "<th>Since</th>\n";
195 >
196 >        cout << "</tr>\n";
197   }
198  
199   void HostStatus::footer()
200   {
201          cout << "</table>\n"
202 < /*              << "<pre>" << flush;
149 <
150 <        ipstream env("env");
151 <
152 <        do
153 <        {
154 <                string line;
155 <
156 <                getline(env, line);
157 <
158 <                cout << line << '\n';
159 <        }
160 <        while (env.good());
161 <
162 <        cout << "</pre>\n"*/
202 >                << "</form>\n"
203                  << "</html>\n";
204   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines