This source file includes following definitions.
- crm_element_name
- crm_map_element_name
- numXpathResults
1
2
3
4
5
6
7
8
9
10 #ifndef CRM_COMMON_XML__H
11 # define CRM_COMMON_XML__H
12
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16
17
18
19
20
21
22
23 # include <stdio.h>
24 # include <sys/types.h>
25 # include <unistd.h>
26
27 # include <stdlib.h>
28 # include <errno.h>
29 # include <fcntl.h>
30
31 # include <libxml/tree.h>
32 # include <libxml/xpath.h>
33
34 # include <crm/crm.h>
35 # include <crm/common/nvpair.h>
36
37
38
39
40
41
42
43
44
45 # define CRM_BZ2_BLOCKS 4
46 # define CRM_BZ2_WORK 20
47 # define CRM_BZ2_THRESHOLD 128 * 1024
48
49 # define XML_PARANOIA_CHECKS 0
50
51 typedef const xmlChar *pcmkXmlStr;
52
53 gboolean add_message_xml(xmlNode * msg, const char *field, xmlNode * xml);
54 xmlNode *get_message_xml(xmlNode * msg, const char *field);
55
56 xmlDoc *getDocPtr(xmlNode * node);
57
58
59
60
61
62
63
64
65
66
67 void copy_in_properties(xmlNode * target, xmlNode * src);
68 void expand_plus_plus(xmlNode * target, const char *name, const char *value);
69 void fix_plus_plus_recursive(xmlNode * target);
70
71
72
73
74
75
76
77
78 xmlNode *create_xml_node(xmlNode * parent, const char *name);
79
80
81
82
83
84
85
86
87
88 xmlNode *pcmk_create_xml_text_node(xmlNode * parent, const char *name, const char *content);
89
90
91
92
93
94
95
96 xmlNode *pcmk_create_html_node(xmlNode * parent, const char *element_name, const char *id,
97 const char *class_name, const char *text);
98
99
100
101
102 void purge_diff_markers(xmlNode * a_node);
103
104
105
106
107
108 xmlNode *copy_xml(xmlNode * src_node);
109
110
111
112
113 xmlNode *add_node_copy(xmlNode * new_parent, xmlNode * xml_node);
114
115 int add_node_nocopy(xmlNode * parent, const char *name, xmlNode * child);
116
117
118
119
120
121
122 xmlNode *filename2xml(const char *filename);
123
124 xmlNode *stdin2xml(void);
125
126 xmlNode *string2xml(const char *input);
127
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);
130
131 char *dump_xml_formatted(xmlNode * msg);
132
133 char *dump_xml_formatted_with_text(xmlNode * msg);
134
135 char *dump_xml_unformatted(xmlNode * msg);
136
137
138
139
140 xmlNode *diff_xml_object(xmlNode * left, xmlNode * right, gboolean suppress);
141
142 xmlNode *subtract_xml_object(xmlNode * parent, xmlNode * left, xmlNode * right,
143 gboolean full, gboolean * changed, const char *marker);
144
145 gboolean can_prune_leaf(xmlNode * xml_node);
146
147
148
149
150 xmlNode *find_xml_node(xmlNode * cib, const char *node_path, gboolean must_find);
151
152 void xml_remove_prop(xmlNode * obj, const char *name);
153
154 gboolean replace_xml_child(xmlNode * parent, xmlNode * child, xmlNode * update,
155 gboolean delete_only);
156
157 gboolean update_xml_child(xmlNode * child, xmlNode * to_update);
158
159 int find_xml_children(xmlNode ** children, xmlNode * root,
160 const char *tag, const char *field, const char *value,
161 gboolean search_matches);
162
163 xmlNode *get_xpath_object(const char *xpath, xmlNode * xml_obj, int error_level);
164 xmlNode *get_xpath_object_relative(const char *xpath, xmlNode * xml_obj, int error_level);
165
166 static inline const char *
167 crm_element_name(const xmlNode *xml)
168 {
169 return xml? (const char *)(xml->name) : NULL;
170 }
171
172 static inline const char *
173 crm_map_element_name(const xmlNode *xml)
174 {
175 const char *name = crm_element_name(xml);
176
177 if (strcmp(name, "master") == 0) {
178 return "clone";
179 } else {
180 return name;
181 }
182 }
183
184 gboolean xml_has_children(const xmlNode * root);
185
186 char *calculate_on_disk_digest(xmlNode * local_cib);
187 char *calculate_operation_digest(xmlNode * local_cib, const char *version);
188 char *calculate_xml_versioned_digest(xmlNode * input, gboolean sort, gboolean do_filter,
189 const char *version);
190
191
192 gboolean validate_xml(xmlNode * xml_blob, const char *validation, gboolean to_logs);
193 gboolean validate_xml_verbose(xmlNode * xml_blob);
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232 int update_validation(xmlNode **xml_blob, int *best, int max,
233 gboolean transform, gboolean to_logs);
234
235 int get_schema_version(const char *name);
236 const char *get_schema_name(int version);
237 const char *xml_latest_schema(void);
238 gboolean cli_config_update(xmlNode ** xml, int *best_version, gboolean to_logs);
239
240 void crm_xml_init(void);
241 void crm_xml_cleanup(void);
242
243 void pcmk_free_xml_subtree(xmlNode *xml);
244 void free_xml(xmlNode * child);
245
246 xmlNode *first_named_child(const xmlNode *parent, const char *name);
247 xmlNode *crm_next_same_xml(const xmlNode *sibling);
248
249 xmlNode *sorted_xml(xmlNode * input, xmlNode * parent, gboolean recursive);
250 xmlXPathObjectPtr xpath_search(xmlNode * xml_top, const char *path);
251 void crm_foreach_xpath_result(xmlNode *xml, const char *xpath,
252 void (*helper)(xmlNode*, void*), void *user_data);
253 xmlNode *expand_idref(xmlNode * input, xmlNode * top);
254
255 void freeXpathObject(xmlXPathObjectPtr xpathObj);
256 xmlNode *getXpathResult(xmlXPathObjectPtr xpathObj, int index);
257 void dedupXpathResults(xmlXPathObjectPtr xpathObj);
258
259 static inline int numXpathResults(xmlXPathObjectPtr xpathObj)
260 {
261 if(xpathObj == NULL || xpathObj->nodesetval == NULL) {
262 return 0;
263 }
264 return xpathObj->nodesetval->nodeNr;
265 }
266
267 bool xml_tracking_changes(xmlNode * xml);
268 bool xml_document_dirty(xmlNode *xml);
269 void xml_track_changes(xmlNode * xml, const char *user, xmlNode *acl_source, bool enforce_acls);
270 void xml_calculate_changes(xmlNode *old_xml, xmlNode *new_xml);
271 void xml_calculate_significant_changes(xmlNode *old_xml, xmlNode *new_xml);
272 void xml_accept_changes(xmlNode * xml);
273 void xml_log_changes(uint8_t level, const char *function, xmlNode *xml);
274 void xml_log_patchset(uint8_t level, const char *function, xmlNode *xml);
275 bool xml_patch_versions(xmlNode *patchset, int add[3], int del[3]);
276
277 xmlNode *xml_create_patchset(
278 int format, xmlNode *source, xmlNode *target, bool *config, bool manage_version);
279 int xml_apply_patchset(xmlNode *xml, xmlNode *patchset, bool check_version);
280
281 void patchset_process_digest(xmlNode *patch, xmlNode *source, xmlNode *target, bool with_digest);
282
283 void save_xml_to_file(xmlNode * xml, const char *desc, const char *filename);
284 char *xml_get_path(xmlNode *xml);
285
286 char * crm_xml_escape(const char *text);
287 void crm_xml_sanitize_id(char *id);
288 void crm_xml_set_id(xmlNode *xml, const char *format, ...) G_GNUC_PRINTF(2, 3);
289
290
291
292
293 void crm_destroy_xml(gpointer data);
294
295 #if !defined(PCMK_ALLOW_DEPRECATED) || (PCMK_ALLOW_DEPRECATED == 1)
296 #include <crm/common/xml_compat.h>
297 #endif
298
299 #ifdef __cplusplus
300 }
301 #endif
302
303 #endif