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 |
12 |
#include "Buddy.hpp" |
9 |
douglas |
5 |
|
10 |
|
|
int main(int argc, char* argv[]) |
11 |
|
|
{ |
12 |
douglas |
7 |
Zoe::program = argv[0]; |
13 |
douglas |
5 |
|
14 |
douglas |
7 |
for (int index(1); index < argc; ++index) |
15 |
|
|
{ |
16 |
|
|
ext::String arg(argv[index]); |
17 |
|
|
Matcher matcher; |
18 |
|
|
|
19 |
|
|
if (arg == matcher("^-config=(.*)$")) |
20 |
|
|
{ |
21 |
|
|
Zoe::config = matcher[1]; |
22 |
|
|
} |
23 |
|
|
else if (arg == "-D") |
24 |
|
|
{ |
25 |
|
|
if (!Zoe::debug) Zoe::debug = true; |
26 |
|
|
} |
27 |
|
|
else |
28 |
|
|
{ |
29 |
|
|
cerr << "Usage: " << Zoe::program << " [-config=config] [-D]\n"; |
30 |
douglas |
9 |
|
31 |
|
|
return 1; |
32 |
douglas |
7 |
} |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
Zoe zoe; |
36 |
|
|
|
37 |
douglas |
5 |
return 0; |
38 |
|
|
} |
39 |
douglas |
7 |
|
40 |
douglas |
12 |
Zoe::Zoe() |
41 |
douglas |
7 |
{ |
42 |
|
|
configure(); |
43 |
douglas |
8 |
|
44 |
|
|
// This is just to figure out Jay's XML output, seems to have worked! |
45 |
douglas |
9 |
// It should really go in Rss.cpp later |
46 |
douglas |
12 |
/* api::FileOutputStream fout(this->rss != "-" ? this->rss : "/dev/null"); |
47 |
douglas |
11 |
xml::TextWriter rss(this->rss != "-" ? fout : api::Cout.GetStream()); |
48 |
douglas |
8 |
xml::ScopeElement root(rss, "rss"); |
49 |
|
|
|
50 |
|
|
rss.SetAttribute("version", "2.0"); |
51 |
|
|
|
52 |
|
|
xml::ScopeElement channel(rss, "channel"); |
53 |
|
|
|
54 |
|
|
rss.OpenElement("title"); |
55 |
|
|
rss.OutputText("Zoe's Away Messages"); |
56 |
|
|
rss.CloseElement(); |
57 |
|
|
rss.OpenElement("link"); |
58 |
|
|
rss.OutputText("http://computers.douglasthrift.net/zoe.xml"); |
59 |
douglas |
12 |
rss.CloseElement();*/ |
60 |
douglas |
7 |
} |
61 |
|
|
|
62 |
|
|
bool Zoe::debug(false); |
63 |
|
|
ext::String Zoe::program, Zoe::config("zoe.xml"); |
64 |
|
|
|
65 |
|
|
void Zoe::configure() |
66 |
|
|
{ |
67 |
|
|
ext::Handle<xml::Document> document(xml::Parse(config)); |
68 |
|
|
ext::Handle<xml::Node> zoe(*document/"zoe"); |
69 |
|
|
|
70 |
douglas |
12 |
login = std::string(*zoe/"login"); |
71 |
|
|
password = std::string(*zoe/"password"); |
72 |
douglas |
7 |
|
73 |
douglas |
12 |
xml::NodeSet buddies(*zoe/"buddy"); |
74 |
|
|
|
75 |
|
|
for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End(); |
76 |
|
|
++buddy) |
77 |
|
|
{ |
78 |
|
|
this->buddies.insert(Buddy(**buddy/"login", **buddy/"rss")); |
79 |
|
|
} |
80 |
douglas |
7 |
} |