Added frontend requests mapping
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 12 Oct 2008 20:11:39 +0000 (17:11 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sun, 12 Oct 2008 20:11:39 +0000 (17:11 -0300)
atom/ctx.c
include/atompub/map.h

index 8519b31..678509b 100644 (file)
@@ -28,6 +28,7 @@ struct _atom_ctx
   AtomBackend *backend;
   AtomFrontend *frontend;
   GHashTable *bemap;
+  GHashTable *femap;
 };
 
 AtomCtx *
@@ -41,6 +42,8 @@ atom_ctx_new ()
   ctx->frontend = NULL;
   ctx->bemap = g_hash_table_new_full (g_str_hash, g_str_equal,
                                       g_free, g_free);
+  ctx->femap = g_hash_table_new_full (g_str_hash, g_str_equal,
+                                      g_free, g_free);
   return ctx;
 }
 
@@ -55,6 +58,8 @@ atom_ctx_delete (AtomCtx *ctx)
     atom_frontend_delete (ctx->frontend);
   if (ctx->bemap)
     g_hash_table_destroy (ctx->bemap);
+  if (ctx->femap)
+    g_hash_table_destroy (ctx->femap);
   g_slice_free (AtomCtx, ctx);
 }
 
@@ -120,3 +125,16 @@ atom_map_backend_requests (AtomCtx *ctx, char **reqs,
       g_hash_table_replace (ctx->bemap, key, val);
     }
 }
+
+void
+atom_map_frontend_requests (AtomCtx *ctx, char **reqs,
+                            AtomEntry **entries, size_t len)
+{
+  int i;
+  for (i = 0; i < len; i++)
+    {
+      char *key = g_strdup (reqs[i]);
+      char *val = g_strdup (atom_entry_id (entries[i]));
+      g_hash_table_replace (ctx->femap, key, val);
+    }
+}
index 06e180f..1be9525 100644 (file)
@@ -24,5 +24,6 @@
 #include <atompub/entry.h>
 
 void atom_map_backend_requests (AtomCtx *, char **, AtomEntry **, size_t);
+void atom_map_frontend_requests (AtomCtx *, char **, AtomEntry **, size_t);
 
 #endif