ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/Search/Search.cpp
(Generate patch)

Comparing trunk/Search/Search.cpp (file contents):
Revision 1 by douglas, 2002-12-04T20:22:59-08:00 vs.
Revision 304 by douglas, 2003-12-10T19:22:26-08:00

# Line 1 | Line 1
1   /* ============================================================================
2   * Douglas Thrift's Search Engine License
3   *
4 < * Copyright (C) 2002, Douglas Thrift. All Rights Reserved.
4 > * Copyright (C) 2002-2003, Douglas Thrift. All Rights Reserved.
5   * Redistribution and use in source and binary forms, with or without
6   * modification, are permitted provided that the following conditions are met:
7   *
# Line 46 | Line 46
46   //
47   // Douglas Thrift
48   //
49 < // Search.cpp
49 > // $Id: Search.cpp,v 1.25 2003/12/11 03:22:26 douglas Exp $
50  
51   #include "Search.h"
52   #include "Indexer.h"
# Line 57 | Line 57
57   #include <sys/utsname.h>
58   #else
59   #include <windows.h>
60 < #endif // _WIN32
60 > #endif
61  
62   string program;
63   string programName = "Douglas Thrift's Search Engine";
64 < string programVersion = "1.1alpha";
64 > string programVersion = "1.2rc2";
65   bool debug = false;
66  
67   int main(int argc, char* argv[])
# Line 84 | Line 84 | int main(int argc, char* argv[])
84          string notfound = "notfound.html";
85          string pages = "pages.html";
86  
87 +        string email;
88 +
89          for (int index = 1; index < argc; index++)
90          {
91                  string arg(argv[index]);
# Line 107 | Line 109 | int main(int argc, char* argv[])
109                  {
110                          if (++index < argc)
111                          {
112 <                                page = strtoul(argv[index],0,0);
112 >                                istringstream number(argv[index]);
113 >
114 >                                number >> page;
115                          }
116                          else
117                          {
118                                  cerr << program << ": Bad arguments\n";
119 +                                usage();
120                                  return 1;
121                          }
122                  }
# Line 126 | Line 131 | int main(int argc, char* argv[])
131                          else
132                          {
133                                  cerr << program << ": Bad arguments\n";
134 +                                usage();
135                                  return 1;
136                          }
137                  }
# Line 138 | Line 144 | int main(int argc, char* argv[])
144                          else
145                          {
146                                  cerr << program << ": Bad arguments\n";
147 +                                usage();
148                                  return 1;
149                          }
150                  }
# Line 150 | Line 157 | int main(int argc, char* argv[])
157                          else
158                          {
159                                  cerr << program << ": Bad arguments\n";
160 +                                usage();
161                                  return 1;
162                          }
163                  }
# Line 162 | Line 170 | int main(int argc, char* argv[])
170                          else
171                          {
172                                  cerr << program << ": Bad arguments\n";
173 +                                usage();
174                                  return 1;
175                          }
176                  }
# Line 174 | Line 183 | int main(int argc, char* argv[])
183                          else
184                          {
185                                  cerr << program << ": Bad arguments\n";
186 +                                usage();
187                                  return 1;
188                          }
189                  }
# Line 186 | Line 196 | int main(int argc, char* argv[])
196                          else
197                          {
198                                  cerr << program << ": Bad arguments\n";
199 +                                usage();
200                                  return 1;
201                          }
202                  }
# Line 198 | Line 209 | int main(int argc, char* argv[])
209                          else
210                          {
211                                  cerr << program << ": Bad arguments\n";
212 +                                usage();
213                                  return 1;
214                          }
215                  }
# Line 210 | Line 222 | int main(int argc, char* argv[])
222                          else
223                          {
224                                  cerr << program << ": Bad arguments\n";
225 +                                usage();
226                                  return 1;
227                          }
228                  }
229                  else if (arg == "-D")
230                  {
231                          debug = true;
232 +                        cerr.setf(ios_base::boolalpha);
233                  }
234                  else
235                  {
# Line 235 | Line 249 | int main(int argc, char* argv[])
249                  {
250                          cerr << program << ": Too many indices, can only build one index"
251                                  << " at a time\n";
252 +                        usage();
253                          return 1;
254                  }
255  
256                  if (indexDomains.size() < 1)
257                  {
258                          cerr << program << ": Must specify at least one domain\n";
259 +                        usage();
260                          return 1;
261                  }
262  
# Line 267 | Line 283 | int main(int argc, char* argv[])
283          return 0;
284   }
285  
286 + string agent(bool version)
287 + {
288 +        string agent = programName + (version ? ('/' + programVersion) : "");
289 +
290 +        return agent;
291 + }
292 +
293   string platform()
294   {
295          string platform;
# Line 366 | Line 389 | string platform()
389  
390   void usage()
391   {
392 + #ifdef _WIN32
393 +        OSVERSIONINFO* computer = new OSVERSIONINFO;
394 +        computer->dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
395 +        GetVersionEx(computer);
396 +
397 +        string program = ::program;
398 +        if (computer->dwPlatformId != VER_PLATFORM_WIN32_NT)
399 +        {
400 +                program = "Search";
401 +        }
402 +
403 +        delete computer;
404 + #endif // _WIN32
405 +
406          string tab(8 + program.length(), ' ');
407  
408          cout << "Usage: " << program << " [index ...] [-P page] [-h header] [-b bo"
# Line 399 | Line 436 | void usage()
436   void version()
437   {
438          cout << programName << " " << programVersion << " "<< platform() << "\n\n"
439 <                << "   Copyright (C) 2002, Douglas Thrift. All Rights Reserved.\n\n"
439 >                << "   Copyright (C) 2002-2003, Douglas Thrift. All Rights Reserved.\n"
440 >                << "\n"
441                  << "   This product includes software developed by Douglas Thrift\n"
442                  << "   (http://computers.douglasthrift.net/searchengine/).\n";
443 + #ifdef _OpenSSL_
444 +        cout << "\n" << openssl() << " " << SSLeay_version(SSLEAY_BUILT_ON) << " "
445 +                << SSLeay_version(SSLEAY_PLATFORM) << "\n";
446 + #endif
447   }
448  
449   void license()
450   {
451          cout << "License:\n"
452                  << "   Douglas Thrift's Search Engine License\n\n"
453 <                << "   Copyright (C) 2002, Douglas Thrift. All Rights Reserved.\n\n"
453 >                << "   Copyright (C) 2002-2003, Douglas Thrift. All Rights Reserved.\n"
454 >                << "\n"
455                  << "   Redistribution and use in source and binary forms, with or with"
456                  << "out\n"
457                  << "   modification, are permitted provided that the following conditi"

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines