41 xml_show_patchset_header(
pcmk__output_t *out,
const xmlNode *patchset)
44 int add[] = { 0, 0, 0 };
45 int del[] = { 0, 0, 0 };
49 if ((add[0] != del[0]) || (add[1] != del[1]) || (add[2] != del[2])) {
53 out->
info(out,
"Diff: --- %d.%d.%d %s", del[0], del[1], del[2], fmt);
54 rc = out->
info(out,
"Diff: +++ %d.%d.%d %s",
55 add[0], add[1], add[2], digest);
57 }
else if ((add[0] != 0) || (add[1] != 0) || (add[2] != 0)) {
58 rc = out->
info(out,
"Local-only Change: %d.%d.%d",
59 add[0], add[1], add[2]);
80 xml_show_patchset_v1_recursive(
pcmk__output_t *out,
const char *prefix,
81 const xmlNode *
data,
int depth, uint32_t options)
83 if ((
data->children == NULL)
100 for (
const xmlNode *child = pcmk__xml_first_child(
data); child != NULL;
101 child = pcmk__xml_next(child)) {
102 int temp_rc = xml_show_patchset_v1_recursive(out, prefix, child,
104 rc = pcmk__output_select_rc(rc, temp_rc);
132 xml_show_patchset_v1(
pcmk__output_t *out,
const xmlNode *patchset,
135 const xmlNode *removed = NULL;
136 const xmlNode *added = NULL;
137 const xmlNode *child = NULL;
138 bool is_first =
true;
139 int rc = xml_show_patchset_header(out, patchset);
147 for (child = pcmk__xml_first_child(removed); child != NULL;
148 child = pcmk__xml_next(child)) {
149 int temp_rc = xml_show_patchset_v1_recursive(out,
"- ", child, 0,
152 rc = pcmk__output_select_rc(rc, temp_rc);
157 rc = pcmk__output_select_rc(rc, out->
info(out,
" --- "));
163 for (child = pcmk__xml_first_child(added); child != NULL;
164 child = pcmk__xml_next(child)) {
165 int temp_rc = xml_show_patchset_v1_recursive(out,
"+ ", child, 0,
168 rc = pcmk__output_select_rc(rc, temp_rc);
173 rc = pcmk__output_select_rc(rc, out->
info(out,
" +++ "));
195 xml_show_patchset_v2(
pcmk__output_t *out,
const xmlNode *patchset)
197 int rc = xml_show_patchset_header(out, patchset);
202 change != NULL; change = pcmk__xe_next(change)) {
217 rc = pcmk__output_select_rc(rc, temp_rc);
220 for (
char *ch = prefix + 2; *ch !=
'\0'; ch++) {
228 rc = pcmk__output_select_rc(rc, temp_rc);
234 temp_rc = out->
info(out,
237 rc = pcmk__output_select_rc(rc, temp_rc);
242 GString *buffer_set = NULL;
243 GString *buffer_unset = NULL;
247 child != NULL; child = pcmk__xe_next(child)) {
256 if (strcmp(op,
"set") == 0) {
262 }
else if (strcmp(op,
"unset") == 0) {
264 g_string_append(buffer_unset,
name);
268 if (buffer_set != NULL) {
269 temp_rc = out->
info(out,
"+ %s: %s", xpath, buffer_set->str);
270 rc = pcmk__output_select_rc(rc, temp_rc);
271 g_string_free(buffer_set, TRUE);
274 if (buffer_unset != NULL) {
275 temp_rc = out->
info(out,
"-- %s: %s",
276 xpath, buffer_unset->str);
277 rc = pcmk__output_select_rc(rc, temp_rc);
278 g_string_free(buffer_unset, TRUE);
286 temp_rc = out->
info(out,
"-- %s (%d)", xpath, position);
288 temp_rc = out->
info(out,
"-- %s", xpath);
290 rc = pcmk__output_select_rc(rc, temp_rc);
316 const xmlNode *patchset = va_arg(args,
const xmlNode *);
320 if (patchset == NULL) {
330 return xml_show_patchset_v2(out, patchset);
332 crm_err(
"Unknown patch format: %d", format);
356 static struct qb_log_callsite *patchset_cs = NULL;
358 const xmlNode *patchset = va_arg(args,
const xmlNode *);
367 if (patchset == NULL) {
372 if (patchset_cs == NULL) {
373 patchset_cs = qb_log_callsite_get(__func__, __FILE__,
"xml-patchset",
386 if (log_level < LOG_DEBUG) {
387 return xml_show_patchset_v1(out, patchset,
393 return xml_show_patchset_v2(out, patchset);
395 crm_err(
"Unknown patch format: %d", format);
419 const xmlNode *patchset = va_arg(args,
const xmlNode *);
421 if (patchset != NULL) {
422 GString *buf = g_string_sized_new(1024);
428 g_string_free(buf, TRUE);
436 {
"xml-patchset",
"default", xml_patchset_default },
437 {
"xml-patchset",
"log", xml_patchset_log },
438 {
"xml-patchset",
"xml", xml_patchset_xml },
461 const xmlNode *patchset)
471 static struct qb_log_callsite *patchset_cs = NULL;
484 if (patchset_cs == NULL) {
485 patchset_cs = qb_log_callsite_get(__func__, __FILE__,
486 "xml-patchset", log_level,
498 if (patchset == NULL) {
507 if (log_level < LOG_DEBUG) {
508 rc = xml_show_patchset_v1(out, patchset,
516 rc = xml_show_patchset_v2(out, patchset);
519 crm_err(
"Unknown patch format: %d", format);
#define CRM_CHECK(expr, failure_action)
#define PCMK__XE_DIFF_REMOVED
void pcmk__register_messages(pcmk__output_t *out, const pcmk__message_entry_t *table)
void pcmk__xml_string(const xmlNode *data, uint32_t options, GString *buffer, int depth)
#define PCMK_VALUE_CREATE
void xml_log_patchset(uint8_t log_level, const char *function, const xmlNode *patchset)
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.
#define PCMK_XE_CHANGE_LIST
void pcmk__register_patchset_messages(pcmk__output_t *out)
#define PCMK__XML_PREFIX_MOVED
XML has been moved.
void pcmk__add_separated_word(GString **list, size_t init_size, const char *word, const char *separator)
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
unsigned int crm_trace_nonlog
void pcmk__output_set_log_level(pcmk__output_t *out, uint8_t log_level)
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
#define PCMK_XA_OPERATION
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.
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
#define PCMK__XE_DIFF_ADDED
#define PCMK__OUTPUT_ARGS(ARGS...)
Include the children of an XML element.
#define PCMK_VALUE_MODIFY
#define crm_trace(fmt, args...)
#define PCMK_VALUE_DELETE
void pcmk__g_strcat(GString *buffer,...) G_GNUC_NULL_TERMINATED
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
Wrappers for and extensions to libxml2.
void(* finish)(pcmk__output_t *out, crm_exit_t exit_status, bool print, void **copy_dest)
#define PCMK__XML_PREFIX_CREATED
XML is newly created.
void pcmk__output_free(pcmk__output_t *out)
gboolean crm_is_callsite_active(struct qb_log_callsite *cs, uint8_t level, uint32_t tags)
Log a removed XML subtree.
#define PCMK_XE_XML_PATCHSET
int pcmk__xml_show(pcmk__output_t *out, const char *prefix, const xmlNode *data, int depth, uint32_t options)
Include the closing tag of an XML element.
#define crm_err(fmt, args...)
#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)
bool xml_patch_versions(const xmlNode *patchset, int add[3], int del[3])
uint8_t pcmk__output_get_log_level(const pcmk__output_t *out)
int pcmk__text_output_new(pcmk__output_t **out, const char *filename)
int pcmk__log_output_new(pcmk__output_t **out)