pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
Macros | Enumerations | Functions
xml_internal.h File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <crm/crm.h>
#include <crm/common/output_internal.h>
#include <libxml/relaxng.h>
Include dependency graph for xml_internal.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define PCMK__XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap)
 Base for directing lib{xml2,xslt} log into standard libqb backend. More...
 
#define PCMK__XP_MEMBER_NODE_CONFIG
 
#define PCMK__XP_GUEST_NODE_CONFIG
 
#define PCMK__XP_REMOTE_NODE_CONFIG
 
#define PCMK__XP_REMOTE_NODE_STATUS
 

Enumerations

enum  pcmk__xml_fmt_options {
  pcmk__xml_fmt_filtered = (1 << 0), pcmk__xml_fmt_pretty = (1 << 1), pcmk__xml_fmt_open = (1 << 3), pcmk__xml_fmt_children = (1 << 4),
  pcmk__xml_fmt_close = (1 << 5), pcmk__xml_fmt_text = (1 << 6), pcmk__xml_fmt_diff_plus = (1 << 7), pcmk__xml_fmt_diff_minus = (1 << 8),
  pcmk__xml_fmt_diff_short = (1 << 9)
}
 
enum  pcmk__xml_artefact_ns { pcmk__xml_artefact_ns_legacy_rng = 1, pcmk__xml_artefact_ns_legacy_xslt, pcmk__xml_artefact_ns_base_rng, pcmk__xml_artefact_ns_base_xslt }
 
enum  xml_private_flags {
  pcmk__xf_none = 0x0000, pcmk__xf_dirty = 0x0001, pcmk__xf_deleted = 0x0002, pcmk__xf_created = 0x0004,
  pcmk__xf_modified = 0x0008, pcmk__xf_tracking = 0x0010, pcmk__xf_processed = 0x0020, pcmk__xf_skip = 0x0040,
  pcmk__xf_moved = 0x0080, pcmk__xf_acl_enabled = 0x0100, pcmk__xf_acl_read = 0x0200, pcmk__xf_acl_write = 0x0400,
  pcmk__xf_acl_deny = 0x0800, pcmk__xf_acl_create = 0x1000, pcmk__xf_acl_denied = 0x2000, pcmk__xf_lazy = 0x4000
}
 

Functions

int pcmk__xml_show (pcmk__output_t *out, const char *prefix, const xmlNode *data, int depth, uint32_t options)
 
int pcmk__xml_show_changes (pcmk__output_t *out, const xmlNode *xml)
 
int pcmk__xml2fd (int fd, xmlNode *cur)
 
void pcmk__strip_xml_text (xmlNode *xml)
 
const char * pcmk__xe_add_last_written (xmlNode *xe)
 
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)
 
GString * pcmk__element_xpath (const xmlNode *xml)
 
char * pcmk__xml_artefact_root (enum pcmk__xml_artefact_ns ns)
 
char * pcmk__xml_artefact_path (enum pcmk__xml_artefact_ns ns, const char *filespec)
 
void pcmk__xe_set_propv (xmlNodePtr node, va_list pairs)
 
void pcmk__xe_set_props (xmlNodePtr node,...) G_GNUC_NULL_TERMINATED
 
char * pcmk__xpath_node_id (const char *xpath, const char *node)
 
void pcmk__set_xml_doc_flag (xmlNode *xml, enum xml_private_flags flag)
 
int pcmk__xe_foreach_child (xmlNode *xml, const char *child_element_name, int(*handler)(xmlNode *xml, void *userdata), void *userdata)
 
gboolean pcmk__validate_xml (xmlNode *xml_blob, const char *validation, xmlRelaxNGValidityErrorFunc error_handler, void *error_handler_context)
 

Macro Definition Documentation

◆ PCMK__XML_LOG_BASE

#define PCMK__XML_LOG_BASE (   priority,
  dechunk,
  postemit,
  prefix,
  fmt,
  ap 
)

Base for directing lib{xml2,xslt} log into standard libqb backend.

This macro implements the core of what can be needed for directing libxml2 or libxslt error messaging into standard, preconfigured libqb-backed log stream.

It's a bit unfortunate that libxml2 (and more sparsely, also libxslt) emits a single message by chunks (location is emitted separatedly from the message itself), so we have to take the effort to combine these chunks back to single message. Whether to do this or not is driven with dechunk toggle.

The form of a macro was chosen for implicit deriving of FILE, etc. and also because static dechunking buffer should be differentiated per library (here we assume different functions referring to this macro will not ever be using both at once), preferably also per-library context of use to avoid clashes altogether.

Note that we cannot use qb_logt, because callsite data have to be known at the moment of compilation, which it is not always the case – xml_log (and unfortunately there's no clear explanation of the fail to compile).

Also note that there's no explicit guard against said libraries producing never-newline-terminated chunks (which would just keep consuming memory), as it's quite improbable. Termination of the program in between the same-message chunks will raise a flag with valgrind and the likes, though.

And lastly, regarding how dechunking combines with other non-message parameters – for priority, most important running specification wins (possibly elevated to LOG_ERR in case of nonconformance with the newline-termination "protocol"), dechunk is expected to always be on once it was at the start, and the rest (postemit and prefix) are picked directly from the last chunk entry finalizing the message (also reasonable to always have it the same with all related entries).

Parameters
[in]prioritySyslog priority for the message to be logged
[in]dechunkWhether to dechunk new-line terminated message
[in]postemitCode to be executed once message is sent out
[in]prefixHow to prefix the message or NULL for raw passing
[in]fmtFormat string as with printf-like functions
[in]apVariable argument list to supplement fmt format string

Definition at line 69 of file xml_internal.h.

◆ PCMK__XP_GUEST_NODE_CONFIG

#define PCMK__XP_GUEST_NODE_CONFIG
Value:
"[@name='" XML_RSC_ATTR_REMOTE_NODE "']"
#define XML_CIB_TAG_NVPAIR
Definition: msg_xml.h:224
#define XML_CIB_TAG_RESOURCE
Definition: msg_xml.h:235
#define XML_TAG_META_SETS
Definition: msg_xml.h:228
#define XML_RSC_ATTR_REMOTE_NODE
Definition: msg_xml.h:258
#define XML_TAG_CIB
Definition: msg_xml.h:137
#define XML_CIB_TAG_CONFIGURATION
Definition: msg_xml.h:203

Definition at line 176 of file xml_internal.h.

◆ PCMK__XP_MEMBER_NODE_CONFIG

#define PCMK__XP_MEMBER_NODE_CONFIG
Value:
"/" XML_CIB_TAG_NODE "[not(@type) or @type='member']"
#define XML_CIB_TAG_NODES
Definition: msg_xml.h:206
#define XML_CIB_TAG_NODE
Definition: msg_xml.h:223
#define XML_TAG_CIB
Definition: msg_xml.h:137
#define XML_CIB_TAG_CONFIGURATION
Definition: msg_xml.h:203

Definition at line 171 of file xml_internal.h.

◆ PCMK__XP_REMOTE_NODE_CONFIG

#define PCMK__XP_REMOTE_NODE_CONFIG
Value:
"[@type='remote'][@provider='pacemaker']"
#define XML_CIB_TAG_RESOURCE
Definition: msg_xml.h:235
#define XML_TAG_CIB
Definition: msg_xml.h:137
#define XML_CIB_TAG_CONFIGURATION
Definition: msg_xml.h:203

Definition at line 182 of file xml_internal.h.

◆ PCMK__XP_REMOTE_NODE_STATUS

#define PCMK__XP_REMOTE_NODE_STATUS
Value:
"[@" XML_NODE_IS_REMOTE "='true']"
#define XML_CIB_TAG_STATE
Definition: msg_xml.h:222
#define XML_NODE_IS_REMOTE
Definition: msg_xml.h:288
#define XML_TAG_CIB
Definition: msg_xml.h:137
#define XML_CIB_TAG_STATUS
Definition: msg_xml.h:204

Definition at line 187 of file xml_internal.h.

Enumeration Type Documentation

◆ pcmk__xml_artefact_ns

Enumerator
pcmk__xml_artefact_ns_legacy_rng 
pcmk__xml_artefact_ns_legacy_xslt 
pcmk__xml_artefact_ns_base_rng 
pcmk__xml_artefact_ns_base_xslt 

Definition at line 201 of file xml_internal.h.

◆ pcmk__xml_fmt_options

Enumerator
pcmk__xml_fmt_filtered 

Exclude certain XML attributes (for calculating digests)

pcmk__xml_fmt_pretty 

Include indentation and newlines.

pcmk__xml_fmt_open 

Include the opening tag of an XML element, and include XML comments.

pcmk__xml_fmt_children 

Include the children of an XML element.

pcmk__xml_fmt_close 

Include the closing tag of an XML element.

pcmk__xml_fmt_text 

Include XML text nodes.

pcmk__xml_fmt_diff_plus 

Log a created XML subtree.

pcmk__xml_fmt_diff_minus 

Log a removed XML subtree.

pcmk__xml_fmt_diff_short 

Log a minimal version of an XML diff (only showing the changes)

Definition at line 132 of file xml_internal.h.

◆ xml_private_flags

Enumerator
pcmk__xf_none 
pcmk__xf_dirty 
pcmk__xf_deleted 
pcmk__xf_created 
pcmk__xf_modified 
pcmk__xf_tracking 
pcmk__xf_processed 
pcmk__xf_skip 
pcmk__xf_moved 
pcmk__xf_acl_enabled 
pcmk__xf_acl_read 
pcmk__xf_acl_write 
pcmk__xf_acl_deny 
pcmk__xf_acl_create 
pcmk__xf_acl_denied 
pcmk__xf_lazy 

Definition at line 388 of file xml_internal.h.

Function Documentation

◆ pcmk__element_xpath()

GString* pcmk__element_xpath ( const xmlNode *  xml)

Definition at line 278 of file xpath.c.

◆ pcmk__set_xml_doc_flag()

void pcmk__set_xml_doc_flag ( xmlNode *  xml,
enum xml_private_flags  flag 
)

Definition at line 78 of file xml.c.

◆ pcmk__strip_xml_text()

void pcmk__strip_xml_text ( xmlNode *  xml)

Definition at line 962 of file xml.c.

◆ pcmk__validate_xml()

gboolean pcmk__validate_xml ( xmlNode *  xml_blob,
const char *  validation,
xmlRelaxNGValidityErrorFunc  error_handler,
void *  error_handler_context 
)

Definition at line 679 of file schemas.c.

◆ pcmk__xe_add_last_written()

const char* pcmk__xe_add_last_written ( xmlNode *  xe)

Definition at line 1089 of file xml.c.

◆ pcmk__xe_foreach_child()

int pcmk__xe_foreach_child ( xmlNode *  xml,
const char *  child_element_name,
int(*)(xmlNode *xml, void *userdata)  handler,
void *  userdata 
)

Definition at line 2663 of file xml.c.

◆ pcmk__xe_match()

xmlNode* pcmk__xe_match ( const xmlNode *  parent,
const char *  node_name,
const char *  attr_n,
const char *  attr_v 
)

Definition at line 429 of file xml.c.

◆ pcmk__xe_remove_matching_attrs()

void pcmk__xe_remove_matching_attrs ( xmlNode *  element,
bool(*)(xmlAttrPtr, void *)  match,
void *  user_data 
)

Definition at line 593 of file xml.c.

◆ pcmk__xe_set_props()

void pcmk__xe_set_props ( xmlNodePtr  node,
  ... 
)

Definition at line 2654 of file xml.c.

◆ pcmk__xe_set_propv()

void pcmk__xe_set_propv ( xmlNodePtr  node,
va_list  pairs 
)

Definition at line 2636 of file xml.c.

◆ pcmk__xml2fd()

int pcmk__xml2fd ( int  fd,
xmlNode *  cur 
)

Definition at line 1675 of file xml.c.

◆ pcmk__xml_artefact_path()

char* pcmk__xml_artefact_path ( enum pcmk__xml_artefact_ns  ns,
const char *  filespec 
)

Definition at line 2614 of file xml.c.

◆ pcmk__xml_artefact_root()

char* pcmk__xml_artefact_root ( enum pcmk__xml_artefact_ns  ns)

Definition at line 2586 of file xml.c.

◆ pcmk__xml_show()

int pcmk__xml_show ( pcmk__output_t out,
const char *  prefix,
const xmlNode *  data,
int  depth,
uint32_t  options 
)

Definition at line 228 of file xml_display.c.

◆ pcmk__xml_show_changes()

int pcmk__xml_show_changes ( pcmk__output_t out,
const xmlNode *  xml 
)

Definition at line 369 of file xml_display.c.

◆ pcmk__xpath_node_id()

char* pcmk__xpath_node_id ( const char *  xpath,
const char *  node 
)

Definition at line 312 of file xpath.c.