4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
< |
#include "Matcher.hpp" |
7 |
> |
#include "Matcher/Matcher.hpp" |
8 |
|
#include "Collector.hpp" |
9 |
|
#include "Publisher.hpp" |
10 |
|
|
11 |
|
#include <menes-api/exename.hpp> |
12 |
|
#include <menes-app/application.hpp> |
13 |
+ |
#include <menes-ios/stdadapters.hpp> |
14 |
|
|
15 |
|
#include <algorithm> |
16 |
|
#include <cstring> |
27 |
|
{ |
28 |
|
virtual int Run(const app::ArgumentList& args) |
29 |
|
{ |
30 |
< |
Zoe::program = api::GetExecutableName(); |
30 |
> |
Zoe::program = api::GetExecutablePath().GetName(); |
31 |
|
|
32 |
|
for (size_t index(0); index < args.GetSize(); ++index) |
33 |
|
{ |
68 |
|
if (!(collector || publisher)) usage(); |
69 |
|
|
70 |
|
configure(); |
70 |
– |
initialize(); |
71 |
|
|
72 |
|
Collector collector(login, password, buddies, database, Zoe::collector); |
73 |
|
Publisher publisher(buddies, database, Zoe::publisher); |
79 |
|
|
80 |
|
void Zoe::usage() |
81 |
|
{ |
82 |
< |
cerr << "Usage: " << Zoe::program << " [-config=config] [-collector] " |
82 |
> |
api::Cerr << "Usage: " << Zoe::program << " [-config=config] [-collector] " |
83 |
|
"[-publisher] [-color] [-D]\n"; |
84 |
|
|
85 |
|
exit(1); |
99 |
|
|
100 |
|
uname(&system); |
101 |
|
|
102 |
< |
generator_.InsertAllLast(_R(" (") + system.sysname); |
102 |
> |
generator_.InsertAllLast(ios::String() << " (" << system.sysname); |
103 |
|
} |
104 |
|
|
105 |
|
if (generator == agent) |
124 |
|
|
125 |
|
void Zoe::configure() |
126 |
|
{ |
127 |
< |
if (debug) cerr << "config = " << config << '\n'; |
127 |
> |
if (debug) api::Cerr << "config = " << config << "\n"; |
128 |
|
|
129 |
|
ext::Handle<xml::Document> document(xml::Parse(config)); |
130 |
|
ext::Handle<xml::Node> zoe(*document/"zoe"); |
151 |
|
|
152 |
|
database.db = *zoe/"database"/"db"; |
153 |
|
|
154 |
< |
if (debug) cerr << "login = " << login << "\npassword = " |
154 |
> |
if (debug) api::Cerr << "login = " << login << "\npassword = " |
155 |
|
<< std::string(password.GetSize(), '*') << "\ndatabase = {\n" |
156 |
|
<< " driver = " << database.driver << "\n host = " << database.host |
157 |
< |
<< "\n user = " << database.user << '\n' |
157 |
> |
<< "\n user = " << database.user << "\n" |
158 |
|
<< " password = " << std::string(database.password.GetSize(), '*') |
159 |
|
<< "\n db = " << database.db << "\n}\n"; |
160 |
|
|
171 |
|
this->buddies.insert(buddy_); |
172 |
|
} |
173 |
|
|
174 |
+ |
initialize(); |
175 |
+ |
|
176 |
|
if (debug) |
177 |
|
{ |
178 |
< |
cerr << "buddies = {\n"; |
178 |
> |
api::Cerr << "buddies = {\n"; |
179 |
|
|
180 |
|
for (std::set<Buddy>::const_iterator buddy(this->buddies.begin()); |
181 |
|
buddy != this->buddies.end(); ++buddy) |
182 |
|
{ |
183 |
< |
cerr << " " << *buddy << " = {\n rss = " << buddy->getRss() |
184 |
< |
<< "\n atom = " << buddy->getAtom() << "\n link = " |
185 |
< |
<< buddy->getLink() << "\n }\n"; |
183 |
> |
api::Cerr << " " << *buddy << " = {\n rss = " |
184 |
> |
<< buddy->getRss() << "\n atom = " << buddy->getAtom() |
185 |
> |
<< "\n link = " << buddy->getLink() << "\n id = " |
186 |
> |
<< buddy->getId() << "\n }\n"; |
187 |
|
} |
188 |
|
|
189 |
< |
cerr << "}\n"; |
189 |
> |
api::Cerr << "}\n"; |
190 |
|
} |
191 |
|
|
192 |
< |
if (debug) cerr << "collector = " << lexical_cast<ext::String>(collector) |
193 |
< |
<< "\npublisher = " << lexical_cast<ext::String>(publisher) |
191 |
< |
<< "\ncolor = " << lexical_cast<ext::String>(color) << '\n'; |
192 |
> |
if (debug) api::Cerr << "collector = " << collector << "\npublisher = " |
193 |
> |
<< publisher << "\ncolor = " << color << "\n"; |
194 |
|
} |
195 |
|
|
196 |
|
void Zoe::initialize() |
221 |
|
for (std::vector<Buddy>::iterator buddy(difference.begin()); |
222 |
|
buddy != difference.end(); ++buddy) |
223 |
|
{ |
224 |
< |
ext::Uuid id; |
224 |
> |
ext::Uuid id(api::Uuid::CreateSequential()); |
225 |
|
|
226 |
< |
api::Uuid::CreateSequential(id); |
226 |
> |
// api::Uuid::CreateSequential(id); |
227 |
|
|
228 |
|
buddy->setId(id); |
229 |
|
db->Execute("INSERT INTO buddies (id, buddy) VALUES ('" |