MCPcopy Create free account
hub / github.com/apache/httpd / dav_xml_get_cdata

Function dav_xml_get_cdata

modules/dav/main/util.c:385–460  ·  view source on GitHub ↗

gather up all the CDATA into a single string */

Source from the content-addressed store, hash-verified

383
384/* gather up all the CDATA into a single string */
385DAV_DECLARE(const char *) dav_xml_get_cdata(const apr_xml_elem *elem, apr_pool_t *pool,
386 int strip_white)
387{
388 apr_size_t len = 0;
389 apr_text *scan;
390 const apr_xml_elem *child;
391 char *cdata;
392 char *s;
393 apr_size_t tlen;
394 const char *found_text = NULL; /* initialize to avoid gcc warning */
395 int found_count = 0;
396
397 for (scan = elem->first_cdata.first; scan != NULL; scan = scan->next) {
398 found_text = scan->text;
399 ++found_count;
400 len += strlen(found_text);
401 }
402
403 for (child = elem->first_child; child != NULL; child = child->next) {
404 for (scan = child->following_cdata.first;
405 scan != NULL;
406 scan = scan->next) {
407 found_text = scan->text;
408 ++found_count;
409 len += strlen(found_text);
410 }
411 }
412
413 /* some fast-path cases:
414 * 1) zero-length cdata
415 * 2) a single piece of cdata with no whitespace to strip
416 */
417 if (len == 0)
418 return "";
419 if (found_count == 1) {
420 if (!strip_white
421 || (!apr_isspace(*found_text)
422 && !apr_isspace(found_text[len - 1])))
423 return found_text;
424 }
425
426 cdata = s = apr_palloc(pool, len + 1);
427
428 for (scan = elem->first_cdata.first; scan != NULL; scan = scan->next) {
429 tlen = strlen(scan->text);
430 memcpy(s, scan->text, tlen);
431 s += tlen;
432 }
433
434 for (child = elem->first_child; child != NULL; child = child->next) {
435 for (scan = child->following_cdata.first;
436 scan != NULL;
437 scan = scan->next) {
438 tlen = strlen(scan->text);
439 memcpy(s, scan->text, tlen);
440 s += tlen;
441 }
442 }

Callers 2

dav_method_checkoutFunction · 0.85
dav_method_mergeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected