author | Michael Krelin <hacker@klever.net> | 2008-06-29 18:47:27 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2008-06-29 18:47:27 (UTC) |
commit | 73f6183b26b1ebc460a27554b71e44037c07e09c (patch) (unidiff) | |
tree | ebb9d9af6008a3946220e1b65f6b464ccf687546 /lib/discovery.cc | |
parent | 12837594b705ad10fdadfd0ba1bfc2249b3b1264 (diff) | |
download | libopkele-73f6183b26b1ebc460a27554b71e44037c07e09c.zip libopkele-73f6183b26b1ebc460a27554b71e44037c07e09c.tar.gz libopkele-73f6183b26b1ebc460a27554b71e44037c07e09c.tar.bz2 |
fixed debugging info settings for htmltidy
Thanks to Brian Muller for spotting it!
Signed-off-by: Michael Krelin <hacker@klever.net>
-rw-r--r-- | lib/discovery.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc index 984e308..bd1f917 100644 --- a/lib/discovery.cc +++ b/lib/discovery.cc | |||
@@ -208,99 +208,102 @@ namespace opkele { | |||
208 | st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) | 208 | st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) |
209 | queue_endpoints(oi,idis,st); | 209 | queue_endpoints(oi,idis,st); |
210 | } | 210 | } |
211 | }else{ | 211 | }else{ |
212 | idis.clear(); | 212 | idis.clear(); |
213 | idis.canonicalized_id = cid; | 213 | idis.canonicalized_id = cid; |
214 | discover_at(idis,xrds_location,xmode_xrd); | 214 | discover_at(idis,xrds_location,xmode_xrd); |
215 | if(idis.xrd.empty()) | 215 | if(idis.xrd.empty()) |
216 | html2xrd(oi,idis); | 216 | html2xrd(oi,idis); |
217 | else{ | 217 | else{ |
218 | for(const service_type_t *st=op_service_types; | 218 | for(const service_type_t *st=op_service_types; |
219 | st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) | 219 | st<&op_service_types[sizeof(op_service_types)/sizeof(*op_service_types)];++st) |
220 | queue_endpoints(oi,idis,st); | 220 | queue_endpoints(oi,idis,st); |
221 | } | 221 | } |
222 | } | 222 | } |
223 | } | 223 | } |
224 | return rv; | 224 | return rv; |
225 | } | 225 | } |
226 | 226 | ||
227 | void discover_at(idiscovery_t& idis,const string& url,int xm) { | 227 | void discover_at(idiscovery_t& idis,const string& url,int xm) { |
228 | CURLcode r = easy_setopt(CURLOPT_MAXREDIRS, (xm&xmode_noredirs)?0:5); | 228 | CURLcode r = easy_setopt(CURLOPT_MAXREDIRS, (xm&xmode_noredirs)?0:5); |
229 | if(r) | 229 | if(r) |
230 | throw exception_curl(OPKELE_CP_ "failed to set curly maxredirs option"); | 230 | throw exception_curl(OPKELE_CP_ "failed to set curly maxredirs option"); |
231 | if( (r=easy_setopt(CURLOPT_URL,url.c_str())) ) | 231 | if( (r=easy_setopt(CURLOPT_URL,url.c_str())) ) |
232 | throw exception_curl(OPKELE_CP_ "failed to set curly urlie",r); | 232 | throw exception_curl(OPKELE_CP_ "failed to set curly urlie",r); |
233 | 233 | ||
234 | http_content_type.clear(); | 234 | http_content_type.clear(); |
235 | xmode = xm; | 235 | xmode = xm; |
236 | prepare_to_parse(); | 236 | prepare_to_parse(); |
237 | if(xmode&xmode_html) { | 237 | if(xmode&xmode_html) { |
238 | xrds_location.clear(); | 238 | xrds_location.clear(); |
239 | save_html.clear(); | 239 | save_html.clear(); |
240 | save_html.reserve(max_html); | 240 | save_html.reserve(max_html); |
241 | } | 241 | } |
242 | xrd = &idis.xrd; | 242 | xrd = &idis.xrd; |
243 | 243 | ||
244 | r = easy_perform(); | 244 | r = easy_perform(); |
245 | if(r && r!=CURLE_WRITE_ERROR) | 245 | if(r && r!=CURLE_WRITE_ERROR) |
246 | throw exception_curl(OPKELE_CP_ "failed to perform curly request",r); | 246 | throw exception_curl(OPKELE_CP_ "failed to perform curly request",r); |
247 | 247 | ||
248 | if(!parser_choked) { | 248 | if(!parser_choked) { |
249 | parse(0,0,true); | 249 | parse(0,0,true); |
250 | }else if(xmode&xmode_html){ | 250 | }else if(xmode&xmode_html){ |
251 | /* TODO: do not bother if we've seen xml */ | 251 | /* TODO: do not bother if we've seen xml */ |
252 | try { | 252 | try { |
253 | util::tidy_doc_t td = util::tidy_doc_t::create(); | 253 | util::tidy_doc_t td = util::tidy_doc_t::create(); |
254 | if(!td) | 254 | if(!td) |
255 | throw exception_tidy(OPKELE_CP_ "failed to create htmltidy document"); | 255 | throw exception_tidy(OPKELE_CP_ "failed to create htmltidy document"); |
256 | #ifndef NDEBUG | 256 | #ifdef NDEBUG |
257 | td.opt_set(TidyQuiet,false); | 257 | td.opt_set(TidyQuiet,true); |
258 | td.opt_set(TidyShowWarnings,false); | 258 | td.opt_set(TidyShowWarnings,false); |
259 | #else /* NDEBUG */ | ||
260 | td.opt_set(TidyQuiet,false); | ||
261 | td.opt_set(TidyShowWarnings,true); | ||
259 | #endif /* NDEBUG */ | 262 | #endif /* NDEBUG */ |
260 | td.opt_set(TidyForceOutput,true); | 263 | td.opt_set(TidyForceOutput,true); |
261 | td.opt_set(TidyXhtmlOut,true); | 264 | td.opt_set(TidyXhtmlOut,true); |
262 | td.opt_set(TidyDoctypeMode,TidyDoctypeOmit); | 265 | td.opt_set(TidyDoctypeMode,TidyDoctypeOmit); |
263 | td.opt_set(TidyMark,false); | 266 | td.opt_set(TidyMark,false); |
264 | td.opt_set(TidyNumEntities,true); | 267 | td.opt_set(TidyNumEntities,true); |
265 | if(td.parse_string(save_html)<=0) | 268 | if(td.parse_string(save_html)<=0) |
266 | throw exception_tidy(OPKELE_CP_ "tidy failed to parse document"); | 269 | throw exception_tidy(OPKELE_CP_ "tidy failed to parse document"); |
267 | if(td.clean_and_repair()<=0) | 270 | if(td.clean_and_repair()<=0) |
268 | throw exception_tidy(OPKELE_CP_ "tidy failed to clean and repair"); | 271 | throw exception_tidy(OPKELE_CP_ "tidy failed to clean and repair"); |
269 | util::tidy_buf_t tide; | 272 | util::tidy_buf_t tide; |
270 | if(td.save_buffer(tide)<=0) | 273 | if(td.save_buffer(tide)<=0) |
271 | throw exception_tidy(OPKELE_CP_ "tidy failed to save buffer"); | 274 | throw exception_tidy(OPKELE_CP_ "tidy failed to save buffer"); |
272 | prepare_to_parse(); | 275 | prepare_to_parse(); |
273 | parse(tide.c_str(),tide.size(),true); | 276 | parse(tide.c_str(),tide.size(),true); |
274 | }catch(exception_tidy& et) { } | 277 | }catch(exception_tidy& et) { } |
275 | } | 278 | } |
276 | save_html.clear(); | 279 | save_html.clear(); |
277 | } | 280 | } |
278 | 281 | ||
279 | void prepare_to_parse() { | 282 | void prepare_to_parse() { |
280 | (*(expat_t*)this) = parser_create_ns(); | 283 | (*(expat_t*)this) = parser_create_ns(); |
281 | set_user_data(); set_element_handler(); | 284 | set_user_data(); set_element_handler(); |
282 | set_character_data_handler(); | 285 | set_character_data_handler(); |
283 | 286 | ||
284 | if(xmode&xmode_html) { | 287 | if(xmode&xmode_html) { |
285 | html_openid1.clear(); html_openid2.clear(); | 288 | html_openid1.clear(); html_openid2.clear(); |
286 | parser_choked = false; | 289 | parser_choked = false; |
287 | } | 290 | } |
288 | 291 | ||
289 | cdata = 0; xrd_service = 0; skipping = 0; | 292 | cdata = 0; xrd_service = 0; skipping = 0; |
290 | pt_stack.clear(); | 293 | pt_stack.clear(); |
291 | status_code = 100; status_string.clear(); | 294 | status_code = 100; status_string.clear(); |
292 | } | 295 | } |
293 | 296 | ||
294 | void html2xrd(endpoint_discovery_iterator& oi,idiscovery_t& id) { | 297 | void html2xrd(endpoint_discovery_iterator& oi,idiscovery_t& id) { |
295 | XRD_t& x = id.xrd; | 298 | XRD_t& x = id.xrd; |
296 | if(!html_openid2.uris.empty()) { | 299 | if(!html_openid2.uris.empty()) { |
297 | html_openid2.types.insert(STURI_OPENID20); | 300 | html_openid2.types.insert(STURI_OPENID20); |
298 | x.services.add(-1,html_openid2); | 301 | x.services.add(-1,html_openid2); |
299 | queue_endpoints(oi,id,&op_service_types[st_index_2]); | 302 | queue_endpoints(oi,id,&op_service_types[st_index_2]); |
300 | } | 303 | } |
301 | if(!html_openid1.uris.empty()) { | 304 | if(!html_openid1.uris.empty()) { |
302 | html_openid1.types.insert(STURI_OPENID11); | 305 | html_openid1.types.insert(STURI_OPENID11); |
303 | x.services.add(-1,html_openid1); | 306 | x.services.add(-1,html_openid1); |
304 | queue_endpoints(oi,id,&op_service_types[st_index_1]); | 307 | queue_endpoints(oi,id,&op_service_types[st_index_1]); |
305 | } | 308 | } |
306 | } | 309 | } |