From 0585e4c354924c71a990fb75536a6c6c8313c510 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sun, 26 Oct 2008 18:50:50 -0200 Subject: [PATCH] Implement publish handler in CGI frontend --- frontend/cgi/cgi.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontend/cgi/cgi.c b/frontend/cgi/cgi.c index 9b1b8d0..ec011ce 100644 --- a/frontend/cgi/cgi.c +++ b/frontend/cgi/cgi.c @@ -191,6 +191,22 @@ cgi_handle_feed (AtomCtx *ctx, AtomFeed *feed) g_free (str); } +static void +cgi_handle_publish (AtomCtx *ctx, AtomEntry *entry) +{ + char * str; + size_t len; + char *req; + req = atom_id_to_backend (ctx, atom_entry_id (entry)); + fprintf (stdout, "Status: 201 Created\n"); + fprintf (stdout, "Location: %s%s\n", getbaseurl (), req); + cgi_write_header (); + atom_entry_string (entry, &str, &len); + atom_entry_delete (entry); + write (1, str, len); + g_free (str); +} + static int cgi_is_feed (AtomCtx *ctx, char *req) { @@ -208,5 +224,6 @@ cgi_frontend (void) atom_frontend_handle_error_set (frontend, cgi_handle_error); atom_frontend_handle_entry_set (frontend, cgi_handle_entry); atom_frontend_handle_feed_set (frontend, cgi_handle_feed); + atom_frontend_handle_publish_set (frontend, cgi_handle_publish); return frontend; } -- 2.20.1