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;
118 if ((hidden != NULL) && (p_name[0] !=
'\0')
119 && (strstr(hidden, p_name) != NULL)) {
129 pcmk__s(p_value,
"<null>"),
"\"", NULL);
133 if ((
data->children != NULL)
135 g_string_append_c(buffer,
'>');
138 g_string_append(buffer,
"/>");
141 rc = out->
info(out,
"%s%s%s",
142 pcmk__s(prefix,
""), pcmk__str_empty(prefix)?
"" :
" ",
146 if (
data->children == NULL) {
151 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
152 child = pcmk__xml_next(child)) {
154 int temp_rc = show_xml_node(out, buffer, prefix, child, depth + 1,
158 rc = pcmk__output_select_rc(rc, temp_rc);
163 int temp_rc = out->
info(out,
"%s%s%*s</%s>",
165 pcmk__str_empty(prefix)?
"" :
" ",
166 spaces,
"",
data->name);
167 rc = pcmk__output_select_rc(rc, temp_rc);
193 show_xml_node(
pcmk__output_t *out, GString *buffer,
const char *prefix,
194 const xmlNode *
data,
int depth, uint32_t options)
196 switch (
data->type) {
197 case XML_COMMENT_NODE:
198 return show_xml_comment(out,
data, depth, options);
199 case XML_ELEMENT_NODE:
200 return show_xml_element(out, buffer, prefix,
data, depth, options);
222 int depth, uint32_t options)
225 GString *buffer = NULL;
237 buffer = g_string_sized_new(1024);
238 rc = show_xml_node(out, buffer, prefix,
data, depth, options);
239 g_string_free(buffer, TRUE);
280 int spaces = pretty? (2 * depth) : 0;
292 for (
const xmlAttr *attr = pcmk__xe_first_attr(
data); attr != NULL;
294 const char *
name = (
const char *) attr->name;
296 nodepriv = attr->_private;
299 const char *value = pcmk__xml_attr_value(attr);
301 temp_rc = out->
info(out,
"%s %*s @%s=%s",
306 const char *value = pcmk__xml_attr_value(attr);
321 temp_rc = out->
info(out,
"%s %*s @%s=%s",
322 prefix, spaces,
"",
name, value);
324 rc = pcmk__output_select_rc(rc, temp_rc);
328 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
329 child = pcmk__xml_next(child)) {
330 temp_rc = show_xml_changes_recursive(out, child, depth + 1,
332 rc = pcmk__output_select_rc(rc, temp_rc);
338 return pcmk__output_select_rc(rc, temp_rc);
342 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
343 child = pcmk__xml_next(child)) {
344 temp_rc = show_xml_changes_recursive(out, child, depth + 1, options);
345 rc = pcmk__output_select_rc(rc, temp_rc);
368 pcmk__assert((out != NULL) && (xml != NULL) && (xml->doc != NULL));
370 docpriv = xml->doc->_private;
375 for (
const GList *iter = docpriv->
deleted_objs; iter != NULL;
386 rc = pcmk__output_select_rc(rc, temp_rc);
390 return pcmk__output_select_rc(rc, temp_rc);
#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 crm_abort(const char *file, const char *function, int line, const char *condition, gboolean do_core, gboolean do_fork)
Include the opening tag of an XML element, and include XML comments.
#define PCMK__XML_PREFIX_MOVED
XML has been moved.
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
Include indentation and newlines.
#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.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
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 pcmk__log_xmllib_err(void *ctx, const char *fmt,...)
#define PCMK__XML_PREFIX_CREATED
XML is newly created.
#define pcmk__assert(expr)
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__XML_PREFIX_MODIFIED
XML has been modified.