changeset 462:b65fe3b68300 trunk

[svn] Move xml_document stuff into libaudacious.
author nenolod
date Wed, 18 Jan 2006 10:38:51 -0800
parents 60dac59c393a
children 6af6627e14f5
files audacious/Makefile.am audacious/main.c audacious/xml_document.c audacious/xml_document.h libaudacious/Makefile.am libaudacious/xml_document.c libaudacious/xml_document.h
diffstat 7 files changed, 407 insertions(+), 405 deletions(-) [+]
line wrap: on
line diff
--- a/audacious/Makefile.am	Tue Jan 17 18:15:15 2006 -0800
+++ b/audacious/Makefile.am	Wed Jan 18 10:38:51 2006 -0800
@@ -55,7 +55,6 @@
 	eq_slider.c eq_slider.h \
 	main.c main.h \
 	logger.c logger.h \
-	xml_document.c xml_document.h \
 	mainwin.c mainwin.h \
 	skinwin.c skinwin.h \
 	prefswin.c prefswin.h \
--- a/audacious/main.c	Tue Jan 17 18:15:15 2006 -0800
+++ b/audacious/main.c	Wed Jan 18 10:38:51 2006 -0800
@@ -73,6 +73,7 @@
 #include "skinwin.h"
 #include "util.h"
 #include "visualization.h"
+#include "xml_document.h"
 
 #include "pixmaps.h"
 #include "images/audacious_player.xpm"
--- a/audacious/xml_document.c	Tue Jan 17 18:15:15 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,312 +0,0 @@
-/*  BMP - Cross-platform multimedia player
- *  Copyright (C) 2003-2004  BMP development team.
- *
- *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include "xml_document.h"
-
-#include <glib.h>
-#include <string.h>
-
-/* document builder callbacks */
-
-static void bmp_xml_doc_build_start_element(GMarkupParseContext * context,
-                                            const gchar * element_name,
-                                            const gchar ** attrib_names,
-                                            const gchar ** attrib_values,
-                                            gpointer user_data,
-                                            GError ** error);
-
-static void bmp_xml_doc_build_end_element(GMarkupParseContext * context,
-                                          const gchar * element_name,
-                                          gpointer user_data,
-                                          GError ** error);
-
-static void bmp_xml_doc_build_text(GMarkupParseContext * context,
-                                   const gchar * text,
-                                   gsize text_len,
-                                   gpointer user_data,
-                                   GError ** error);
-
-static void bmp_xml_doc_build_ignore(GMarkupParseContext * context,
-                                     const gchar * text,
-                                     gsize text_len,
-                                     gpointer user_data,
-                                     GError ** error);
-
-static void bmp_xml_doc_build_error(GMarkupParseContext * context,
-                                    GError * error,
-                                    gpointer user_data);
-
-static void bmp_xml_doc_build_destroy(BmpXmlDocument * data);
-
-static GMarkupParser bmp_xml_doc_builder = {
-    bmp_xml_doc_build_start_element,
-    bmp_xml_doc_build_end_element,
-    bmp_xml_doc_build_text,
-    bmp_xml_doc_build_ignore,
-    bmp_xml_doc_build_error
-};
-
-static GDestroyNotify bmp_xml_node_data_free_func[] = {
-    (GDestroyNotify) bmp_xml_doc_node_data_free,
-    (GDestroyNotify) bmp_xml_element_node_data_free,
-    (GDestroyNotify) bmp_xml_attrib_node_data_free,
-    (GDestroyNotify) bmp_xml_text_node_data_free
-};
-
-GNode *
-bmp_xml_doc_node_new(void)
-{
-    BmpXmlDocNodeData *data;
-    data = g_new0(BmpXmlDocNodeData, 1);
-    data->type = BMP_XML_NODE_DOC;
-    return g_node_new(data);
-}
-
-void
-bmp_xml_doc_node_data_free(BmpXmlDocNodeData * data)
-{
-    g_return_if_fail(data != NULL);
-    g_free(data);
-}
-
-GNode *
-bmp_xml_element_node_new(const gchar * name)
-{
-    BmpXmlElementNodeData *data;
-    data = g_new0(BmpXmlElementNodeData, 1);
-    data->type = BMP_XML_NODE_ELEMENT;
-    data->name = g_strdup(name);
-    return g_node_new(data);
-}
-
-void
-bmp_xml_element_node_data_free(BmpXmlElementNodeData * data)
-{
-    g_return_if_fail(data != NULL);
-    g_free(data->name);
-    g_free(data);
-}
-
-GNode *
-bmp_xml_attrib_node_new(const gchar * name,
-                        const gchar * value)
-{
-    BmpXmlAttribNodeData *data;
-    data = g_new0(BmpXmlAttribNodeData, 1);
-    data->type = BMP_XML_NODE_ATTRIB;
-    data->name = g_strdup(name);
-    data->value = g_strdup(value);
-    return g_node_new(data);
-}
-
-void
-bmp_xml_attrib_node_data_free(BmpXmlAttribNodeData * data)
-{
-    g_assert(data != NULL);
-    g_free(data->name);
-    g_free(data->value);
-    g_free(data);
-}
-
-GNode *
-bmp_xml_text_node_new(const gchar * text, gsize length)
-{
-    BmpXmlTextNodeData *data;
-    data = g_new0(BmpXmlTextNodeData, 1);
-    data->type = BMP_XML_NODE_TEXT;
-    data->text = g_new0(gchar, length);
-    memcpy(data->text, text, length);
-    data->length = length;
-    return g_node_new(data);
-}
-
-void
-bmp_xml_text_node_data_free(BmpXmlTextNodeData * data)
-{
-    g_return_if_fail(data != NULL);
-    g_free(data->text);
-    g_free(data);
-}
-
-void
-bmp_xml_node_data_free(GNode * node)
-{
-    BmpXmlNodeData *data;
-
-    g_return_if_fail(node != NULL);
-    g_return_if_fail(node->data != NULL);
-
-    data = BMP_XML_NODE_DATA(node->data);
-    (*bmp_xml_node_data_free_func[data->type]) (data);
-}
-
-BmpXmlDocument *
-bmp_xml_document_new(void)
-{
-    BmpXmlDocument *document;
-
-    document = g_new0(BmpXmlDocument, 1);
-
-    document->parse_context =
-        g_markup_parse_context_new(&bmp_xml_doc_builder, 0,
-                                   document, (GDestroyNotify)
-                                   bmp_xml_doc_build_destroy);
-    document->current_depth = 0;
-
-    document->tree = bmp_xml_doc_node_new();
-    document->current_node = document->tree;
-
-    return document;
-}
-
-void
-bmp_xml_document_free(BmpXmlDocument * document)
-{
-    g_return_if_fail(document != NULL);
-
-    g_node_traverse(document->tree, G_IN_ORDER, G_TRAVERSE_ALL, -1,
-                    (GNodeTraverseFunc) bmp_xml_node_data_free, NULL);
-    g_node_destroy(document->tree);
-
-    g_free(document);
-}
-
-GNode *
-bmp_xml_document_get_tree(BmpXmlDocument * document)
-{
-    return document->tree;
-}
-
-gboolean
-bmp_xml_document_load(BmpXmlDocument ** document_ref,
-                      const gchar * filename, GError ** error_out)
-{
-    BmpXmlDocument *document;
-    gchar *buffer;
-    gsize buffer_size;
-    GError *error = NULL;
-
-    g_assert(document_ref != NULL);
-    g_assert(filename != NULL);
-
-    *document_ref = NULL;
-
-    if (!g_file_get_contents(filename, &buffer, &buffer_size, &error)) {
-        g_propagate_error(error_out, error);
-        return FALSE;
-    }
-
-    if (!(document = bmp_xml_document_new())) {
-        g_free(buffer);
-        return FALSE;
-    }
-
-    if (!g_markup_parse_context_parse(document->parse_context, buffer,
-                                      buffer_size, &error)) {
-        bmp_xml_document_free(document);
-        g_free(buffer);
-        g_propagate_error(error_out, error);
-        return FALSE;
-    }
-
-    g_free(buffer);
-
-    if (!g_markup_parse_context_end_parse(document->parse_context, &error)) {
-        bmp_xml_document_free(document);
-        g_propagate_error(error_out, error);
-        return FALSE;
-    }
-
-    *document_ref = document;
-
-    return TRUE;
-}
-
-
-static void
-bmp_xml_doc_build_start_element(GMarkupParseContext * context,
-                                const gchar * element_name,
-                                const gchar ** attrib_names,
-                                const gchar ** attrib_values,
-                                gpointer user_data,
-                                GError ** error)
-{
-    BmpXmlDocument *document;
-
-    document = BMP_XML_DOCUMENT(user_data);
-
-    document->current_node =
-        g_node_append(document->current_node,
-                      bmp_xml_element_node_new(element_name));
-
-    while (*attrib_names) {
-        g_node_append(document->current_node,
-                      bmp_xml_attrib_node_new(*attrib_names++,
-                                              *attrib_values++));
-    }
-
-    document->current_depth++;
-}
-
-static void
-bmp_xml_doc_build_end_element(GMarkupParseContext * context,
-                              const gchar * element_name,
-                              gpointer user_data,
-                              GError ** error)
-{
-    BmpXmlDocument *document;
-
-    document = BMP_XML_DOCUMENT(user_data);
-    document->current_node = document->current_node->parent;
-    document->current_depth--;
-}
-
-static void
-bmp_xml_doc_build_text(GMarkupParseContext * context,
-                       const gchar * text,
-                       gsize text_len,
-                       gpointer user_data,
-                       GError ** error)
-{
-    BmpXmlDocument *document;
-    document = BMP_XML_DOCUMENT(user_data);
-    g_node_append(document->current_node,
-                  bmp_xml_text_node_new(text, text_len));
-}
-
-static void
-bmp_xml_doc_build_ignore(GMarkupParseContext * context,
-                         const gchar * text,
-                         gsize text_len,
-                         gpointer user_data,
-                         GError ** error)
-{
-}
-
-static void
-bmp_xml_doc_build_error(GMarkupParseContext * context,
-                        GError * error,
-                        gpointer user_data)
-{
-}
-
-static void
-bmp_xml_doc_build_destroy(BmpXmlDocument * document)
-{
-    g_markup_parse_context_free(document->parse_context);
-}
--- a/audacious/xml_document.h	Tue Jan 17 18:15:15 2006 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*  BMP - Cross-platform multimedia player
- *  Copyright (C) 2003-2004  BMP development team.
- *
- *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef XML_DOCUMENT_H
-#define XML_DOCUMENT_H
-
-#include <glib.h>
-
-typedef enum {
-    BMP_XML_NODE_DOC = 0,
-    BMP_XML_NODE_ELEMENT,
-    BMP_XML_NODE_ATTRIB,
-    BMP_XML_NODE_TEXT
-} BmpXmlNodeType;
-
-#define BMP_XML_DOCUMENT(x)           ((BmpXmlDocument *)(x))
-typedef struct {
-    GNode *tree;
-    GNode *current_node;
-    guint current_depth;
-    GMarkupParseContext *parse_context;
-} BmpXmlDocument;
-
-#define BMP_XML_NODE_DATA(x)          ((BmpXmlNodeData *)(x))
-typedef struct {
-    BmpXmlNodeType type;
-} BmpXmlNodeData;
-
-#define BMP_XML_DOC_NODE_DATA(x)      ((BmpXmlDocNodeData *)(x))
-typedef struct {
-    BmpXmlNodeType type;
-} BmpXmlDocNodeData;
-
-#define BMP_XML_ELEMENT_NODE_DATA(x)  ((BmpXmlElementNodeData *)(x))
-typedef struct {
-    BmpXmlNodeType type;
-    gchar *name;
-} BmpXmlElementNodeData;
-
-#define BMP_XML_ATTRIB_NODE_DATA(x)   ((BmpXmlAttribNodeData *)(x))
-typedef struct {
-    BmpXmlNodeType type;
-    gchar *name;
-    gchar *value;
-} BmpXmlAttribNodeData;
-
-#define BMP_XML_TEXT_NODE_DATA(x)     ((BmpXmlTextNodeData *)(x))
-typedef struct {
-    BmpXmlNodeType type;
-    gchar *text;
-    gsize length;
-} BmpXmlTextNodeData;
-
-
-GNode *bmp_xml_doc_node_new(void);
-void bmp_xml_doc_node_data_free(BmpXmlDocNodeData * data);
-
-GNode *bmp_xml_element_node_new(const gchar * name);
-void bmp_xml_element_node_data_free(BmpXmlElementNodeData * data);
-
-GNode *bmp_xml_attrib_node_new(const gchar * name, const gchar * value);
-void bmp_xml_attrib_node_data_free(BmpXmlAttribNodeData * data);
-
-void bmp_xml_text_node_data_free(BmpXmlTextNodeData * data);
-GNode *bmp_xml_text_node_new(const gchar * text, gsize length);
-
-
-gboolean bmp_xml_document_load(BmpXmlDocument ** document,
-                               const gchar * filename, GError ** error);
-
-void bmp_xml_document_free(BmpXmlDocument * document);
-
-GNode *bmp_xml_document_get_tree(BmpXmlDocument * document);
-
-#endif
--- a/libaudacious/Makefile.am	Tue Jan 17 18:15:15 2006 -0800
+++ b/libaudacious/Makefile.am	Wed Jan 18 10:38:51 2006 -0800
@@ -42,10 +42,11 @@
 	formatter.c formatter.h \
 	titlestring.c titlestring.h \
 	xentry.c xentry.h \
-	xconvert.c xconvert.h
+	xconvert.c xconvert.h \
+	xml_document.c xml_document.h
 
 beepinclude_HEADERS = \
 	vfs.h rcfile.h configdb.h \
 	configfile.h \
 	beepctrl.h dirbrowser.h util.h \
-	formatter.h titlestring.h
+	formatter.h titlestring.h xml_document.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libaudacious/xml_document.c	Wed Jan 18 10:38:51 2006 -0800
@@ -0,0 +1,313 @@
+/*  BMP - Cross-platform multimedia player
+ *  Copyright (C) 2003-2004  BMP development team.
+ *
+ *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include "xml_document.h"
+
+#include <glib.h>
+#include <string.h>
+
+/* document builder callbacks */
+
+static void bmp_xml_doc_build_start_element(GMarkupParseContext * context,
+                                            const gchar * element_name,
+                                            const gchar ** attrib_names,
+                                            const gchar ** attrib_values,
+                                            gpointer user_data,
+                                            GError ** error);
+
+static void bmp_xml_doc_build_end_element(GMarkupParseContext * context,
+                                          const gchar * element_name,
+                                          gpointer user_data,
+                                          GError ** error);
+
+static void bmp_xml_doc_build_text(GMarkupParseContext * context,
+                                   const gchar * text,
+                                   gsize text_len,
+                                   gpointer user_data,
+                                   GError ** error);
+
+static void bmp_xml_doc_build_ignore(GMarkupParseContext * context,
+                                     const gchar * text,
+                                     gsize text_len,
+                                     gpointer user_data,
+                                     GError ** error);
+
+static void bmp_xml_doc_build_error(GMarkupParseContext * context,
+                                    GError * error,
+                                    gpointer user_data);
+
+static void bmp_xml_doc_build_destroy(BmpXmlDocument * data);
+
+static GMarkupParser bmp_xml_doc_builder = {
+    bmp_xml_doc_build_start_element,
+    bmp_xml_doc_build_end_element,
+    bmp_xml_doc_build_text,
+    bmp_xml_doc_build_ignore,
+    bmp_xml_doc_build_error
+};
+
+static GDestroyNotify bmp_xml_node_data_free_func[] = {
+    (GDestroyNotify) bmp_xml_doc_node_data_free,
+    (GDestroyNotify) bmp_xml_element_node_data_free,
+    (GDestroyNotify) bmp_xml_attrib_node_data_free,
+    (GDestroyNotify) bmp_xml_text_node_data_free
+};
+
+GNode *
+bmp_xml_doc_node_new(void)
+{
+    BmpXmlDocNodeData *data;
+    data = g_new0(BmpXmlDocNodeData, 1);
+    data->type = BMP_XML_NODE_DOC;
+    return g_node_new(data);
+}
+
+void
+bmp_xml_doc_node_data_free(BmpXmlDocNodeData * data)
+{
+    g_return_if_fail(data != NULL);
+    g_free(data);
+}
+
+GNode *
+bmp_xml_element_node_new(const gchar * name)
+{
+    BmpXmlElementNodeData *data;
+    data = g_new0(BmpXmlElementNodeData, 1);
+    data->type = BMP_XML_NODE_ELEMENT;
+    data->name = g_strdup(name);
+    return g_node_new(data);
+}
+
+void
+bmp_xml_element_node_data_free(BmpXmlElementNodeData * data)
+{
+    g_return_if_fail(data != NULL);
+    g_free(data->name);
+    g_free(data);
+}
+
+GNode *
+bmp_xml_attrib_node_new(const gchar * name,
+                        const gchar * value)
+{
+    BmpXmlAttribNodeData *data;
+    data = g_new0(BmpXmlAttribNodeData, 1);
+    data->type = BMP_XML_NODE_ATTRIB;
+    data->name = g_strdup(name);
+    data->value = g_strdup(value);
+    return g_node_new(data);
+}
+
+void
+bmp_xml_attrib_node_data_free(BmpXmlAttribNodeData * data)
+{
+    g_assert(data != NULL);
+    g_free(data->name);
+    g_free(data->value);
+    g_free(data);
+}
+
+GNode *
+bmp_xml_text_node_new(const gchar * text, gsize length)
+{
+    BmpXmlTextNodeData *data;
+    data = g_new0(BmpXmlTextNodeData, 1);
+    data->type = BMP_XML_NODE_TEXT;
+    data->text = g_new0(gchar, length);
+    memcpy(data->text, text, length);
+    data->length = length;
+    return g_node_new(data);
+}
+
+void
+bmp_xml_text_node_data_free(BmpXmlTextNodeData * data)
+{
+    g_return_if_fail(data != NULL);
+    g_free(data->text);
+    g_free(data);
+}
+
+void
+bmp_xml_node_data_free(GNode * node)
+{
+    BmpXmlNodeData *data;
+
+    g_return_if_fail(node != NULL);
+    g_return_if_fail(node->data != NULL);
+
+    data = BMP_XML_NODE_DATA(node->data);
+    (*bmp_xml_node_data_free_func[data->type]) (data);
+}
+
+BmpXmlDocument *
+bmp_xml_document_new(void)
+{
+    BmpXmlDocument *document;
+
+    document = g_new0(BmpXmlDocument, 1);
+
+    document->parse_context =
+        g_markup_parse_context_new(&bmp_xml_doc_builder, 0,
+                                   document, (GDestroyNotify)
+                                   bmp_xml_doc_build_destroy);
+    document->current_depth = 0;
+
+    document->tree = bmp_xml_doc_node_new();
+    document->current_node = document->tree;
+
+    return document;
+}
+
+void
+bmp_xml_document_free(BmpXmlDocument * document)
+{
+    g_return_if_fail(document != NULL);
+
+    g_node_traverse(document->tree, G_IN_ORDER, G_TRAVERSE_ALL, -1,
+                    (GNodeTraverseFunc) bmp_xml_node_data_free, NULL);
+    g_node_destroy(document->tree);
+
+    g_free(document);
+}
+
+GNode *
+bmp_xml_document_get_tree(BmpXmlDocument * document)
+{
+    return document->tree;
+}
+
+gboolean
+bmp_xml_document_load(BmpXmlDocument ** document_ref,
+                      const gchar * filename, GError ** error_out)
+{
+    BmpXmlDocument *document;
+    gchar *buffer;
+    gsize buffer_size;
+    GError *error = NULL;
+
+    g_assert(document_ref != NULL);
+    g_assert(filename != NULL);
+
+    *document_ref = NULL;
+
+    if (!g_file_get_contents(filename, &buffer, &buffer_size, &error)) {
+        g_propagate_error(error_out, error);
+        return FALSE;
+    }
+
+    if (!(document = bmp_xml_document_new())) {
+        g_free(buffer);
+        return FALSE;
+    }
+
+    if (!g_markup_parse_context_parse(document->parse_context, buffer,
+                                      buffer_size, &error)) {
+        bmp_xml_document_free(document);
+        g_free(buffer);
+        g_propagate_error(error_out, error);
+        return FALSE;
+    }
+
+    g_free(buffer);
+
+    if (!g_markup_parse_context_end_parse(document->parse_context, &error)) {
+        bmp_xml_document_free(document);
+        g_propagate_error(error_out, error);
+        return FALSE;
+    }
+
+    *document_ref = document;
+
+    return TRUE;
+}
+
+
+static void
+bmp_xml_doc_build_start_element(GMarkupParseContext * context,
+                                const gchar * element_name,
+                                const gchar ** attrib_names,
+                                const gchar ** attrib_values,
+                                gpointer user_data,
+                                GError ** error)
+{
+    BmpXmlDocument *document;
+
+    document = BMP_XML_DOCUMENT(user_data);
+
+    document->current_node =
+        g_node_append(document->current_node,
+                      bmp_xml_element_node_new(element_name));
+
+    while (*attrib_names) {
+	g_print("%s = %s\n", *attrib_names, *attrib_values);
+        g_node_append(document->current_node,
+                      bmp_xml_attrib_node_new(*attrib_names++,
+                                              *attrib_values++));
+    }
+
+    document->current_depth++;
+}
+
+static void
+bmp_xml_doc_build_end_element(GMarkupParseContext * context,
+                              const gchar * element_name,
+                              gpointer user_data,
+                              GError ** error)
+{
+    BmpXmlDocument *document;
+
+    document = BMP_XML_DOCUMENT(user_data);
+    document->current_node = document->current_node->parent;
+    document->current_depth--;
+}
+
+static void
+bmp_xml_doc_build_text(GMarkupParseContext * context,
+                       const gchar * text,
+                       gsize text_len,
+                       gpointer user_data,
+                       GError ** error)
+{
+    BmpXmlDocument *document;
+    document = BMP_XML_DOCUMENT(user_data);
+    g_node_append(document->current_node,
+                  bmp_xml_text_node_new(text, text_len));
+}
+
+static void
+bmp_xml_doc_build_ignore(GMarkupParseContext * context,
+                         const gchar * text,
+                         gsize text_len,
+                         gpointer user_data,
+                         GError ** error)
+{
+}
+
+static void
+bmp_xml_doc_build_error(GMarkupParseContext * context,
+                        GError * error,
+                        gpointer user_data)
+{
+}
+
+static void
+bmp_xml_doc_build_destroy(BmpXmlDocument * document)
+{
+    g_markup_parse_context_free(document->parse_context);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libaudacious/xml_document.h	Wed Jan 18 10:38:51 2006 -0800
@@ -0,0 +1,90 @@
+/*  BMP - Cross-platform multimedia player
+ *  Copyright (C) 2003-2004  BMP development team.
+ *
+ *  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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef XML_DOCUMENT_H
+#define XML_DOCUMENT_H
+
+#include <glib.h>
+
+typedef enum {
+    BMP_XML_NODE_DOC = 0,
+    BMP_XML_NODE_ELEMENT,
+    BMP_XML_NODE_ATTRIB,
+    BMP_XML_NODE_TEXT
+} BmpXmlNodeType;
+
+#define BMP_XML_DOCUMENT(x)           ((BmpXmlDocument *)(x))
+typedef struct {
+    GNode *tree;
+    GNode *current_node;
+    guint current_depth;
+    GMarkupParseContext *parse_context;
+} BmpXmlDocument;
+
+#define BMP_XML_NODE_DATA(x)          ((BmpXmlNodeData *)(x))
+typedef struct {
+    BmpXmlNodeType type;
+} BmpXmlNodeData;
+
+#define BMP_XML_DOC_NODE_DATA(x)      ((BmpXmlDocNodeData *)(x))
+typedef struct {
+    BmpXmlNodeType type;
+} BmpXmlDocNodeData;
+
+#define BMP_XML_ELEMENT_NODE_DATA(x)  ((BmpXmlElementNodeData *)(x))
+typedef struct {
+    BmpXmlNodeType type;
+    gchar *name;
+} BmpXmlElementNodeData;
+
+#define BMP_XML_ATTRIB_NODE_DATA(x)   ((BmpXmlAttribNodeData *)(x))
+typedef struct {
+    BmpXmlNodeType type;
+    gchar *name;
+    gchar *value;
+} BmpXmlAttribNodeData;
+
+#define BMP_XML_TEXT_NODE_DATA(x)     ((BmpXmlTextNodeData *)(x))
+typedef struct {
+    BmpXmlNodeType type;
+    gchar *text;
+    gsize length;
+} BmpXmlTextNodeData;
+
+
+GNode *bmp_xml_doc_node_new(void);
+void bmp_xml_doc_node_data_free(BmpXmlDocNodeData * data);
+
+GNode *bmp_xml_element_node_new(const gchar * name);
+void bmp_xml_element_node_data_free(BmpXmlElementNodeData * data);
+
+GNode *bmp_xml_attrib_node_new(const gchar * name, const gchar * value);
+void bmp_xml_attrib_node_data_free(BmpXmlAttribNodeData * data);
+
+void bmp_xml_text_node_data_free(BmpXmlTextNodeData * data);
+GNode *bmp_xml_text_node_new(const gchar * text, gsize length);
+
+
+gboolean bmp_xml_document_load(BmpXmlDocument ** document,
+                               const gchar * filename, GError ** error);
+
+void bmp_xml_document_free(BmpXmlDocument * document);
+
+GNode *bmp_xml_document_get_tree(BmpXmlDocument * document);
+
+#endif