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 |
|
{ |