From: Art Cancro Date: Wed, 8 Sep 2010 21:52:13 +0000 (-0400) Subject: More work on the RSS feed generator. The fetch loop is in place, now to just tune... X-Git-Tag: v8.01~731 X-Git-Url: https://code.citadel.org/?a=commitdiff_plain;h=38654157de673b1d9e1d6d87f7db4e226cdef273;p=citadel.git More work on the RSS feed generator. The fetch loop is in place, now to just tune the individual message output and we'll be ready for testing... --- diff --git a/webcit/feed_generator.c b/webcit/feed_generator.c index 107856dc5..e7bcaa2eb 100644 --- a/webcit/feed_generator.c +++ b/webcit/feed_generator.c @@ -1,7 +1,7 @@ /* * RSS/Atom feed generator * - * Copyright (c) 2005-2010 by the citadel.org team + * Copyright (c) 2010 by the citadel.org team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,9 +22,54 @@ #include "webserver.h" +/* + * RSS feed generator -- do one message + */ +void feed_rss_one_message(long msgnum) { + wc_printf(""); + wc_printf("title %ld title", msgnum); + wc_printf("Wed, 08 Sep 2010 20:03:21 GMT"); + wc_printf("http://xxxxx.xxxx.xxxxxx.xxxx.xxx"); + wc_printf("<b>foo bar baz:</b> message %ld", msgnum); + wc_printf("xxxx-xxxx-xxxx-xxxx-xxxx-xxxx"); + wc_printf(""); +} + +/* + * RSS feed generator -- go through the message list + */ +void feed_rss_do_messages(void) { + char buf[1024]; + long *msgs = NULL; + int num_msgs = 0; + int num_msgs_alloc = 0; + int i; + + serv_puts("MSGS ALL"); + serv_getln(buf, sizeof buf); + if (buf[0] != '1') return; + + while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) + { + if (num_msgs >= num_msgs_alloc) { + num_msgs_alloc += 1024; + msgs = realloc(msgs, num_msgs_alloc*sizeof(long) ); + } + msgs[num_msgs++] = atol(buf); + } + + i = num_msgs; + while (i > 0) { + feed_rss_one_message(msgs[i-1]); + --i; + } + + free(msgs); + +} /* - * Main entry point for GroupDAV requests + * Entry point for RSS feed generator */ void feed_rss(void) { @@ -61,15 +106,7 @@ void feed_rss(void) { // http://linuxtoday.com // -#if 0 - - lorem ipsum dolor sit amet - Wed, 08 Sep 2010 20:03:21 GMT - http://xxxxx.xxxx.xxxxxx.xxxx.xxx - <b>foo bar baz:</b> lorem ipsum dolor sit amet, foo bar eek - xxxx-xxxx-xxxx-xxxx-xxxx-xxxx - -#endif + feed_rss_do_messages(); wc_printf("" ""