* Purple is the legal property of its developers, whose names are too numerous * to list here. Please refer to the COPYRIGHT file distributed with this * Rewritten from scratch during Google Summer of Code 2012 * by Tomek Wasilczyk (http://www.wasilczyk.pl). * Previously implemented by: * - Arkadiusz Miskiewicz <misiek@pld.org.pl> - first implementation (2001); * - Bartosz Oler <bartosz@bzimage.us> - reimplemented during GSoC 2005; * - Krzysztof Klinikowski <grommasher@gmail.com> - some parts (2009-2011). * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA gboolean ggp_xml_get_string(const PurpleXmlNode *xml, gchar *childName, gchar **var) g_return_val_if_fail(xml != NULL, FALSE); g_return_val_if_fail(var != NULL, FALSE); xml = purple_xmlnode_get_child(xml, childName); str = purple_xmlnode_get_data(xml); gboolean ggp_xml_get_bool(const PurpleXmlNode *xml, gchar *childName, gboolean *var) succ = ggp_xml_get_string(xml, childName, &str); *var = (strcmp(str, "true") == 0 || strcmp(str, "True") == 0 || strcmp(str, "TRUE") == 0 || gboolean ggp_xml_get_uint(const PurpleXmlNode *xml, gchar *childName, unsigned int *var) succ = ggp_xml_get_string(xml, childName, &str); val = strtoul(str, &endptr, 10); succ = (errno != ERANGE && endptr[0] == '\0'); gboolean ggp_xml_set_string(PurpleXmlNode *xml, gchar *childName, const gchar *val) g_return_val_if_fail(xml != NULL, FALSE); g_return_val_if_fail(val != NULL, FALSE); PurpleXmlNode *child = purple_xmlnode_get_child(xml, childName); child = purple_xmlnode_new_child(xml, childName); ggp_xmlnode_remove_children(xml); purple_xmlnode_insert_data(xml, val, -1); gboolean ggp_xml_set_bool(PurpleXmlNode *xml, gchar *childName, gboolean val) return ggp_xml_set_string(xml, childName, val ? "true" : "false"); gboolean ggp_xml_set_uint(PurpleXmlNode *xml, gchar *childName, unsigned int val) g_snprintf(buff, sizeof(buff), "%u", val); return ggp_xml_set_string(xml, childName, buff); void ggp_xmlnode_remove_children(PurpleXmlNode *xml) PurpleXmlNode *child = xml->child; PurpleXmlNode *next = child->next; if (child->type != PURPLE_XMLNODE_TYPE_ATTRIB) purple_xmlnode_free(child); unsigned int ggp_xml_child_count(PurpleXmlNode *xml, const gchar *childName) g_return_val_if_fail(xml != NULL, 0); child = purple_xmlnode_get_child(xml, childName); child = purple_xmlnode_get_next_twin(child);