This source file includes following definitions.
- pcmk__xml_first_child
- pcmk__xml_next
- pcmk__xe_first_child
- pcmk__xe_next
- pcmk__xe_set_props
1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__XML_INTERNAL__H
11 # define PCMK__XML_INTERNAL__H
12
13
14
15
16
17 # include <stdlib.h>
18 # include <stdio.h>
19 # include <string.h>
20
21 # include <crm/crm.h>
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 #define PCMK__XML_LOG_BASE(priority, dechunk, postemit, prefix, fmt, ap) \
68 do { \
69 if (!(dechunk) && (prefix) == NULL) { \
70 qb_log_from_external_source_va(__func__, __FILE__, (fmt), \
71 (priority), __LINE__, 0, (ap)); \
72 (void) (postemit); \
73 } else { \
74 int CXLB_len = 0; \
75 char *CXLB_buf = NULL; \
76 static int CXLB_buffer_len = 0; \
77 static char *CXLB_buffer = NULL; \
78 static uint8_t CXLB_priority = 0; \
79 \
80 CXLB_len = vasprintf(&CXLB_buf, (fmt), (ap)); \
81 \
82 if (CXLB_len <= 0 || CXLB_buf[CXLB_len - 1] == '\n' || !(dechunk)) { \
83 if (CXLB_len < 0) { \
84 CXLB_buf = (char *) "LOG CORRUPTION HAZARD"; \
85 CXLB_priority = QB_MIN(CXLB_priority, LOG_ERR); \
86 } else if (CXLB_len > 0 \
87 && CXLB_buf[CXLB_len - 1] == '\n') { \
88 CXLB_buf[CXLB_len - 1] = '\0'; \
89 } \
90 if (CXLB_buffer) { \
91 qb_log_from_external_source(__func__, __FILE__, "%s%s%s", \
92 CXLB_priority, __LINE__, 0, \
93 (prefix) != NULL ? (prefix) : "", \
94 CXLB_buffer, CXLB_buf); \
95 free(CXLB_buffer); \
96 } else { \
97 qb_log_from_external_source(__func__, __FILE__, "%s%s", \
98 (priority), __LINE__, 0, \
99 (prefix) != NULL ? (prefix) : "", \
100 CXLB_buf); \
101 } \
102 if (CXLB_len < 0) { \
103 CXLB_buf = NULL; \
104 } \
105 CXLB_buffer = NULL; \
106 CXLB_buffer_len = 0; \
107 (void) (postemit); \
108 \
109 } else if (CXLB_buffer == NULL) { \
110 CXLB_buffer_len = CXLB_len; \
111 CXLB_buffer = CXLB_buf; \
112 CXLB_buf = NULL; \
113 CXLB_priority = (priority); \
114 \
115 } else { \
116 CXLB_buffer = realloc(CXLB_buffer, 1 + CXLB_buffer_len + CXLB_len); \
117 memcpy(CXLB_buffer + CXLB_buffer_len, CXLB_buf, CXLB_len); \
118 CXLB_buffer_len += CXLB_len; \
119 CXLB_buffer[CXLB_buffer_len] = '\0'; \
120 CXLB_priority = QB_MIN(CXLB_priority, (priority)); \
121 } \
122 free(CXLB_buf); \
123 } \
124 } while (0)
125
126
127
128
129 #define PCMK__XP_MEMBER_NODE_CONFIG \
130 "//" XML_TAG_CIB "/" XML_CIB_TAG_CONFIGURATION "/" XML_CIB_TAG_NODES \
131 "/" XML_CIB_TAG_NODE "[not(@type) or @type='member']"
132
133
134 #define PCMK__XP_GUEST_NODE_CONFIG \
135 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \
136 "//" XML_TAG_META_SETS "//" XML_CIB_TAG_NVPAIR \
137 "[@name='" XML_RSC_ATTR_REMOTE_NODE "']"
138
139
140 #define PCMK__XP_REMOTE_NODE_CONFIG \
141 "//" XML_TAG_CIB "//" XML_CIB_TAG_CONFIGURATION "//" XML_CIB_TAG_RESOURCE \
142 "[@type='remote'][@provider='pacemaker']"
143
144
145 #define PCMK__XP_REMOTE_NODE_STATUS \
146 "//" XML_TAG_CIB "//" XML_CIB_TAG_STATUS "//" XML_CIB_TAG_STATE \
147 "[@" XML_NODE_IS_REMOTE "='true']"
148
149 enum pcmk__xml_artefact_ns {
150 pcmk__xml_artefact_ns_legacy_rng = 1,
151 pcmk__xml_artefact_ns_legacy_xslt,
152 pcmk__xml_artefact_ns_base_rng,
153 pcmk__xml_artefact_ns_base_xslt,
154 };
155
156 void pcmk__strip_xml_text(xmlNode *xml);
157 const char *pcmk__xe_add_last_written(xmlNode *xe);
158
159 xmlNode *pcmk__xe_match(xmlNode *parent, const char *node_name,
160 const char *attr_n, const char *attr_v);
161
162 void pcmk__xe_remove_matching_attrs(xmlNode *element,
163 bool (*match)(xmlAttrPtr, void *),
164 void *user_data);
165
166
167
168
169
170
171
172
173
174 char *
175 pcmk__xml_artefact_root(enum pcmk__xml_artefact_ns ns);
176
177
178
179
180
181
182
183
184
185
186 char *pcmk__xml_artefact_path(enum pcmk__xml_artefact_ns ns,
187 const char *filespec);
188
189
190
191
192
193
194
195
196
197 static inline xmlNode *
198 pcmk__xml_first_child(const xmlNode *parent)
199 {
200 xmlNode *child = (parent? parent->children : NULL);
201
202 while (child && (child->type == XML_TEXT_NODE)) {
203 child = child->next;
204 }
205 return child;
206 }
207
208
209
210
211
212
213
214
215
216 static inline xmlNode *
217 pcmk__xml_next(const xmlNode *child)
218 {
219 xmlNode *next = (child? child->next : NULL);
220
221 while (next && (next->type == XML_TEXT_NODE)) {
222 next = next->next;
223 }
224 return next;
225 }
226
227
228
229
230
231
232
233
234
235 static inline xmlNode *
236 pcmk__xe_first_child(const xmlNode *parent)
237 {
238 xmlNode *child = (parent? parent->children : NULL);
239
240 while (child && (child->type != XML_ELEMENT_NODE)) {
241 child = child->next;
242 }
243 return child;
244 }
245
246
247
248
249
250
251
252
253
254 static inline xmlNode *
255 pcmk__xe_next(const xmlNode *child)
256 {
257 xmlNode *next = child? child->next : NULL;
258
259 while (next && (next->type != XML_ELEMENT_NODE)) {
260 next = next->next;
261 }
262 return next;
263 }
264
265
266
267
268
269
270 void
271 pcmk__xe_set_propv(xmlNodePtr node, va_list pairs);
272
273
274
275
276
277
278
279
280
281
282
283 void
284 pcmk__xe_set_props(xmlNodePtr node, ...)
285 G_GNUC_NULL_TERMINATED;
286
287
288
289
290
291
292
293
294
295 static inline xmlAttr *
296 pcmk__xe_first_attr(const xmlNode *xe)
297 {
298 return (xe == NULL)? NULL : xe->properties;
299 }
300
301
302
303
304
305
306
307
308
309
310 char *
311 pcmk__xpath_node_id(const char *xpath, const char *node);
312
313
314
315 enum xml_private_flags {
316 pcmk__xf_none = 0x0000,
317 pcmk__xf_dirty = 0x0001,
318 pcmk__xf_deleted = 0x0002,
319 pcmk__xf_created = 0x0004,
320 pcmk__xf_modified = 0x0008,
321
322 pcmk__xf_tracking = 0x0010,
323 pcmk__xf_processed = 0x0020,
324 pcmk__xf_skip = 0x0040,
325 pcmk__xf_moved = 0x0080,
326
327 pcmk__xf_acl_enabled = 0x0100,
328 pcmk__xf_acl_read = 0x0200,
329 pcmk__xf_acl_write = 0x0400,
330 pcmk__xf_acl_deny = 0x0800,
331
332 pcmk__xf_acl_create = 0x1000,
333 pcmk__xf_acl_denied = 0x2000,
334 pcmk__xf_lazy = 0x4000,
335 };
336
337 void pcmk__set_xml_doc_flag(xmlNode *xml, enum xml_private_flags flag);
338
339 #endif