This source file includes following definitions.
- pcmk__xe_id
- pcmk__xe_is
- pcmk__xe_set_content
1
2
3
4
5
6
7
8
9
10 #ifndef PCMK__CRM_COMMON_XML_ELEMENT_INTERNAL__H
11 #define PCMK__CRM_COMMON_XML_ELEMENT_INTERNAL__H
12
13
14
15
16
17
18 #include <stdbool.h>
19 #include <stdint.h>
20 #include <stdio.h>
21 #include <string.h>
22
23 #include <libxml/tree.h>
24
25 #include <crm/common/iso8601.h>
26 #include <crm/common/xml_element.h>
27 #include <crm/common/xml_names.h>
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 const char *pcmk__xe_add_last_written(xmlNode *xe);
34
35 xmlNode *pcmk__xe_first_child(const xmlNode *parent, const char *node_name,
36 const char *attr_n, const char *attr_v);
37
38 void pcmk__xe_remove_attr(xmlNode *element, const char *name);
39 bool pcmk__xe_remove_attr_cb(xmlNode *xml, void *user_data);
40 void pcmk__xe_remove_matching_attrs(xmlNode *element,
41 bool (*match)(xmlAttrPtr, void *),
42 void *user_data);
43 int pcmk__xe_delete_match(xmlNode *xml, xmlNode *search);
44 int pcmk__xe_replace_match(xmlNode *xml, xmlNode *replace);
45 int pcmk__xe_update_match(xmlNode *xml, xmlNode *update, uint32_t flags);
46
47
48
49
50
51
52
53
54
55 static inline const char *
56 pcmk__xe_id(const xmlNode *xml)
57 {
58 return crm_element_value(xml, PCMK_XA_ID);
59 }
60
61
62
63
64
65
66
67
68
69
70 static inline bool
71 pcmk__xe_is(const xmlNode *xml, const char *name)
72 {
73 return (xml != NULL) && (xml->name != NULL) && (name != NULL)
74 && (strcmp((const char *) xml->name, name) == 0);
75 }
76
77 xmlNode *pcmk__xe_create(xmlNode *parent, const char *name);
78 xmlNode *pcmk__xe_next(const xmlNode *node, const char *element_name);
79
80 void pcmk__xe_set_content(xmlNode *node, const char *format, ...)
81 G_GNUC_PRINTF(2, 3);
82
83 int pcmk__xe_get_score(const xmlNode *xml, const char *name, int *score,
84 int default_score);
85
86 int pcmk__xe_copy_attrs(xmlNode *target, const xmlNode *src, uint32_t flags);
87 void pcmk__xe_sort_attrs(xmlNode *xml);
88
89 void pcmk__xe_set_id(xmlNode *xml, const char *format, ...)
90 G_GNUC_PRINTF(2, 3);
91
92
93
94
95
96
97
98
99
100 void
101 pcmk__xe_set_propv(xmlNodePtr node, va_list pairs);
102
103
104
105
106
107
108
109
110
111
112
113 void
114 pcmk__xe_set_props(xmlNodePtr node, ...)
115 G_GNUC_NULL_TERMINATED;
116
117
118
119
120
121
122
123
124
125 static inline xmlAttr *
126 pcmk__xe_first_attr(const xmlNode *xe)
127 {
128 return (xe == NULL)? NULL : xe->properties;
129 }
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151 int
152 pcmk__xe_foreach_child(xmlNode *xml, const char *child_element_name,
153 int (*handler)(xmlNode *xml, void *userdata),
154 void *userdata);
155
156 int pcmk__xe_get_datetime(const xmlNode *xml, const char *attr, crm_time_t **t);
157 int pcmk__xe_get_flags(const xmlNode *xml, const char *name, uint32_t *dest,
158 uint32_t default_value);
159
160 void pcmk__xe_set_bool_attr(xmlNodePtr node, const char *name, bool value);
161 int pcmk__xe_get_bool_attr(const xmlNode *node, const char *name, bool *value);
162 bool pcmk__xe_attr_is_true(const xmlNode *node, const char *name);
163
164 #ifdef __cplusplus
165 }
166 #endif
167
168 #endif