MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / dump_data_element

Function dump_data_element

tools/cib_shadow.c:485–560  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

483extern int print_spaces(char *buffer, int depth, int max);
484
485int
486dump_data_element(int depth, char **buffer, int *max, int *offset, const char *prefix,
487 xmlNode * data, gboolean formatted)
488{
489 int printed = 0;
490 int has_children = 0;
491 xmlNode *child = NULL;
492 const char *name = NULL;
493
494 CRM_CHECK(data != NULL, return 0);
495
496 name = crm_element_name(data);
497
498 CRM_CHECK(name != NULL, return 0);
499 CRM_CHECK(buffer != NULL && *buffer != NULL, return 0);
500
501 crm_trace("Dumping %s...", name);
502
503 if (prefix) {
504 printed = snprintf(bhead(buffer, offset), bremain(max, offset), "%s", prefix);
505 update_buffer_head(printed);
506 }
507
508 if (formatted) {
509 printed = print_spaces(bhead(buffer, offset), depth, bremain(max, offset));
510 update_buffer_head(printed);
511 }
512
513 printed = snprintf(bhead(buffer, offset), bremain(max, offset), "<%s", name);
514 update_buffer_head(printed);
515
516 if(data) {
517 xmlAttrPtr xIter = NULL;
518 for(xIter = data->properties; xIter; xIter = xIter->next) {
519 const char *prop_name = (const char *)xIter->name;
520 const char *prop_value = crm_element_value(data, prop_name);
521 crm_trace("Dumping <%s %s=\"%s\"...",
522 name, prop_name, prop_value);
523 printed = snprintf(bhead(buffer, offset), bremain(max, offset), " %s=\"%s\"", prop_name, prop_value);
524 update_buffer_head(printed);
525 }
526 }
527
528 has_children = xml_has_children(data);
529 printed = snprintf(bhead(buffer, offset), bremain(max, offset), "%s>%s",
530 has_children == 0 ? "/" : "", formatted ? "\n" : "");
531 update_buffer_head(printed);
532
533 if (has_children == 0) {
534 return 0;
535 }
536
537 for (child = __xml_first_child(data); child != NULL; child = __xml_next(child)) {
538 if (dump_data_element(depth + 1, buffer, max, offset, prefix, child, formatted) < 0) {
539 return -1;
540 }
541 }
542

Callers 1

print_xml_diffFunction · 0.85

Calls 5

print_spacesFunction · 0.85
crm_element_valueFunction · 0.85
xml_has_childrenFunction · 0.85
__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85

Tested by

no test coverage detected