ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Zoe.cpp
Revision: 11
Committed: 2004-07-10T22:30:54-07:00 (20 years, 11 months ago) by douglas
File size: 1496 byte(s)
Log Message:
My way was undefined, this is nice, but not as nice.

File Contents

# User Rev Content
1 douglas 5 // Zoe AIM Away Message RSS Feed Generator
2     //
3     // Seth King and Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Zoe.hpp"
8     #include "Matcher.hpp"
9    
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     Zoe::Zoe() : rss("zoe.rss")
41     {
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 11 api::FileOutputStream fout(this->rss != "-" ? this->rss : "/dev/null");
47     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     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     login = *zoe/"login";
71     password = *zoe/"password";
72    
73     if (!(*zoe/"rss").IsEmpty()) rss = *zoe/"rss";
74     }

Properties

Name Value
svn:eol-style native
svn:keywords Id