1 |
douglas |
5 |
// Zoe AIM Away Message RSS Feed Generator |
2 |
|
|
// |
3 |
|
|
// Seth King and Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include "Matcher.hpp" |
8 |
douglas |
13 |
#include "Collector.hpp" |
9 |
|
|
#include "Publisher.hpp" |
10 |
douglas |
5 |
|
11 |
|
|
int main(int argc, char* argv[]) |
12 |
|
|
{ |
13 |
douglas |
7 |
Zoe::program = argv[0]; |
14 |
douglas |
5 |
|
15 |
douglas |
7 |
for (int index(1); index < argc; ++index) |
16 |
|
|
{ |
17 |
|
|
ext::String arg(argv[index]); |
18 |
|
|
Matcher matcher; |
19 |
|
|
|
20 |
|
|
if (arg == matcher("^-config=(.*)$")) |
21 |
|
|
{ |
22 |
|
|
Zoe::config = matcher[1]; |
23 |
|
|
} |
24 |
douglas |
13 |
else if (arg == "-collector") |
25 |
|
|
{ |
26 |
|
|
if (!Zoe::collector) Zoe::collector = true; |
27 |
|
|
} |
28 |
|
|
else if (arg == "-publisher") |
29 |
|
|
{ |
30 |
|
|
if (!Zoe::publisher) Zoe::publisher = true; |
31 |
|
|
} |
32 |
douglas |
7 |
else if (arg == "-D") |
33 |
|
|
{ |
34 |
|
|
if (!Zoe::debug) Zoe::debug = true; |
35 |
|
|
} |
36 |
|
|
else |
37 |
|
|
{ |
38 |
douglas |
13 |
cerr << "Usage: " << Zoe::program << " [-config=config] [-collector" |
39 |
|
|
<< "] [-publisher] [-D]\n"; |
40 |
douglas |
9 |
|
41 |
|
|
return 1; |
42 |
douglas |
7 |
} |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
Zoe zoe; |
46 |
|
|
|
47 |
douglas |
5 |
return 0; |
48 |
|
|
} |
49 |
douglas |
7 |
|
50 |
douglas |
12 |
Zoe::Zoe() |
51 |
douglas |
7 |
{ |
52 |
|
|
configure(); |
53 |
douglas |
8 |
|
54 |
douglas |
13 |
if (collector) Collector collector(buddies); |
55 |
|
|
if (publisher) Publisher publisher(buddies); |
56 |
douglas |
7 |
} |
57 |
|
|
|
58 |
douglas |
13 |
bool Zoe::debug(false), Zoe::collector(false), Zoe::publisher(false); |
59 |
douglas |
7 |
ext::String Zoe::program, Zoe::config("zoe.xml"); |
60 |
|
|
|
61 |
|
|
void Zoe::configure() |
62 |
|
|
{ |
63 |
|
|
ext::Handle<xml::Document> document(xml::Parse(config)); |
64 |
|
|
ext::Handle<xml::Node> zoe(*document/"zoe"); |
65 |
|
|
|
66 |
douglas |
12 |
login = std::string(*zoe/"login"); |
67 |
|
|
password = std::string(*zoe/"password"); |
68 |
douglas |
7 |
|
69 |
douglas |
12 |
xml::NodeSet buddies(*zoe/"buddy"); |
70 |
|
|
|
71 |
|
|
for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End(); |
72 |
|
|
++buddy) |
73 |
|
|
{ |
74 |
|
|
this->buddies.insert(Buddy(**buddy/"login", **buddy/"rss")); |
75 |
|
|
} |
76 |
douglas |
13 |
|
77 |
|
|
if (!collector && !publisher) |
78 |
|
|
{ |
79 |
|
|
collector = true; |
80 |
|
|
publisher = true; |
81 |
|
|
} |
82 |
douglas |
7 |
} |