pacemaker  2.1.7-0f7f88312f
Scalable High-Availability cluster resource manager
xml_compat.h
Go to the documentation of this file.
1 /*
2  * Copyright 2004-2023 the Pacemaker project contributors
3  *
4  * The version control history for this file may have further details.
5  *
6  * This source code is licensed under the GNU Lesser General Public License
7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
8  */
9 
10 #ifndef PCMK__CRM_COMMON_XML_COMPAT__H
11 # define PCMK__CRM_COMMON_XML_COMPAT__H
12 
13 #include <glib.h> // gboolean
14 #include <libxml/tree.h> // xmlNode
15 #include <crm/common/xml.h> // crm_xml_add()
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
30 #define XML_PARANOIA_CHECKS 0
32 
34 xmlDoc *getDocPtr(xmlNode *node);
35 
37 int add_node_nocopy(xmlNode * parent, const char *name, xmlNode * child);
38 
40 xmlNode *find_entity(xmlNode *parent, const char *node_name, const char *id);
41 
43 char *xml_get_path(const xmlNode *xml);
44 
46 void xml_log_changes(uint8_t level, const char *function, const xmlNode *xml);
47 
49 void xml_log_patchset(uint8_t level, const char *function, const xmlNode *xml);
50 
52 gboolean apply_xml_diff(xmlNode *old_xml, xmlNode *diff, xmlNode **new_xml);
53 
55 void crm_destroy_xml(gpointer data);
56 
58 gboolean xml_has_children(const xmlNode *root);
59 
61 static inline const char *
62 crm_xml_add_boolean(xmlNode *node, const char *name, gboolean value)
63 {
64  return crm_xml_add(node, name, (value? "true" : "false"));
65 }
66 
68 static inline const char *
69 crm_element_name(const xmlNode *xml)
70 {
71  return (xml == NULL)? NULL : (const char *) xml->name;
72 }
73 
74 #ifdef __cplusplus
75 }
76 #endif
77 
78 #endif // PCMK__CRM_COMMON_XML_COMPAT__H
void xml_log_changes(uint8_t level, const char *function, const xmlNode *xml)
Definition: xml_display.c:523
char data[0]
Definition: cpg.c:55
const char * name
Definition: cib.c:26
gboolean xml_has_children(const xmlNode *root)
Definition: xml.c:2727
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
Definition: nvpair.c:302
void crm_destroy_xml(gpointer data)
Definition: xml.c:2698
xmlDoc * getDocPtr(xmlNode *node)
Definition: xml.c:2704
Wrappers for and extensions to libxml2.
gboolean apply_xml_diff(xmlNode *old_xml, xmlNode *diff, xmlNode **new_xml)
Definition: patchset.c:1416
int add_node_nocopy(xmlNode *parent, const char *name, xmlNode *child)
Definition: xml.c:2719
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
Definition: xml.c:2691
void xml_log_patchset(uint8_t level, const char *function, const xmlNode *xml)
char * xml_get_path(const xmlNode *xml)
Get an XPath string that matches an XML element as closely as possible.
Definition: xpath.c:358
const char * parent
Definition: cib.c:27