Added functions to convert AtomID from and to frontend and backend requests
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 00:14:00 +0000 (21:14 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 00:18:03 +0000 (21:18 -0300)
atom/ctx.c
include/atompub/id.h

index 678509b..37a5a0d 100644 (file)
@@ -138,3 +138,22 @@ atom_map_frontend_requests (AtomCtx *ctx, char **reqs,
       g_hash_table_replace (ctx->femap, key, val);
     }
 }
+
+AtomID *
+atom_id_new_from_frontend (AtomCtx *ctx, char * req)
+{
+  char *id;
+  if (g_hash_table_lookup_extended (ctx->femap, req, NULL, &id))
+    return atom_id_new (id);
+  return NULL;
+}
+
+char *
+atom_id_to_backend (AtomCtx *ctx, AtomID *id)
+{
+  char *key = atom_id_string (id);
+  char *val;
+  if (g_hash_table_lookup_extended (ctx->bemap, key, NULL, &val))
+    return val;
+  return NULL;
+}
index e1c9a62..60e2ff2 100644 (file)
@@ -25,6 +25,8 @@
 typedef struct _atom_id AtomID;
 
 AtomID * atom_id_new (char *);
+AtomID * atom_id_new_from_frontend (AtomCtx *, char *);
+char * atom_id_to_backend (AtomCtx *, AtomID *);
 void atom_id_delete (AtomID *);
 char * atom_id_string (AtomID *);