diff options
Diffstat (limited to 'include/crm/common/xml_internal.h')
-rw-r--r-- | include/crm/common/xml_internal.h | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/include/crm/common/xml_internal.h b/include/crm/common/xml_internal.h index 43b3b8c..ddb4384 100644 --- a/include/crm/common/xml_internal.h +++ b/include/crm/common/xml_internal.h @@ -21,6 +21,7 @@ # include <crm/crm.h> /* transitively imports qblog.h */ # include <crm/common/output_internal.h> +# include <libxml/relaxng.h> /*! * \brief Base for directing lib{xml2,xslt} log into standard libqb backend @@ -135,9 +136,6 @@ enum pcmk__xml_fmt_options { //! Include indentation and newlines pcmk__xml_fmt_pretty = (1 << 1), - //! Include full XML subtree (with any text), using libxml serialization - pcmk__xml_fmt_full = (1 << 2), - //! Include the opening tag of an XML element, and include XML comments pcmk__xml_fmt_open = (1 << 3), @@ -147,7 +145,6 @@ enum pcmk__xml_fmt_options { //! Include the closing tag of an XML element pcmk__xml_fmt_close = (1 << 5), - // @COMPAT Remove when log_data_element() is removed //! Include XML text nodes pcmk__xml_fmt_text = (1 << 6), @@ -190,6 +187,16 @@ int pcmk__xml_show_changes(pcmk__output_t *out, const xmlNode *xml); #define PCMK__XP_REMOTE_NODE_STATUS \ "//" XML_TAG_CIB "//" XML_CIB_TAG_STATUS "//" XML_CIB_TAG_STATE \ "[@" XML_NODE_IS_REMOTE "='true']" +/*! + * \internal + * \brief Serialize XML (using libxml) into provided descriptor + * + * \param[in] fd File descriptor to (piece-wise) write to + * \param[in] cur XML subtree to proceed + * + * \return a standard Pacemaker return code + */ +int pcmk__xml2fd(int fd, xmlNode *cur); enum pcmk__xml_artefact_ns { pcmk__xml_artefact_ns_legacy_rng = 1, @@ -235,6 +242,22 @@ char *pcmk__xml_artefact_path(enum pcmk__xml_artefact_ns ns, /*! * \internal + * \brief Check whether an XML element is of a particular type + * + * \param[in] xml XML element to compare + * \param[in] name XML element name to compare + * + * \return \c true if \p xml is of type \p name, otherwise \c false + */ +static inline bool +pcmk__xe_is(const xmlNode *xml, const char *name) +{ + return (xml != NULL) && (xml->name != NULL) && (name != NULL) + && (strcmp((const char *) xml->name, name) == 0); +} + +/*! + * \internal * \brief Return first non-text child node of an XML node * * \param[in] parent XML node to check @@ -411,4 +434,15 @@ pcmk__xe_foreach_child(xmlNode *xml, const char *child_element_name, int (*handler)(xmlNode *xml, void *userdata), void *userdata); +static inline const char * +pcmk__xml_attr_value(const xmlAttr *attr) +{ + return ((attr == NULL) || (attr->children == NULL))? NULL + : (const char *) attr->children->content; +} + +gboolean pcmk__validate_xml(xmlNode *xml_blob, const char *validation, + xmlRelaxNGValidityErrorFunc error_handler, + void *error_handler_context); + #endif // PCMK__XML_INTERNAL__H |