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

Comparing SiteMapper/SiteMapper.cpp (file contents):
Revision 237 by Douglas Thrift, 2004-09-10T16:22:07-07:00 vs.
Revision 250 by Douglas Thrift, 2004-09-11T23:21:58-07:00

# Line 8 | Line 8
8   #include "Matcher.hpp"
9   #include "Page.hpp"
10  
11 + #include <menes-api/exename.hpp>
12 + #include <menes-app/application.hpp>
13 +
14   string program;
15   bool debug(false);
16  
17 < int main(int argc, char* argv[])
17 > struct SiteMapperCommand : public app::Application
18   {
19 <        program = argv[0];
17 <
18 <        string siteIndex, siteMap;
19 <
20 <        for (int index(1); index < argc; index++)
19 >        virtual int Run(const app::ArgumentList& args)
20          {
21 <                string arg(argv[index]);
22 <                Matcher matcher;
21 >                program = api::GetExecutableName();
22 >
23 >                string siteIndex, siteMap;
24  
25 <                if (arg == matcher("^-index=(.*)$"))
25 >                for (size_t index(0); index < args.GetSize(); index++)
26                  {
27 <                        siteIndex = matcher[1];
27 >                        string arg(args[index]);
28 >                        Matcher matcher;
29 >
30 >                        if (arg == matcher("^-index=(.*)$"))
31 >                        {
32 >                                siteIndex = matcher[1];
33 >                        }
34 >                        else if (arg == matcher("^-map=(.*)$"))
35 >                        {
36 >                                siteMap = matcher[1];
37 >                        }
38 >                        else if (arg == "-D")
39 >                        {
40 >                                if (!debug) debug = true;
41 >                        }
42                  }
43 <                else if (arg == matcher("^-map=(.*)$"))
43 >
44 >                if (!siteIndex.empty() && !siteMap.empty())
45                  {
46 <                        siteMap = matcher[1];
46 >                        SiteMapper mapper(siteIndex, siteMap);
47                  }
48 <                else if (arg == "-D")
48 >                else
49                  {
50 <                        if (!debug) debug = true;
50 >                        cout << "Usage: " << program << " -index=index -map=map [-D]\n";
51                  }
37        }
52  
53 <        if (!siteIndex.empty() && !siteMap.empty())
40 <        {
41 <                SiteMapper mapper(siteIndex, siteMap);
42 <        }
43 <        else
44 <        {
45 <                cout << "Usage: " << program << " -index=index -map=map [-D]\n";
53 >                return 0;
54          }
55 <
48 <        return 0;
49 < }
55 > } mapper;
56  
57   SiteMapper::SiteMapper(const string& siteIndex, const string& siteMap)
58   {
# Line 62 | Line 68 | void SiteMapper::oldMap(const string& si
68  
69          comment = ext::String(*document/"comment()");
70  
71 +        if (debug) cerr << "comment = " << comment << '\n';
72 +
73          oldMap(pages, list);
74   }
75  
# Line 91 | Line 99 | void SiteMapper::newIndex(const string&
99          for (xml::NodeSet::Iterator node(nodes.Begin()); node != nodes.End();
100                  ++node)
101          {
102 <                string address(ext::String(**node/"address"));
103 <                string port(ext::String(**node/"port"));
102 >                string address(ext::String(**node/"address")),
103 >                        port(ext::String(**node/"port"));
104  
105                  if (!port.empty())
106                  {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines