Tue, 16 Jul 2013 20:08:53 +0530
Added GBoxed wrapping to xmlnode
| 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 | |
|
34791
df49377a0778
Added GBoxed wrapping to xmlnode
Ankit Vani <a@nevitus.org>
parents:
33889
diff
changeset
|
31 | #define PURPLE_TYPE_XMLNODE (xmlnode_get_type()) |
|
df49377a0778
Added GBoxed wrapping to xmlnode
Ankit Vani <a@nevitus.org>
parents:
33889
diff
changeset
|
32 | |
| 10327 | 33 | /** |
| 34 | * The valid types for an xmlnode | |
| 35 | */ | |
|
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
|
36 | typedef enum |
| 7131 | 37 | { |
|
33889
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
38 | XMLNODE_TYPE_TAG, /**< Just a tag */ |
|
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
39 | XMLNODE_TYPE_ATTRIB, /**< Has attributes */ |
|
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
40 | XMLNODE_TYPE_DATA /**< Has data */ |
| 8135 | 41 | } XMLNodeType; |
| 7131 | 42 | |
| 10327 | 43 | /** |
| 44 | * An xmlnode. | |
| 45 | */ | |
| 14386 | 46 | typedef struct _xmlnode xmlnode; |
| 47 | struct _xmlnode | |
| 7131 | 48 | { |
|
33889
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
49 | char *name; /**< The name of the node. */ |
|
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
50 | char *xmlns; /**< The namespace of the node */ |
|
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
51 | XMLNodeType type; /**< The type of the node. */ |
|
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
52 | char *data; /**< The data for the node. */ |
|
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
53 | 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
|
54 | 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
|
55 | 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
|
56 | 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
|
57 | 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
|
58 | char *prefix; /**< The namespace prefix if any. */ |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
59 | GHashTable *namespace_map; /**< The namespace map. */ |
| 14386 | 60 | }; |
| 7131 | 61 | |
|
32787
7072f190d6ad
Use G_BEGIN/END_DECLS in public libpurple files. This was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32554
diff
changeset
|
62 | G_BEGIN_DECLS |
|
7072f190d6ad
Use G_BEGIN/END_DECLS in public libpurple files. This was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32554
diff
changeset
|
63 | |
| 10327 | 64 | /** |
|
34791
df49377a0778
Added GBoxed wrapping to xmlnode
Ankit Vani <a@nevitus.org>
parents:
33889
diff
changeset
|
65 | * Returns the GType for the xmlnode boxed structure. |
|
df49377a0778
Added GBoxed wrapping to xmlnode
Ankit Vani <a@nevitus.org>
parents:
33889
diff
changeset
|
66 | */ |
|
df49377a0778
Added GBoxed wrapping to xmlnode
Ankit Vani <a@nevitus.org>
parents:
33889
diff
changeset
|
67 | GType xmlnode_get_type(void); |
|
df49377a0778
Added GBoxed wrapping to xmlnode
Ankit Vani <a@nevitus.org>
parents:
33889
diff
changeset
|
68 | |
|
df49377a0778
Added GBoxed wrapping to xmlnode
Ankit Vani <a@nevitus.org>
parents:
33889
diff
changeset
|
69 | /** |
| 10327 | 70 | * Creates a new xmlnode. |
| 71 | * | |
| 72 | * @param name The name of the node. | |
| 73 | * | |
| 74 | * @return The new node. | |
| 75 | */ | |
| 7131 | 76 | xmlnode *xmlnode_new(const char *name); |
| 10327 | 77 | |
| 78 | /** | |
| 79 | * Creates a new xmlnode child. | |
| 80 | * | |
| 81 | * @param parent The parent node. | |
| 82 | * @param name The name of the child node. | |
| 83 | * | |
| 84 | * @return The new child node. | |
| 85 | */ | |
| 7131 | 86 | xmlnode *xmlnode_new_child(xmlnode *parent, const char *name); |
| 10327 | 87 | |
| 88 | /** | |
| 89 | * Inserts a node into a node as a child. | |
| 90 | * | |
| 91 | * @param parent The parent node to insert child into. | |
| 92 | * @param child The child node to insert into parent. | |
| 93 | */ | |
| 7131 | 94 | void xmlnode_insert_child(xmlnode *parent, xmlnode *child); |
| 10327 | 95 | |
| 96 | /** | |
| 97 | * Gets a child node named name. | |
| 98 | * | |
| 99 | * @param parent The parent node. | |
| 100 | * @param name The child's name. | |
| 101 | * | |
| 102 | * @return The child or NULL. | |
| 103 | */ | |
|
10736
fb529f29c25c
[gaim-migrate @ 12338]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
104 | xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name); |
| 10327 | 105 | |
| 106 | /** | |
| 107 | * Gets a child node named name in a namespace. | |
| 108 | * | |
| 109 | * @param parent The parent node. | |
| 110 | * @param name The child's name. | |
| 111 | * @param xmlns The namespace. | |
| 112 | * | |
| 113 | * @return The child or NULL. | |
| 114 | */ | |
|
10736
fb529f29c25c
[gaim-migrate @ 12338]
Mark Doliner <markdoliner@pidgin.im>
parents:
10425
diff
changeset
|
115 | xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns); |
| 10327 | 116 | |
| 117 | /** | |
| 118 | * Gets the next node with the same name as node. | |
| 119 | * | |
| 120 | * @param node The node of a twin to find. | |
| 121 | * | |
| 122 | * @return The twin of node or NULL. | |
| 123 | */ | |
| 8135 | 124 | xmlnode *xmlnode_get_next_twin(xmlnode *node); |
| 10327 | 125 | |
| 126 | /** | |
| 127 | * Inserts data into a node. | |
| 128 | * | |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
129 | * @param node The node to insert data into. |
| 10327 | 130 | * @param data The data to insert. |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
131 | * @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
|
132 | * null-terminated you can pass in -1. |
| 10327 | 133 | */ |
| 10848 | 134 | void xmlnode_insert_data(xmlnode *node, const char *data, gssize size); |
| 10327 | 135 | |
| 136 | /** | |
|
18131
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
137 | * Gets (escaped) data from a node. |
| 10327 | 138 | * |
| 139 | * @param node The node to get data from. | |
| 140 | * | |
|
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
|
141 | * @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
|
142 | * 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
|
143 | */ |
|
27345
37d67bee50c2
These parameters aren't modified
Mark Doliner <markdoliner@pidgin.im>
parents:
26831
diff
changeset
|
144 | 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
|
145 | |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
146 | /** |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
147 | * 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
|
148 | * |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
149 | * @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
|
150 | * |
|
7127441da3ba
add xmlnode_get_data_unescaped(), and got rid of an unecessary realloc
Nathan Walp <nwalp@pidgin.im>
parents:
15884
diff
changeset
|
151 | * @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
|
152 | * this string when finished using it. |
| 10327 | 153 | */ |
|
27345
37d67bee50c2
These parameters aren't modified
Mark Doliner <markdoliner@pidgin.im>
parents:
26831
diff
changeset
|
154 | char *xmlnode_get_data_unescaped(const xmlnode *node); |
| 10327 | 155 | |
| 156 | /** | |
| 157 | * Sets an attribute for a node. | |
| 158 | * | |
| 159 | * @param node The node to set an attribute for. | |
| 160 | * @param attr The name of the attribute. | |
| 161 | * @param value The value of the attribute. | |
| 162 | */ | |
| 7131 | 163 | void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value); |
| 10327 | 164 | |
|
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
|
165 | /** |
|
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
|
166 | * 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
|
167 | * |
|
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 | * @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
|
169 | * @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
|
170 | * @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
|
171 | * @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
|
172 | * @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
|
173 | */ |
|
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
|
174 | void xmlnode_set_attrib_full(xmlnode *node, const char *attr, const char *xmlns, |
|
33889
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
175 | const char *prefix, const char *value); |
| 15265 | 176 | |
| 177 | /** | |
| 10327 | 178 | * Gets an attribute from a node. |
| 179 | * | |
| 180 | * @param node The node to get an attribute from. | |
| 181 | * @param attr The attribute to get. | |
| 182 | * | |
| 183 | * @return The value of the attribute. | |
| 184 | */ | |
|
30510
570fa2a907ea
const-ify the xmlnode* parameter to xmlnode_get_attrib(_with_namespace)
Paul Aurich <darkrain42@pidgin.im>
parents:
28092
diff
changeset
|
185 | const char *xmlnode_get_attrib(const xmlnode *node, const char *attr); |
| 10327 | 186 | |
| 187 | /** | |
| 15265 | 188 | * Gets a namespaced attribute from a node |
| 189 | * | |
| 190 | * @param node The node to get an attribute from. | |
| 191 | * @param attr The attribute to get | |
| 192 | * @param xmlns The namespace of the attribute to get | |
| 193 | * | |
| 194 | * @return The value of the attribute/ | |
| 195 | */ | |
|
30510
570fa2a907ea
const-ify the xmlnode* parameter to xmlnode_get_attrib(_with_namespace)
Paul Aurich <darkrain42@pidgin.im>
parents:
28092
diff
changeset
|
196 | const char *xmlnode_get_attrib_with_namespace(const xmlnode *node, const char *attr, const char *xmlns); |
| 15265 | 197 | |
| 198 | /** | |
| 10327 | 199 | * Removes an attribute from a node. |
| 200 | * | |
| 201 | * @param node The node to remove an attribute from. | |
| 202 | * @param attr The attribute to remove. | |
| 203 | */ | |
| 7131 | 204 | void xmlnode_remove_attrib(xmlnode *node, const char *attr); |
| 10327 | 205 | |
| 206 | /** | |
| 15265 | 207 | * Removes a namespaced attribute from a node |
| 208 | * | |
| 209 | * @param node The node to remove an attribute from | |
| 210 | * @param attr The attribute to remove | |
| 211 | * @param xmlns The namespace of the attribute to remove | |
| 212 | */ | |
| 213 | void xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns); | |
| 214 | ||
| 215 | /** | |
| 13808 | 216 | * Sets the namespace of a node |
| 217 | * | |
| 218 | * @param node The node to qualify | |
| 219 | * @param xmlns The namespace of the node | |
| 220 | */ | |
| 221 | void xmlnode_set_namespace(xmlnode *node, const char *xmlns); | |
| 222 | ||
| 223 | /** | |
| 224 | * Returns the namespace of a node | |
| 225 | * | |
| 226 | * @param node The node to get the namepsace from | |
| 227 | * @return The namespace of this node | |
| 228 | */ | |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
229 | 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
|
230 | |
|
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 | * 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
|
233 | * 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
|
234 | * 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
|
235 | * own namespace. |
|
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 | * For example, given: |
|
32554
0d844fac6679
Fix a bunch of tiny problems generating our doxygen documentation
Mark Doliner <markdoliner@pidgin.im>
parents:
32322
diff
changeset
|
238 | * \verbatim |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
239 | * <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
|
240 | * <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
|
241 | * </iq> |
|
32554
0d844fac6679
Fix a bunch of tiny problems generating our doxygen documentation
Mark Doliner <markdoliner@pidgin.im>
parents:
32322
diff
changeset
|
242 | * \endverbatim |
|
32321
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
243 | * |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
244 | * 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
|
245 | * 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
|
246 | * |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
247 | * @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
|
248 | * @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
|
249 | */ |
|
ae17a89ef666
xmlnode: Fix some brokeness in xmlnode serialization with prefixed elements.
Paul Aurich <darkrain42@pidgin.im>
parents:
32313
diff
changeset
|
250 | const char *xmlnode_get_default_namespace(const xmlnode *node); |
| 13808 | 251 | |
| 252 | /** | |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
253 | * Returns the defined namespace for a prefix. |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
254 | * |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
255 | * @param node The node from which to start the search. |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
256 | * @param prefix The prefix for which to return the associated namespace. |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
257 | * @return The namespace for this prefix. |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
258 | */ |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
259 | const char *xmlnode_get_prefix_namespace(const xmlnode *node, const char *prefix); |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
260 | |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
261 | /** |
|
21454
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
262 | * Sets the prefix of a node |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
263 | * |
|
21552
6920e51d8f27
Get rid of a few silly doxygen warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
21454
diff
changeset
|
264 | * @param node The node to qualify |
|
6920e51d8f27
Get rid of a few silly doxygen warnings
Mark Doliner <markdoliner@pidgin.im>
parents:
21454
diff
changeset
|
265 | * @param prefix The prefix of the node |
|
21454
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
266 | */ |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
267 | 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
|
268 | |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
269 | /** |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
270 | * Returns the prefix of a node |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
271 | * |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
272 | * @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
|
273 | * @return The prefix of this node |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
274 | */ |
|
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
|
275 | 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
|
276 | |
|
2ca06ee152ac
make our xmlnode preserve prefixes
Ka-Hing Cheung <khc@pidgin.im>
parents:
20603
diff
changeset
|
277 | /** |
|
32322
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
278 | * Remove all element prefixes from an xmlnode tree. The prefix's |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
279 | * namespace is transformed into the default namespace for an element. |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
280 | * |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
281 | * Note that this will not necessarily remove all prefixes in use |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
282 | * (prefixed attributes may still exist), and that this usage may |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
283 | * break some applications (SOAP / XPath apparently often rely on |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
284 | * the prefixes having the same name. |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
285 | * |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
286 | * @param node The node from which to strip prefixes |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
287 | */ |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
288 | void xmlnode_strip_prefixes(xmlnode *node); |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
289 | |
|
5c1dd6d9d57f
xmlnode: Add xmlnode_strip_prefixes
Paul Aurich <darkrain42@pidgin.im>
parents:
32321
diff
changeset
|
290 | /** |
|
23750
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
291 | * Gets the parent node. |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
292 | * |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
293 | * @param child The child node. |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
294 | * |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
295 | * @return The parent or NULL. |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
296 | */ |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
297 | xmlnode *xmlnode_get_parent(const xmlnode *child); |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
298 | |
|
57baab09bf45
Added xmlnode_get_parent.
Michael Ruprecht <maiku@pidgin.im>
parents:
21552
diff
changeset
|
299 | /** |
| 10327 | 300 | * Returns the node in a string of xml. |
| 301 | * | |
| 302 | * @param node The starting node to output. | |
| 303 | * @param len Address for the size of the string. | |
| 304 | * | |
|
12887
4235bbee17b1
[gaim-migrate @ 15240]
Daniel Atallah <datallah@pidgin.im>
parents:
12233
diff
changeset
|
305 | * @return The node represented as a string. You must |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
306 | * g_free this string when finished using it. |
| 10327 | 307 | */ |
|
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
|
308 | char *xmlnode_to_str(const xmlnode *node, int *len); |
| 10327 | 309 | |
| 310 | /** | |
| 311 | * Returns the node in a string of human readable xml. | |
| 312 | * | |
| 313 | * @param node The starting node to output. | |
| 314 | * @param len Address for the size of the string. | |
| 315 | * | |
| 316 | * @return The node as human readable string including | |
|
10415
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
317 | * tab and new line characters. You must |
|
faceb835eb87
[gaim-migrate @ 11665]
Mark Doliner <markdoliner@pidgin.im>
parents:
10337
diff
changeset
|
318 | * g_free this string when finished using it. |
| 10327 | 319 | */ |
|
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
|
320 | char *xmlnode_to_formatted_str(const xmlnode *node, int *len); |
| 10327 | 321 | |
| 322 | /** | |
|
10337
778231f38df6
[gaim-migrate @ 11545]
Mark Doliner <markdoliner@pidgin.im>
parents:
10327
diff
changeset
|
323 | * 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
|
324 | * root node of an XML document will parse the entire document |
|
778231f38df6
[gaim-migrate @ 11545]
Mark Doliner <markdoliner@pidgin.im>
parents:
10327
diff
changeset
|
325 | * into a tree of nodes, and return the xmlnode of the root. |
| 10327 | 326 | * |
| 327 | * @param str The string of xml. | |
|
11707
a2c8dd795e3b
[gaim-migrate @ 13998]
Richard Laager <rlaager@pidgin.im>
parents:
10848
diff
changeset
|
328 | * @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
|
329 | * NUL-terminated. |
| 10327 | 330 | * |
| 331 | * @return The new node. | |
| 332 | */ | |
| 10848 | 333 | xmlnode *xmlnode_from_str(const char *str, gssize size); |
| 10327 | 334 | |
| 335 | /** | |
| 336 | * Creates a new node from the source node. | |
| 337 | * | |
| 338 | * @param src The node to copy. | |
| 339 | * | |
| 340 | * @return A new copy of the src node. | |
| 341 | */ | |
|
15609
e432251bd57e
sf patch #1647731, from Markus Elfring
Mark Doliner <markdoliner@pidgin.im>
parents:
15435
diff
changeset
|
342 | xmlnode *xmlnode_copy(const xmlnode *src); |
| 7131 | 343 | |
| 10327 | 344 | /** |
|
17775
1df27cab581c
implemented user mood, still missing the front end interface
Andreas Monitzer <am@adiumx.com>
parents:
15884
diff
changeset
|
345 | * Frees a node and all of its children. |
| 10327 | 346 | * |
| 347 | * @param node The node to free. | |
| 348 | */ | |
| 7131 | 349 | void xmlnode_free(xmlnode *node); |
| 350 | ||
|
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
|
351 | /** |
|
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
|
352 | * 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
|
353 | * 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
|
354 | * 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
|
355 | * |
|
26384
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
356 | * @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
|
357 | * @param filename The filename |
|
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
358 | * @param description A description of the file being parsed. Displayed to |
|
33889
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
359 | * the user if the file cannot be read. |
|
26384
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
360 | * @param process The subsystem that is calling xmlnode_from_file. Used as |
|
33889
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
361 | * 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
|
362 | * |
|
26384
1b9c946aaafa
Fixing warnings from `make docs` and stuff
Paul Aurich <darkrain42@pidgin.im>
parents:
25911
diff
changeset
|
363 | * @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
|
364 | */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25885
diff
changeset
|
365 | xmlnode *xmlnode_from_file(const char *dir, const char *filename, |
|
33889
4efe5c21db45
Doc and code formatting (use spaces not tabs to align comments after code and
Mark Doliner <mark@kingant.net>
parents:
32787
diff
changeset
|
366 | const char *description, const char *process); |
|
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
|
367 | |
|
32787
7072f190d6ad
Use G_BEGIN/END_DECLS in public libpurple files. This was
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32554
diff
changeset
|
368 | G_END_DECLS |
|
14988
66b34458d49e
[gaim-migrate @ 17698]
Richard Laager <rlaager@pidgin.im>
parents:
14498
diff
changeset
|
369 | |
| 15884 | 370 | #endif /* _PURPLE_XMLNODE_H_ */ |
|
32313
3f58eb41a9a8
Remove deprecated xmlnode functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32206
diff
changeset
|
371 |