// Zoe AIM Away Message RSS Feed Generator // // Seth King and Douglas Thrift // // $Id$ #include "Matcher.hpp" #include "Collector.hpp" #include "Publisher.hpp" enum Color { reset, bright, dim, underscore = 4, blink, reverse = 7, hidden, black = 30, red, green, yellow, blue, magenta, cyan, white, _black = 40, _red, _green, _yellow, _blue, _magenta, _cyan, _white }; inline std::ostream& operator<<(std::ostream& sout, Color color) { sout << "\033[" << unsigned(color) << 'm'; return sout; } int main(int argc, char* argv[]) { Zoe::program = argv[0]; for (int index(1); index < argc; ++index) { ext::String arg(argv[index]); Matcher matcher; if (arg == matcher("^-config=(.*)$")) { Zoe::config = matcher[1]; } else if (arg == "-collector") { if (!Zoe::collector) Zoe::collector = true; } else if (arg == "-publisher") { if (!Zoe::publisher) Zoe::publisher = true; } else if (arg == "-D") { if (!Zoe::debug) Zoe::debug = true; } else { cerr << bright << "Usage: " << cyan << Zoe::program << reset << " [" << bright << blue << "-config=" << yellow << "config" << reset << "] [" << bright << blue << "-collector" << reset << "] [" << bright << blue << "-publisher" << reset << "] [" << bright << blue << "-D" << reset << "]\n"; return 1; } } Zoe zoe; return 0; } Zoe::Zoe() { configure(); if (collector) Collector collector(buddies); if (publisher) Publisher publisher(buddies); } bool Zoe::debug(false), Zoe::collector(false), Zoe::publisher(false); ext::String Zoe::program, Zoe::config("zoe.xml"); void Zoe::configure() { ext::Handle document(xml::Parse(config)); ext::Handle zoe(*document/"zoe"); login = std::string(*zoe/"login"); password = std::string(*zoe/"password"); xml::NodeSet buddies(*zoe/"buddy"); for (xml::NodeSet::Iterator buddy(buddies.Begin()); buddy != buddies.End(); ++buddy) { this->buddies.insert(Buddy(**buddy/"login", **buddy/"rss")); } if (!collector && !publisher) { collector = true; publisher = true; } }