17 |
|
#include "Sleep.hpp" |
18 |
|
#include "Zlib/GzipWriter.hpp" |
19 |
|
|
20 |
< |
int Usage() |
20 |
> |
namespace |
21 |
|
{ |
22 |
– |
api::Cout << _B("Usage: ") << api::GetExecutablePath().GetName() << _B(" [-sitemap=.+] -base=.+ [-fs=.*] [-blog=.*] [-wiki=.*] [...]") << ios::NewLine; |
22 |
|
|
23 |
< |
return 1; |
23 |
> |
static struct Apr |
24 |
> |
{ |
25 |
> |
Apr() |
26 |
> |
{ |
27 |
> |
api::Apr::CheckError(::apr_initialize()); |
28 |
> |
} |
29 |
> |
|
30 |
> |
~Apr() |
31 |
> |
{ |
32 |
> |
::apr_terminate(); |
33 |
> |
} |
34 |
> |
} |
35 |
> |
arp; |
36 |
> |
|
37 |
|
} |
38 |
|
|
39 |
|
int Main(const app::Options &options) |
58 |
|
else if (match = wiki(*arg)) |
59 |
|
commands.InsertLast(new _H<WikiCommand>(match[1])); |
60 |
|
else |
61 |
< |
return Usage(); |
61 |
> |
goto usage; |
62 |
|
} |
63 |
|
|
64 |
|
if (base.IsEmpty() || commands.IsEmpty()) |
65 |
< |
return Usage(); |
65 |
> |
{ |
66 |
> |
usage: api::Cout << _B("Usage: ") << api::GetExecutablePath().GetName() << _B(" [-sitemap=.+] -base=.+ [-fs=.*] [-blog=.*] [-wiki=.*] [...]") << ios::NewLine; |
67 |
> |
|
68 |
> |
return 1; |
69 |
> |
} |
70 |
|
|
71 |
|
GoogleTron tron(sitemap, base, commands); |
72 |
|
|
103 |
|
writer.SetAttribute(_B("xmlns:xsi"), _B("http://www.w3.org/2001/XMLSchema-instance")); |
104 |
|
writer.SetAttribute(_B("xsi:schemaLocation"), _B("http://www.google.com/schemas/sitemap/0.84 http://www.google.com/schemas/sitemap/0.84/sitemap.xsd")); |
105 |
|
|
106 |
< |
do |
107 |
< |
{ |
108 |
< |
Sleep(); |
93 |
< |
|
94 |
< |
_synchronized (queueLock) |
95 |
< |
if (queue.GetSize()) |
106 |
> |
_synchronized (queueLock) |
107 |
> |
do |
108 |
> |
_desynchronized (queueLock) |
109 |
|
{ |
110 |
< |
xml::ScopeElement url_(writer, _B("url")); |
111 |
< |
const Url &url(queue.Front()); |
110 |
> |
Sleep(); |
111 |
> |
|
112 |
> |
_synchronized (queueLock) |
113 |
> |
if (queue.GetSize()) |
114 |
> |
{ |
115 |
> |
xml::ScopeElement url_(writer, _B("url")); |
116 |
> |
const Url &url(queue.Front()); |
117 |
|
|
118 |
< |
{ |
119 |
< |
xml::ScopeElement loc(writer, _B("loc")); |
118 |
> |
{ |
119 |
> |
xml::ScopeElement loc(writer, _B("loc")); |
120 |
|
|
121 |
< |
writer.OutputText(url.GetLocation()); |
122 |
< |
} |
121 |
> |
writer.OutputText(url.GetLocation()); |
122 |
> |
} |
123 |
|
|
124 |
< |
{ |
125 |
< |
xml::ScopeElement lastmod(writer, _B("lastmod")); |
124 |
> |
{ |
125 |
> |
xml::ScopeElement lastmod(writer, _B("lastmod")); |
126 |
|
|
127 |
< |
writer.OutputText(url.GetModified()); |
128 |
< |
} |
127 |
> |
writer.OutputText(url.GetModified()); |
128 |
> |
} |
129 |
|
|
130 |
< |
{ |
131 |
< |
xml::ScopeElement changefreq(writer, _B("changefreq")); |
130 |
> |
{ |
131 |
> |
xml::ScopeElement changefreq(writer, _B("changefreq")); |
132 |
|
|
133 |
< |
writer.OutputText(url.GetFrequency()); |
134 |
< |
} |
133 |
> |
writer.OutputText(url.GetFrequency()); |
134 |
> |
} |
135 |
|
|
136 |
< |
{ |
137 |
< |
xml::ScopeElement priority(writer, _B("priority")); |
136 |
> |
{ |
137 |
> |
xml::ScopeElement priority(writer, _B("priority")); |
138 |
|
|
139 |
< |
writer.OutputText(url.GetPriority()); |
140 |
< |
} |
139 |
> |
writer.OutputText(url.GetPriority()); |
140 |
> |
} |
141 |
|
|
142 |
< |
queue.Pop(); |
142 |
> |
api::Cout << _B("Url: ") << url.GetLocation() << ios::NewLine << _B(" ") << url.GetModified() << _B(" ") << url.GetFrequency() << _B(" ") << url.GetPriority() << ios::NewLine; |
143 |
> |
|
144 |
> |
queue.Pop(); |
145 |
> |
} |
146 |
|
} |
147 |
< |
} |
127 |
< |
while (working); |
147 |
> |
while (working || queue.GetSize()); |
148 |
|
|
149 |
|
return 0; |
150 |
|
} |