12 #include <libxml/tree.h> 20 const char *prefix,
const xmlNode *
data,
int depth,
34 __LINE__,
"xml library error", TRUE,
36 "XML Error: ", fmt, ap);
65 return out->
info(out,
"%*s<!--%s-->",
66 width,
"", (
const char *)
data->content);
91 show_xml_element(
pcmk__output_t *out, GString *buffer,
const char *prefix,
92 const xmlNode *
data,
int depth, uint32_t options)
100 g_string_truncate(buffer, 0);
102 for (
int lpc = 0; lpc < spaces; lpc++) {
103 g_string_append_c(buffer,
' ');
107 for (
const xmlAttr *attr = pcmk__xe_first_attr(
data); attr != NULL;
110 const char *p_name = (
const char *) attr->name;
111 const char *p_value = pcmk__xml_attr_value(attr);
112 gchar *p_copy = NULL;
119 if (pcmk_any_flags_set(options,
126 if ((hidden != NULL) && (p_name[0] !=
'\0')
127 && (strstr(hidden, p_name) != NULL)) {
137 pcmk__s(p_value,
"<null>"),
"\"", NULL);
141 if ((
data->children != NULL)
143 g_string_append_c(buffer,
'>');
146 g_string_append(buffer,
"/>");
149 rc = out->
info(out,
"%s%s%s",
150 pcmk__s(prefix,
""), pcmk__str_empty(prefix)?
"" :
" ",
154 if (
data->children == NULL) {
159 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
160 child = pcmk__xml_next(child)) {
162 int temp_rc = show_xml_node(out, buffer, prefix, child, depth + 1,
166 rc = pcmk__output_select_rc(rc, temp_rc);
171 int temp_rc = out->
info(out,
"%s%s%*s</%s>",
173 pcmk__str_empty(prefix)?
"" :
" ",
174 spaces,
"",
data->name);
175 rc = pcmk__output_select_rc(rc, temp_rc);
201 show_xml_node(
pcmk__output_t *out, GString *buffer,
const char *prefix,
202 const xmlNode *
data,
int depth, uint32_t options)
204 switch (
data->type) {
205 case XML_COMMENT_NODE:
206 return show_xml_comment(out,
data, depth, options);
207 case XML_ELEMENT_NODE:
208 return show_xml_element(out, buffer, prefix,
data, depth, options);
230 int depth, uint32_t options)
233 GString *buffer = NULL;
245 buffer = g_string_sized_new(1024);
246 rc = show_xml_node(out, buffer, prefix,
data, depth, options);
247 g_string_free(buffer, TRUE);
288 int spaces = pretty? (2 * depth) : 0;
300 for (
const xmlAttr *attr = pcmk__xe_first_attr(
data); attr != NULL;
302 const char *
name = (
const char *) attr->name;
304 nodepriv = attr->_private;
307 const char *value = pcmk__xml_attr_value(attr);
309 temp_rc = out->
info(out,
"%s %*s @%s=%s",
314 const char *value = pcmk__xml_attr_value(attr);
329 temp_rc = out->
info(out,
"%s %*s @%s=%s",
330 prefix, spaces,
"",
name, value);
332 rc = pcmk__output_select_rc(rc, temp_rc);
336 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
337 child = pcmk__xml_next(child)) {
338 temp_rc = show_xml_changes_recursive(out, child, depth + 1,
340 rc = pcmk__output_select_rc(rc, temp_rc);
346 return pcmk__output_select_rc(rc, temp_rc);
350 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
351 child = pcmk__xml_next(child)) {
352 temp_rc = show_xml_changes_recursive(out, child, depth + 1, options);
353 rc = pcmk__output_select_rc(rc, temp_rc);
380 docpriv = xml->doc->_private;
385 for (
const GList *iter = docpriv->
deleted_objs; iter != NULL;
396 rc = pcmk__output_select_rc(rc, temp_rc);
400 return pcmk__output_select_rc(rc, temp_rc);
411 int line,
const char *prefix,
const xmlNode *
data,
int depth,
414 uint32_t options = 0;
418 log_level = pcmk__clip_log_level(log_level);
421 do_crm_log(log_level,
"%s%sNo data to dump as XML",
422 pcmk__s(prefix,
""), pcmk__str_empty(prefix)?
"" :
" ");
475 show_xml_changes_recursive(out,
data, depth, options);
480 && ((
data->children == NULL)
496 if (!pcmk_any_flags_set(options,
504 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
505 child = pcmk__xml_next(child)) {
#define CRM_CHECK(expr, failure_action)
char * pcmk__xml_escape(const char *text, enum pcmk__xml_escape_type type)
#define pcmk__if_tracing(if_action, else_action)
void log_data_element(int log_level, const char *file, const char *function, int line, const char *prefix, const xmlNode *data, int depth, int legacy_options)
Exclude certain XML attributes (for calculating digests)
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
Include the opening tag of an XML element, and include XML comments.
void xml_log_changes(uint8_t log_level, const char *function, const xmlNode *xml)
#define PCMK__XML_PREFIX_MOVED
XML has been moved.
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
void pcmk__output_set_log_level(pcmk__output_t *out, uint8_t log_level)
Deprecated Pacemaker logging API.
Include indentation and newlines.
Deprecated Pacemaker XML API.
Log a created XML subtree.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define PCMK__XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap)
Base for directing lib{xml2,xslt} log into standard libqb backend.
Include the children of an XML element.
#define do_crm_log(level, fmt, args...)
Log a message.
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
int pcmk__xml_show(pcmk__output_t *out, const char *prefix, const xmlNode *data, int depth, uint32_t options)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
int pcmk__xml_show_changes(pcmk__output_t *out, const xmlNode *xml)
Wrappers for and extensions to libxml2.
void(* finish)(pcmk__output_t *out, crm_exit_t exit_status, bool print, void **copy_dest)
void pcmk__log_xmllib_err(void *ctx, const char *fmt,...)
#define PCMK__XML_PREFIX_CREATED
XML is newly created.
void pcmk__output_free(pcmk__output_t *out)
Log a removed XML subtree.
Include the closing tag of an XML element.
#define PCMK__XML_PREFIX_DELETED
XML has been deleted.
This structure contains everything that makes up a single output formatter.
#define PCMK__XA_CRM_DIFF_MARKER
Log a minimal version of an XML diff (only showing the changes)
void crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
int pcmk__text_output_new(pcmk__output_t **out, const char *filename)
#define PCMK__XML_PREFIX_MODIFIED
XML has been modified.
int pcmk__log_output_new(pcmk__output_t **out)