From: Thadeu Lima de Souza Cascardo Date: Sun, 12 Oct 2008 01:43:42 +0000 (-0300) Subject: Added map from atom:IDs to backend requests X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fatompub.git;a=commitdiff_plain;h=5b8c44ae4d79ea49088f912ff87aae3e935c8f14 Added map from atom:IDs to backend requests --- diff --git a/include/atompub/Makefile.am b/include/atompub/Makefile.am index fb38d4d..9e0f413 100644 --- a/include/atompub/Makefile.am +++ b/include/atompub/Makefile.am @@ -1,3 +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 resource.h + entry-xml.h person-xml.h feed-xml.h globals.h resource.h \ + map.h diff --git a/include/atompub/atom.h b/include/atompub/atom.h index 73bd5cb..162affc 100644 --- a/include/atompub/atom.h +++ b/include/atompub/atom.h @@ -31,5 +31,6 @@ #include #include #include +#include #endif diff --git a/include/atompub/map.h b/include/atompub/map.h new file mode 100644 index 0000000..06e180f --- /dev/null +++ b/include/atompub/map.h @@ -0,0 +1,28 @@ +/* + * 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_MAP_H +#define ATOMPUB_MAP_H + +#include +#include + +void atom_map_backend_requests (AtomCtx *, char **, AtomEntry **, size_t); + +#endif diff --git a/src/ctx.c b/src/ctx.c index e9d940b..a472dae 100644 --- a/src/ctx.c +++ b/src/ctx.c @@ -26,6 +26,7 @@ struct _atom_ctx AtomError *error; gpointer config_data; AtomBackend *backend; + GHashTable *bemap; }; AtomCtx * @@ -36,6 +37,8 @@ atom_ctx_new () ctx->error = NULL; ctx->config_data = NULL; ctx->backend = NULL; + ctx->bemap = g_hash_table_new_full (g_str_hash, g_str_equal, + g_free, g_free); return ctx; } @@ -46,6 +49,8 @@ atom_ctx_delete (AtomCtx *ctx) atom_error_delete (ctx->error); if (ctx->backend) atom_backend_delete (ctx->backend); + if (ctx->bemap) + g_hash_table_destroy (ctx->bemap); g_slice_free (AtomCtx, ctx); } @@ -86,3 +91,16 @@ atom_backend_set (AtomCtx *ctx, AtomBackend *backend) { ctx->backend = backend; } + +void +atom_map_backend_requests (AtomCtx *ctx, char **reqs, + AtomEntry **entries, size_t len) +{ + int i; + for (i = 0; i < len; i++) + { + char *key = g_strdup (atom_entry_id (entries[i])); + char *val = g_strdup (reqs[i]); + g_hash_table_replace (ctx->bemap, key, val); + } +}