10 #ifndef CRM_COMMON_XML__H 11 # define CRM_COMMON_XML__H 24 # include <sys/types.h> 31 # include <libxml/tree.h> 32 # include <libxml/xpath.h> 45 # define CRM_BZ2_BLOCKS 4 46 # define CRM_BZ2_WORK 20 47 # define CRM_BZ2_THRESHOLD 128 * 1024 49 # define XML_PARANOIA_CHECKS 0 53 gboolean
add_message_xml(xmlNode * msg,
const char *field, xmlNode * xml);
97 const char *class_name,
const char *text);
108 xmlNode *
copy_xml(xmlNode * src_node);
113 xmlNode *
add_node_copy(xmlNode * new_parent, xmlNode * xml_node);
128 int write_xml_fd(xmlNode * xml_node,
const char *filename,
int fd, gboolean compress);
129 int write_xml_file(xmlNode * xml_node,
const char *filename, gboolean compress);
140 xmlNode *
diff_xml_object(xmlNode * left, xmlNode * right, gboolean suppress);
143 gboolean full, gboolean * changed,
const char *marker);
150 xmlNode *
find_xml_node(xmlNode * cib,
const char *node_path, gboolean must_find);
155 gboolean delete_only);
160 const char *tag,
const char *field,
const char *value,
161 gboolean search_matches);
163 xmlNode *
get_xpath_object(
const char *xpath, xmlNode * xml_obj,
int error_level);
166 static inline const char *
167 crm_element_name(
const xmlNode *xml)
169 return xml? (
const char *)(xml->name) : NULL;
172 static inline const char *
173 crm_map_element_name(
const xmlNode *xml)
175 const char *
name = crm_element_name(xml);
177 if (strcmp(
name,
"master") == 0) {
192 gboolean
validate_xml(xmlNode * xml_blob,
const char *validation, gboolean to_logs);
233 gboolean transform, gboolean to_logs);
249 xmlNode *
sorted_xml(xmlNode * input, xmlNode * parent, gboolean recursive);
250 xmlXPathObjectPtr
xpath_search(xmlNode * xml_top,
const char *path);
252 void (*helper)(xmlNode*,
void*),
void *user_data);
259 static inline int numXpathResults(xmlXPathObjectPtr xpathObj)
261 if(xpathObj == NULL || xpathObj->nodesetval == NULL) {
264 return xpathObj->nodesetval->nodeNr;
269 void xml_track_changes(xmlNode * xml,
const char *user, xmlNode *acl_source,
bool enforce_acls);
273 void xml_log_changes(uint8_t level,
const char *
function, xmlNode *xml);
278 int format, xmlNode *
source, xmlNode *
target,
bool *config,
bool manage_version);
283 void save_xml_to_file(xmlNode * xml,
const char *desc,
const char *filename);
296 #ifndef PCMK__NO_COMPAT 301 xmlNode *
find_entity(xmlNode *parent,
const char *node_name,
const char *
id);
303 gboolean
apply_xml_diff(xmlNode *old_xml, xmlNode *diff, xmlNode **new_xml);
xmlNode * find_xml_node(xmlNode *cib, const char *node_path, gboolean must_find)
xmlNode * get_xpath_object_relative(const char *xpath, xmlNode *xml_obj, int error_level)
xmlNode * get_message_xml(xmlNode *msg, const char *field)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
void crm_xml_cleanup(void)
xmlNode * pcmk_create_html_node(xmlNode *parent, const char *element_name, const char *id, const char *class_name, const char *text)
void xml_track_changes(xmlNode *xml, const char *user, xmlNode *acl_source, bool enforce_acls)
int write_xml_file(xmlNode *xml_node, const char *filename, gboolean compress)
Write XML to a file.
int get_schema_version(const char *name)
void copy_in_properties(xmlNode *target, xmlNode *src)
void xml_accept_changes(xmlNode *xml)
xmlNode * filename2xml(const char *filename)
void dedupXpathResults(xmlXPathObjectPtr xpathObj)
void purge_diff_markers(xmlNode *a_node)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
xmlNode * string2xml(const char *input)
void crm_xml_sanitize_id(char *id)
Sanitize a string so it is usable as an XML ID.
gboolean validate_xml(xmlNode *xml_blob, const char *validation, gboolean to_logs)
xmlDoc * getDocPtr(xmlNode *node)
gboolean validate_xml_verbose(xmlNode *xml_blob)
void expand_plus_plus(xmlNode *target, const char *name, const char *value)
bool xml_tracking_changes(xmlNode *xml)
xmlNode * copy_xml(xmlNode *src_node)
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
xmlNode * stdin2xml(void)
void pcmk_free_xml_subtree(xmlNode *xml)
int xml_apply_patchset(xmlNode *xml, xmlNode *patchset, bool check_version)
gboolean update_xml_child(xmlNode *child, xmlNode *to_update)
xmlNode * pcmk_create_xml_text_node(xmlNode *parent, const char *name, const char *content)
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
gboolean apply_xml_diff(xmlNode *old_xml, xmlNode *diff, xmlNode **new_xml)
bool xml_document_dirty(xmlNode *xml)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
char * dump_xml_formatted(xmlNode *msg)
void void crm_destroy_xml(gpointer data)
xmlNode destructor which can be used in glib collections
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
void free_xml(xmlNode *child)
gboolean xml_has_children(const xmlNode *root)
char * calculate_on_disk_digest(xmlNode *local_cib)
Calculate and return digest of XML tree, suitable for storing on disk.
xmlNode * sorted_xml(xmlNode *input, xmlNode *parent, gboolean recursive)
const char * xml_latest_schema(void)
void patchset_process_digest(xmlNode *patch, xmlNode *source, xmlNode *target, bool with_digest)
const xmlChar * pcmkXmlStr
Functionality for manipulating name/value pairs.
int find_xml_children(xmlNode **children, xmlNode *root, const char *tag, const char *field, const char *value, gboolean search_matches)
bool xml_patch_versions(xmlNode *patchset, int add[3], int del[3])
void xml_log_changes(uint8_t level, const char *function, xmlNode *xml)
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
void xml_remove_prop(xmlNode *obj, const char *name)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
char * calculate_xml_versioned_digest(xmlNode *input, gboolean sort, gboolean do_filter, const char *version)
Calculate and return digest of XML tree.
gboolean can_prune_leaf(xmlNode *xml_node)
char * xml_get_path(xmlNode *xml)
char * dump_xml_unformatted(xmlNode *msg)
void save_xml_to_file(xmlNode *xml, const char *desc, const char *filename)
void crm_foreach_xpath_result(xmlNode *xml, const char *xpath, void(*helper)(xmlNode *, void *), void *user_data)
Run a supplied function for each result of an xpath search.
int update_validation(xmlNode **xml_blob, int *best, int max, gboolean transform, gboolean to_logs)
Update CIB XML to most recent schema version.
xmlNode * diff_xml_object(xmlNode *left, xmlNode *right, gboolean suppress)
int add_node_nocopy(xmlNode *parent, const char *name, xmlNode *child)
xmlNode * subtract_xml_object(xmlNode *parent, xmlNode *left, xmlNode *right, gboolean full, gboolean *changed, const char *marker)
void xml_log_patchset(uint8_t level, const char *function, xmlNode *xml)
void xml_calculate_significant_changes(xmlNode *old_xml, xmlNode *new_xml)
int write_xml_fd(xmlNode *xml_node, const char *filename, int fd, gboolean compress)
Write XML to a file descriptor.
char * crm_xml_escape(const char *text)
gboolean cli_config_update(xmlNode **xml, int *best_version, gboolean to_logs)
void fix_plus_plus_recursive(xmlNode *target)
void freeXpathObject(xmlXPathObjectPtr xpathObj)
xmlNode * xml_create_patchset(int format, xmlNode *source, xmlNode *target, bool *config, bool manage_version)
void xml_calculate_changes(xmlNode *old_xml, xmlNode *new_xml)
char * dump_xml_formatted_with_text(xmlNode *msg)
gboolean replace_xml_child(xmlNode *parent, xmlNode *child, xmlNode *update, gboolean delete_only)
const char * get_schema_name(int version)
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.