9 |
|
|
10 |
|
int main(int argc, char* argv[]) |
11 |
|
{ |
12 |
< |
// |
12 |
> |
Zoe::program = argv[0]; |
13 |
> |
|
14 |
> |
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 |
> |
|
31 |
> |
return 1; |
32 |
> |
} |
33 |
> |
} |
34 |
> |
|
35 |
> |
Zoe zoe; |
36 |
|
|
37 |
|
return 0; |
38 |
|
} |
39 |
+ |
|
40 |
+ |
Zoe::Zoe() : rss("zoe.rss") |
41 |
+ |
{ |
42 |
+ |
configure(); |
43 |
+ |
|
44 |
+ |
// This is just to figure out Jay's XML output, seems to have worked! |
45 |
+ |
// It should really go in Rss.cpp later |
46 |
+ |
api::FileOutputStream fout; |
47 |
+ |
|
48 |
+ |
if (this->rss != "-") fout.Open(this->rss); // need to ask Jay "Why?" |
49 |
+ |
|
50 |
+ |
xml::TextWriter rss(this->rss != "-" ? /*api::FileOutputStream(this->rss)*/ |
51 |
+ |
fout : api::Cout.GetStream()); |
52 |
+ |
xml::ScopeElement root(rss, "rss"); |
53 |
+ |
|
54 |
+ |
rss.SetAttribute("version", "2.0"); |
55 |
+ |
|
56 |
+ |
xml::ScopeElement channel(rss, "channel"); |
57 |
+ |
|
58 |
+ |
rss.OpenElement("title"); |
59 |
+ |
rss.OutputText("Zoe's Away Messages"); |
60 |
+ |
rss.CloseElement(); |
61 |
+ |
rss.OpenElement("link"); |
62 |
+ |
rss.OutputText("http://computers.douglasthrift.net/zoe.xml"); |
63 |
+ |
rss.CloseElement(); |
64 |
+ |
} |
65 |
+ |
|
66 |
+ |
bool Zoe::debug(false); |
67 |
+ |
ext::String Zoe::program, Zoe::config("zoe.xml"); |
68 |
+ |
|
69 |
+ |
void Zoe::configure() |
70 |
+ |
{ |
71 |
+ |
ext::Handle<xml::Document> document(xml::Parse(config)); |
72 |
+ |
ext::Handle<xml::Node> zoe(*document/"zoe"); |
73 |
+ |
|
74 |
+ |
login = *zoe/"login"; |
75 |
+ |
password = *zoe/"password"; |
76 |
+ |
|
77 |
+ |
if (!(*zoe/"rss").IsEmpty()) rss = *zoe/"rss"; |
78 |
+ |
} |