12 #include <libxml/tree.h> 21 const char *prefix,
const xmlNode *
data,
int depth,
35 __LINE__,
"xml library error", TRUE,
37 "XML Error: ", fmt, ap);
66 return out->
info(out,
"%*s<!--%s-->",
67 width,
"", (
const char *)
data->content);
92 show_xml_element(
pcmk__output_t *out, GString *buffer,
const char *prefix,
93 const xmlNode *
data,
int depth, uint32_t options)
101 g_string_truncate(buffer, 0);
103 for (
int lpc = 0; lpc < spaces; lpc++) {
104 g_string_append_c(buffer,
' ');
108 for (
const xmlAttr *attr = pcmk__xe_first_attr(
data); attr != NULL;
111 const char *p_name = (
const char *) attr->name;
112 const char *p_value = pcmk__xml_attr_value(attr);
120 if (pcmk_any_flags_set(options,
127 if ((hidden != NULL) && (p_name[0] !=
'\0')
128 && (strstr(hidden, p_name) != NULL)) {
136 pcmk__s(p_copy,
"<null>"),
"\"", NULL);
140 if ((
data->children != NULL)
142 g_string_append_c(buffer,
'>');
145 g_string_append(buffer,
"/>");
148 rc = out->
info(out,
"%s%s%s",
149 pcmk__s(prefix,
""), pcmk__str_empty(prefix)?
"" :
" ",
153 if (
data->children == NULL) {
158 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
159 child = pcmk__xml_next(child)) {
161 int temp_rc = show_xml_node(out, buffer, prefix, child, depth + 1,
165 rc = pcmk__output_select_rc(rc, temp_rc);
170 int temp_rc = out->
info(out,
"%s%s%*s</%s>",
172 pcmk__str_empty(prefix)?
"" :
" ",
173 spaces,
"",
data->name);
174 rc = pcmk__output_select_rc(rc, temp_rc);
200 show_xml_node(
pcmk__output_t *out, GString *buffer,
const char *prefix,
201 const xmlNode *
data,
int depth, uint32_t options)
203 switch (
data->type) {
204 case XML_COMMENT_NODE:
205 return show_xml_comment(out,
data, depth, options);
206 case XML_ELEMENT_NODE:
207 return show_xml_element(out, buffer, prefix,
data, depth, options);
229 int depth, uint32_t options)
232 GString *buffer = NULL;
244 buffer = g_string_sized_new(1024);
245 rc = show_xml_node(out, buffer, prefix,
data, depth, options);
246 g_string_free(buffer, TRUE);
287 int spaces = pretty? (2 * depth) : 0;
299 for (
const xmlAttr *attr = pcmk__xe_first_attr(
data); attr != NULL;
301 const char *
name = (
const char *) attr->name;
303 nodepriv = attr->_private;
306 const char *value = pcmk__xml_attr_value(attr);
308 temp_rc = out->
info(out,
"%s %*s @%s=%s",
313 const char *value = pcmk__xml_attr_value(attr);
328 temp_rc = out->
info(out,
"%s %*s @%s=%s",
329 prefix, spaces,
"",
name, value);
331 rc = pcmk__output_select_rc(rc, temp_rc);
335 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
336 child = pcmk__xml_next(child)) {
337 temp_rc = show_xml_changes_recursive(out, child, depth + 1,
339 rc = pcmk__output_select_rc(rc, temp_rc);
345 return pcmk__output_select_rc(rc, temp_rc);
349 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
350 child = pcmk__xml_next(child)) {
351 temp_rc = show_xml_changes_recursive(out, child, depth + 1, options);
352 rc = pcmk__output_select_rc(rc, temp_rc);
379 docpriv = xml->doc->_private;
384 for (
const GList *iter = docpriv->
deleted_objs; iter != NULL;
395 rc = pcmk__output_select_rc(rc, temp_rc);
399 return pcmk__output_select_rc(rc, temp_rc);
410 int line,
const char *prefix,
const xmlNode *
data,
int depth,
413 uint32_t options = 0;
417 log_level = pcmk__clip_log_level(log_level);
420 do_crm_log(log_level,
"%s%sNo data to dump as XML",
421 pcmk__s(prefix,
""), pcmk__str_empty(prefix)?
"" :
" ");
474 show_xml_changes_recursive(out,
data, depth, options);
479 && ((
data->children == NULL)
495 if (!pcmk_any_flags_set(options,
503 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
504 child = pcmk__xml_next(child)) {
#define CRM_CHECK(expr, failure_action)
#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)
void pcmk__str_update(char **str, const char *value)
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.
Log a minimal version of an XML diff (only showing the changes)
char * crm_xml_escape(const char *text)
Replace special characters with their XML escape sequences.
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)