Insert key and value in the group table, not the main table.
[cascardo/atompub.git] / atom / ctx.c
index 678509b..d5011e2 100644 (file)
@@ -24,7 +24,7 @@
 struct _atom_ctx
 {
   AtomError *error;
-  gpointer config_data;
+  AtomConfig *config;
   AtomBackend *backend;
   AtomFrontend *frontend;
   GHashTable *bemap;
@@ -37,7 +37,7 @@ atom_ctx_new ()
   AtomCtx *ctx;
   ctx = g_slice_new (AtomCtx);
   ctx->error = NULL;
-  ctx->config_data = NULL;
+  ctx->config = NULL;
   ctx->backend = NULL;
   ctx->frontend = NULL;
   ctx->bemap = g_hash_table_new_full (g_str_hash, g_str_equal,
@@ -77,16 +77,16 @@ atom_error_get (AtomCtx *ctx)
   return ctx->error;
 }
 
-void *
-atom_config_data (AtomCtx *ctx)
+AtomConfig *
+atom_config (AtomCtx *ctx)
 {
-  return ctx->config_data;
+  return ctx->config;
 }
 
 void
-atom_config_data_set (AtomCtx *ctx, void *data)
+atom_config_set (AtomCtx *ctx, AtomConfig *config)
 {
-  ctx->config_data = data;
+  ctx->config = config;
 }
 
 AtomBackend *
@@ -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;
+}