10 #ifndef PCMK__XML_INTERNAL__H 11 # define PCMK__XML_INTERNAL__H 68 #define PCMK__XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap) \ 70 if (!(dechunk) && (prefix) == NULL) { \ 71 qb_log_from_external_source_va(__func__, __FILE__, (fmt), \ 72 (priority), __LINE__, 0, (ap)); \ 76 char *CXLB_buf = NULL; \ 77 static int CXLB_buffer_len = 0; \ 78 static char *CXLB_buffer = NULL; \ 79 static uint8_t CXLB_priority = 0; \ 81 CXLB_len = vasprintf(&CXLB_buf, (fmt), (ap)); \ 83 if (CXLB_len <= 0 || CXLB_buf[CXLB_len - 1] == '\n' || !(dechunk)) { \ 85 CXLB_buf = (char *) "LOG CORRUPTION HAZARD"; \ 86 CXLB_priority = QB_MIN(CXLB_priority, LOG_ERR); \ 87 } else if (CXLB_len > 0 \ 88 && CXLB_buf[CXLB_len - 1] == '\n') { \ 89 CXLB_buf[CXLB_len - 1] = '\0'; \ 92 qb_log_from_external_source(__func__, __FILE__, "%s%s%s", \ 93 CXLB_priority, __LINE__, 0, \ 94 (prefix) != NULL ? (prefix) : "", \ 95 CXLB_buffer, CXLB_buf); \ 98 qb_log_from_external_source(__func__, __FILE__, "%s%s", \ 99 (priority), __LINE__, 0, \ 100 (prefix) != NULL ? (prefix) : "", \ 103 if (CXLB_len < 0) { \ 106 CXLB_buffer = NULL; \ 107 CXLB_buffer_len = 0; \ 110 } else if (CXLB_buffer == NULL) { \ 111 CXLB_buffer_len = CXLB_len; \ 112 CXLB_buffer = CXLB_buf; \ 114 CXLB_priority = (priority); \ 117 CXLB_buffer = realloc(CXLB_buffer, 1 + CXLB_buffer_len + CXLB_len); \ 118 memcpy(CXLB_buffer + CXLB_buffer_len, CXLB_buf, CXLB_len); \ 119 CXLB_buffer_len += CXLB_len; \ 120 CXLB_buffer[CXLB_buffer_len] = '\0'; \ 121 CXLB_priority = QB_MIN(CXLB_priority, (priority)); \ 168 int depth, uint32_t options);
174 #define PCMK__XP_MEMBER_NODE_CONFIG \ 175 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_NODES \ 176 "/" XML_CIB_TAG_NODE "[not(@type) or @type='member']" 179 #define PCMK__XP_GUEST_NODE_CONFIG \ 180 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \ 181 "//" XML_TAG_META_SETS "//" XML_CIB_TAG_NVPAIR \ 182 "[@name='" XML_RSC_ATTR_REMOTE_NODE "']" 185 #define PCMK__XP_REMOTE_NODE_CONFIG \ 186 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \ 187 "[@type='remote'][@provider='pacemaker']" 190 #define PCMK__XP_REMOTE_NODE_STATUS \ 191 "//" XML_TAG_CIB "//" XML_CIB_TAG_STATUS "//" XML_CIB_TAG_STATE \ 192 "[@" XML_NODE_IS_REMOTE "='true']" 205 const char *attr_n,
const char *attr_v);
208 bool (*match)(xmlAttrPtr,
void *),
234 const char *filespec);
244 static inline xmlNode *
245 pcmk__xml_first_child(
const xmlNode *
parent)
249 while (child && (child->type == XML_TEXT_NODE)) {
263 static inline xmlNode *
264 pcmk__xml_next(
const xmlNode *child)
266 xmlNode *next = (child? child->next : NULL);
268 while (next && (next->type == XML_TEXT_NODE)) {
282 static inline xmlNode *
283 pcmk__xe_first_child(
const xmlNode *
parent)
287 while (child && (child->type != XML_ELEMENT_NODE)) {
301 static inline xmlNode *
302 pcmk__xe_next(
const xmlNode *child)
304 xmlNode *next = child? child->next : NULL;
306 while (next && (next->type != XML_ELEMENT_NODE)) {
335 G_GNUC_NULL_TERMINATED;
345 static inline xmlAttr *
346 pcmk__xe_first_attr(const xmlNode *xe)
348 return (xe == NULL)? NULL : xe->properties;
411 int (*handler)(xmlNode *xml,
void *userdata),
414 #endif // PCMK__XML_INTERNAL__H char * pcmk__xml_artefact_root(enum pcmk__xml_artefact_ns ns)
xmlNode * pcmk__xe_match(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
const char * pcmk__xe_add_last_written(xmlNode *xe)
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)
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.
Formatted output for pacemaker tools.
void pcmk__strip_xml_text(xmlNode *xml)
Include the children of an XML element.
void pcmk__xe_remove_matching_attrs(xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
Include full XML subtree (with any text), using libxml serialization.
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)
This structure contains everything that makes up a single output formatter.
Log a minimal version of an XML diff (only showing the changes)
GString * pcmk__element_xpath(const xmlNode *xml)
char * pcmk__xml_artefact_path(enum pcmk__xml_artefact_ns ns, const char *filespec)