6 |
|
|
7 |
|
#include "HostUpdate.hpp" |
8 |
|
#include "Host.hpp" |
9 |
+ |
#include <windows.h> |
10 |
|
|
11 |
|
int main(int argc, char* argv[]) |
12 |
|
{ |
81 |
|
cout << "Content-Type: text/plain\n\n"; |
82 |
|
|
83 |
|
multimap<string, string>::iterator itor = cgi.find("host"); |
84 |
< |
|
84 |
> |
|
85 |
|
if (itor == cgi.end()) return; |
86 |
|
if (itor->second == "") return; |
87 |
|
|
107 |
|
cout << "Content-Type: text/plain\n\n"; |
108 |
|
|
109 |
|
set<Host> hosts; |
110 |
+ |
|
111 |
+ |
#ifndef _WIN32 |
112 |
|
DIR* dir = opendir("hosts"); |
113 |
|
struct dirent* ent; |
114 |
|
|
117 |
|
string file = ent->d_name; |
118 |
|
|
119 |
|
if (file == "." || file == "..") continue; |
120 |
< |
|
120 |
> |
|
121 |
|
Host host(file); |
122 |
|
|
123 |
|
hosts.insert(++host); |
124 |
|
} |
125 |
|
|
126 |
|
closedir(dir); |
127 |
+ |
#else |
128 |
+ |
WIN32_FIND_DATA found; |
129 |
+ |
HANDLE find = FindFirstFile("hosts\\*", &found); |
130 |
+ |
|
131 |
+ |
do |
132 |
+ |
{ |
133 |
+ |
string file = found.cFileName; |
134 |
+ |
|
135 |
+ |
if (file == "." || file == "..") continue; |
136 |
+ |
|
137 |
+ |
Host host(file); |
138 |
+ |
|
139 |
+ |
hosts.insert(++host); |
140 |
+ |
} |
141 |
+ |
while (FindNextFile(find, &found) != 0); |
142 |
+ |
|
143 |
+ |
FindClose(find); |
144 |
+ |
#endif |
145 |
|
|
146 |
|
for (set<Host>::iterator itor = hosts.begin(); itor != hosts.end(); itor++) |
147 |
|
{ |
150 |
|
cout << "host=" << host.getHost() << '\n' |
151 |
|
<< "name=" << host.getName() << '\n' |
152 |
|
<< "address=" << host.getAddress() << '\n' |
153 |
< |
<< "platform=" << host.getPlatform() << "\n\n"; |
153 |
> |
<< "platform=" << host.getPlatform() << '\n'; |
154 |
> |
|
155 |
> |
string name = string("hosts") + slash + host.getHost(); |
156 |
> |
struct stat file; |
157 |
> |
|
158 |
> |
if (stat(name.c_str(), &file) == 0) |
159 |
> |
{ |
160 |
> |
char since[20]; |
161 |
> |
|
162 |
> |
strftime(since, 20, "%m/%d/%Y %H:%M:%S", gmtime(&file.st_mtime)); |
163 |
> |
|
164 |
> |
cout << "since=" << since << " GMT\n"; |
165 |
> |
} |
166 |
|
} |
167 |
|
} |