Added functions to handle errors, entries or feeds in frontend
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 03:00:08 +0000 (00:00 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Mon, 13 Oct 2008 03:34:16 +0000 (00:34 -0300)
atom/frontend.c
include/atompub/frontend.h

index e530aa8..64d33d5 100644 (file)
@@ -28,6 +28,9 @@ struct _atom_frontend
   void (*map_entries) (AtomCtx *, char **, AtomEntry **, size_t);
   int  (*is_feed) (AtomCtx *, char *);
   AtomRequest * (*get_request) (AtomCtx *);
+  void (*handle_error) (AtomCtx *);
+  void (*handle_entry) (AtomCtx *, AtomEntry *);
+  void (*handle_feed) (AtomCtx *, AtomFeed *);
 };
 
 AtomFrontend *
@@ -71,6 +74,27 @@ atom_frontend_get_request_set (AtomFrontend *frontend,
   frontend->get_request = get_request;
 }
 
+void
+atom_frontend_handle_error_set (AtomFrontend *frontend,
+                               void handle_error (AtomCtx *))
+{
+  frontend->handle_error = handle_error;
+}
+
+void
+atom_frontend_handle_entry_set (AtomFrontend *frontend,
+                               void handle_entry (AtomCtx *, AtomEntry *))
+{
+  frontend->handle_entry = handle_entry;
+}
+
+void
+atom_frontend_handle_feed_set (AtomFrontend *frontend,
+                              void handle_feed (AtomCtx *, AtomFeed *))
+{
+  frontend->handle_feed = handle_feed;
+}
+
 void
 atom_frontend_map_entries (AtomCtx *ctx, char ** reqs,
                           AtomEntry ** entries, size_t len)
@@ -111,3 +135,36 @@ atom_get_request (AtomCtx *ctx)
     }
   return NULL;
 }
+
+void
+atom_handle_error (AtomCtx *ctx)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend (ctx);
+  if (frontend && frontend->handle_error)
+    {
+      frontend->handle_error (ctx);
+    }
+}
+
+void
+atom_handle_entry (AtomCtx *ctx, AtomEntry *entry)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend (ctx);
+  if (frontend && frontend->handle_entry)
+    {
+      frontend->handle_entry (ctx, entry);
+    }
+}
+
+void
+atom_handle_feed (AtomCtx *ctx, AtomFeed *feed)
+{
+  AtomFrontend *frontend;
+  frontend = atom_frontend (ctx);
+  if (frontend && frontend->handle_feed)
+    {
+      frontend->handle_feed (ctx, feed);
+    }
+}
index e3b97d5..80555eb 100644 (file)
@@ -21,6 +21,8 @@
 #define ATOMPUB_FRONTEND_H
 
 #include <atompub/ctx.h>
+#include <atompub/entry.h>
+#include <atompub/feed.h>
 
 typedef struct _atom_frontend AtomFrontend;
 
@@ -32,9 +34,18 @@ void atom_frontend_map_entries_set (AtomFrontend *,
 void atom_frontend_is_feed_set (AtomFrontend *, int (AtomCtx *, char *));
 void atom_frontend_get_request_set (AtomFrontend *,
                                    AtomRequest * (AtomCtx *));
+void atom_frontend_handle_error_set (AtomFrontend *,
+                                    void (AtomCtx *));
+void atom_frontend_handle_entry_set (AtomFrontend *,
+                                    void (AtomCtx *, AtomEntry *));
+void atom_frontend_handle_feed_set (AtomFrontend *,
+                                   void (AtomCtx *, AtomFeed *));
 void atom_map_entries (AtomCtx *, char **, AtomEntry **, size_t);
 int atom_is_feed (AtomCtx *, char *);
 AtomRequest * atom_get_request (AtomCtx *);
+void atom_handle_error (AtomCtx *);
+void atom_handle_entry (AtomCtx *, AtomEntry *);
+void atom_handle_feed (AtomCtx *, AtomFeed *);
 AtomFrontend * atom_frontend (AtomCtx *);
 void atom_frontend_set (AtomCtx *, AtomFrontend *);