pacemaker  2.1.9-49aab99839
Scalable High-Availability cluster resource manager
Macros | Enumerations | Functions
xml_internal.h File Reference
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <crm/crm.h>
#include <crm/common/output_internal.h>
#include <crm/common/xml_io_internal.h>
#include <crm/common/xml_names_internal.h>
#include <libxml/relaxng.h>
Include dependency graph for xml_internal.h:

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  pcmk__xml_escape_type { pcmk__xml_escape_text, pcmk__xml_escape_attr, pcmk__xml_escape_attr_pretty }
 
enum  pcmk__xa_flags { pcmk__xaf_none = 0U, pcmk__xaf_no_overwrite = (1U << 0), pcmk__xaf_score_update = (1U << 1) }
 
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_first_child (const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
 
void pcmk__xe_remove_attr (xmlNode *element, const char *name)
 
bool pcmk__xe_remove_attr_cb (xmlNode *xml, void *user_data)
 
void pcmk__xe_remove_matching_attrs (xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
 
int pcmk__xe_delete_match (xmlNode *xml, xmlNode *search)
 
int pcmk__xe_replace_match (xmlNode *xml, xmlNode *replace)
 
int pcmk__xe_update_match (xmlNode *xml, xmlNode *update, uint32_t flags)
 
GString * pcmk__element_xpath (const xmlNode *xml)
 
bool pcmk__xml_needs_escape (const char *text, enum pcmk__xml_escape_type type)
 
char * pcmk__xml_escape (const char *text, enum pcmk__xml_escape_type type)
 
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)
 
xmlNode * pcmk__xe_create (xmlNode *parent, const char *name)
 
xmlNode * pcmk__xc_create (xmlDoc *doc, const char *content)
 
void pcmk__xml_free_doc (xmlDoc *doc)
 
xmlNode * pcmk__xml_copy (xmlNode *parent, xmlNode *src)
 
xmlNode * pcmk__xe_next_same (const xmlNode *node)
 
void pcmk__xe_set_content (xmlNode *node, const char *format,...) G_GNUC_PRINTF(2
 
int pcmk__xe_get_score (const xmlNode *xml, const char *name, int *score, int default_score)
 
int pcmk__xe_copy_attrs (xmlNode *target, const xmlNode *src, uint32_t flags)
 
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__warn_multiple_name_matches (pcmk__output_t *out, xmlNode *search, const char *name)
 
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)
 
bool pcmk__xml_tree_foreach (xmlNode *xml, bool(*fn)(xmlNode *, void *), void *user_data)
 
xmlNode * pcmk__diff_v1_xml_object (xmlNode *left, xmlNode *right, bool suppress)
 

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 72 of file xml_internal.h.

◆ PCMK__XP_GUEST_NODE_CONFIG

#define PCMK__XP_GUEST_NODE_CONFIG
Value:
#define PCMK_XE_NVPAIR
Definition: xml_names.h:144
#define PCMK_XA_NAME
Definition: xml_names.h:330
#define PCMK_XE_CIB
Definition: xml_names.h:79
#define PCMK_XE_PRIMITIVE
Definition: xml_names.h:164
#define PCMK_META_REMOTE_NODE
Definition: options.h:108
#define PCMK_XE_CONFIGURATION
Definition: xml_names.h:87
#define PCMK_XE_META_ATTRIBUTES
Definition: xml_names.h:130

Definition at line 181 of file xml_internal.h.

◆ PCMK__XP_MEMBER_NODE_CONFIG

#define PCMK__XP_MEMBER_NODE_CONFIG
Value:
"[not(@" PCMK_XA_TYPE ") or @" PCMK_XA_TYPE "='" PCMK_VALUE_MEMBER "']"
#define PCMK_XE_CIB
Definition: xml_names.h:79
#define PCMK_XA_TYPE
Definition: xml_names.h:430
#define PCMK_VALUE_MEMBER
Definition: options.h:169
#define PCMK_XE_CONFIGURATION
Definition: xml_names.h:87
#define PCMK_XE_NODE
Definition: xml_names.h:136
#define PCMK_XE_NODES
Definition: xml_names.h:142

Definition at line 175 of file xml_internal.h.

◆ PCMK__XP_REMOTE_NODE_CONFIG

#define PCMK__XP_REMOTE_NODE_CONFIG
Value:
"[@" PCMK_XA_PROVIDER "='pacemaker']"
#define PCMK_XE_CIB
Definition: xml_names.h:79
#define PCMK_XE_PRIMITIVE
Definition: xml_names.h:164
#define PCMK_XA_PROVIDER
Definition: xml_names.h:364
#define PCMK_XA_TYPE
Definition: xml_names.h:430
#define PCMK_XE_CONFIGURATION
Definition: xml_names.h:87
#define PCMK_VALUE_REMOTE
Definition: options.h:198

Definition at line 187 of file xml_internal.h.

◆ PCMK__XP_REMOTE_NODE_STATUS

#define PCMK__XP_REMOTE_NODE_STATUS
Value:
#define PCMK_XA_REMOTE_NODE
Definition: xml_names.h:376
#define PCMK_XE_CIB
Definition: xml_names.h:79
#define PCMK_XE_STATUS
Definition: xml_names.h:204
#define PCMK_VALUE_TRUE
Definition: options.h:215
#define PCMK__XE_NODE_STATE

Definition at line 193 of file xml_internal.h.

Enumeration Type Documentation

◆ pcmk__xa_flags

Enumerator
pcmk__xaf_none 

Flag has no effect.

pcmk__xaf_no_overwrite 

Don't overwrite existing values.

pcmk__xaf_score_update 

Treat values as score updates where possible (see pcmk__xe_set_score())

Definition at line 438 of file xml_internal.h.

◆ 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 207 of file xml_internal.h.

◆ pcmk__xml_escape_type

Enumerator
pcmk__xml_escape_text 

For text nodes.

  • Escape '<', '>', and '&' using entity references.
  • Do not escape ' ' and ' '.
  • Escape other non-printing characters using character references.
pcmk__xml_escape_attr 

For attribute values.

  • Escape '<', '>', '&', and '"' using entity references.
  • Escape ' ', ' ', and other non-printing characters using character references.
pcmk__xml_escape_attr_pretty 

For attribute values displayed in text output delimited by double quotes.

  • Escape ' ' as "\\n"
  • Escape ' ' as "\\r"
  • Escape ' ' as "\\t"
  • Escape '"' as "\\""

Definition at line 276 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 135 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 524 of file xml_internal.h.

Function Documentation

◆ pcmk__diff_v1_xml_object()

xmlNode* pcmk__diff_v1_xml_object ( xmlNode *  left,
xmlNode *  right,
bool  suppress 
)

Definition at line 1435 of file patchset.c.

◆ pcmk__element_xpath()

GString* pcmk__element_xpath ( const xmlNode *  xml)

Definition at line 256 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 94 of file xml.c.

◆ pcmk__strip_xml_text()

void pcmk__strip_xml_text ( xmlNode *  xml)

Definition at line 1012 of file xml.c.

◆ pcmk__warn_multiple_name_matches()

void pcmk__warn_multiple_name_matches ( pcmk__output_t out,
xmlNode *  search,
const char *  name 
)

Definition at line 332 of file xpath.c.

◆ pcmk__xc_create()

xmlNode* pcmk__xc_create ( xmlDoc *  doc,
const char *  content 
)

Definition at line 28 of file xml_comment.c.

◆ pcmk__xe_add_last_written()

const char* pcmk__xe_add_last_written ( xmlNode *  xe)

Definition at line 1048 of file xml.c.

◆ pcmk__xe_copy_attrs()

int pcmk__xe_copy_attrs ( xmlNode *  target,
const xmlNode *  src,
uint32_t  flags 
)

Definition at line 669 of file xml.c.

◆ pcmk__xe_create()

xmlNode* pcmk__xe_create ( xmlNode *  parent,
const char *  name 
)

Definition at line 770 of file xml.c.

◆ pcmk__xe_delete_match()

int pcmk__xe_delete_match ( xmlNode *  xml,
xmlNode *  search 
)

Definition at line 1859 of file xml.c.

◆ pcmk__xe_first_child()

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

Definition at line 481 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 2306 of file xml.c.

◆ pcmk__xe_get_score()

int pcmk__xe_get_score ( const xmlNode *  xml,
const char *  name,
int *  score,
int  default_score 
)

Definition at line 549 of file xml.c.

◆ pcmk__xe_next_same()

xmlNode* pcmk__xe_next_same ( const xmlNode *  node)

Definition at line 2130 of file xml.c.

◆ pcmk__xe_remove_attr()

void pcmk__xe_remove_attr ( xmlNode *  element,
const char *  name 
)

Definition at line 702 of file xml.c.

◆ pcmk__xe_remove_attr_cb()

bool pcmk__xe_remove_attr_cb ( xmlNode *  xml,
void *  user_data 
)

Definition at line 724 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 742 of file xml.c.

◆ pcmk__xe_replace_match()

int pcmk__xe_replace_match ( xmlNode *  xml,
xmlNode *  replace 
)

Definition at line 1974 of file xml.c.

◆ pcmk__xe_set_content()

void pcmk__xe_set_content ( xmlNode *  node,
const char *  format,
  ... 
)

◆ pcmk__xe_set_props()

void pcmk__xe_set_props ( xmlNodePtr  node,
  ... 
)

Definition at line 2297 of file xml.c.

◆ pcmk__xe_set_propv()

void pcmk__xe_set_propv ( xmlNodePtr  node,
va_list  pairs 
)

Definition at line 2279 of file xml.c.

◆ pcmk__xe_update_match()

int pcmk__xe_update_match ( xmlNode *  xml,
xmlNode *  update,
uint32_t  flags 
)

Definition at line 2068 of file xml.c.

◆ pcmk__xml2fd()

int pcmk__xml2fd ( int  fd,
xmlNode *  cur 
)

Definition at line 715 of file xml_io.c.

◆ pcmk__xml_artefact_path()

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

Definition at line 2259 of file xml.c.

◆ pcmk__xml_artefact_root()

char* pcmk__xml_artefact_root ( enum pcmk__xml_artefact_ns  ns)

Definition at line 2202 of file xml.c.

◆ pcmk__xml_copy()

xmlNode* pcmk__xml_copy ( xmlNode *  parent,
xmlNode *  src 
)

Definition at line 974 of file xml.c.

◆ pcmk__xml_escape()

char* pcmk__xml_escape ( const char *  text,
enum pcmk__xml_escape_type  type 
)

Definition at line 1199 of file xml.c.

◆ pcmk__xml_free_doc()

void pcmk__xml_free_doc ( xmlDoc *  doc)

Definition at line 819 of file xml.c.

◆ pcmk__xml_needs_escape()

bool pcmk__xml_needs_escape ( const char *  text,
enum pcmk__xml_escape_type  type 
)

Definition at line 1117 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 229 of file xml_display.c.

◆ pcmk__xml_show_changes()

int pcmk__xml_show_changes ( pcmk__output_t out,
const xmlNode *  xml 
)

Definition at line 370 of file xml_display.c.

◆ pcmk__xml_tree_foreach()

bool pcmk__xml_tree_foreach ( xmlNode *  xml,
bool(*)(xmlNode *, void *)  fn,
void *  user_data 
)

Definition at line 45 of file xml.c.

◆ pcmk__xpath_node_id()

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

Definition at line 290 of file xpath.c.