Added a backend per context
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 2 Aug 2008 02:22:33 +0000 (23:22 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 2 Aug 2008 02:22:33 +0000 (23:22 -0300)
include/atompub/backend.h
src/backend.c
src/ctx.c

index 5b3756a..ef553d9 100644 (file)
 #include <atompub/entry.h>
 #include <atompub/iri.h>
 
+typedef struct _atom_backend AtomBackend;
+
 Atom * atom_retrieve_resource (AtomCtx *, IRI *);
+AtomBackend * atom_backend (AtomCtx *);
+void atom_backend_set (AtomCtx *, AtomBackend *);
 
 #endif
index cf72b30..c0f0162 100644 (file)
 
 #include <atompub/atom.h>
 
-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;
 }
index 7289ab3..8904b38 100644 (file)
--- 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;
+}