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