1 |
// Host Status |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#ifndef _HostStatus_hpp_ |
8 |
#define _HostStatus_hpp_ |
9 |
|
10 |
#define _BSD_SOURCE |
11 |
|
12 |
#include <iostream> |
13 |
#include <string> |
14 |
#include <sstream> |
15 |
#include <list> |
16 |
#include <set> |
17 |
#include <map> |
18 |
#include <cstdlib> |
19 |
#include <ctime> |
20 |
|
21 |
#include <pstream.h> |
22 |
|
23 |
using namespace std; |
24 |
using namespace redi; |
25 |
|
26 |
inline string sgetenv(const string& name) |
27 |
{ |
28 |
char* value = getenv(name.c_str()); |
29 |
|
30 |
return value != NULL ? value : ""; |
31 |
} |
32 |
|
33 |
inline int sputenv(const string& name) |
34 |
{ |
35 |
char* value = new char[name.size() + 1]; |
36 |
|
37 |
sprintf(value, name.c_str()); |
38 |
|
39 |
int code = putenv(value); |
40 |
|
41 |
delete [] value; |
42 |
|
43 |
return code; |
44 |
} |
45 |
|
46 |
inline void sunsetenv(const string& name) { unsetenv(name.c_str()); } |
47 |
|
48 |
#ifdef __CYGWIN__ |
49 |
|
50 |
inline time_t timegm(struct tm* time) |
51 |
{ |
52 |
string zone = sgetenv("TZ"); |
53 |
|
54 |
sputenv("TZ="); |
55 |
tzset(); |
56 |
|
57 |
time_t when = mktime(time); |
58 |
|
59 |
sputenv("TZ=" + zone); |
60 |
tzset(); |
61 |
|
62 |
return when; |
63 |
} |
64 |
|
65 |
#endif |
66 |
|
67 |
class HostStatus |
68 |
{ |
69 |
private: |
70 |
multimap<string, string> cgi; |
71 |
bool page; |
72 |
bool host; |
73 |
bool name; |
74 |
bool address; |
75 |
bool platform; |
76 |
bool since; |
77 |
void parse(const string& method); |
78 |
void mode(); |
79 |
void display(const string& method); |
80 |
void header(const string& method); |
81 |
void footer(); |
82 |
public: |
83 |
HostStatus(); |
84 |
~HostStatus() {} |
85 |
}; |
86 |
|
87 |
#endif // _HostStatus_hpp_ |