46 |
|
// |
47 |
|
// Douglas Thrift |
48 |
|
// |
49 |
< |
// Search.cpp |
49 |
> |
// $Id: Search.cpp,v 1.17 2003/07/15 07:22:06 douglas Exp $ |
50 |
|
|
51 |
|
#include "Search.h" |
52 |
|
#include "Indexer.h" |
57 |
|
#include <sys/utsname.h> |
58 |
|
#else |
59 |
|
#include <windows.h> |
60 |
< |
#endif // _WIN32 |
60 |
> |
#endif |
61 |
> |
|
62 |
> |
#ifdef _OpenSSL_ |
63 |
> |
#include <openssl/crypto.h> |
64 |
> |
|
65 |
> |
inline string openssl(bool agent = false) |
66 |
> |
{ |
67 |
> |
ostringstream openssl; |
68 |
> |
|
69 |
> |
openssl << "OpenSSL" << (agent ? "/" : " "); |
70 |
> |
|
71 |
> |
long version = SSLeay(); |
72 |
> |
long major = version / 0x10000000; |
73 |
> |
long minor = (version % 0x10000000) / 0x100000; |
74 |
> |
long fix = (version % 0x100000) / 0x1000; |
75 |
> |
long patch = (version % 0x1000); |
76 |
> |
|
77 |
> |
openssl << major << "." << minor << "." << fix; |
78 |
> |
|
79 |
> |
if (patch == 0x0) |
80 |
> |
{ |
81 |
> |
openssl << "-dev"; |
82 |
> |
} |
83 |
> |
else if (patch >= 0x1 && patch <= 0xe) |
84 |
> |
{ |
85 |
> |
openssl << "-beta" << patch; |
86 |
> |
} |
87 |
> |
else if (patch == 0xf) |
88 |
> |
{ |
89 |
> |
// release |
90 |
> |
} |
91 |
> |
else if (patch > 0xf) |
92 |
> |
{ |
93 |
> |
openssl << char('a' - 1 + (patch / 0x10) % 26); |
94 |
> |
} |
95 |
> |
|
96 |
> |
openssl << " " << SSLeay_version(SSLEAY_PLATFORM); |
97 |
> |
|
98 |
> |
return openssl.str(); |
99 |
> |
} |
100 |
> |
#endif |
101 |
|
|
102 |
|
string program; |
103 |
|
string programName = "Douglas Thrift's Search Engine"; |
104 |
< |
string programVersion = "1.1alpha1"; |
104 |
> |
string programVersion = "1.2alpha"; |
105 |
|
bool debug = false; |
106 |
|
|
107 |
|
int main(int argc, char* argv[]) |
124 |
|
string notfound = "notfound.html"; |
125 |
|
string pages = "pages.html"; |
126 |
|
|
127 |
+ |
string email; |
128 |
+ |
|
129 |
|
for (int index = 1; index < argc; index++) |
130 |
|
{ |
131 |
|
string arg(argv[index]); |
154 |
|
else |
155 |
|
{ |
156 |
|
cerr << program << ": Bad arguments\n"; |
157 |
+ |
usage(); |
158 |
|
return 1; |
159 |
|
} |
160 |
|
} |
169 |
|
else |
170 |
|
{ |
171 |
|
cerr << program << ": Bad arguments\n"; |
172 |
+ |
usage(); |
173 |
|
return 1; |
174 |
|
} |
175 |
|
} |
182 |
|
else |
183 |
|
{ |
184 |
|
cerr << program << ": Bad arguments\n"; |
185 |
+ |
usage(); |
186 |
|
return 1; |
187 |
|
} |
188 |
|
} |
195 |
|
else |
196 |
|
{ |
197 |
|
cerr << program << ": Bad arguments\n"; |
198 |
+ |
usage(); |
199 |
|
return 1; |
200 |
|
} |
201 |
|
} |
208 |
|
else |
209 |
|
{ |
210 |
|
cerr << program << ": Bad arguments\n"; |
211 |
+ |
usage(); |
212 |
|
return 1; |
213 |
|
} |
214 |
|
} |
221 |
|
else |
222 |
|
{ |
223 |
|
cerr << program << ": Bad arguments\n"; |
224 |
+ |
usage(); |
225 |
|
return 1; |
226 |
|
} |
227 |
|
} |
234 |
|
else |
235 |
|
{ |
236 |
|
cerr << program << ": Bad arguments\n"; |
237 |
+ |
usage(); |
238 |
|
return 1; |
239 |
|
} |
240 |
|
} |
247 |
|
else |
248 |
|
{ |
249 |
|
cerr << program << ": Bad arguments\n"; |
250 |
+ |
usage(); |
251 |
|
return 1; |
252 |
|
} |
253 |
|
} |
260 |
|
else |
261 |
|
{ |
262 |
|
cerr << program << ": Bad arguments\n"; |
263 |
+ |
usage(); |
264 |
|
return 1; |
265 |
|
} |
266 |
|
} |
267 |
|
else if (arg == "-D") |
268 |
|
{ |
269 |
|
debug = true; |
270 |
+ |
cerr.setf(ios_base::boolalpha); |
271 |
|
} |
272 |
|
else |
273 |
|
{ |
287 |
|
{ |
288 |
|
cerr << program << ": Too many indices, can only build one index" |
289 |
|
<< " at a time\n"; |
290 |
+ |
usage(); |
291 |
|
return 1; |
292 |
|
} |
293 |
|
|
294 |
|
if (indexDomains.size() < 1) |
295 |
|
{ |
296 |
|
cerr << program << ": Must specify at least one domain\n"; |
297 |
+ |
usage(); |
298 |
|
return 1; |
299 |
|
} |
300 |
|
|
427 |
|
|
428 |
|
void usage() |
429 |
|
{ |
430 |
+ |
#ifdef _WIN32 |
431 |
+ |
OSVERSIONINFO* computer = new OSVERSIONINFO; |
432 |
+ |
computer->dwOSVersionInfoSize = sizeof(OSVERSIONINFO); |
433 |
+ |
GetVersionEx(computer); |
434 |
+ |
|
435 |
+ |
string program = ::program; |
436 |
+ |
if (computer->dwPlatformId != VER_PLATFORM_WIN32_NT) |
437 |
+ |
{ |
438 |
+ |
program = "Search"; |
439 |
+ |
} |
440 |
+ |
|
441 |
+ |
delete computer; |
442 |
+ |
#endif // _WIN32 |
443 |
+ |
|
444 |
|
string tab(8 + program.length(), ' '); |
445 |
|
|
446 |
|
cout << "Usage: " << program << " [index ...] [-P page] [-h header] [-b bo" |
478 |
|
<< "\n" |
479 |
|
<< " This product includes software developed by Douglas Thrift\n" |
480 |
|
<< " (http://computers.douglasthrift.net/searchengine/).\n"; |
481 |
+ |
#ifdef _OpenSSL_ |
482 |
+ |
cout << "\n" << openssl() << "\n"; |
483 |
+ |
#endif |
484 |
|
} |
485 |
|
|
486 |
|
void license() |