10 #ifndef PCMK__XML_INTERNAL__H 11 # define PCMK__XML_INTERNAL__H 24 # include <libxml/relaxng.h> 69 #define PCMK__XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap) \ 71 if (!(dechunk) && (prefix) == NULL) { \ 72 qb_log_from_external_source_va(__func__, __FILE__, (fmt), \ 73 (priority), __LINE__, 0, (ap)); \ 77 char *CXLB_buf = NULL; \ 78 static int CXLB_buffer_len = 0; \ 79 static char *CXLB_buffer = NULL; \ 80 static uint8_t CXLB_priority = 0; \ 82 CXLB_len = vasprintf(&CXLB_buf, (fmt), (ap)); \ 84 if (CXLB_len <= 0 || CXLB_buf[CXLB_len - 1] == '\n' || !(dechunk)) { \ 86 CXLB_buf = (char *) "LOG CORRUPTION HAZARD"; \ 87 CXLB_priority = QB_MIN(CXLB_priority, LOG_ERR); \ 88 } else if (CXLB_len > 0 \ 89 && CXLB_buf[CXLB_len - 1] == '\n') { \ 90 CXLB_buf[CXLB_len - 1] = '\0'; \ 93 qb_log_from_external_source(__func__, __FILE__, "%s%s%s", \ 94 CXLB_priority, __LINE__, 0, \ 95 (prefix) != NULL ? (prefix) : "", \ 96 CXLB_buffer, CXLB_buf); \ 99 qb_log_from_external_source(__func__, __FILE__, "%s%s", \ 100 (priority), __LINE__, 0, \ 101 (prefix) != NULL ? (prefix) : "", \ 104 if (CXLB_len < 0) { \ 107 CXLB_buffer = NULL; \ 108 CXLB_buffer_len = 0; \ 111 } else if (CXLB_buffer == NULL) { \ 112 CXLB_buffer_len = CXLB_len; \ 113 CXLB_buffer = CXLB_buf; \ 115 CXLB_priority = (priority); \ 118 CXLB_buffer = realloc(CXLB_buffer, 1 + CXLB_buffer_len + CXLB_len); \ 119 memcpy(CXLB_buffer + CXLB_buffer_len, CXLB_buf, CXLB_len); \ 120 CXLB_buffer_len += CXLB_len; \ 121 CXLB_buffer[CXLB_buffer_len] = '\0'; \ 122 CXLB_priority = QB_MIN(CXLB_priority, (priority)); \ 165 int depth, uint32_t options);
171 #define PCMK__XP_MEMBER_NODE_CONFIG \ 172 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_NODES \ 173 "/" XML_CIB_TAG_NODE "[not(@type) or @type='member']" 176 #define PCMK__XP_GUEST_NODE_CONFIG \ 177 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \ 178 "//" XML_TAG_META_SETS "//" XML_CIB_TAG_NVPAIR \ 179 "[@name='" XML_RSC_ATTR_REMOTE_NODE "']" 182 #define PCMK__XP_REMOTE_NODE_CONFIG \ 183 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \ 184 "[@type='remote'][@provider='pacemaker']" 187 #define PCMK__XP_REMOTE_NODE_STATUS \ 188 "//" XML_TAG_CIB "//" XML_CIB_TAG_STATUS "//" XML_CIB_TAG_STATE \ 189 "[@" XML_NODE_IS_REMOTE "='true']" 212 const char *attr_n,
const char *attr_v);
215 bool (*match)(xmlAttrPtr,
void *),
241 const char *filespec);
253 pcmk__xe_is(
const xmlNode *xml,
const char *
name)
255 return (xml != NULL) && (xml->name != NULL) && (
name != NULL)
256 && (strcmp((
const char *) xml->name,
name) == 0);
267 static inline xmlNode *
268 pcmk__xml_first_child(
const xmlNode *
parent)
272 while (child && (child->type == XML_TEXT_NODE)) {
286 static inline xmlNode *
287 pcmk__xml_next(
const xmlNode *child)
289 xmlNode *next = (child? child->next : NULL);
291 while (next && (next->type == XML_TEXT_NODE)) {
305 static inline xmlNode *
306 pcmk__xe_first_child(
const xmlNode *
parent)
310 while (child && (child->type != XML_ELEMENT_NODE)) {
324 static inline xmlNode *
325 pcmk__xe_next(
const xmlNode *child)
327 xmlNode *next = child? child->next : NULL;
329 while (next && (next->type != XML_ELEMENT_NODE)) {
358 G_GNUC_NULL_TERMINATED;
368 static inline xmlAttr *
369 pcmk__xe_first_attr(const xmlNode *xe)
371 return (xe == NULL)? NULL : xe->properties;
434 int (*handler)(xmlNode *xml,
void *userdata),
437 static inline const char *
438 pcmk__xml_attr_value(
const xmlAttr *attr)
440 return ((attr == NULL) || (attr->children == NULL))? NULL
441 : (
const char *) attr->children->content;
445 xmlRelaxNGValidityErrorFunc error_handler,
446 void *error_handler_context);
448 #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)
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)
int pcmk__xml2fd(int fd, xmlNode *cur)
char * pcmk__xml_artefact_path(enum pcmk__xml_artefact_ns ns, const char *filespec)
gboolean pcmk__validate_xml(xmlNode *xml_blob, const char *validation, xmlRelaxNGValidityErrorFunc error_handler, void *error_handler_context)