// Google Tron // // Douglas Thrift // // $Id$ #include #include #include #include #include "GoogleTron.hpp" #include "GzipWriter.hpp" #include "Sleep.hpp" int Main(const app::Options &options) { GoogleTron tron(_B("sitemap.gz")); return 0; } GoogleTron::GoogleTron(const cse::String &sitemap) : working(true), sitemap(sitemap) { // XXX: start some threads } GoogleTron::~GoogleTron() { // XXX: wait on threads working = false; // XXX: wait on output thread } int GoogleTron::Output() { _S gzip(sitemap); _S writer(gzip); xml::ScopeElement urlset(writer, _B("urlset")); writer.SetAttribute(_B("xmlns"), _B("http://www.google.com/schemas/sitemap/0.84")); do { Sleep(); _synchronized (queueLock) if (queue.size()) { xml::ScopeElement url_(writer, _B("url")); const Url &url(queue.front()); { xml::ScopeElement loc(writer, _B("loc")); writer.OutputText(url.GetLocation()); } { xml::ScopeElement lastmod(writer, _B("lastmod")); writer.OutputText(url.GetModified()); } { xml::ScopeElement changefreq(writer, _B("changefreq")); writer.OutputText(url.GetFrequency()); } { xml::ScopeElement priority(writer, _B("priority")); writer.OutputText(url.GetPriority()); } queue.pop(); } } while (working); return 0; }