Added map from atom:IDs to backend requests
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 12 Oct 2008 01:43:42 +0000 (22:43 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 12 Oct 2008 04:25:40 +0000 (01:25 -0300)
include/atompub/Makefile.am
include/atompub/atom.h
include/atompub/map.h [new file with mode: 0644]
src/ctx.c

index fb38d4d..9e0f413 100644 (file)
@@ -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
index 73bd5cb..162affc 100644 (file)
@@ -31,5 +31,6 @@
 #include <atompub/feed.h>
 #include <atompub/resource.h>
 #include <atompub/backend.h>
+#include <atompub/map.h>
 
 #endif
diff --git a/include/atompub/map.h b/include/atompub/map.h
new file mode 100644 (file)
index 0000000..06e180f
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ *  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_MAP_H
+#define ATOMPUB_MAP_H
+
+#include <atompub/ctx.h>
+#include <atompub/entry.h>
+
+void atom_map_backend_requests (AtomCtx *, char **, AtomEntry **, size_t);
+
+#endif
index e9d940b..a472dae 100644 (file)
--- 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);
+    }
+}