--- /dev/null
+/*
+ * Copyright (C) 2007 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 <stdlib.h>
+#include <string.h>
+
+void
+cgi_serve_request (AtomCtx *ctx)
+{
+ char *method = getenv ("REQUEST_METHOD");
+ char *path = getenv ("PATH_INFO");
+ if (method == NULL)
+ return;
+ if (path == NULL)
+ {
+ path = atom_config_get_str (ctx, "cgi", "index");
+ }
+ if (!strcmp (method, "GET"))
+ {
+ IRI *iri = iri_new ();
+ Atom *atom;
+ iri_set_path (iri, path);
+ atom = atom_retrieve_resource (ctx, iri);
+ iri_delete (iri);
+ if (atom)
+ {
+ fprintf (stdout, "Content-Type: application/atom+xml\n\n");
+ write (stdout, atom_string (atom), atom_len (atom));
+ atom_delete (atom);
+ }
+ }
+ else
+ {
+ fprintf (stdout, "Status: 501 Not Implemented\n\n");
+ }
+}
atompub_CFLAGS = -I$(top_srcdir)/include
atompub_CFLAGS += $(GLIB_CFLAGS)
atompub_LDADD = -L$(top_builddir)/backend/files -lgiochannel
+atompub_LDADD = -L$(top_builddir)/frontend/cgi -lcgi
atompub_LDADD += -L$(top_builddir)/config -lgkeyfile
atompub_LDADD += -L$(top_builddir)/atom -latom
atompub_LDADD += -L$(top_builddir)/iri -liri