From: Thadeu Lima de Souza Cascardo Date: Mon, 13 Oct 2008 00:14:00 +0000 (-0300) Subject: Added functions to convert AtomID from and to frontend and backend requests X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fatompub.git;a=commitdiff_plain;h=fa0617be40ce39e9c159ab785bbf41ec93372b4a Added functions to convert AtomID from and to frontend and backend requests --- diff --git a/atom/ctx.c b/atom/ctx.c index 678509b..37a5a0d 100644 --- a/atom/ctx.c +++ b/atom/ctx.c @@ -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; +} diff --git a/include/atompub/id.h b/include/atompub/id.h index e1c9a62..60e2ff2 100644 --- a/include/atompub/id.h +++ b/include/atompub/id.h @@ -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 *);