Added request structure
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 02:38:07 +0000 (23:38 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 03:34:15 +0000 (00:34 -0300)
This is needed to allow the core to know about the request made to the
frontend. A request will need to represent more things besides a type
and the requested object, like the entry or data provided, in the case
of a POST or PUT, for example.

atom/Makefile.am
atom/request.c [new file with mode: 0644]
include/atompub/Makefile.am
include/atompub/atom.h
include/atompub/request.h [new file with mode: 0644]

index 28a604e..439d11a 100644 (file)
@@ -1,6 +1,6 @@
 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
+               config.c ctx.c backend.c error.c frontend.c request.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)
diff --git a/atom/request.c b/atom/request.c
new file mode 100644 (file)
index 0000000..6a39497
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ *  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>
+
+struct _atom_request
+{
+  int type;
+  char *request;
+};
+
+AtomRequest *
+atom_request_new (int type, char *request)
+{
+  AtomRequest *req;
+  req = g_slice_new (AtomRequest);
+  req->type = type;
+  req->request = g_strdup (request);
+  return req;
+}
+
+void
+atom_request_delete (AtomRequest *req)
+{
+  if (req->request)
+    g_free (req->request);
+  g_slice_free (AtomRequest, req);
+}
+
+int
+atom_request_type (AtomRequest *req)
+{
+  return req->type;
+}
+
+char *
+atom_request_request (AtomRequest *req)
+{
+  return req->request;
+}
index 3c00973..0a4af0a 100644 (file)
@@ -1,4 +1,4 @@
 pkginclude_HEADERS = atom.h config.h ctx.h entry.h person.h error.h feed.h \
                id.h iri.h backend.h atom-glib.h error-glib.h atom-xml.h \
                entry-xml.h person-xml.h feed-xml.h globals.h \
-               map.h frontend.h
+               map.h frontend.h request.h
index e374963..ee56898 100644 (file)
@@ -32,5 +32,6 @@
 #include <atompub/backend.h>
 #include <atompub/map.h>
 #include <atompub/frontend.h>
+#include <atompub/request.h>
 
 #endif
diff --git a/include/atompub/request.h b/include/atompub/request.h
new file mode 100644 (file)
index 0000000..b3c84f1
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ *  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_REQUEST_H
+#define ATOMPUB_REQUEST_H
+
+#include <atompub/ctx.h>
+
+enum
+{
+  ATOM_REQUEST_NONE,
+  ATOM_REQUEST_GET
+};
+
+typedef struct _atom_request AtomRequest;
+
+AtomRequest *atom_request_new (int, char *);
+void atom_request_delete (AtomRequest *);
+int atom_request_type (AtomRequest *);
+char *atom_request_request (AtomRequest *);
+
+#endif