10 #ifndef PCMK__XML_INTERNAL__H 11 # define PCMK__XML_INTERNAL__H 67 #define PCMK__XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap) \ 69 if (!(dechunk) && (prefix) == NULL) { \ 70 qb_log_from_external_source_va(__func__, __FILE__, (fmt), \ 71 (priority), __LINE__, 0, (ap)); \ 75 char *CXLB_buf = NULL; \ 76 static int CXLB_buffer_len = 0; \ 77 static char *CXLB_buffer = NULL; \ 78 static uint8_t CXLB_priority = 0; \ 80 CXLB_len = vasprintf(&CXLB_buf, (fmt), (ap)); \ 82 if (CXLB_len <= 0 || CXLB_buf[CXLB_len - 1] == '\n' || !(dechunk)) { \ 84 CXLB_buf = (char *) "LOG CORRUPTION HAZARD"; \ 85 CXLB_priority = QB_MIN(CXLB_priority, LOG_ERR); \ 86 } else if (CXLB_len > 0 \ 87 && CXLB_buf[CXLB_len - 1] == '\n') { \ 88 CXLB_buf[CXLB_len - 1] = '\0'; \ 91 qb_log_from_external_source(__func__, __FILE__, "%s%s%s", \ 92 CXLB_priority, __LINE__, 0, \ 93 (prefix) != NULL ? (prefix) : "", \ 94 CXLB_buffer, CXLB_buf); \ 97 qb_log_from_external_source(__func__, __FILE__, "%s%s", \ 98 (priority), __LINE__, 0, \ 99 (prefix) != NULL ? (prefix) : "", \ 102 if (CXLB_len < 0) { \ 105 CXLB_buffer = NULL; \ 106 CXLB_buffer_len = 0; \ 109 } else if (CXLB_buffer == NULL) { \ 110 CXLB_buffer_len = CXLB_len; \ 111 CXLB_buffer = CXLB_buf; \ 113 CXLB_priority = (priority); \ 116 CXLB_buffer = realloc(CXLB_buffer, 1 + CXLB_buffer_len + CXLB_len); \ 117 memcpy(CXLB_buffer + CXLB_buffer_len, CXLB_buf, CXLB_len); \ 118 CXLB_buffer_len += CXLB_len; \ 119 CXLB_buffer[CXLB_buffer_len] = '\0'; \ 120 CXLB_priority = QB_MIN(CXLB_priority, (priority)); \ 129 #define PCMK__XP_MEMBER_NODE_CONFIG \ 130 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_NODES \ 131 "/" XML_CIB_TAG_NODE "[not(@type) or @type='member']" 134 #define PCMK__XP_GUEST_NODE_CONFIG \ 135 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \ 136 "//" XML_TAG_META_SETS "//" XML_CIB_TAG_NVPAIR \ 137 "[@name='" XML_RSC_ATTR_REMOTE_NODE "']" 140 #define PCMK__XP_REMOTE_NODE_CONFIG \ 141 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \ 142 "[@type='remote'][@provider='pacemaker']" 145 #define PCMK__XP_REMOTE_NODE_STATUS \ 146 "//" XML_TAG_CIB "//" XML_CIB_TAG_STATUS "//" XML_CIB_TAG_STATE \ 147 "[@" XML_NODE_IS_REMOTE "='true']" 160 const char *attr_n,
const char *attr_v);
163 bool (*match)(xmlAttrPtr,
void *),
187 const char *filespec);
197 static inline xmlNode *
198 pcmk__xml_first_child(
const xmlNode *
parent)
202 while (child && (child->type == XML_TEXT_NODE)) {
216 static inline xmlNode *
217 pcmk__xml_next(
const xmlNode *child)
219 xmlNode *next = (child? child->next : NULL);
221 while (next && (next->type == XML_TEXT_NODE)) {
235 static inline xmlNode *
236 pcmk__xe_first_child(
const xmlNode *
parent)
240 while (child && (child->type != XML_ELEMENT_NODE)) {
254 static inline xmlNode *
255 pcmk__xe_next(
const xmlNode *child)
257 xmlNode *next = child? child->next : NULL;
259 while (next && (next->type != XML_ELEMENT_NODE)) {
285 G_GNUC_NULL_TERMINATED;
295 static inline xmlAttr *
296 pcmk__xe_first_attr(const xmlNode *xe)
298 return (xe == NULL)? NULL : xe->properties;
339 #endif // PCMK__XML_INTERNAL__H char * pcmk__xml_artefact_root(enum pcmk__xml_artefact_ns ns)
const char * pcmk__xe_add_last_written(xmlNode *xe)
xmlNode * pcmk__xe_match(xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
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)
void pcmk__strip_xml_text(xmlNode *xml)
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
char * pcmk__xml_artefact_path(enum pcmk__xml_artefact_ns ns, const char *filespec)