author | Michael Krelin <hacker@klever.net> | 2008-01-05 19:39:07 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-01-05 22:03:51 (UTC) |
commit | 7bde7f66284b47a75bbceadc360e7f03550ace21 (patch) (unidiff) | |
tree | 401b24fc8b952fee21ad3dce117d4baf99048c9f | |
parent | 8e3f9231383194d94e41032b64d87cc6ef1c2ee8 (diff) | |
download | libopkele-7bde7f66284b47a75bbceadc360e7f03550ace21.zip libopkele-7bde7f66284b47a75bbceadc360e7f03550ace21.tar.gz libopkele-7bde7f66284b47a75bbceadc360e7f03550ace21.tar.bz2 |
discovery: stop parser with XML_StopParser()
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | include/opkele/expat.h | 6 | ||||
-rw-r--r-- | lib/discovery.cc | 18 |
2 files changed, 16 insertions, 8 deletions
diff --git a/include/opkele/expat.h b/include/opkele/expat.h index 60c41ac..97ed61a 100644 --- a/include/opkele/expat.h +++ b/include/opkele/expat.h | |||
@@ -24,6 +24,8 @@ namespace opkele { | |||
24 | inline bool parse(const char *s,int len,bool final=false) { | 24 | inline bool parse(const char *s,int len,bool final=false) { |
25 | assert(_x); | 25 | assert(_x); |
26 | return XML_Parse(_x,s,len,final); | 26 | return XML_Parse(_x,s,len,final); } |
27 | } | 27 | enum XML_Status stop_parser(bool resumable=false) { |
28 | assert(_x); | ||
29 | return XML_StopParser(_x,resumable); } | ||
28 | 30 | ||
29 | virtual void start_element(const XML_Char *n,const XML_Char **a) { } | 31 | virtual void start_element(const XML_Char *n,const XML_Char **a) { } |
diff --git a/lib/discovery.cc b/lib/discovery.cc index 81727c0..8729cfb 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -6,4 +6,5 @@ | |||
6 | #include <opkele/exception.h> | 6 | #include <opkele/exception.h> |
7 | #include <opkele/util.h> | 7 | #include <opkele/util.h> |
8 | #include <opkele/debug.h> | ||
8 | 9 | ||
9 | #include "config.h" | 10 | #include "config.h" |
@@ -176,5 +177,9 @@ namespace opkele { | |||
176 | /* TODO: limit total size */ | 177 | /* TODO: limit total size */ |
177 | size_t bytes = s*nm; | 178 | size_t bytes = s*nm; |
178 | parse((const char *)p,bytes,false); | 179 | bool rp = parse((const char *)p,bytes,false); |
180 | if(!rp) { | ||
181 | skipping = -1; | ||
182 | bytes = 0; | ||
183 | } | ||
179 | return bytes; | 184 | return bytes; |
180 | } | 185 | } |
@@ -226,5 +231,5 @@ namespace opkele { | |||
226 | html_start_element(n,a); | 231 | html_start_element(n,a); |
227 | }else{ | 232 | }else{ |
228 | skipping = -1; | 233 | skipping = -1; stop_parser(); |
229 | } | 234 | } |
230 | }else{ | 235 | }else{ |
@@ -311,6 +316,7 @@ namespace opkele { | |||
311 | assert(cdata==&status_string); | 316 | assert(cdata==&status_string); |
312 | pt_stack.pop_back(); | 317 | pt_stack.pop_back(); |
313 | if(status_code!=100) | 318 | if(status_code!=100) { |
314 | skipping = -1; | 319 | skipping = -1; stop_parser(); |
320 | } | ||
315 | } | 321 | } |
316 | }else if(is_qelement(n,NSURI_XRD "\tExpires")) { | 322 | }else if(is_qelement(n,NSURI_XRD "\tExpires")) { |
@@ -318,5 +324,5 @@ namespace opkele { | |||
318 | xrd->expires = util::w3c_to_time(cdata_buf); | 324 | xrd->expires = util::w3c_to_time(cdata_buf); |
319 | }else if((xmode&xmode_html) && is_element(n,"head")) { | 325 | }else if((xmode&xmode_html) && is_element(n,"head")) { |
320 | skipping = -1; | 326 | skipping = -1; stop_parser(); |
321 | } | 327 | } |
322 | cdata = 0; | 328 | cdata = 0; |
@@ -375,5 +381,5 @@ namespace opkele { | |||
375 | } | 381 | } |
376 | }else if(is_element(n,"body")) { | 382 | }else if(is_element(n,"body")) { |
377 | skipping = -1; | 383 | skipping = -1; stop_parser(); |
378 | } | 384 | } |
379 | } | 385 | } |