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

Comparing trunk/Zoe.cpp (file contents):
Revision 39 by douglas, 2004-07-23T17:52:53-07:00 vs.
Revision 54 by douglas, 2004-08-30T22:34:27-07:00

# Line 19 | Line 19 | extern "C"
19   #include <unistd.h>
20   }
21  
22 < int main(int argc, char* argv[])
22 > int zoe(const std::vector<const char*> args)
23   {
24 <        Zoe::program = argv[0];
24 >        Zoe::program = args[0];
25  
26 <        for (int index(1); index < argc; ++index)
26 >        for (int index(1); index < args.size(); ++index)
27          {
28 <                ext::String arg(argv[index]);
28 >                ext::String arg(args[index]);
29                  Matcher matcher;
30  
31                  if (arg == matcher("^-config=(.*)$"))
# Line 48 | Line 48 | int main(int argc, char* argv[])
48                  {
49                          if (!Zoe::debug) Zoe::debug = true;
50                  }
51 <                else
52 <                {
53 <                        cerr << "Usage: " << Zoe::program << " [-config=config] "
54 <                                "[-collector] [-publisher] [-color] [-D]\n";
55 <
56 <                        return 1;
57 <                }
51 >                else Zoe::usage();
52          }
53  
54          Zoe zoe;
# Line 62 | Line 56 | int main(int argc, char* argv[])
56          return 0;
57   }
58  
59 + int main(int argc, char* argv[])
60 + {
61 +        std::vector<const char*> args(argv, argv + argc);
62 +
63 +        return app::be::ThreadMain_(etl::BindAll(&zoe, args));
64 + }
65 +
66   Zoe::Zoe()
67   {
68 +        if (!(collector || publisher)) usage();
69 +        
70          configure();
71          initialize();
72  
# Line 75 | Line 78 | bool Zoe::debug(false), Zoe::collector(f
78           Zoe::color(false);
79   ext::String Zoe::program, Zoe::config("zoe.xml");
80  
81 + void Zoe::usage()
82 + {
83 +        cerr << "Usage: " << Zoe::program << " [-config=config] [-collector] "
84 +                "[-publisher] [-color] [-D]\n";
85 +
86 +        exit(1);
87 + }
88 +
89   ext::String Zoe::generator(Generator generator)
90   {
91          ext::String generator_(generator == all || generator == agent ? "Zoe" : "");
# Line 119 | Line 130 | void Zoe::configure()
130          ext::Handle<xml::Document> document(xml::Parse(config));
131          ext::Handle<xml::Node> zoe(*document/"zoe");
132  
133 <        login = std::string(*zoe/"login");
134 <        password = std::string(*zoe/"password");
135 <        database.driver = std::string(*zoe/"database"/"driver");
136 <        database.host = std::string(*zoe/"database"/"host");
137 <        database.user = std::string(*zoe/"database"/"user");
133 >        login = *zoe/"login";
134 >        password = *zoe/"password";
135 >        database.driver = *zoe/"database"/"driver";
136 >        database.host = *zoe/"database"/"host";
137 >        database.user = *zoe/"database"/"user";
138  
139          if ((*zoe/"database"/"password").IsEmpty())
140          {
# Line 137 | Line 148 | void Zoe::configure()
148                  for (size_t index(std::strlen(password)); index > 0; --index)
149                          password[index - 1] = '\0';
150          }
151 <        else database.password = std::string(*zoe/"database"/"password");
151 >        else database.password = *zoe/"database"/"password";
152  
153 <        database.db = std::string(*zoe/"database"/"db");
153 >        database.db = *zoe/"database"/"db";
154  
155          if (debug) cerr << "login = " << login << "\npassword = "
156                  << std::string(password.GetSize(), '*') << "\ndatabase = {\n"
157 <                << "   driver = " << database.driver << "\n   host=" << database.host
157 >                << "   driver = " << database.driver << "\n   host = " << database.host
158                  << "\n   user = " << database.user << '\n'
159                  << "   password = " << std::string(database.password.GetSize(), '*')
160                  << "\n   db = " << database.db << "\n}\n";
161  
162 <        std::string link(*zoe/"link");
162 >        ext::String link(*zoe/"link");
163          xml::NodeSet buddies(*zoe/"buddy");
164  
165          for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End();
166                  ++buddy)
167          {
168                  Buddy buddy_(**buddy/"login", **buddy/"rss", **buddy/"atom",
169 <                        !(**buddy/"link").IsEmpty() ? **buddy/"link" : link);
169 >                        !(**buddy/"link").IsEmpty() ? **buddy/"link" : (link
170 >                        + ext::String(**buddy/"login") + ".html"));
171  
172                  this->buddies.insert(buddy_);
173          }
# Line 175 | Line 187 | void Zoe::configure()
187                  cerr << "}\n";
188          }
189  
178        if (!collector && !publisher) { collector = true; publisher = true; }
179
190          if (debug) cerr << "collector = " << lexical_cast<ext::String>(collector)
191                  << "\npublisher = " << lexical_cast<ext::String>(publisher)
192                  << "\ncolor = " << lexical_cast<ext::String>(color) << '\n';
# Line 191 | Line 201 | void Zoe::initialize()
201  
202          while (buddies->MoveNext())
203          {
204 <                Buddy buddy(*this->buddies.find(buddies->GetString("buddy")));
204 >                if (this->buddies.find(buddies->GetString("buddy")) != this->buddies.end())
205 >                {
206 >                        Buddy buddy(*this->buddies.find(buddies->GetString("buddy")));
207  
208 <                buddy.setId(lexical_cast<ext::Uuid>(buddies->GetString("id")));
209 <                buddies_.insert(buddy);
208 >                        buddy.setId(lexical_cast<ext::Uuid>(buddies->GetString("id")));
209 >                        buddies_.insert(buddy);
210 >                }
211          }
212  
213          std::vector<Buddy> difference;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines