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