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