Sun, 04 Sep 2011 18:52:18 +0000
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Basically we were treating node->xmlns as the default namespace, but
that isn't the case with prefexed elements. In our serialization,
I believe we were adding an extraneous xmlns='' to a prefixed element,
which changes the (default) namespace for its children. (It's been
a bit too long with this in my tree, so I've forgotten the exact details)
| 7131 | 1 | /** |
| 2 | * @file xmlnode.h XML DOM functions | |
| 10327 | 3 | * @ingroup core |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19897
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19897
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19897
diff
changeset
|
6 | /* purple |
| 7131 | 7 | * |
| 15884 | 8 | * Purple is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 7131 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18131
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7131 | 25 | */ |
| 15884 | 26 | #ifndef _PURPLE_XMLNODE_H_ |
| 27 | #define _PURPLE_XMLNODE_H_ | |
| 7131 | 28 | |
|
23659
8251d0f67df5
restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23643
diff
changeset
|
29 | #include <glib.h> |
|
8251d0f67df5
restructured much of the loader and themes for the buddy list, along with a basic trial of group background
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
23643
diff
changeset
|
30 | |
|
14988
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
31 | #ifdef __cplusplus |
|
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
32 | extern "C" { |
|
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
33 | #endif |
|
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
34 | |
| 10327 | 35 | /** |
| 36 | * The valid types for an xmlnode | |
| 37 | */ | |
|
32206
a2c62b07ae5a
Please correct me if I'm wrong, but I don't think we gain anything
Mark Doliner <markdoliner@pidgin.im>
parents:
30510
diff
changeset
|
38 | typedef enum |
| 7131 | 39 | { |
| 10327 | 40 | XMLNODE_TYPE_TAG, /**< Just a tag */ |
|
14162
3546040af8e2
[gaim-migrate @ 16730]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
41 | XMLNODE_TYPE_ATTRIB, /**< Has attributes */ |
| 10327 | 42 | XMLNODE_TYPE_DATA /**< Has data */ |
| 8135 | 43 | } XMLNodeType; |
| 7131 | 44 | |
| 10327 | 45 | /** |
| 46 | * An xmlnode. | |
| 47 | */ | |
| 14386 | 48 | typedef struct _xmlnode xmlnode; |
| 49 | struct _xmlnode | |
| 7131 | 50 | { |
|
14162
3546040af8e2
[gaim-migrate @ 16730]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
51 | char *name; /**< The name of the node. */ |
|
15238
e52522b871ee
[gaim-migrate @ 17963]
Mark Doliner <markdoliner@pidgin.im>
parents:
14988
diff
changeset
|
52 | char *xmlns; /**< The namespace of the node */ |
|
14162
3546040af8e2
[gaim-migrate @ 16730]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
53 | XMLNodeType type; /**< The type of the node. */ |
|
3546040af8e2
[gaim-migrate @ 16730]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
54 | char *data; /**< The data for the node. */ |
|
3546040af8e2
[gaim-migrate @ 16730]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
55 | size_t data_sz; /**< The size of the data. */ |
|
28092
96050b11724c
We can use the typedef here, right?
Mark Doliner <markdoliner@pidgin.im>
parents:
27345
diff
changeset
|
56 | xmlnode *parent; /**< The parent node or @c NULL.*/ |
|
96050b11724c
We can use the typedef here, right?
Mark Doliner <markdoliner@pidgin.im>
parents:
27345
diff
changeset
|
57 | xmlnode *child; /**< The child node or @c NULL.*/ |
|
96050b11724c
We can use the typedef here, right?
Mark Doliner <markdoliner@pidgin.im>
parents:
27345
diff
changeset
|
58 | xmlnode *lastchild; /**< The last child node or @c NULL.*/ |
|
96050b11724c
We can use the typedef here, right?
Mark Doliner <markdoliner@pidgin.im>
parents:
27345
diff
changeset
|
59 | xmlnode *next; /**< The next node or @c NULL. */ |
|
21454
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
60 | char *prefix; /**< The namespace prefix if any. */ |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
61 | GHashTable *namespace_map; /**< The namespace map. */ |
| 14386 | 62 | }; |
| 7131 | 63 | |
| 10327 | 64 | /** |
| 65 | * Creates a new xmlnode. | |
| 66 | * | |
| 67 | * @param name The name of the node. | |
| 68 | * | |
| 69 | * @return The new node. | |
| 70 | */ | |
| 7131 | 71 | xmlnode *xmlnode_new(const char *name); |
| 10327 | 72 | |
| 73 | /** | |
| 74 | * Creates a new xmlnode child. | |
| 75 | * | |
| 76 | * @param parent The parent node. | |
| 77 | * @param name The name of the child node. | |
| 78 | * | |
| 79 | * @return The new child node. | |
| 80 | */ | |
| 7131 | 81 | xmlnode *xmlnode_new_child(xmlnode *parent, const char *name); |
| 10327 | 82 | |
| 83 | /** | |
| 84 | * Inserts a node into a node as a child. | |
| 85 | * | |
| 86 | * @param parent The parent node to insert child into. | |
| 87 | * @param child The child node to insert into parent. | |
| 88 | */ | |
| 7131 | 89 | void xmlnode_insert_child(xmlnode *parent, xmlnode *child); |
| 10327 | 90 | |
| 91 | /** | |
| 92 | * Gets a child node named name. | |
| 93 | * | |
| 94 | * @param parent The parent node. | |
| 95 | * @param name The child's name. | |
| 96 | * | |
| 97 | * @return The child or NULL. | |
| 98 | */ | |
|
10736
fb529f29c25c
[gaim-migrate @ 12338]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
99 | xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name); |
| 10327 | 100 | |
| 101 | /** | |
| 102 | * Gets a child node named name in a namespace. | |
| 103 | * | |
| 104 | * @param parent The parent node. | |
| 105 | * @param name The child's name. | |
| 106 | * @param xmlns The namespace. | |
| 107 | * | |
| 108 | * @return The child or NULL. | |
| 109 | */ | |
|
10736
fb529f29c25c
[gaim-migrate @ 12338]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
110 | xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns); |
| 10327 | 111 | |
| 112 | /** | |
| 113 | * Gets the next node with the same name as node. | |
| 114 | * | |
| 115 | * @param node The node of a twin to find. | |
| 116 | * | |
| 117 | * @return The twin of node or NULL. | |
| 118 | */ | |
| 8135 | 119 | xmlnode *xmlnode_get_next_twin(xmlnode *node); |
| 10327 | 120 | |
| 121 | /** | |
| 122 | * Inserts data into a node. | |
| 123 | * | |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
124 | * @param node The node to insert data into. |
| 10327 | 125 | * @param data The data to insert. |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
126 | * @param size The size of the data to insert. If data is |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
127 | * null-terminated you can pass in -1. |
| 10327 | 128 | */ |
| 10848 | 129 | void xmlnode_insert_data(xmlnode *node, const char *data, gssize size); |
| 10327 | 130 | |
| 131 | /** | |
|
18131
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
132 | * Gets (escaped) data from a node. |
| 10327 | 133 | * |
| 134 | * @param node The node to get data from. | |
| 135 | * | |
|
20546
35d778ab0450
Correctly process an additional <Service> with type Profile and name 'Messenger Roaming Identity' sent with the contact list using a recently registered WLM account, that was causing the initial ADL command to be sent malformed, and our presence status not being forwarded to our buddies
Carlos Silva <typ0@pidgin.im>
parents:
18131
diff
changeset
|
136 | * @return The data from the node or NULL. This data is in raw escaped format. |
|
18131
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
137 | * You must g_free this string when finished using it. |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
138 | */ |
|
27345
37d67bee50c2
These parameters aren't modified
Mark Doliner <markdoliner@pidgin.im>
parents:
26831
diff
changeset
|
139 | char *xmlnode_get_data(const xmlnode *node); |
|
18131
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
140 | |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
141 | /** |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
142 | * Gets unescaped data from a node. |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
143 | * |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
144 | * @param node The node to get data from. |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
145 | * |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
146 | * @return The data from the node, in unescaped form. You must g_free |
|
14162
3546040af8e2
[gaim-migrate @ 16730]
Daniel Atallah <datallah@pidgin.im>
parents:
13808
diff
changeset
|
147 | * this string when finished using it. |
| 10327 | 148 | */ |
|
27345
37d67bee50c2
These parameters aren't modified
Mark Doliner <markdoliner@pidgin.im>
parents:
26831
diff
changeset
|
149 | char *xmlnode_get_data_unescaped(const xmlnode *node); |
| 10327 | 150 | |
| 151 | /** | |
| 152 | * Sets an attribute for a node. | |
| 153 | * | |
| 154 | * @param node The node to set an attribute for. | |
| 155 | * @param attr The name of the attribute. | |
| 156 | * @param value The value of the attribute. | |
| 157 | */ | |
| 7131 | 158 | void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value); |
| 10327 | 159 | |
|
26393
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
160 | /** |
|
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
161 | * Sets a namespaced attribute for a node |
|
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
162 | * |
|
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
163 | * @param node The node to set an attribute for. |
|
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
164 | * @param attr The name of the attribute to set |
|
32313
3f58eb41a9a8
Remove deprecated xmlnode functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32206
diff
changeset
|
165 | * @param xmlns The namespace of the attribute to set |
|
3f58eb41a9a8
Remove deprecated xmlnode functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32206
diff
changeset
|
166 | * @param prefix The prefix of the attribute to set |
|
26393
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
167 | * @param value The value of the attribute |
|
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
168 | */ |
|
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
169 | void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, |
|
7420fd99903a
Add xmlnode_set_attrib_full that enables you to set an attribute with both
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25911
diff
changeset
|
170 | const char *prefix, const char *value); |
| 15265 | 171 | |
| 172 | /** | |
| 10327 | 173 | * Gets an attribute from a node. |
| 174 | * | |
| 175 | * @param node The node to get an attribute from. | |
| 176 | * @param attr The attribute to get. | |
| 177 | * | |
| 178 | * @return The value of the attribute. | |
| 179 | */ | |
|
30510
570fa2a907ea
const-ify the xmlnode* parameter to xmlnode_get_attrib(_with_namespace)
Paul Aurich <darkrain42@pidgin.im>
parents:
28092
diff
changeset
|
180 | const char *xmlnode_get_attrib(const xmlnode *node, const char *attr); |
| 10327 | 181 | |
| 182 | /** | |
| 15265 | 183 | * Gets a namespaced attribute from a node |
| 184 | * | |
| 185 | * @param node The node to get an attribute from. | |
| 186 | * @param attr The attribute to get | |
| 187 | * @param xmlns The namespace of the attribute to get | |
| 188 | * | |
| 189 | * @return The value of the attribute/ | |
| 190 | */ | |
|
30510
570fa2a907ea
const-ify the xmlnode* parameter to xmlnode_get_attrib(_with_namespace)
Paul Aurich <darkrain42@pidgin.im>
parents:
28092
diff
changeset
|
191 | const char *xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns); |
| 15265 | 192 | |
| 193 | /** | |
| 10327 | 194 | * Removes an attribute from a node. |
| 195 | * | |
| 196 | * @param node The node to remove an attribute from. | |
| 197 | * @param attr The attribute to remove. | |
| 198 | */ | |
| 7131 | 199 | void xmlnode_remove_attrib(xmlnode *node, const char *attr); |
| 10327 | 200 | |
| 201 | /** | |
| 15265 | 202 | * Removes a namespaced attribute from a node |
| 203 | * | |
| 204 | * @param node The node to remove an attribute from | |
| 205 | * @param attr The attribute to remove | |
| 206 | * @param xmlns The namespace of the attribute to remove | |
| 207 | */ | |
| 208 | void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns); | |
| 209 | ||
| 210 | /** | |
| 13808 | 211 | * Sets the namespace of a node |
| 212 | * | |
| 213 | * @param node The node to qualify | |
| 214 | * @param xmlns The namespace of the node | |
| 215 | */ | |
| 216 | void xmlnode_set_namespace(xmlnode *node, const char *xmlns); | |
| 217 | ||
| 218 | /** | |
| 219 | * Returns the namespace of a node | |
| 220 | * | |
| 221 | * @param node The node to get the namepsace from | |
| 222 | * @return The namespace of this node | |
| 223 | */ | |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
224 | const char *xmlnode_get_namespace(const xmlnode *node); |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
225 | |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
226 | /** |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
227 | * Returns the current default namespace. The default |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
228 | * namespace is the current namespace which applies to child |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
229 | * elements which are unprefixed and which do not contain their |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
230 | * own namespace. |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
231 | * |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
232 | * For example, given: |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
233 | * <iq type='get' xmlns='jabber:client' xmlns:ns1='http://example.org/ns1'> |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
234 | * <ns1:element><child1/></ns1:element> |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
235 | * </iq> |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
236 | * |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
237 | * The default namespace of all nodes (including 'child1') is "jabber:client", |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
238 | * though the namespace for 'element' is "http://example.org/ns1". |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
239 | * |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
240 | * @param node The node for which to return the default namespace |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
241 | * @return The default namespace of this node |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
242 | */ |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
243 | const char *xmlnode_get_default_namespace(const xmlnode *node); |
| 13808 | 244 | |
| 245 | /** | |
|
21454
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
246 | * Sets the prefix of a node |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
247 | * |
|
21552
6920e51d8f27
Get rid of a few silly doxygen warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
21454
diff
changeset
|
248 | * @param node The node to qualify |
|
6920e51d8f27
Get rid of a few silly doxygen warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
21454
diff
changeset
|
249 | * @param prefix The prefix of the node |
|
21454
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
250 | */ |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
251 | void xmlnode_set_prefix(xmlnode *node, const char *prefix); |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
252 | |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
253 | /** |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
254 | * Returns the prefix of a node |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
255 | * |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
256 | * @param node The node to get the prefix from |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
257 | * @return The prefix of this node |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
258 | */ |
|
25559
b8df546bf422
There's no reason for these to not be const is there? This doesn't
Mark Doliner <markdoliner@pidgin.im>
parents:
21552
diff
changeset
|
259 | const char *xmlnode_get_prefix(const xmlnode *node); |
|
21454
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
260 | |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
261 | /** |
|
23750
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
262 | * Gets the parent node. |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
263 | * |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
264 | * @param child The child node. |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
265 | * |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
266 | * @return The parent or NULL. |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
267 | */ |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
268 | xmlnode *xmlnode_get_parent(const xmlnode *child); |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
269 | |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
270 | /** |
| 10327 | 271 | * Returns the node in a string of xml. |
| 272 | * | |
| 273 | * @param node The starting node to output. | |
| 274 | * @param len Address for the size of the string. | |
| 275 | * | |
|
12887
4235bbee17b1
[gaim-migrate @ 15240]
Daniel Atallah <datallah@pidgin.im>
parents:
12233
diff
changeset
|
276 | * @return The node represented as a string. You must |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
277 | * g_free this string when finished using it. |
| 10327 | 278 | */ |
|
25559
b8df546bf422
There's no reason for these to not be const is there? This doesn't
Mark Doliner <markdoliner@pidgin.im>
parents:
21552
diff
changeset
|
279 | char *xmlnode_to_str(const xmlnode *node, int *len); |
| 10327 | 280 | |
| 281 | /** | |
| 282 | * Returns the node in a string of human readable xml. | |
| 283 | * | |
| 284 | * @param node The starting node to output. | |
| 285 | * @param len Address for the size of the string. | |
| 286 | * | |
| 287 | * @return The node as human readable string including | |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
288 | * tab and new line characters. You must |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
289 | * g_free this string when finished using it. |
| 10327 | 290 | */ |
|
25559
b8df546bf422
There's no reason for these to not be const is there? This doesn't
Mark Doliner <markdoliner@pidgin.im>
parents:
21552
diff
changeset
|
291 | char *xmlnode_to_formatted_str(const xmlnode *node, int *len); |
| 10327 | 292 | |
| 293 | /** | |
|
10337
778231f38df6
[gaim-migrate @ 11545]
Mark Doliner <markdoliner@pidgin.im>
parents:
10327
diff
changeset
|
294 | * Creates a node from a string of XML. Calling this on the |
|
778231f38df6
[gaim-migrate @ 11545]
Mark Doliner <markdoliner@pidgin.im>
parents:
10327
diff
changeset
|
295 | * root node of an XML document will parse the entire document |
|
778231f38df6
[gaim-migrate @ 11545]
Mark Doliner <markdoliner@pidgin.im>
parents:
10327
diff
changeset
|
296 | * into a tree of nodes, and return the xmlnode of the root. |
| 10327 | 297 | * |
| 298 | * @param str The string of xml. | |
|
11707
a2c8dd795e3b
[gaim-migrate @ 13998]
Richard Laager <rlaager@pidgin.im>
parents:
10848
diff
changeset
|
299 | * @param size The size of the string, or -1 if @a str is |
|
a2c8dd795e3b
[gaim-migrate @ 13998]
Richard Laager <rlaager@pidgin.im>
parents:
10848
diff
changeset
|
300 | * NUL-terminated. |
| 10327 | 301 | * |
| 302 | * @return The new node. | |
| 303 | */ | |
| 10848 | 304 | xmlnode *xmlnode_from_str(const char *str, gssize size); |
| 10327 | 305 | |
| 306 | /** | |
| 307 | * Creates a new node from the source node. | |
| 308 | * | |
| 309 | * @param src The node to copy. | |
| 310 | * | |
| 311 | * @return A new copy of the src node. | |
| 312 | */ | |
|
15609
e432251bd57e
sf patch #1647731, from Markus Elfring
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
313 | xmlnode *xmlnode_copy(const xmlnode *src); |
| 7131 | 314 | |
| 10327 | 315 | /** |
|
17775
1df27cab581c
implemented user mood, still missing the front end interface
Andreas Monitzer <am@adiumx.com>
parents:
15884
diff
changeset
|
316 | * Frees a node and all of its children. |
| 10327 | 317 | * |
| 318 | * @param node The node to free. | |
| 319 | */ | |
| 7131 | 320 | void xmlnode_free(xmlnode *node); |
| 321 | ||
|
23643
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
322 | /** |
|
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
323 | * Creates a node from a XML File. Calling this on the |
|
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
324 | * root node of an XML document will parse the entire document |
|
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
325 | * into a tree of nodes, and return the xmlnode of the root. |
|
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
326 | * |
|
26384
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
327 | * @param dir The directory where the file is located |
|
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
328 | * @param filename The filename |
|
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
329 | * @param description A description of the file being parsed. Displayed to |
|
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
330 | * the user if the file cannot be read. |
|
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
331 | * @param process The subsystem that is calling xmlnode_from_file. Used as |
|
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
332 | * the category for debugging. |
|
23643
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
333 | * |
|
26384
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
334 | * @return The new node or NULL if an error occurred. |
|
23643
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
335 | */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25885
diff
changeset
|
336 | xmlnode *xmlnode_from_file(const char *dir, const char *filename, |
|
23643
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
337 | const char *description, const char *process); |
|
4a68ddefa857
added a more generic function to read xml files (and made the util version into a wrapper) so it can be used by the
Justin Rodriguez <ffdragon@soc.pidgin.im>
parents:
21552
diff
changeset
|
338 | |
|
14988
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
339 | #ifdef __cplusplus |
|
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
340 | } |
|
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
341 | #endif |
|
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
342 | |
| 15884 | 343 | #endif /* _PURPLE_XMLNODE_H_ */ |
|
32313
3f58eb41a9a8
Remove deprecated xmlnode functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32206
diff
changeset
|
344 |