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

Function add_xml_object

lib/common/xml.c:1614–1684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1612}
1613
1614int
1615add_xml_object(xmlNode *parent, xmlNode *target, xmlNode *update, gboolean as_diff)
1616{
1617 xmlNode *a_child = NULL;
1618 const char *object_id = NULL;
1619 const char *object_name = NULL;
1620
1621#if XML_PARSE_DEBUG
1622 crm_log_xml_trace("update:", update);
1623 crm_log_xml_trace("target:", target);
1624#endif
1625
1626 CRM_CHECK(update != NULL, return 0);
1627
1628 object_name = crm_element_name(update);
1629 object_id = ID(update);
1630
1631 CRM_CHECK(object_name != NULL, return 0);
1632
1633 if(target == NULL && object_id == NULL) {
1634 /* placeholder object */
1635 target = find_xml_node(parent, object_name, FALSE);
1636
1637 } else if(target == NULL) {
1638 target = find_entity(parent, object_name, object_id);
1639 }
1640
1641 if(target == NULL) {
1642 target = create_xml_node(parent, object_name);
1643 CRM_CHECK(target != NULL, return 0);
1644#if XML_PARSER_DEBUG
1645 crm_trace("Added <%s%s%s/>", crm_str(object_name),
1646 object_id?" id=":"", object_id?object_id:"");
1647
1648 } else {
1649 crm_trace("Found node <%s%s%s/> to update",
1650 crm_str(object_name),
1651 object_id?" id=":"", object_id?object_id:"");
1652#endif
1653 }
1654
1655 if(as_diff == FALSE) {
1656 /* So that expand_plus_plus() gets called */
1657 copy_in_properties(target, update);
1658
1659 } else {
1660 /* No need for expand_plus_plus(), just raw speed */
1661 xmlAttrPtr pIter = NULL;
1662 for(pIter = crm_first_attr(update); pIter != NULL; pIter = pIter->next) {
1663 const char *p_name = (const char *)pIter->name;
1664 const char *p_value = crm_attr_value(pIter);
1665 /* Remove it first so the ordering of the update is preserved */
1666 xmlUnsetProp(target, (const xmlChar*)p_name);
1667 xmlSetProp(target, (const xmlChar*)p_name, (const xmlChar*)p_value);
1668 }
1669 }
1670
1671 for(a_child = __xml_first_child(update); a_child != NULL; a_child = __xml_next(a_child)) {

Callers 2

apply_xml_diffFunction · 0.85
update_xml_childFunction · 0.85

Calls 8

find_xml_nodeFunction · 0.85
find_entityFunction · 0.85
create_xml_nodeFunction · 0.85
copy_in_propertiesFunction · 0.85
crm_first_attrFunction · 0.85
crm_attr_valueFunction · 0.85
__xml_first_childFunction · 0.85
__xml_nextFunction · 0.85

Tested by

no test coverage detected