29 |
|
{ |
30 |
|
Zoe::program = api::GetExecutablePath().GetName(); |
31 |
|
|
32 |
< |
for (size_t index(0); index < args.GetSize(); ++index) |
32 |
> |
_foreach (app::ArgumentList, arg, args) |
33 |
|
{ |
34 |
– |
ext::String arg(args[index]); |
34 |
|
Matcher matcher; |
35 |
|
|
36 |
< |
if (arg == matcher("^-config=(.*)$")) |
36 |
> |
if (*arg == matcher("^-config=(.*)$")) |
37 |
|
{ |
38 |
|
Zoe::config = matcher[1]; |
39 |
|
} |
40 |
< |
else if (arg == "-collector") |
40 |
> |
else if (*arg == "-collector") |
41 |
|
{ |
42 |
|
if (!Zoe::collector) Zoe::collector = true; |
43 |
|
} |
44 |
< |
else if (arg == "-publisher") |
44 |
> |
else if (*arg == "-publisher") |
45 |
|
{ |
46 |
|
if (!Zoe::publisher) Zoe::publisher = true; |
47 |
|
} |
48 |
< |
else if (arg == "-color") |
48 |
> |
else if (*arg == "-color") |
49 |
|
{ |
50 |
|
if (!Zoe::color) Zoe::color = true; |
51 |
|
} |
52 |
< |
else if (arg == "-D") |
52 |
> |
else if (*arg == "-D") |
53 |
|
{ |
54 |
|
if (!Zoe::debug) Zoe::debug = true; |
55 |
|
} |
56 |
< |
else Zoe::usage(); |
56 |
> |
else |
57 |
> |
{ |
58 |
> |
Zoe::usage(); |
59 |
> |
|
60 |
> |
return 1; |
61 |
> |
} |
62 |
|
} |
63 |
|
|
64 |
|
Zoe zoe; |
69 |
|
|
70 |
|
Zoe::Zoe() |
71 |
|
{ |
72 |
< |
if (!(collector || publisher)) usage(); |
72 |
> |
if (!(collector || publisher)) |
73 |
> |
{ |
74 |
> |
usage(); |
75 |
> |
|
76 |
> |
return; |
77 |
> |
} |
78 |
|
|
79 |
|
configure(); |
80 |
|
|
88 |
|
|
89 |
|
void Zoe::usage() |
90 |
|
{ |
91 |
< |
api::Cerr << "Usage: " << Zoe::program << " [-config=config] [-collector] " |
83 |
< |
"[-publisher] [-color] [-D]\n"; |
84 |
< |
|
85 |
< |
exit(1); |
91 |
> |
api::Cerr << "Usage: " << Zoe::program << " [-config=config] [-collector] [-publisher] [-color] [-D]" << ios::NewLine; |
92 |
|
} |
93 |
|
|
94 |
|
ext::String Zoe::generator(Generator generator) |
101 |
|
generator_.InsertAllLast("/0.9"); |
102 |
|
case agent: |
103 |
|
{ |
104 |
< |
utsname system; |
104 |
> |
::utsname system; |
105 |
|
|
106 |
< |
uname(&system); |
106 |
> |
::uname(&system); |
107 |
|
|
108 |
|
generator_.InsertAllLast(ios::String() << " (" << system.sysname); |
109 |
|
} |
130 |
|
|
131 |
|
void Zoe::configure() |
132 |
|
{ |
133 |
< |
if (debug) api::Cerr << "config = " << config << "\n"; |
133 |
> |
if (debug) api::Cerr << "config = " << config << ios::NewLine; |
134 |
|
|
135 |
|
ext::Handle<xml::Document> document(xml::Parse(config)); |
136 |
|
ext::Handle<xml::Node> zoe(*document/"zoe"); |
196 |
|
} |
197 |
|
|
198 |
|
if (debug) api::Cerr << "collector = " << collector << "\npublisher = " |
199 |
< |
<< publisher << "\ncolor = " << color << "\n"; |
199 |
> |
<< publisher << "\ncolor = " << color << "\n" << ios::Flush; |
200 |
|
} |
201 |
|
|
202 |
|
void Zoe::initialize() |
229 |
|
{ |
230 |
|
ext::Uuid id(api::Uuid::CreateSequential()); |
231 |
|
|
226 |
– |
// api::Uuid::CreateSequential(id); |
227 |
– |
|
232 |
|
buddy->setId(id); |
233 |
|
db->Execute("INSERT INTO buddies (id, buddy) VALUES ('" |
234 |
|
+ lexical_cast<ext::String>(id) + "', '" + ext::String(*buddy) |