core cleanup: 6 more modules are purple free
[siplcs.git] / src / core / sipe-xml.h
blob70f038a46abe4b9526d88f708bf7341e0b932af4
1 /**
2 * @file sipe-xml.h
4 * pidgin-sipe
6 * Copyright (C) 2010 SIPE Project <http://sipe.sourceforge.net/>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 typedef struct _sipe_xml sipe_xml;
25 /**
26 * Parse XML from a string.
28 * @param string String with the XML to be parsed.
29 * @param length Length of the string.
31 * @return Parsed XML information. Must be @c sipe_xml_free()'d.
33 sipe_xml *sipe_xml_parse(const gchar *string, gsize length);
35 /**
36 * Free XML information.
38 * @param string XML information to be freed.
40 void sipe_xml_free(sipe_xml *xml);
42 /**
43 * Convert XML information to string.
45 * @param xml XML information.
47 * @return XML converted to a string. Must be @c g_free()'d.
49 gchar *sipe_xml_stringify(const sipe_xml *xml);
51 /**
52 * Gets a child node named name.
54 * @param parent The parent node.
55 * @param name relative XPATH of the child (a, a/b, a/b/c, etc.).
57 * @return The child or @c NULL. Never try to @c sipe_xml_free() it!
59 const sipe_xml *sipe_xml_child(const sipe_xml *parent, const gchar *name);
61 /**
62 * Gets the next node with the same name as node.
64 * @param node The node of a twin to find.
66 * @return The twin of node or @c NULL.
68 const sipe_xml *sipe_xml_twin(const sipe_xml *node);
70 /**
71 * Gets an attribute from the current XML node.
73 * @param node The node to get an attribute from.
74 * @param attr The attribute to get.
76 * @return The value of the attribute or @c NULL.
78 const gchar *sipe_xml_attribute(const sipe_xml *node, const gchar *attr);
80 /**
81 * Gets an attribute from the current XML node and convert it to an integer.
83 * @param node The node to get an attribute from.
84 * @param attr The attribute to get.
85 * @param fallback Default value if the attribute doesn't exist.
87 * @return Attribute value converted to an integer or the fallback value.
89 gint sipe_xml_int_attribute(const sipe_xml *node, const gchar *attr,
90 gint fallback);
92 /**
93 * Gets escaped data from the curretn XML node.
95 * @param node The node to get data from.
97 * @return The data from the node or @c NULL. Must be @c g_free()'d.
99 gchar *sipe_xml_data(const sipe_xml *node);