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);
244static inline xmlNode *
245pcmk__xml_first_child(
const xmlNode *
parent)
249 while (child && (child->type == XML_TEXT_NODE)) {
263static inline xmlNode *
264pcmk__xml_next(
const xmlNode *child)
266 xmlNode *next = (child? child->next : NULL);
268 while (next && (next->type == XML_TEXT_NODE)) {
282static inline xmlNode *
283pcmk__xe_first_child(
const xmlNode *
parent)
287 while (child && (child->type != XML_ELEMENT_NODE)) {
301static inline xmlNode *
302pcmk__xe_next(
const xmlNode *child)
304 xmlNode *next = child? child->next : NULL;
306 while (next && (next->type != XML_ELEMENT_NODE)) {
335G_GNUC_NULL_TERMINATED;
345static inline xmlAttr *
346pcmk__xe_first_attr(const xmlNode *xe)
348 return (xe == NULL)? NULL : xe->properties;
411 int (*handler)(xmlNode *xml,
void *userdata),
Formatted output for pacemaker tools.
This structure contains everything that makes up a single output formatter.
@ pcmk__xml_fmt_close
Include the closing tag of an XML element.
@ pcmk__xml_fmt_diff_plus
Log a created XML subtree.
@ pcmk__xml_fmt_children
Include the children of an XML element.
@ pcmk__xml_fmt_open
Include the opening tag of an XML element, and include XML comments.
@ pcmk__xml_fmt_diff_minus
Log a removed XML subtree.
@ pcmk__xml_fmt_pretty
Include indentation and newlines.
@ pcmk__xml_fmt_full
Include full XML subtree (with any text), using libxml serialization.
@ pcmk__xml_fmt_filtered
Exclude certain XML attributes (for calculating digests)
@ pcmk__xml_fmt_text
Include XML text nodes.
@ pcmk__xml_fmt_diff_short
Log a minimal version of an XML diff (only showing the changes)
void pcmk__set_xml_doc_flag(xmlNode *xml, enum xml_private_flags flag)
xmlNode * pcmk__xe_match(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
void pcmk__xe_remove_matching_attrs(xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
char * pcmk__xml_artefact_root(enum pcmk__xml_artefact_ns ns)
const char * pcmk__xe_add_last_written(xmlNode *xe)
int pcmk__xe_foreach_child(xmlNode *xml, const char *child_element_name, int(*handler)(xmlNode *xml, void *userdata), void *userdata)
void pcmk__strip_xml_text(xmlNode *xml)
void pcmk__xe_set_propv(xmlNodePtr node, va_list pairs)
int pcmk__xml_show_changes(pcmk__output_t *out, const xmlNode *xml)
GString * pcmk__element_xpath(const xmlNode *xml)
void pcmk__xe_set_props(xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
int pcmk__xml_show(pcmk__output_t *out, const char *prefix, const xmlNode *data, int depth, uint32_t options)
@ pcmk__xml_artefact_ns_legacy_xslt
@ pcmk__xml_artefact_ns_legacy_rng
@ pcmk__xml_artefact_ns_base_rng
@ pcmk__xml_artefact_ns_base_xslt
char * pcmk__xpath_node_id(const char *xpath, const char *node)
char * pcmk__xml_artefact_path(enum pcmk__xml_artefact_ns ns, const char *filespec)