10 #ifndef PCMK__XML_INTERNAL__H 11 #define PCMK__XML_INTERNAL__H 27 #include <libxml/relaxng.h> 72 #define PCMK__XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap) \ 74 if (!(dechunk) && (prefix) == NULL) { \ 75 qb_log_from_external_source_va(__func__, __FILE__, (fmt), \ 76 (priority), __LINE__, 0, (ap)); \ 80 char *CXLB_buf = NULL; \ 81 static int CXLB_buffer_len = 0; \ 82 static char *CXLB_buffer = NULL; \ 83 static uint8_t CXLB_priority = 0; \ 85 CXLB_len = vasprintf(&CXLB_buf, (fmt), (ap)); \ 87 if (CXLB_len <= 0 || CXLB_buf[CXLB_len - 1] == '\n' || !(dechunk)) { \ 89 CXLB_buf = (char *) "LOG CORRUPTION HAZARD"; \ 90 CXLB_priority = QB_MIN(CXLB_priority, LOG_ERR); \ 91 } else if (CXLB_len > 0 \ 92 && CXLB_buf[CXLB_len - 1] == '\n') { \ 93 CXLB_buf[CXLB_len - 1] = '\0'; \ 96 qb_log_from_external_source(__func__, __FILE__, "%s%s%s", \ 97 CXLB_priority, __LINE__, 0, \ 98 (prefix) != NULL ? (prefix) : "", \ 99 CXLB_buffer, CXLB_buf); \ 102 qb_log_from_external_source(__func__, __FILE__, "%s%s", \ 103 (priority), __LINE__, 0, \ 104 (prefix) != NULL ? (prefix) : "", \ 107 if (CXLB_len < 0) { \ 110 CXLB_buffer = NULL; \ 111 CXLB_buffer_len = 0; \ 114 } else if (CXLB_buffer == NULL) { \ 115 CXLB_buffer_len = CXLB_len; \ 116 CXLB_buffer = CXLB_buf; \ 118 CXLB_priority = (priority); \ 121 CXLB_buffer = realloc(CXLB_buffer, 1 + CXLB_buffer_len + CXLB_len); \ 122 memcpy(CXLB_buffer + CXLB_buffer_len, CXLB_buf, CXLB_len); \ 123 CXLB_buffer_len += CXLB_len; \ 124 CXLB_buffer[CXLB_buffer_len] = '\0'; \ 125 CXLB_priority = QB_MIN(CXLB_priority, (priority)); \ 169 int depth, uint32_t options);
175 #define PCMK__XP_MEMBER_NODE_CONFIG \ 176 "//" PCMK_XE_CIB "/" PCMK_XE_CONFIGURATION "/" PCMK_XE_NODES \ 178 "[not(@" PCMK_XA_TYPE ") or @" PCMK_XA_TYPE "='" PCMK_VALUE_MEMBER "']" 181 #define PCMK__XP_GUEST_NODE_CONFIG \ 182 "//" PCMK_XE_CIB "//" PCMK_XE_CONFIGURATION "//" PCMK_XE_PRIMITIVE \ 183 "//" PCMK_XE_META_ATTRIBUTES "//" PCMK_XE_NVPAIR \ 184 "[@" PCMK_XA_NAME "='" PCMK_META_REMOTE_NODE "']" 187 #define PCMK__XP_REMOTE_NODE_CONFIG \ 188 "//" PCMK_XE_CIB "//" PCMK_XE_CONFIGURATION "//" PCMK_XE_PRIMITIVE \ 189 "[@" PCMK_XA_TYPE "='" PCMK_VALUE_REMOTE "']" \ 190 "[@" PCMK_XA_PROVIDER "='pacemaker']" 193 #define PCMK__XP_REMOTE_NODE_STATUS \ 194 "//" PCMK_XE_CIB "//" PCMK_XE_STATUS "//" PCMK__XE_NODE_STATE \ 195 "[@" PCMK_XA_REMOTE_NODE "='" PCMK_VALUE_TRUE "']" 218 const char *attr_n,
const char *attr_v);
224 bool (*match)(xmlAttrPtr,
void *),
335 const char *filespec);
345 static inline const char *
346 pcmk__xe_id(
const xmlNode *xml)
361 pcmk__xe_is(
const xmlNode *xml,
const char *
name)
363 return (xml != NULL) && (xml->name != NULL) && (
name != NULL)
364 && (strcmp((
const char *) xml->name,
name) == 0);
375 static inline xmlNode *
376 pcmk__xml_first_child(
const xmlNode *
parent)
380 while (child && (child->type == XML_TEXT_NODE)) {
394 static inline xmlNode *
395 pcmk__xml_next(
const xmlNode *child)
397 xmlNode *next = (child? child->next : NULL);
399 while (next && (next->type == XML_TEXT_NODE)) {
413 static inline xmlNode *
414 pcmk__xe_next(
const xmlNode *child)
416 xmlNode *next = child? child->next : NULL;
418 while (next && (next->type != XML_ELEMENT_NODE)) {
480 G_GNUC_NULL_TERMINATED;
490 static inline xmlAttr *
491 pcmk__xe_first_attr(const xmlNode *xe)
493 return (xe == NULL)? NULL : xe->properties;
570 int (*handler)(xmlNode *xml,
void *userdata),
576 static inline const char *
577 pcmk__xml_attr_value(
const xmlAttr *attr)
579 return ((attr == NULL) || (attr->children == NULL))? NULL
580 : (
const char *) attr->children->content;
587 static inline const char *
588 pcmk__map_element_name(
const xmlNode *xml)
595 return (
const char *) xml->name;
599 #endif // PCMK__XML_INTERNAL__H char * pcmk__xml_artefact_root(enum pcmk__xml_artefact_ns ns)
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
char * pcmk__xml_escape(const char *text, enum pcmk__xml_escape_type type)
int pcmk__xe_copy_attrs(xmlNode *target, const xmlNode *src, uint32_t flags)
xmlNode * pcmk__diff_v1_xml_object(xmlNode *left, xmlNode *right, bool suppress)
const char * pcmk__xe_add_last_written(xmlNode *xe)
int pcmk__xe_replace_match(xmlNode *xml, xmlNode *replace)
bool pcmk__xml_needs_escape(const char *text, enum pcmk__xml_escape_type type)
Exclude certain XML attributes (for calculating digests)
Include the opening tag of an XML element, and include XML comments.
void pcmk__xe_set_propv(xmlNodePtr node, va_list pairs)
enum crm_ais_msg_types type
void pcmk__set_xml_doc_flag(xmlNode *xml, enum xml_private_flags flag)
char * pcmk__xpath_node_id(const char *xpath, const char *node)
Include indentation and newlines.
Log a created XML subtree.
void pcmk__xe_set_content(xmlNode *node, const char *format,...) G_GNUC_PRINTF(2
int pcmk__xe_delete_match(xmlNode *xml, xmlNode *search)
Formatted output for pacemaker tools.
void pcmk__strip_xml_text(xmlNode *xml)
xmlNode * pcmk__xc_create(xmlDoc *doc, const char *content)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
Include the children of an XML element.
void pcmk__xe_remove_matching_attrs(xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
void pcmk__xe_remove_attr(xmlNode *element, const char *name)
bool pcmk__xe_remove_attr_cb(xmlNode *xml, void *user_data)
int pcmk__xe_update_match(xmlNode *xml, xmlNode *update, uint32_t flags)
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
Log a removed XML subtree.
int pcmk__xe_foreach_child(xmlNode *xml, const char *child_element_name, int(*handler)(xmlNode *xml, void *userdata), void *userdata)
int pcmk__xml_show(pcmk__output_t *out, const char *prefix, const xmlNode *data, int depth, uint32_t options)
Include the closing tag of an XML element.
int pcmk__xml_show_changes(pcmk__output_t *out, const xmlNode *xml)
int pcmk__xe_get_score(const xmlNode *xml, const char *name, int *score, int default_score)
This structure contains everything that makes up a single output formatter.
void pcmk__xml_free_doc(xmlDoc *doc)
bool pcmk__xml_tree_foreach(xmlNode *xml, bool(*fn)(xmlNode *, void *), void *user_data)
Log a minimal version of an XML diff (only showing the changes)
GString * pcmk__element_xpath(const xmlNode *xml)
void pcmk__warn_multiple_name_matches(pcmk__output_t *out, xmlNode *search, const char *name)
int pcmk__xml2fd(int fd, xmlNode *cur)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
char * pcmk__xml_artefact_path(enum pcmk__xml_artefact_ns ns, const char *filespec)
xmlNode * pcmk__xe_next_same(const xmlNode *node)
#define PCMK__XE_PROMOTABLE_LEGACY
Don't overwrite existing values.