 |
pacemaker
2.0.1-9e909a5bdd
Scalable High-Availability cluster resource manager
|
Go to the documentation of this file.
8 #ifndef CRM_COMMON_XML__H
9 # define CRM_COMMON_XML__H
22 # include <sys/types.h>
29 # include <libxml/tree.h>
30 # include <libxml/xpath.h>
43 # define CRM_BZ2_BLOCKS 4
44 # define CRM_BZ2_WORK 20
45 # define CRM_BZ2_THRESHOLD 128 * 1024
47 # define XML_PARANOIA_CHECKS 0
49 gboolean
add_message_xml(xmlNode * msg,
const char *field, xmlNode * xml);
64 void expand_plus_plus(xmlNode * target,
const char *name,
const char *value);
85 xmlNode *
copy_xml(xmlNode * src_node);
90 xmlNode *
add_node_copy(xmlNode * new_parent, xmlNode * xml_node);
92 int add_node_nocopy(xmlNode * parent,
const char *name, xmlNode * child);
105 int write_xml_fd(xmlNode * xml_node,
const char *filename,
int fd, gboolean compress);
106 int write_xml_file(xmlNode * xml_node,
const char *filename, gboolean compress);
117 xmlNode *
diff_xml_object(xmlNode * left, xmlNode * right, gboolean suppress);
120 gboolean full, gboolean * changed,
const char *marker);
124 gboolean
apply_xml_diff(xmlNode *old_xml, xmlNode *diff, xmlNode **new_xml);
129 xmlNode *
find_xml_node(xmlNode * cib,
const char *node_path, gboolean must_find);
131 xmlNode *
find_entity(xmlNode * parent,
const char *node_name,
const char *
id);
136 gboolean delete_only);
141 const char *tag,
const char *field,
const char *value,
142 gboolean search_matches);
144 xmlNode *
get_xpath_object(
const char *xpath, xmlNode * xml_obj,
int error_level);
147 static inline const char *
148 crm_element_name(
const xmlNode *xml)
150 return xml? (
const char *)(xml->name) : NULL;
161 gboolean
validate_xml(xmlNode * xml_blob,
const char *validation, gboolean to_logs);
202 gboolean transform, gboolean to_logs);
212 static inline xmlNode *
213 __xml_first_child(
const xmlNode *parent)
215 xmlNode *child = parent? parent->children : NULL;
217 while (child && (child->type == XML_TEXT_NODE)) {
223 static inline xmlNode *
224 __xml_next(
const xmlNode *child)
226 xmlNode *next = child? child->next : NULL;
228 while (next && (next->type == XML_TEXT_NODE)) {
234 static inline xmlNode *
235 __xml_first_child_element(
const xmlNode *parent)
237 xmlNode *child = parent? parent->children : NULL;
239 while (child && (child->type != XML_ELEMENT_NODE)) {
245 static inline xmlNode *
246 __xml_next_element(
const xmlNode *child)
248 xmlNode *next = child? child->next : NULL;
250 while (next && (next->type != XML_ELEMENT_NODE)) {
261 xmlNode *
sorted_xml(xmlNode * input, xmlNode * parent, gboolean recursive);
262 xmlXPathObjectPtr
xpath_search(xmlNode * xml_top,
const char *path);
264 void (*helper)(xmlNode*,
void*),
void *user_data);
271 static inline int numXpathResults(xmlXPathObjectPtr xpathObj)
273 if(xpathObj == NULL || xpathObj->nodesetval == NULL) {
276 return xpathObj->nodesetval->nodeNr;
286 void xml_track_changes(xmlNode * xml,
const char *user, xmlNode *acl_source,
bool enforce_acls);
295 int format, xmlNode *
source, xmlNode *target,
bool *config,
bool manage_version);
300 void save_xml_to_file(xmlNode * xml,
const char *desc,
const char *filename);
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
gboolean replace_xml_child(xmlNode *parent, xmlNode *child, xmlNode *update, gboolean delete_only)
int find_xml_children(xmlNode **children, xmlNode *root, const char *tag, const char *field, const char *value, gboolean search_matches)
char * dump_xml_unformatted(xmlNode *msg)
void save_xml_to_file(xmlNode *xml, const char *desc, const char *filename)
void xml_log_changes(uint8_t level, const char *function, xmlNode *xml)
int xml_apply_patchset(xmlNode *xml, xmlNode *patchset, bool check_version)
int get_schema_version(const char *name)
int add_node_nocopy(xmlNode *parent, const char *name, xmlNode *child)
bool xml_patch_versions(xmlNode *patchset, int add[3], int del[3])
xmlNode * diff_xml_object(xmlNode *left, xmlNode *right, gboolean suppress)
void xml_calculate_significant_changes(xmlNode *old_xml, xmlNode *new_xml)
xmlDoc * getDocPtr(xmlNode *node)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
void expand_plus_plus(xmlNode *target, const char *name, const char *value)
xmlNode * get_xpath_object(const char *xpath, xmlNode *xml_obj, int error_level)
bool xml_document_dirty(xmlNode *xml)
xmlNode * copy_xml(xmlNode *src_node)
void patchset_process_digest(xmlNode *patch, xmlNode *source, xmlNode *target, bool with_digest)
xmlNode * filename2xml(const char *filename)
int write_xml_file(xmlNode *xml_node, const char *filename, gboolean compress)
Write XML to a file.
void free_xml(xmlNode *child)
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
gboolean update_xml_child(xmlNode *child, xmlNode *to_update)
gboolean xml_has_children(const xmlNode *root)
void xml_acl_disable(xmlNode *xml)
int write_xml_fd(xmlNode *xml_node, const char *filename, int fd, gboolean compress)
Write XML to a file descriptor.
gboolean add_message_xml(xmlNode *msg, const char *field, xmlNode *xml)
void xml_calculate_changes(xmlNode *old_xml, xmlNode *new_xml)
xmlNode * sorted_xml(xmlNode *input, xmlNode *parent, gboolean recursive)
char * crm_xml_escape(const char *text)
xmlNode * first_named_child(const xmlNode *parent, const char *name)
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
void purge_diff_markers(xmlNode *a_node)
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
int update_validation(xmlNode **xml_blob, int *best, int max, gboolean transform, gboolean to_logs)
Update CIB XML to most recent schema version.
xmlNode * stdin2xml(void)
xmlNode * xml_create_patchset(int format, xmlNode *source, xmlNode *target, bool *config, bool manage_version)
xmlNode * string2xml(const char *input)
xmlNode * expand_idref(xmlNode *input, xmlNode *top)
char * calculate_xml_versioned_digest(xmlNode *input, gboolean sort, gboolean do_filter, const char *version)
Calculate and return digest of XML tree.
void dedupXpathResults(xmlXPathObjectPtr xpathObj)
xmlNode * get_message_xml(xmlNode *msg, const char *field)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
bool xml_acl_enabled(xmlNode *xml)
void xml_track_changes(xmlNode *xml, const char *user, xmlNode *acl_source, bool enforce_acls)
xmlNode * subtract_xml_object(xmlNode *parent, xmlNode *left, xmlNode *right, gboolean full, gboolean *changed, const char *marker)
gboolean validate_xml(xmlNode *xml_blob, const char *validation, gboolean to_logs)
void xml_accept_changes(xmlNode *xml)
char * dump_xml_formatted_with_text(xmlNode *msg)
bool xml_acl_denied(xmlNode *xml)
void fix_plus_plus_recursive(xmlNode *target)
void xml_remove_prop(xmlNode *obj, const char *name)
char * xml_get_path(xmlNode *xml)
bool xml_acl_filtered_copy(const char *user, xmlNode *acl_source, xmlNode *xml, xmlNode **result)
Functionality for manipulating name/value pairs.
xmlNode * get_xpath_object_relative(const char *xpath, xmlNode *xml_obj, int error_level)
void crm_xml_cleanup(void)
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)
const char * xml_latest_schema(void)
xmlNode * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.
gboolean validate_xml_verbose(xmlNode *xml_blob)
void copy_in_properties(xmlNode *target, xmlNode *src)
void xml_log_patchset(uint8_t level, const char *function, xmlNode *xml)
gboolean can_prune_leaf(xmlNode *xml_node)
gboolean cli_config_update(xmlNode **xml, int *best_version, gboolean to_logs)
char * dump_xml_formatted(xmlNode *msg)
const char * get_schema_name(int version)
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
bool xml_tracking_changes(xmlNode *xml)
void void crm_destroy_xml(gpointer data)
xmlNode destructor which can be used in glib collections
void freeXpathObject(xmlXPathObjectPtr xpathObj)
char * calculate_on_disk_digest(xmlNode *local_cib)
Calculate and return digest of XML tree, suitable for storing on disk.
void crm_xml_sanitize_id(char *id)
Sanitize a string so it is usable as an XML ID.
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.