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

Function crm_xml_replace

lib/common/xml.c:382–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

380}
381
382const char *
383crm_xml_replace(xmlNode* node, const char *name, const char *value)
384{
385 xmlAttr *attr = NULL;
386 const char *old_value = NULL;
387 CRM_CHECK(node != NULL, return NULL);
388 CRM_CHECK(name != NULL && name[0] != 0, return NULL);
389
390 old_value = crm_element_value(node, name);
391
392 /* Could be re-setting the same value */
393 CRM_CHECK(old_value != value, return value);
394
395 if (old_value != NULL && value == NULL) {
396 xml_remove_prop(node, name);
397 return NULL;
398
399 } else if(value == NULL) {
400 return NULL;
401 }
402
403 attr = xmlSetProp(node, (const xmlChar*)name, (const xmlChar*)value);
404 CRM_CHECK(attr && attr->children && attr->children->content, return NULL);
405 return (char *)attr->children->content;
406}
407
408const char *
409crm_xml_add_int(xmlNode* node, const char *name, int value)

Callers 3

cib_process_commandFunction · 0.85
determine_request_userFunction · 0.85
unpack_templateFunction · 0.85

Calls 2

crm_element_valueFunction · 0.85
xml_remove_propFunction · 0.85

Tested by

no test coverage detected