From: Thadeu Lima de Souza Cascardo Date: Fri, 24 Oct 2008 23:49:59 +0000 (-0200) Subject: Implement backend interface to publish entries X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Fatompub.git;a=commitdiff_plain;h=678b016bcbb04d298bcae3a956ad368cfc4864d7 Implement backend interface to publish entries --- diff --git a/atom/backend.c b/atom/backend.c index 793d23f..1b3ff32 100644 --- a/atom/backend.c +++ b/atom/backend.c @@ -27,6 +27,7 @@ struct _atom_backend { AtomEntry * (*retrieve_entry) (AtomCtx *, char *); void (*enumerate_entries) (AtomCtx *, char ***, AtomEntry ***, size_t *); + void (*publish_entry) (AtomCtx *, char *, AtomEntry *); }; AtomBackend * @@ -63,6 +64,14 @@ atom_backend_enumerate_entries_set (AtomBackend *backend, backend->enumerate_entries = enumerate_entries; } +void +atom_backend_publish_entry_set (AtomBackend *backend, + void publish_entry (AtomCtx *, char *, + AtomEntry *)) +{ + backend->publish_entry = publish_entry; +} + AtomEntry * atom_retrieve_entry (AtomCtx *ctx, char *req) { @@ -127,3 +136,22 @@ atom_retrieve_feed (AtomCtx *ctx) g_free (entries); return feed; } + +void +atom_publish_entry (AtomCtx *ctx, char *req, AtomEntry *entry) +{ + AtomBackend *backend; + AtomError *aerr; + backend = atom_backend (ctx); + if (backend && backend->publish_entry) + { + backend->publish_entry (ctx, req, entry); + } + else + { + aerr = atom_error_new (); + atom_error_code_set (aerr, 501); + atom_error_message_set (aerr, "Not Implemented"); + atom_error_set (ctx, aerr); + } +} diff --git a/include/atompub/backend.h b/include/atompub/backend.h index 93a147a..30c516a 100644 --- a/include/atompub/backend.h +++ b/include/atompub/backend.h @@ -34,9 +34,12 @@ void atom_backend_retrieve_entry_set (AtomBackend *, void atom_backend_enumerate_entries_set (AtomBackend *, void (AtomCtx *, char ***, AtomEntry ***, size_t *)); +void atom_backend_publish_entry_set (AtomBackend *, + void (AtomCtx *, char *, AtomEntry*)); AtomEntry * atom_retrieve_entry (AtomCtx *, char *); void atom_enumerate_entries (AtomCtx *, char ***, AtomEntry ***, size_t *); AtomFeed * atom_retrieve_feed (AtomCtx *); +void atom_publish_entry (AtomCtx *, char *, AtomEntry *); AtomBackend * atom_backend (AtomCtx *); void atom_backend_set (AtomCtx *, AtomBackend *);