From 01b135dee457f16f9061bff489081a2b649ae85b Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sun, 12 Oct 2008 23:38:07 -0300 Subject: [PATCH] Added request structure 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 | 2 +- atom/request.c | 58 +++++++++++++++++++++++++++++++++++++ include/atompub/Makefile.am | 2 +- include/atompub/atom.h | 1 + include/atompub/request.h | 38 ++++++++++++++++++++++++ 5 files changed, 99 insertions(+), 2 deletions(-) create mode 100644 atom/request.c create mode 100644 include/atompub/request.h diff --git a/atom/Makefile.am b/atom/Makefile.am index 28a604e..439d11a 100644 --- a/atom/Makefile.am +++ b/atom/Makefile.am @@ -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 index 0000000..6a39497 --- /dev/null +++ b/atom/request.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2008 Thadeu Lima de Souza Cascardo + * + * 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 + +#include + +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; +} diff --git a/include/atompub/Makefile.am b/include/atompub/Makefile.am index 3c00973..0a4af0a 100644 --- a/include/atompub/Makefile.am +++ b/include/atompub/Makefile.am @@ -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 diff --git a/include/atompub/atom.h b/include/atompub/atom.h index e374963..ee56898 100644 --- a/include/atompub/atom.h +++ b/include/atompub/atom.h @@ -32,5 +32,6 @@ #include #include #include +#include #endif diff --git a/include/atompub/request.h b/include/atompub/request.h new file mode 100644 index 0000000..b3c84f1 --- /dev/null +++ b/include/atompub/request.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2008 Thadeu Lima de Souza Cascardo + * + * 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 + +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 -- 2.20.1