13 #include <sys/types.h> 21 #include <libxml/parser.h> 22 #include <libxml/tree.h> 23 #include <libxml/xmlIO.h> 31 static xmlNode *subtract_xml_comment(xmlNode *
parent, xmlNode *left,
32 xmlNode *right, gboolean *changed);
85 add_xml_changes_to_patchset(xmlNode *xml, xmlNode *patchset)
87 xmlNode *cIter = NULL;
88 xmlAttr *pIter = NULL;
89 xmlNode *change = NULL;
91 const char *value = NULL;
99 sizeof(buffer)) > 0) {
114 for (pIter = pcmk__xe_first_attr(xml); pIter != NULL;
115 pIter = pIter->next) {
116 xmlNode *attr = NULL;
123 if (change == NULL) {
128 sizeof(buffer)) > 0) {
158 for (pIter = pcmk__xe_first_attr(xml); pIter != NULL;
159 pIter = pIter->next) {
169 for (cIter = pcmk__xml_first_child(xml); cIter != NULL;
170 cIter = pcmk__xml_next(cIter)) {
171 add_xml_changes_to_patchset(cIter, patchset);
182 sizeof(buffer)) > 0) {
194 is_config_change(xmlNode *xml)
201 p = config->_private;
207 if ((xml->doc != NULL) && (xml->doc->_private != NULL)) {
208 p = xml->doc->_private;
209 for (gIter = p->
deleted_objs; gIter; gIter = gIter->next) {
212 if (strstr(deleted_obj->
path,
222 xml_repair_v1_diff(xmlNode *last, xmlNode *next, xmlNode *local_diff,
227 xmlNode *diff_child = NULL;
229 const char *tag = NULL;
231 const char *vfields[] = {
237 if (local_diff == NULL) {
242 tag =
"diff-removed";
244 if (diff_child == NULL) {
254 for (lpc = 0; (last != NULL) && (lpc <
PCMK__NELEM(vfields)); lpc++) {
258 if (changed || lpc == 2) {
265 if (diff_child == NULL) {
275 for (lpc = 0; next && lpc <
PCMK__NELEM(vfields); lpc++) {
281 for (xmlAttrPtr a = pcmk__xe_first_attr(next); a != NULL; a = a->next) {
284 xmlSetProp(cib, a->name, (
pcmkXmlStr) p_value);
291 xml_create_patchset_v1(xmlNode *source, xmlNode *
target,
bool config,
298 xml_repair_v1_diff(source,
target, patchset, config);
305 xml_create_patchset_v2(xmlNode *source, xmlNode *
target)
313 xmlNode *patchset = NULL;
314 const char *vfields[] = {
326 doc =
target->doc->_private;
353 for (gIter = doc->
deleted_objs; gIter; gIter = gIter->next) {
364 add_xml_changes_to_patchset(
target, patchset);
370 bool *config_changed,
bool manage_version)
374 xmlNode *patch = NULL;
383 config = is_config_change(
target);
384 if (config_changed) {
385 *config_changed = config;
388 if (manage_version && config) {
395 }
else if (manage_version) {
397 crm_trace(
"Status changed %d - %d %s", format, counter,
413 patch = xml_create_patchset_v1(source,
target, config, FALSE);
416 patch = xml_create_patchset_v2(source,
target);
419 crm_err(
"Unknown patch format: %d", format);
433 if ((patch == NULL) || (source == NULL) || (
target == NULL)) {
443 if ((format > 1) && !with_digest) {
460 xmlNode *child = NULL;
461 xmlNode *added = NULL;
462 xmlNode *removed = NULL;
463 gboolean is_first = TRUE;
465 int add[] = { 0, 0, 0 };
466 int del[] = { 0, 0, 0 };
468 const char *fmt = NULL;
469 const char *digest = NULL;
472 static struct qb_log_callsite *patchset_cs = NULL;
477 if (patchset_cs == NULL) {
478 patchset_cs = qb_log_callsite_get(
function, __FILE__,
"xml-patchset",
479 log_level, __LINE__, 0);
482 if (patchset == NULL) {
495 if ((add[2] != del[2]) || (add[1] != del[1]) || (add[0] != del[0])) {
497 "Diff: --- %d.%d.%d %s", del[0], del[1], del[2], fmt);
499 "Diff: +++ %d.%d.%d %s",
500 add[0], add[1], add[2], digest);
502 }
else if ((patchset != NULL) && (add[0] || add[1] || add[2])) {
504 "%s: Local-only Change: %d.%d.%d",
505 (
function?
function :
""), add[0], add[1], add[2]);
510 xmlNode *change = NULL;
512 for (change = pcmk__xml_first_child(patchset); change != NULL;
513 change = pcmk__xml_next(change)) {
518 }
else if (strcmp(op,
"create") == 0) {
519 int lpc = 0, max = 0;
522 max = strlen(prefix);
523 pcmk__xe_log(log_level, __FILE__,
function, __LINE__, prefix,
527 for (lpc = 2; lpc < max; lpc++) {
531 pcmk__xe_log(log_level, __FILE__,
function, __LINE__, prefix,
537 }
else if (strcmp(op,
"move") == 0) {
539 "+~ %s moved to offset %s", xpath,
542 }
else if (strcmp(op,
"modify") == 0) {
551 for (child = pcmk__xml_first_child(clist); child != NULL;
552 child = pcmk__xml_next(child)) {
557 }
else if (strcmp(op,
"set") == 0) {
561 o_set += snprintf(buffer_set + o_set,
564 o_set += snprintf(buffer_set + o_set,
568 }
else if (strcmp(op,
"unset") == 0) {
570 o_unset += snprintf(buffer_unset + o_unset,
574 o_unset += snprintf(buffer_unset + o_unset,
581 "+ %s: %s", xpath, buffer_set);
585 "-- %s: %s", xpath, buffer_unset);
588 }
else if (strcmp(op,
"delete") == 0) {
594 "-- %s (%d)", xpath, position);
605 if ((log_level < LOG_DEBUG) || (
function == NULL)) {
610 for (child = pcmk__xml_first_child(removed); child != NULL;
611 child = pcmk__xml_next(child)) {
623 for (child = pcmk__xml_first_child(added); child != NULL;
624 child = pcmk__xml_next(child)) {
637 not_id(xmlAttrPtr attr,
void *user_data)
639 return strcmp((
const char *) attr->name,
XML_ATTR_ID) != 0;
644 process_v1_removals(xmlNode *
target, xmlNode *patch)
646 xmlNode *patch_child = NULL;
647 xmlNode *cIter = NULL;
650 const char *
name = NULL;
651 const char *value = NULL;
653 if ((
target == NULL) || (patch == NULL)) {
657 if (
target->type == XML_COMMENT_NODE) {
665 CRM_CHECK(pcmk__str_eq(crm_element_name(
target), crm_element_name(patch),
673 if ((value != NULL) && (strcmp(value,
"removed:top") == 0)) {
674 crm_trace(
"We are the root of the deletion: %s.id=%s",
name,
id);
684 cIter = pcmk__xml_first_child(
target);
686 xmlNode *target_child = cIter;
688 cIter = pcmk__xml_next(cIter);
690 process_v1_removals(target_child, patch_child);
697 process_v1_additions(xmlNode *
parent, xmlNode *
target, xmlNode *patch)
699 xmlNode *patch_child = NULL;
700 xmlNode *target_child = NULL;
701 xmlAttrPtr xIter = NULL;
703 const char *
id = NULL;
704 const char *
name = NULL;
705 const char *value = NULL;
715 if ((
target == NULL) && (value != NULL)
716 && (strcmp(value,
"added:top") == 0)) {
718 name = crm_element_name(patch);
719 crm_trace(
"We are the root of the addition: %s.id=%s",
name,
id);
723 }
else if (
target == NULL) {
725 name = crm_element_name(patch);
730 if (
target->type == XML_COMMENT_NODE) {
736 CRM_CHECK(pcmk__str_eq(crm_element_name(
target), crm_element_name(patch),
741 for (xIter = pcmk__xe_first_attr(patch); xIter != NULL;
742 xIter = xIter->next) {
743 const char *p_name = (
const char *) xIter->name;
751 for (patch_child = pcmk__xml_first_child(patch); patch_child != NULL;
752 patch_child = pcmk__xml_next(patch_child)) {
755 process_v1_additions(
target, target_child, patch_child);
771 find_patch_xml_node(xmlNode *patchset,
int format,
bool added,
772 xmlNode **patch_node)
779 label = added?
"diff-added" :
"diff-removed";
782 if (cib_node != NULL) {
783 *patch_node = cib_node;
787 label = added?
"target" :
"source";
792 crm_warn(
"Unknown patch format: %d", format);
807 const char *vfields[] = {
817 if (!find_patch_xml_node(patchset, format, FALSE, &tmp)) {
823 crm_trace(
"Got %d for del[%s]", del[lpc], vfields[lpc]);
828 if (!find_patch_xml_node(patchset, format, TRUE, &tmp)) {
834 crm_trace(
"Got %d for add[%s]", add[lpc], vfields[lpc]);
851 xml_patch_version_check(xmlNode *xml, xmlNode *patchset,
int format)
854 bool changed = FALSE;
856 int this[] = { 0, 0, 0 };
857 int add[] = { 0, 0, 0 };
858 int del[] = { 0, 0, 0 };
860 const char *vfields[] = {
868 crm_trace(
"Got %d for this[%s]",
this[lpc], vfields[lpc]);
877 add[2] =
this[2] + 1;
879 del[lpc] =
this[lpc];
885 if (
this[lpc] < del[lpc]) {
886 crm_debug(
"Current %s is too low (%d.%d.%d < %d.%d.%d --> %d.%d.%d)",
887 vfields[lpc],
this[0],
this[1],
this[2],
888 del[0], del[1], del[2], add[0], add[1], add[2]);
891 }
else if (
this[lpc] > del[lpc]) {
892 crm_info(
"Current %s is too high (%d.%d.%d > %d.%d.%d --> %d.%d.%d) %p",
893 vfields[lpc],
this[0],
this[1],
this[2],
894 del[0], del[1], del[2], add[0], add[1], add[2], patchset);
901 if (add[lpc] > del[lpc]) {
907 crm_notice(
"Versions did not change in patch %d.%d.%d",
908 add[0], add[1], add[2]);
912 crm_debug(
"Can apply patch %d.%d.%d to %d.%d.%d",
913 add[0], add[1], add[2],
this[0],
this[1],
this[2]);
927 apply_v1_patchset(xmlNode *xml, xmlNode *patchset)
930 int root_nodes_seen = 0;
932 xmlNode *child_diff = NULL;
933 xmlNode *added =
find_xml_node(patchset,
"diff-added", FALSE);
934 xmlNode *removed =
find_xml_node(patchset,
"diff-removed", FALSE);
938 for (child_diff = pcmk__xml_first_child(removed); child_diff != NULL;
939 child_diff = pcmk__xml_next(child_diff)) {
940 CRM_CHECK(root_nodes_seen == 0, rc = FALSE);
941 if (root_nodes_seen == 0) {
942 process_v1_removals(xml, child_diff);
947 if (root_nodes_seen > 1) {
948 crm_err(
"(-) Diffs cannot contain more than one change set... saw %d",
956 xmlNode *child_diff = NULL;
958 for (child_diff = pcmk__xml_first_child(added); child_diff != NULL;
959 child_diff = pcmk__xml_next(child_diff)) {
960 CRM_CHECK(root_nodes_seen == 0, rc = FALSE);
961 if (root_nodes_seen == 0) {
962 process_v1_additions(NULL, xml, child_diff);
968 if (root_nodes_seen > 1) {
969 crm_err(
"(+) Diffs cannot contain more than one change set... saw %d",
982 first_matching_xml_child(xmlNode *
parent,
const char *
name,
const char *
id,
985 xmlNode *cIter = NULL;
987 for (cIter = pcmk__xml_first_child(
parent); cIter != NULL;
988 cIter = pcmk__xml_next(cIter)) {
989 if (strcmp((
const char *) cIter->name,
name) != 0) {
992 const char *cid =
ID(cIter);
994 if ((cid == NULL) || (strcmp(cid,
id) != 0)) {
1000 if ((cIter->type == XML_COMMENT_NODE)
1025 search_v2_xpath(xmlNode *top,
const char *key,
int target_position)
1027 xmlNode *
target = (xmlNode *) top->doc;
1028 const char *current = key;
1038 key_len = strlen(key);
1044 remainder = calloc(key_len,
sizeof(
char));
1047 section = calloc(key_len,
sizeof(
char));
1050 id = calloc(key_len,
sizeof(
char));
1053 tag = calloc(key_len,
sizeof(
char));
1058 rc = sscanf(current,
"/%[^/]%s", section, remainder);
1061 int f = sscanf(section,
"%[^[][@id='%[^']", tag,
id);
1062 int current_position = -1;
1067 if ((rc == 1) && (target_position >= 0)) {
1068 current_position = target_position;
1085 current = remainder;
1089 }
while ((rc == 2) &&
target);
1093 (
path = (
char *) xmlGetNodePath(
target)), key);
1106 typedef struct xml_change_obj_s {
1112 sort_change_obj_by_position(gconstpointer a, gconstpointer b)
1116 int position_a = -1;
1117 int position_b = -1;
1122 if (position_a < position_b) {
1125 }
else if (position_a > position_b) {
1142 apply_v2_patchset(xmlNode *xml, xmlNode *patchset)
1145 xmlNode *change = NULL;
1146 GList *change_objs = NULL;
1147 GList *gIter = NULL;
1149 for (change = pcmk__xml_first_child(patchset); change != NULL;
1150 change = pcmk__xml_next(change)) {
1151 xmlNode *match = NULL;
1160 crm_trace(
"Processing %s %s", change->name, op);
1163 if (strcmp(op,
"delete") == 0) {
1166 match = search_v2_xpath(xml, xpath, position);
1167 crm_trace(
"Performing %s on %s with %p", op, xpath, match);
1169 if ((match == NULL) && (strcmp(op,
"delete") == 0)) {
1170 crm_debug(
"No %s match for %s in %p", op, xpath, xml->doc);
1173 }
else if (match == NULL) {
1174 crm_err(
"No %s match for %s in %p", op, xpath, xml->doc);
1178 }
else if ((strcmp(op,
"create") == 0) || (strcmp(op,
"move") == 0)) {
1184 change_obj->change = change;
1185 change_obj->match = match;
1187 change_objs = g_list_append(change_objs, change_obj);
1189 if (strcmp(op,
"move") == 0) {
1191 if ((match->parent != NULL) && (match->parent->last != NULL)) {
1192 xmlAddNextSibling(match->parent->last, match);
1196 }
else if (strcmp(op,
"delete") == 0) {
1199 }
else if (strcmp(op,
"modify") == 0) {
1200 xmlNode *attrs = NULL;
1204 if (attrs == NULL) {
1210 for (xmlAttrPtr pIter = pcmk__xe_first_attr(attrs); pIter != NULL;
1211 pIter = pIter->next) {
1212 const char *
name = (
const char *) pIter->name;
1219 crm_err(
"Unknown operation: %s", op);
1225 change_objs = g_list_sort(change_objs, sort_change_obj_by_position);
1227 for (gIter = change_objs; gIter; gIter = gIter->next) {
1229 xmlNode *match = change_obj->match;
1230 const char *op = NULL;
1231 const char *xpath = NULL;
1233 change = change_obj->change;
1238 crm_trace(
"Continue performing %s on %s with %p", op, xpath, match);
1240 if (strcmp(op,
"create") == 0) {
1242 xmlNode *child = NULL;
1243 xmlNode *match_child = NULL;
1245 match_child = match->children;
1248 while ((match_child != NULL)
1250 match_child = match_child->next;
1253 child = xmlDocCopyNode(change->children, match->doc, 1);
1255 crm_trace(
"Adding %s at position %d", child->name, position);
1256 xmlAddPrevSibling(match_child, child);
1258 }
else if (match->last) {
1259 crm_trace(
"Adding %s at position %d (end)",
1260 child->name, position);
1261 xmlAddNextSibling(match->last, child);
1264 crm_trace(
"Adding %s at position %d (first)",
1265 child->name, position);
1267 xmlAddChild(match, child);
1271 }
else if (strcmp(op,
"move") == 0) {
1276 xmlNode *match_child = NULL;
1284 match_child = match->parent->children;
1286 while ((match_child != NULL)
1288 match_child = match_child->next;
1291 crm_trace(
"Moving %s to position %d (was %d, prev %p, %s %p)",
1292 match->name, position,
1294 match->prev, (match_child?
"next":
"last"),
1295 (match_child? match_child : match->parent->last));
1298 xmlAddPrevSibling(match_child, match);
1302 xmlAddNextSibling(match->parent->last, match);
1306 crm_trace(
"%s is already in position %d",
1307 match->name, position);
1311 crm_err(
"Moved %s.%s to position %d instead of %d (%p)",
1312 match->name,
ID(match),
1314 position, match->prev);
1320 g_list_free_full(change_objs, free);
1329 xmlNode *old = NULL;
1332 if (patchset == NULL) {
1339 if (check_version) {
1340 rc =
pcmk_rc2legacy(xml_patch_version_check(xml, patchset, format));
1360 crm_err(
"Unknown patch format: %d", format);
1365 if ((rc ==
pcmk_ok) && (digest != NULL)) {
1366 static struct qb_log_callsite *digest_cs = NULL;
1368 char *new_digest = NULL;
1371 if (digest_cs == NULL) {
1372 digest_cs = qb_log_callsite_get(__func__, __FILE__,
"diff-digest",
1379 crm_info(
"v%d digest mis-match: expected %s, calculated %s",
1380 format, digest, new_digest);
1383 if ((digest_cs != NULL) && digest_cs->targets) {
1390 ((digest_cs != NULL)? digest_cs->targets : 0));
1394 crm_trace(
"v%d digest matched: expected %s, calculated %s",
1395 format, digest, new_digest);
1407 xmlNode *child = NULL;
1412 for (child = pcmk__xml_first_child(a_node); child != NULL;
1413 child = pcmk__xml_next(child)) {
1421 xmlNode *tmp1 = NULL;
1438 if ((added->children == NULL) && (removed->children == NULL)) {
1447 subtract_xml_comment(xmlNode *
parent, xmlNode *left, xmlNode *right,
1451 CRM_CHECK(left->type == XML_COMMENT_NODE,
return NULL);
1453 if ((right == NULL) || !pcmk__str_eq((
const char *)left->content,
1454 (
const char *)right->content,
1456 xmlNode *deleted = NULL;
1469 gboolean full, gboolean *changed,
const char *marker)
1471 gboolean
dummy = FALSE;
1472 xmlNode *diff = NULL;
1473 xmlNode *right_child = NULL;
1474 xmlNode *left_child = NULL;
1475 xmlAttrPtr xIter = NULL;
1477 const char *
id = NULL;
1478 const char *
name = NULL;
1479 const char *value = NULL;
1480 const char *right_val = NULL;
1482 if (changed == NULL) {
1490 if (left->type == XML_COMMENT_NODE) {
1491 return subtract_xml_comment(
parent, left, right, changed);
1495 if (right == NULL) {
1496 xmlNode *deleted = NULL;
1498 crm_trace(
"Processing <%s id=%s> (complete copy)",
1499 crm_element_name(left),
id);
1507 name = crm_element_name(left);
1509 CRM_CHECK(pcmk__str_eq(crm_element_name(left), crm_element_name(right),
1515 if ((value != NULL) && (strcmp(value,
"removed:top") == 0)) {
1516 crm_trace(
"We are the root of the deletion: %s.id=%s",
name,
id);
1525 for (left_child = pcmk__xml_first_child(left); left_child != NULL;
1526 left_child = pcmk__xml_next(left_child)) {
1527 gboolean child_changed = FALSE;
1532 if (child_changed) {
1541 xmlAttrPtr pIter = NULL;
1543 for (pIter = pcmk__xe_first_attr(left); pIter != NULL;
1544 pIter = pIter->next) {
1545 const char *p_name = (
const char *)pIter->name;
1546 const char *p_value = pcmk__xml_attr_value(pIter);
1556 for (xIter = pcmk__xe_first_attr(left); xIter != NULL;
1557 xIter = xIter->next) {
1558 const char *prop_name = (
const char *) xIter->name;
1559 xmlAttrPtr right_attr = NULL;
1572 right_attr = xmlHasProp(right, (
pcmkXmlStr) prop_name);
1574 p = right_attr->_private;
1582 xmlAttrPtr pIter = NULL;
1584 for (pIter = pcmk__xe_first_attr(left); pIter != NULL;
1585 pIter = pIter->next) {
1586 const char *p_name = (
const char *) pIter->name;
1587 const char *p_value = pcmk__xml_attr_value(pIter);
1604 if (strcmp(left_value, right_val) == 0) {
1610 xmlAttrPtr pIter = NULL;
1612 crm_trace(
"Changes detected to %s in <%s id=%s>", prop_name,
1613 crm_element_name(left),
id);
1614 for (pIter = pcmk__xe_first_attr(left); pIter != NULL;
1615 pIter = pIter->next) {
1616 const char *p_name = (
const char *) pIter->name;
1617 const char *p_value = pcmk__xml_attr_value(pIter);
1625 crm_trace(
"Changes detected to %s (%s -> %s) in <%s id=%s>",
1626 prop_name, left_value, right_val,
1627 crm_element_name(left),
id);
1638 }
else if (!full && (
id != NULL)) {
1654 int root_nodes_seen = 0;
1655 static struct qb_log_callsite *digest_cs = NULL;
1659 xmlNode *child_diff = NULL;
1661 xmlNode *removed =
find_xml_node(diff,
"diff-removed", FALSE);
1663 CRM_CHECK(new_xml != NULL,
return FALSE);
1664 if (digest_cs == NULL) {
1665 digest_cs = qb_log_callsite_get(__func__, __FILE__,
"diff-digest",
1670 for (child_diff = pcmk__xml_first_child(removed); child_diff != NULL;
1671 child_diff = pcmk__xml_next(child_diff)) {
1673 if (root_nodes_seen == 0) {
1680 if (root_nodes_seen == 0) {
1683 }
else if (root_nodes_seen > 1) {
1684 crm_err(
"(-) Diffs cannot contain more than one change set... saw %d",
1689 root_nodes_seen = 0;
1692 xmlNode *child_diff = NULL;
1694 for (child_diff = pcmk__xml_first_child(added); child_diff != NULL;
1695 child_diff = pcmk__xml_next(child_diff)) {
1697 if (root_nodes_seen == 0) {
1704 if (root_nodes_seen > 1) {
1705 crm_err(
"(+) Diffs cannot contain more than one change set... saw %d",
1709 }
else if (
result && (digest != NULL)) {
1710 char *new_digest = NULL;
1716 crm_info(
"Digest mis-match: expected %s, calculated %s",
1717 digest, new_digest);
1720 crm_trace(
"%p %.6x", digest_cs, digest_cs ? digest_cs->targets : 0);
1721 if ((digest_cs != NULL) && digest_cs->targets) {
1728 crm_trace(
"Digest matched: expected %s, calculated %s",
1729 digest, new_digest);
#define CRM_CHECK(expr, failure_action)
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
#define crm_notice(fmt, args...)
void patchset_process_digest(xmlNode *patch, xmlNode *source, xmlNode *target, bool with_digest)
#define XML_ATTR_NUMUPDATES
int pcmk_rc2legacy(int rc)
bool xml_patch_versions(xmlNode *patchset, int add[3], int del[3])
void log_data_element(int log_level, const char *file, const char *function, int line, const char *prefix, xmlNode *data, int depth, gboolean formatted)
G_GNUC_INTERNAL int pcmk__element_xpath(const char *prefix, xmlNode *xml, char *buffer, int offset, size_t buffer_size)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define XML_NVPAIR_ATTR_NAME
#define CRM_LOG_ASSERT(expr)
#define do_crm_log_alias(level, file, function, line, fmt, args...)
Log a message as if it came from a different code location.
unsigned int crm_trace_nonlog
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
Deprecated Pacemaker XML API.
#define XML_ATTR_GENERATION
void xml_log_patchset(uint8_t log_level, const char *function, xmlNode *patchset)
xmlNode * copy_xml(xmlNode *src_node)
#define crm_warn(fmt, args...)
#define pcmk_err_diff_failed
G_GNUC_INTERNAL void pcmk__xc_update(xmlNode *parent, xmlNode *target, xmlNode *update)
#define crm_debug(fmt, args...)
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
struct xml_change_obj_s xml_change_obj_t
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
void pcmk__xe_remove_matching_attrs(xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
#define crm_trace(fmt, args...)
#define crm_log_xml_explicit(xml, text)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
Wrappers for and extensions to libxml2.
bool xml_document_dirty(xmlNode *xml)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define XML_DIFF_POSITION
void purge_diff_markers(xmlNode *a_node)
void free_xml(xmlNode *child)
xmlNode * xml_create_patchset(int format, xmlNode *source, xmlNode *target, bool *config_changed, bool manage_version)
G_GNUC_INTERNAL xmlNode * pcmk__xml_match(xmlNode *haystack, xmlNode *needle, bool exact)
const xmlChar * pcmkXmlStr
G_GNUC_INTERNAL void pcmk__xe_log(int log_level, const char *file, const char *function, int line, const char *prefix, xmlNode *data, int depth, int options)
G_GNUC_INTERNAL bool pcmk__xa_filterable(const char *name)
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
gboolean apply_xml_diff(xmlNode *old_xml, xmlNode *diff, xmlNode **new_xml)
#define PCMK__BUFFER_SIZE
xmlNode * diff_xml_object(xmlNode *old, xmlNode *new, gboolean suppress)
pcmk__action_result_t result
#define crm_err(fmt, args...)
void xml_remove_prop(xmlNode *obj, const char *name)
char * calculate_xml_versioned_digest(xmlNode *input, gboolean sort, gboolean do_filter, const char *version)
Calculate and return digest of XML tree.
gboolean can_prune_leaf(xmlNode *xml_node)
void xml_acl_disable(xmlNode *xml)
int compare_version(const char *version1, const char *version2)
#define crm_log_xml_info(xml, text)
#define XML_ATTR_GENERATION_ADMIN
#define XML_NVPAIR_ATTR_VALUE
#define XML_ATTR_CRM_VERSION
void save_xml_to_file(xmlNode *xml, const char *desc, const char *filename)
#define XML_CIB_TAG_CONFIGURATION
xmlNode * subtract_xml_object(xmlNode *parent, xmlNode *left, xmlNode *right, gboolean full, gboolean *changed, const char *marker)
int xml_apply_patchset(xmlNode *xml, xmlNode *patchset, bool check_version)
G_GNUC_INTERNAL void pcmk__mark_xml_created(xmlNode *xml)
G_GNUC_INTERNAL void pcmk__xml_update(xmlNode *parent, xmlNode *target, xmlNode *update, bool as_diff)
#define crm_info(fmt, args...)
G_GNUC_INTERNAL int pcmk__xml_position(xmlNode *xml, enum xml_private_flags ignore_if_set)