summaryrefslogtreecommitdiffabout
path: root/lib
authorMichael Krelin <hacker@klever.net>2008-01-06 23:00:18 (UTC)
committer Michael Krelin <hacker@klever.net>2008-01-06 23:05:57 (UTC)
commit7b5a82f255a85fe2ef466b68e40d9eb1829c633a (patch) (unidiff)
treee466813db17bd974de0b0d277f35219c393c5796 /lib
parent6a843bb112988976892058c56d5fe2f24e24300a (diff)
downloadlibopkele-7b5a82f255a85fe2ef466b68e40d9eb1829c633a.zip
libopkele-7b5a82f255a85fe2ef466b68e40d9eb1829c633a.tar.gz
libopkele-7b5a82f255a85fe2ef466b68e40d9eb1829c633a.tar.bz2
Revert "discovery: stop parser with XML_StopParser()" for now
This reverts commit 7bde7f66284b47a75bbceadc360e7f03550ace21. because some older expat version do not support this function I don't want to make it conditional for now. Conflicts: lib/discovery.cc Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'lib') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/discovery.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/discovery.cc b/lib/discovery.cc
index af9686a..d868308 100644
--- a/lib/discovery.cc
+++ b/lib/discovery.cc
@@ -262,49 +262,49 @@ namespace opkele {
262 http_content_type.assign(hv,sc?(sc-hv):rb); 262 http_content_type.assign(hv,sc?(sc-hv):rb);
263 } 263 }
264 } 264 }
265 } 265 }
266 return curl_t::header(p,s,nm); 266 return curl_t::header(p,s,nm);
267 } 267 }
268 268
269 void start_element(const XML_Char *n,const XML_Char **a) { 269 void start_element(const XML_Char *n,const XML_Char **a) {
270 if(skipping<0) return; 270 if(skipping<0) return;
271 if(skipping) { 271 if(skipping) {
272 if(xmode&xmode_html) 272 if(xmode&xmode_html)
273 html_start_element(n,a); 273 html_start_element(n,a);
274 ++skipping; return; 274 ++skipping; return;
275 } 275 }
276 if(pt_stack.empty()) { 276 if(pt_stack.empty()) {
277 if(is_qelement(n,NSURI_XRDS "\tXRDS")) 277 if(is_qelement(n,NSURI_XRDS "\tXRDS"))
278 return; 278 return;
279 if(is_qelement(n,NSURI_XRD "\tXRD")) { 279 if(is_qelement(n,NSURI_XRD "\tXRD")) {
280 assert(xrd); 280 assert(xrd);
281 xrd->clear(); 281 xrd->clear();
282 pt_stack.push_back(n); 282 pt_stack.push_back(n);
283 }else if(xmode&xmode_html) { 283 }else if(xmode&xmode_html) {
284 html_start_element(n,a); 284 html_start_element(n,a);
285 }else{ 285 }else{
286 skipping = -1; stop_parser(); 286 skipping = -1;
287 } 287 }
288 }else{ 288 }else{
289 int pt_s = pt_stack.size(); 289 int pt_s = pt_stack.size();
290 if(pt_s==1) { 290 if(pt_s==1) {
291 if(is_qelement(n,NSURI_XRD "\tCanonicalID")) { 291 if(is_qelement(n,NSURI_XRD "\tCanonicalID")) {
292 assert(xrd); 292 assert(xrd);
293 cdata = &(xrd->canonical_ids.add(element_priority(a),string())); 293 cdata = &(xrd->canonical_ids.add(element_priority(a),string()));
294 }else if(is_qelement(n,NSURI_XRD "\tLocalID")) { 294 }else if(is_qelement(n,NSURI_XRD "\tLocalID")) {
295 assert(xrd); 295 assert(xrd);
296 cdata = &(xrd->local_ids.add(element_priority(a),string())); 296 cdata = &(xrd->local_ids.add(element_priority(a),string()));
297 }else if(is_qelement(n,NSURI_XRD "\tProviderID")) { 297 }else if(is_qelement(n,NSURI_XRD "\tProviderID")) {
298 assert(xrd); 298 assert(xrd);
299 cdata = &(xrd->provider_id); 299 cdata = &(xrd->provider_id);
300 }else if(is_qelement(n,NSURI_XRD "\tService")) { 300 }else if(is_qelement(n,NSURI_XRD "\tService")) {
301 assert(xrd); 301 assert(xrd);
302 xrd_service = &(xrd->services.add(element_priority(a), 302 xrd_service = &(xrd->services.add(element_priority(a),
303 service_t())); 303 service_t()));
304 pt_stack.push_back(n); 304 pt_stack.push_back(n);
305 }else if(is_qelement(n,NSURI_XRD "\tStatus")) { 305 }else if(is_qelement(n,NSURI_XRD "\tStatus")) {
306 for(;*a;) { 306 for(;*a;) {
307 if(!strcasecmp(*(a++),"code")) { 307 if(!strcasecmp(*(a++),"code")) {
308 if(sscanf(*(a++),"%ld",&status_code)==1 && status_code!=100) { 308 if(sscanf(*(a++),"%ld",&status_code)==1 && status_code!=100) {
309 cdata = &status_string; 309 cdata = &status_string;
310 pt_stack.push_back(n); 310 pt_stack.push_back(n);
@@ -347,57 +347,56 @@ namespace opkele {
347 }else{ 347 }else{
348 skipping = 1; 348 skipping = 1;
349 } 349 }
350 } 350 }
351 } 351 }
352 void end_element(const XML_Char *n) { 352 void end_element(const XML_Char *n) {
353 if(skipping<0) return; 353 if(skipping<0) return;
354 if(skipping) { 354 if(skipping) {
355 --skipping; return; 355 --skipping; return;
356 } 356 }
357 if(is_qelement(n,NSURI_XRD "\tType")) { 357 if(is_qelement(n,NSURI_XRD "\tType")) {
358 assert(xrd); assert(xrd_service); assert(cdata==&cdata_buf); 358 assert(xrd); assert(xrd_service); assert(cdata==&cdata_buf);
359 xrd_service->types.insert(cdata_buf); 359 xrd_service->types.insert(cdata_buf);
360 }else if(is_qelement(n,NSURI_XRD "\tService")) { 360 }else if(is_qelement(n,NSURI_XRD "\tService")) {
361 assert(xrd); assert(xrd_service); 361 assert(xrd); assert(xrd_service);
362 assert(!pt_stack.empty()); 362 assert(!pt_stack.empty());
363 assert(pt_stack.back()==(NSURI_XRD "\tService")); 363 assert(pt_stack.back()==(NSURI_XRD "\tService"));
364 pt_stack.pop_back(); 364 pt_stack.pop_back();
365 xrd_service = 0; 365 xrd_service = 0;
366 }else if(is_qelement(n,NSURI_XRD "\tStatus")) { 366 }else if(is_qelement(n,NSURI_XRD "\tStatus")) {
367 assert(xrd); 367 assert(xrd);
368 if(is_qelement(pt_stack.back().c_str(),n)) { 368 if(is_qelement(pt_stack.back().c_str(),n)) {
369 assert(cdata==&status_string); 369 assert(cdata==&status_string);
370 pt_stack.pop_back(); 370 pt_stack.pop_back();
371 if(status_code!=100) { 371 if(status_code!=100)
372 skipping = -1; stop_parser(); 372 skipping = -1;
373 }
374 } 373 }
375 }else if(is_qelement(n,NSURI_XRD "\tExpires")) { 374 }else if(is_qelement(n,NSURI_XRD "\tExpires")) {
376 assert(xrd); 375 assert(xrd);
377 xrd->expires = util::w3c_to_time(cdata_buf); 376 xrd->expires = util::w3c_to_time(cdata_buf);
378 }else if((xmode&xmode_html) && is_element(n,"head")) { 377 }else if((xmode&xmode_html) && is_element(n,"head")) {
379 skipping = -1; stop_parser(); 378 skipping = -1;
380 } 379 }
381 cdata = 0; 380 cdata = 0;
382 } 381 }
383 void character_data(const XML_Char *s,int l) { 382 void character_data(const XML_Char *s,int l) {
384 if(skipping) return; 383 if(skipping) return;
385 if(cdata) cdata->append(s,l); 384 if(cdata) cdata->append(s,l);
386 } 385 }
387 386
388 void html_start_element(const XML_Char *n,const XML_Char **a) { 387 void html_start_element(const XML_Char *n,const XML_Char **a) {
389 if(is_element(n,"meta")) { 388 if(is_element(n,"meta")) {
390 bool heq = false; 389 bool heq = false;
391 string l; 390 string l;
392 for(;*a;a+=2) { 391 for(;*a;a+=2) {
393 if(!( strcasecmp(a[0],"http-equiv") 392 if(!( strcasecmp(a[0],"http-equiv")
394 || strcasecmp(a[1],XRDS_HEADER) )) 393 || strcasecmp(a[1],XRDS_HEADER) ))
395 heq = true; 394 heq = true;
396 else if(!strcasecmp(a[0],"content")) 395 else if(!strcasecmp(a[0],"content"))
397 l.assign(a[1]); 396 l.assign(a[1]);
398 } 397 }
399 if(heq) 398 if(heq)
400 xrds_location = l; 399 xrds_location = l;
401 }else if(is_element(n,"link")) { 400 }else if(is_element(n,"link")) {
402 string rels; 401 string rels;
403 string href; 402 string href;
@@ -412,36 +411,36 @@ namespace opkele {
412 href.erase(lns+1); 411 href.erase(lns+1);
413 } 412 }
414 } 413 }
415 for(string::size_type ns=rels.find_first_not_of(whitespace); 414 for(string::size_type ns=rels.find_first_not_of(whitespace);
416 ns!=string::npos; ns=rels.find_first_not_of(whitespace,ns)) { 415 ns!=string::npos; ns=rels.find_first_not_of(whitespace,ns)) {
417 string::size_type s = rels.find_first_of(whitespace,ns); 416 string::size_type s = rels.find_first_of(whitespace,ns);
418 string rel; 417 string rel;
419 if(s==string::npos) { 418 if(s==string::npos) {
420 rel.assign(rels,ns,string::npos); 419 rel.assign(rels,ns,string::npos);
421 ns = string::npos; 420 ns = string::npos;
422 }else{ 421 }else{
423 rel.assign(rels,ns,s-ns); 422 rel.assign(rels,ns,s-ns);
424 ns = s; 423 ns = s;
425 } 424 }
426 if(rel=="openid.server") 425 if(rel=="openid.server")
427 html_openid1.uris.add(-1,href); 426 html_openid1.uris.add(-1,href);
428 else if(rel=="openid.delegate") 427 else if(rel=="openid.delegate")
429 html_openid1.local_ids.add(-1,href); 428 html_openid1.local_ids.add(-1,href);
430 else if(rel=="openid2.provider") 429 else if(rel=="openid2.provider")
431 html_openid2.uris.add(-1,href); 430 html_openid2.uris.add(-1,href);
432 else if(rel=="openid2.local_id") 431 else if(rel=="openid2.local_id")
433 html_openid2.local_ids.add(-1,href); 432 html_openid2.local_ids.add(-1,href);
434 } 433 }
435 }else if(is_element(n,"body")) { 434 }else if(is_element(n,"body")) {
436 skipping = -1; stop_parser(); 435 skipping = -1;
437 } 436 }
438 } 437 }
439 438
440 }; 439 };
441 440
442 void idiscover(idiscovery_t& result,const string& identity) { 441 void idiscover(idiscovery_t& result,const string& identity) {
443 idigger_t idigger; 442 idigger_t idigger;
444 idigger.discover(result,identity); 443 idigger.discover(result,identity);
445 } 444 }
446 445
447} 446}