pacemaker 3.0.1-16e74fc4da
Scalable High-Availability cluster resource manager
Loading...
Searching...
No Matches
xml_internal.h File Reference
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <crm/crm.h>
#include <crm/common/output_internal.h>
#include <crm/common/xml_names.h>
#include <crm/common/xml_comment_internal.h>
#include <crm/common/xml_element_internal.h>
#include <crm/common/xml_idref_internal.h>
#include <crm/common/xml_io_internal.h>
#include <crm/common/xml_names_internal.h>
#include <crm/common/xpath_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.
 

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)
}
 
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  pcmk__xml_flags {
  pcmk__xf_none = UINT32_C(0) , pcmk__xf_dirty = (UINT32_C(1) << 0) , pcmk__xf_deleted = (UINT32_C(1) << 1) , pcmk__xf_created = (UINT32_C(1) << 2) ,
  pcmk__xf_modified = (UINT32_C(1) << 3) , pcmk__xf_tracking = (UINT32_C(1) << 4) , pcmk__xf_skip = (UINT32_C(1) << 6) , pcmk__xf_moved = (UINT32_C(1) << 7) ,
  pcmk__xf_acl_enabled = (UINT32_C(1) << 8) , pcmk__xf_acl_read = (UINT32_C(1) << 9) , pcmk__xf_acl_write = (UINT32_C(1) << 10) , pcmk__xf_acl_deny = (UINT32_C(1) << 11) ,
  pcmk__xf_acl_create = (UINT32_C(1) << 12) , pcmk__xf_acl_denied = (UINT32_C(1) << 13) , pcmk__xf_ignore_attr_pos = (UINT32_C(1) << 14)
}
 

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)
 
void pcmk__strip_xml_text (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)
 
void pcmk__xml_free (xmlNode *xml)
 
void pcmk__xml_free_doc (xmlDoc *doc)
 
xmlNode * pcmk__xml_copy (xmlNode *parent, xmlNode *src)
 
void pcmk__xml_sanitize_id (char *id)
 
void pcmk__xml_doc_set_flags (xmlDoc *doc, uint32_t flags)
 
bool pcmk__xml_doc_all_flags_set (const xmlDoc *xml, uint32_t flags)
 
void pcmk__xml_commit_changes (xmlDoc *doc)
 
void pcmk__xml_mark_changes (xmlNode *old_xml, xmlNode *new_xml)
 
bool pcmk__xml_tree_foreach (xmlNode *xml, bool(*fn)(xmlNode *, void *), void *user_data)
 
bool pcmk__cib_element_in_patchset (const xmlNode *patchset, const char *element)
 

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 82 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 329 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 170 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 '\n ' and '\t '.
  • Escape other non-printing characters using character references.
pcmk__xml_escape_attr 

For attribute values.

  • Escape '<', '>', '&', and '"' using entity references.
  • Escape '\n ', '\t ', 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 '\n ' as "\\n"
  • Escape '\r ' as "\\r"
  • Escape '\t ' as "\\t"
  • Escape '"' as "\\""

Definition at line 222 of file xml_internal.h.

◆ pcmk__xml_flags

Enumerator
pcmk__xf_none 

This flag has no effect.

pcmk__xf_dirty 

Node was created or modified, or one of its descendants was created, modified, moved, or deleted.

pcmk__xf_deleted 

Node was deleted (set for attribute only)

pcmk__xf_created 

Node was created.

pcmk__xf_modified 

Node was modified.

pcmk__xf_tracking 

Tracking is enabled (set for document only)

Call pcmk__xml_commit_changes() before setting this flag if a clean start for tracking is needed.

pcmk__xf_skip 

Skip counting this node when getting a node's position among siblings.

pcmk__xf_moved 

Node was moved.

pcmk__xf_acl_enabled 

ACLs are enabled (set for document only)

pcmk__xf_acl_read 

ACL read permission.

pcmk__xf_acl_write 

ACL write permission (implies read permission in most or all contexts)

pcmk__xf_acl_deny 

ACL deny permission (that is, no permission)

pcmk__xf_acl_create 

ACL create permission for attributes (if attribute exists, this is mapped to pcmk__xf_acl_write)

pcmk__xf_acl_denied 

ACLs deny the user access (set for document only)

pcmk__xf_ignore_attr_pos 

Ignore attribute moves within an element (set for document only)

Definition at line 351 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.

Definition at line 145 of file xml_internal.h.

Function Documentation

◆ pcmk__cib_element_in_patchset()

bool pcmk__cib_element_in_patchset ( const xmlNode * patchset,
const char * element )

Definition at line 833 of file patchset.c.

◆ pcmk__strip_xml_text()

void pcmk__strip_xml_text ( xmlNode * xml)

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

◆ pcmk__xml_artefact_root()

char * pcmk__xml_artefact_root ( enum pcmk__xml_artefact_ns ns)

Definition at line 1635 of file xml.c.

◆ pcmk__xml_commit_changes()

void pcmk__xml_commit_changes ( xmlDoc * doc)

Definition at line 468 of file xml.c.

◆ pcmk__xml_copy()

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

Definition at line 832 of file xml.c.

◆ pcmk__xml_doc_all_flags_set()

bool pcmk__xml_doc_all_flags_set ( const xmlDoc * xml,
uint32_t flags )

Definition at line 147 of file xml.c.

◆ pcmk__xml_doc_set_flags()

void pcmk__xml_doc_set_flags ( xmlDoc * doc,
uint32_t flags )

Definition at line 128 of file xml.c.

◆ pcmk__xml_escape()

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

Definition at line 991 of file xml.c.

◆ pcmk__xml_free()

void pcmk__xml_free ( xmlNode * xml)

Definition at line 816 of file xml.c.

◆ pcmk__xml_free_doc()

void pcmk__xml_free_doc ( xmlDoc * doc)

Definition at line 515 of file xml.c.

◆ pcmk__xml_mark_changes()

void pcmk__xml_mark_changes ( xmlNode * old_xml,
xmlNode * new_xml )

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

◆ pcmk__xml_sanitize_id()

void pcmk__xml_sanitize_id ( char * id)

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

◆ pcmk__xml_show_changes()

int pcmk__xml_show_changes ( pcmk__output_t * out,
const xmlNode * xml )

Definition at line 362 of file xml_display.c.

◆ pcmk__xml_tree_foreach()

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

Definition at line 87 of file xml.c.