23 #define BEST_EFFORT_STATUS 0 33 dump_xml_for_digest(xmlNode * an_xml_node)
36 int offset = 0, max = 0;
57 calculate_xml_digest_v1(xmlNode * input, gboolean sort, gboolean ignored)
70 buffer = dump_xml_for_digest(input);
92 calculate_xml_digest_v2(xmlNode * source, gboolean do_filter)
98 static struct qb_log_callsite *digest_cs = NULL;
100 crm_trace(
"Begin digest %s", do_filter?
"filtered":
"");
116 &buffer, &offset, &max, 0);
122 if (digest_cs == NULL) {
123 digest_cs = qb_log_callsite_get(__func__, __FILE__,
"cib-digest",
LOG_TRACE, __LINE__,
126 if (digest_cs && digest_cs->targets) {
158 return calculate_xml_digest_v1(input, FALSE, FALSE);
173 return calculate_xml_digest_v1(input, TRUE, FALSE);
204 return calculate_xml_digest_v1(input, sort, do_filter);
207 return calculate_xml_digest_v2(input, do_filter);
222 char *calculated = NULL;
227 if (calculated == NULL) {
228 crm_perror(LOG_ERR,
"Could not calculate digest for comparison");
234 crm_trace(
"Digest comparison passed: %s", calculated);
236 crm_err(
"Digest comparison failed: expected %s, calculated %s",
237 expected, calculated);
254 static const char *filter[] = {
262 for (
int i = 0; i <
DIMOF(filter); i++) {
263 if (strcmp(
name, filter[i]) == 0) {
273 int lpc = 0, len = 0;
277 if (buffer == NULL) {
280 len = strlen(buffer);
282 crm_trace(
"Beginning digest of %d bytes", len);
287 sprintf(digest + (2 * lpc),
"%02x", raw_digest[lpc]);
293 crm_err(
"Could not create digest");
#define CRM_CHECK(expr, failure_action)
#define XML_ATTR_UPDATE_ORIG
#define XML_ATTR_UPDATE_CLIENT
#define XML_ATTR_NUMUPDATES
G_GNUC_INTERNAL void pcmk__buffer_add_char(char **buffer, int *offset, int *max, char c)
char * calculate_on_disk_digest(xmlNode *input)
Calculate and return digest of XML tree, suitable for storing on disk.
#define XML_ATTR_UPDATE_USER
unsigned int crm_trace_nonlog
#define XML_ATTR_GENERATION
void * md5_buffer(const char *buffer, size_t len, void *resblock)
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define crm_trace(fmt, args...)
Wrappers for and extensions to libxml2.
bool pcmk__xa_filterable(const char *name)
void free_xml(xmlNode *child)
char * calculate_xml_versioned_digest(xmlNode *input, gboolean sort, gboolean do_filter, const char *version)
Calculate and return digest of XML tree.
xmlNode * sorted_xml(xmlNode *input, xmlNode *parent, gboolean recursive)
G_GNUC_INTERNAL void pcmk__xml2text(xmlNode *data, int options, char **buffer, int *offset, int *max, int depth)
bool pcmk__verify_digest(xmlNode *input, const char *expected)
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
#define crm_err(fmt, args...)
#define XML_CIB_ATTR_WRITTEN
const char * pcmk__get_tmpdir(void)
int compare_version(const char *version1, const char *version2)
#define BEST_EFFORT_STATUS
#define XML_ATTR_GENERATION_ADMIN
char * calculate_operation_digest(xmlNode *input, const char *version)
Calculate and return digest of XML operation.
void save_xml_to_file(xmlNode *xml, const char *desc, const char *filename)
#define crm_log_xml_trace(xml, text)
char * crm_md5sum(const char *buffer)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__