lib_LTLIBRARIES = libatom.la
libatom_la_SOURCES = id.c entry.c person.c feed.c \
- config.c ctx.c backend.c error.c frontend.c request.c
+ config.c ctx.c backend.c error.c frontend.c request.c \
+ core.c
libatom_la_CFLAGS = -I$(top_srcdir)/include $(GLIB_CFLAGS)
libatom_la_CFLAGS += $(XML_CFLAGS) $(GIO_CFLAGS)
libatom_la_LIBADD = $(GIO_LIBS) $(GLIB_LIBS) $(XML_LIBS)
--- /dev/null
+/*
+ * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * 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 02110-1301 USA.
+ */
+
+
+#include <atompub/atom.h>
+
+#include <glib.h>
+
+#include <string.h>
+
+static
+void atom_get (AtomCtx *ctx, AtomRequest *request)
+{
+ if (atom_is_feed (ctx, atom_request_request (request)))
+ {
+ AtomFeed *feed;
+ feed = atom_retrieve_feed (ctx);
+ if (feed != NULL)
+ {
+ atom_handle_feed (ctx, feed);
+ atom_feed_delete (feed);
+ }
+ }
+ else
+ {
+ AtomEntry *entry;
+ entry = atom_retrieve_entry (ctx, atom_request_request (request));
+ if (entry != NULL)
+ {
+ atom_handle_entry (ctx, entry);
+ atom_entry_delete (entry);
+ }
+ }
+}
+
+void
+atom_serve_request (AtomCtx *ctx)
+{
+ AtomRequest *request;
+ AtomError *error;
+ request = atom_get_request (ctx);
+ if (request != NULL)
+ {
+ if (atom_request_type (request) == ATOM_REQUEST_GET)
+ {
+ atom_get (ctx, request);
+ }
+ else
+ {
+ error = atom_error_new ();
+ atom_error_code_set (error, 501);
+ atom_error_message_set (error, "Not Implemented");
+ atom_error_set (ctx, error);
+ }
+ }
+ if (atom_error_get (ctx))
+ {
+ atom_handle_error (ctx);
+ atom_error_set (ctx, NULL);
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * 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 02110-1301 USA.
+ */
+
+
+#ifndef ATOMPUB_CORE_H
+#define ATOMPUB_CORE_H
+
+#include <atompub/ctx.h>
+
+void atom_serve_request (AtomCtx *);
+
+#endif