Changeset 2727 for pjproject/trunk/pjlib-util/src/pjlib-util/xml.c
- Timestamp:
- Jun 1, 2009 9:28:28 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib-util/src/pjlib-util/xml.c
r2394 r2727 341 341 } 342 342 343 PJ_DEF(pj_xml_node*) pj_xml_find_node(pj_xml_node *parent, const pj_str_t *name) 344 { 345 pj_xml_node *node = parent->node_head.next; 343 PJ_DEF(pj_xml_node*) pj_xml_find_node(const pj_xml_node *parent, 344 const pj_str_t *name) 345 { 346 const pj_xml_node *node = parent->node_head.next; 346 347 347 348 PJ_CHECK_STACK(); … … 349 350 while (node != (void*)&parent->node_head) { 350 351 if (pj_stricmp(&node->name, name) == 0) 351 return node;352 return (pj_xml_node*)node; 352 353 node = node->next; 353 354 } … … 355 356 } 356 357 357 358 PJ_DEF(pj_xml_node*) pj_xml_find_next_node( pj_xml_node *parent, pj_xml_node *node, 358 PJ_DEF(pj_xml_node*) pj_xml_find_node_rec(const pj_xml_node *parent, 359 const pj_str_t *name) 360 { 361 const pj_xml_node *node = parent->node_head.next; 362 363 PJ_CHECK_STACK(); 364 365 while (node != (void*)&parent->node_head) { 366 pj_xml_node *found; 367 if (pj_stricmp(&node->name, name) == 0) 368 return (pj_xml_node*)node; 369 found = pj_xml_find_node_rec(node, name); 370 if (found) 371 return (pj_xml_node*)found; 372 node = node->next; 373 } 374 return NULL; 375 } 376 377 PJ_DEF(pj_xml_node*) pj_xml_find_next_node( const pj_xml_node *parent, 378 const pj_xml_node *node, 359 379 const pj_str_t *name) 360 380 { … … 364 384 while (node != (void*)&parent->node_head) { 365 385 if (pj_stricmp(&node->name, name) == 0) 366 return node;386 return (pj_xml_node*)node; 367 387 node = node->next; 368 388 } … … 371 391 372 392 373 PJ_DEF(pj_xml_attr*) pj_xml_find_attr( pj_xml_node *node, const pj_str_t *name, 393 PJ_DEF(pj_xml_attr*) pj_xml_find_attr( const pj_xml_node *node, 394 const pj_str_t *name, 374 395 const pj_str_t *value) 375 396 { 376 pj_xml_attr *attr = node->attr_head.next;397 const pj_xml_attr *attr = node->attr_head.next; 377 398 while (attr != (void*)&node->attr_head) { 378 399 if (pj_stricmp(&attr->name, name)==0) { 379 400 if (value) { 380 401 if (pj_stricmp(&attr->value, value)==0) 381 return attr;402 return (pj_xml_attr*)attr; 382 403 } else { 383 return attr;404 return (pj_xml_attr*)attr; 384 405 } 385 406 } … … 391 412 392 413 393 PJ_DEF(pj_xml_node*) pj_xml_find( pj_xml_node *parent, const pj_str_t *name, 414 PJ_DEF(pj_xml_node*) pj_xml_find( const pj_xml_node *parent, 415 const pj_str_t *name, 394 416 const void *data, 395 pj_bool_t (*match)(pj_xml_node *, const void*)) 396 { 397 pj_xml_node *head = (pj_xml_node*) &parent->node_head, *node = head->next; 398 399 while (node != (void*)head) { 400 if (name && pj_stricmp(&node->name, name)==0) { 401 if (match) { 402 if (match(node, data)) 403 return node; 404 } else { 405 return node; 417 pj_bool_t (*match)(const pj_xml_node *, 418 const void*)) 419 { 420 const pj_xml_node *node = (const pj_xml_node *)parent->node_head.next; 421 422 if (!name && !match) 423 return NULL; 424 425 while (node != (const pj_xml_node*) &parent->node_head) { 426 if (name) { 427 if (pj_stricmp(&node->name, name)!=0) { 428 node = node->next; 429 continue; 406 430 } 407 431 } 432 if (match) { 433 if (match(node, data)) 434 return (pj_xml_node*)node; 435 } else { 436 return (pj_xml_node*)node; 437 } 438 408 439 node = node->next; 409 440 } … … 411 442 } 412 443 444 PJ_DEF(pj_xml_node*) pj_xml_find_rec( const pj_xml_node *parent, 445 const pj_str_t *name, 446 const void *data, 447 pj_bool_t (*match)(const pj_xml_node*, 448 const void*)) 449 { 450 const pj_xml_node *node = (const pj_xml_node *)parent->node_head.next; 451 452 if (!name && !match) 453 return NULL; 454 455 while (node != (const pj_xml_node*) &parent->node_head) { 456 pj_xml_node *found; 457 458 if (name) { 459 if (pj_stricmp(&node->name, name)==0) { 460 if (match) { 461 if (match(node, data)) 462 return (pj_xml_node*)node; 463 } else { 464 return (pj_xml_node*)node; 465 } 466 } 467 468 } else if (match) { 469 if (match(node, data)) 470 return (pj_xml_node*)node; 471 } 472 473 found = pj_xml_find_rec(node, name, data, match); 474 if (found) 475 return found; 476 477 node = node->next; 478 } 479 return NULL; 480 } 413 481 414 482 PJ_DEF(pj_xml_node*) pj_xml_clone( pj_pool_t *pool, const pj_xml_node *rhs)
Note: See TracChangeset
for help on using the changeset viewer.