From: Thadeu Lima de Souza Cascardo Date: Sat, 2 Aug 2008 02:22:33 +0000 (-0300) Subject: Added a backend per context X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fatompub.git;a=commitdiff_plain;h=cffbf1cf22d9a392a6c60222b1e6ac779866a273 Added a backend per context --- diff --git a/include/atompub/backend.h b/include/atompub/backend.h index 5b3756a..ef553d9 100644 --- a/include/atompub/backend.h +++ b/include/atompub/backend.h @@ -24,6 +24,10 @@ #include #include +typedef struct _atom_backend AtomBackend; + Atom * atom_retrieve_resource (AtomCtx *, IRI *); +AtomBackend * atom_backend (AtomCtx *); +void atom_backend_set (AtomCtx *, AtomBackend *); #endif diff --git a/src/backend.c b/src/backend.c index cf72b30..c0f0162 100644 --- a/src/backend.c +++ b/src/backend.c @@ -19,10 +19,18 @@ #include -extern Atom *giochannel_atom_retrieve_resource (AtomCtx *, IRI *); +struct _atom_backend +{ + Atom * (*retrieve_resource) (AtomCtx *, IRI *); +}; + Atom * atom_retrieve_resource (AtomCtx *ctx, IRI *iri) { - return giochannel_atom_retrieve_resource (ctx, iri); + AtomBackend *backend; + backend = atom_backend (ctx); + if (backend && backend->retrieve_resource) + return backend->retrieve_resource (ctx, iri); + return NULL; } diff --git a/src/ctx.c b/src/ctx.c index 7289ab3..8904b38 100644 --- a/src/ctx.c +++ b/src/ctx.c @@ -25,6 +25,7 @@ struct _atom_ctx { GError *error; gpointer config_data; + AtomBackend *backend; }; AtomCtx * @@ -62,3 +63,15 @@ atom_config_data_set (AtomCtx *ctx, void *data) { ctx->config_data = data; } + +AtomBackend * +atom_backend (AtomCtx *ctx) +{ + return ctx->backend; +} + +void +atom_backend_set (AtomCtx *ctx, AtomBackend *backend) +{ + ctx->backend = backend; +}