2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <atompub/atom.h>
21 #include <atompub/atom-xml.h>
24 #include <libxml/tree.h>
35 feed = g_slice_new (AtomFeed);
41 atom_feed_delete (AtomFeed *feed)
44 for (l = g_list_first (feed->entries); l != NULL; l = l->next)
46 atom_entry_delete (l->data);
48 g_slice_free (AtomFeed, feed);
52 atom_feed_entry_append (AtomFeed *feed, AtomEntry *entry)
54 feed->entries = g_list_prepend (feed->entries, entry);
58 atom_feed_entry_append_array (AtomFeed *feed, AtomEntry **entries, size_t len)
61 for (i = 0; i < len; i++)
63 feed->entries = g_list_prepend (feed->entries, entries[i]);
68 atom_feed_to_xmlnode (AtomFeed *feed)
73 node = xmlNewNode (NULL, "feed");
74 for (l = g_list_last (feed->entries); l != NULL; l = l->prev)
76 entry = atom_entry_to_xmlnode (l->data);
77 xmlAddChild (node, entry);
83 atom_feed_string (AtomFeed *feed, char **buffer, size_t *len)
87 doc = xmlNewDoc ("1.0");
88 node = atom_feed_to_xmlnode (feed);
89 xmlNewNs (node, ATOM_NAMESPACE, NULL);
90 xmlDocSetRootElement (doc, node);
91 xmlDocDumpMemory (doc, buffer, len);