Mercurial > pidgin
annotate libgaim/xmlnode.h @ 14926:500a8f54354e
[gaim-migrate @ 17698]
Add extern "C" guards to header files which are missing it. This should fix problems similar to SF Bug #1592175. Also, while I was at it, I made the _GaimStringref definition private. It already had a warning to not use it directly, so it should really be safe to make private.
committer: Tailor Script <tailor@pidgin.im>
| author | Richard Laager <rlaager@wiktel.com> |
|---|---|
| date | Tue, 07 Nov 2006 20:40:22 +0000 |
| parents | 289490ee84d1 |
| children | 50f263712df1 |
| rev | line source |
|---|---|
| 14192 | 1 /** |
| 2 * @file xmlnode.h XML DOM functions | |
| 3 * @ingroup core | |
| 4 * | |
| 5 * gaim | |
| 6 * | |
| 7 * Gaim is the legal property of its developers, whose names are too numerous | |
| 8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 9 * source distribution. | |
| 10 * | |
| 11 * This program is free software; you can redistribute it and/or modify | |
| 12 * it under the terms of the GNU General Public License as published by | |
| 13 * the Free Software Foundation; either version 2 of the License, or | |
| 14 * (at your option) any later version. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU General Public License | |
| 22 * along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 */ | |
| 25 #ifndef _GAIM_XMLNODE_H_ | |
| 26 #define _GAIM_XMLNODE_H_ | |
| 27 | |
|
14926
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
28 #ifdef __cplusplus |
|
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
29 extern "C" { |
|
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
30 #endif |
|
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
31 |
| 14192 | 32 /** |
| 33 * The valid types for an xmlnode | |
| 34 */ | |
| 35 typedef enum _XMLNodeType | |
| 36 { | |
| 37 XMLNODE_TYPE_TAG, /**< Just a tag */ | |
| 38 XMLNODE_TYPE_ATTRIB, /**< Has attributes */ | |
| 39 XMLNODE_TYPE_DATA /**< Has data */ | |
| 40 } XMLNodeType; | |
| 41 | |
| 42 /** | |
| 43 * An xmlnode. | |
| 44 */ | |
| 14324 | 45 typedef struct _xmlnode xmlnode; |
| 46 struct _xmlnode | |
| 14192 | 47 { |
| 48 char *name; /**< The name of the node. */ | |
| 49 char *namespace; /**< The namespace of the node */ | |
| 50 XMLNodeType type; /**< The type of the node. */ | |
| 51 char *data; /**< The data for the node. */ | |
| 52 size_t data_sz; /**< The size of the data. */ | |
| 53 struct _xmlnode *parent; /**< The parent node or @c NULL.*/ | |
| 54 struct _xmlnode *child; /**< The child node or @c NULL.*/ | |
| 55 struct _xmlnode *lastchild; /**< The last child node or @c NULL.*/ | |
| 56 struct _xmlnode *next; /**< The next node or @c NULL. */ | |
| 14324 | 57 }; |
| 14192 | 58 |
| 59 /** | |
| 60 * Creates a new xmlnode. | |
| 61 * | |
| 62 * @param name The name of the node. | |
| 63 * | |
| 64 * @return The new node. | |
| 65 */ | |
| 66 xmlnode *xmlnode_new(const char *name); | |
| 67 | |
| 68 /** | |
| 69 * Creates a new xmlnode child. | |
| 70 * | |
| 71 * @param parent The parent node. | |
| 72 * @param name The name of the child node. | |
| 73 * | |
| 74 * @return The new child node. | |
| 75 */ | |
| 76 xmlnode *xmlnode_new_child(xmlnode *parent, const char *name); | |
| 77 | |
| 78 /** | |
| 79 * Inserts a node into a node as a child. | |
| 80 * | |
| 81 * @param parent The parent node to insert child into. | |
| 82 * @param child The child node to insert into parent. | |
| 83 */ | |
| 84 void xmlnode_insert_child(xmlnode *parent, xmlnode *child); | |
| 85 | |
| 86 /** | |
| 87 * Gets a child node named name. | |
| 88 * | |
| 89 * @param parent The parent node. | |
| 90 * @param name The child's name. | |
| 91 * | |
| 92 * @return The child or NULL. | |
| 93 */ | |
| 94 xmlnode *xmlnode_get_child(const xmlnode *parent, const char *name); | |
| 95 | |
| 96 /** | |
| 97 * Gets a child node named name in a namespace. | |
| 98 * | |
| 99 * @param parent The parent node. | |
| 100 * @param name The child's name. | |
| 101 * @param xmlns The namespace. | |
| 102 * | |
| 103 * @return The child or NULL. | |
| 104 */ | |
| 105 xmlnode *xmlnode_get_child_with_namespace(const xmlnode *parent, const char *name, const char *xmlns); | |
| 106 | |
| 107 /** | |
| 108 * Gets the next node with the same name as node. | |
| 109 * | |
| 110 * @param node The node of a twin to find. | |
| 111 * | |
| 112 * @return The twin of node or NULL. | |
| 113 */ | |
| 114 xmlnode *xmlnode_get_next_twin(xmlnode *node); | |
| 115 | |
| 116 /** | |
| 117 * Inserts data into a node. | |
| 118 * | |
| 119 * @param node The node to insert data into. | |
| 120 * @param data The data to insert. | |
| 121 * @param size The size of the data to insert. If data is | |
| 122 * null-terminated you can pass in -1. | |
| 123 */ | |
| 124 void xmlnode_insert_data(xmlnode *node, const char *data, gssize size); | |
| 125 | |
| 126 /** | |
| 127 * Gets data from a node. | |
| 128 * | |
| 129 * @param node The node to get data from. | |
| 130 * | |
| 131 * @return The data from the node. You must g_free | |
| 132 * this string when finished using it. | |
| 133 */ | |
| 134 char *xmlnode_get_data(xmlnode *node); | |
| 135 | |
| 136 /** | |
| 137 * Sets an attribute for a node. | |
| 138 * | |
| 139 * @param node The node to set an attribute for. | |
| 140 * @param attr The name of the attribute. | |
| 141 * @param value The value of the attribute. | |
| 142 */ | |
| 143 void xmlnode_set_attrib(xmlnode *node, const char *attr, const char *value); | |
| 144 | |
| 145 /** | |
| 146 * Gets an attribute from a node. | |
| 147 * | |
| 148 * @param node The node to get an attribute from. | |
| 149 * @param attr The attribute to get. | |
| 150 * | |
| 151 * @return The value of the attribute. | |
| 152 */ | |
| 153 const char *xmlnode_get_attrib(xmlnode *node, const char *attr); | |
| 154 | |
| 155 /** | |
| 156 * Removes an attribute from a node. | |
| 157 * | |
| 158 * @param node The node to remove an attribute from. | |
| 159 * @param attr The attribute to remove. | |
| 160 */ | |
| 161 void xmlnode_remove_attrib(xmlnode *node, const char *attr); | |
| 162 | |
| 163 /** | |
| 164 * Sets the namespace of a node | |
| 165 * | |
| 166 * @param node The node to qualify | |
| 167 * @param xmlns The namespace of the node | |
| 168 */ | |
| 169 void xmlnode_set_namespace(xmlnode *node, const char *xmlns); | |
| 170 | |
| 171 /** | |
| 172 * Returns the namespace of a node | |
| 173 * | |
| 174 * @param node The node to get the namepsace from | |
| 175 * @return The namespace of this node | |
| 176 */ | |
| 177 const char *xmlnode_get_namespace(xmlnode *node); | |
| 178 | |
| 179 /** | |
| 180 * Returns the node in a string of xml. | |
| 181 * | |
| 182 * @param node The starting node to output. | |
| 183 * @param len Address for the size of the string. | |
| 184 * | |
| 185 * @return The node represented as a string. You must | |
| 186 * g_free this string when finished using it. | |
| 187 */ | |
| 188 char *xmlnode_to_str(xmlnode *node, int *len); | |
| 189 | |
| 190 /** | |
| 191 * Returns the node in a string of human readable xml. | |
| 192 * | |
| 193 * @param node The starting node to output. | |
| 194 * @param len Address for the size of the string. | |
| 195 * | |
| 196 * @return The node as human readable string including | |
| 197 * tab and new line characters. You must | |
| 198 * g_free this string when finished using it. | |
| 199 */ | |
| 200 char *xmlnode_to_formatted_str(xmlnode *node, int *len); | |
| 201 | |
| 202 /** | |
| 203 * Creates a node from a string of XML. Calling this on the | |
| 204 * root node of an XML document will parse the entire document | |
| 205 * into a tree of nodes, and return the xmlnode of the root. | |
| 206 * | |
| 207 * @param str The string of xml. | |
| 208 * @param size The size of the string, or -1 if @a str is | |
| 209 * NUL-terminated. | |
| 210 * | |
| 211 * @return The new node. | |
| 212 */ | |
| 213 xmlnode *xmlnode_from_str(const char *str, gssize size); | |
| 214 | |
| 215 /** | |
| 216 * Creates a new node from the source node. | |
| 217 * | |
| 218 * @param src The node to copy. | |
| 219 * | |
| 220 * @return A new copy of the src node. | |
| 221 */ | |
| 222 xmlnode *xmlnode_copy(xmlnode *src); | |
| 223 | |
| 224 /** | |
| 225 * Frees a node and all of it's children. | |
| 226 * | |
| 227 * @param node The node to free. | |
| 228 */ | |
| 229 void xmlnode_free(xmlnode *node); | |
| 230 | |
|
14926
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
231 #ifdef __cplusplus |
|
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
232 } |
|
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
233 #endif |
|
500a8f54354e
[gaim-migrate @ 17698]
Richard Laager <rlaager@wiktel.com>
parents:
14436
diff
changeset
|
234 |
| 14192 | 235 #endif /* _GAIM_XMLNODE_H_ */ |
