/*
* 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
#include "webserver.h"
+/*
+ * RSS feed generator -- do one message
+ */
+void feed_rss_one_message(long msgnum) {
+ wc_printf("<item>");
+ wc_printf("<title>title %ld title</title>", msgnum);
+ wc_printf("<pubDate>Wed, 08 Sep 2010 20:03:21 GMT</pubDate>");
+ wc_printf("<link>http://xxxxx.xxxx.xxxxxx.xxxx.xxx</link>");
+ wc_printf("<description><b>foo bar baz:</b> message %ld</description>", msgnum);
+ wc_printf("<guid>xxxx-xxxx-xxxx-xxxx-xxxx-xxxx</guid>");
+ wc_printf("</item>");
+}
+
+/*
+ * 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) {
// <link>http://linuxtoday.com</link>
// </image>
-#if 0
- <item>
- <title>lorem ipsum dolor sit amet</title>
- <pubDate>Wed, 08 Sep 2010 20:03:21 GMT</pubDate>
- <link>http://xxxxx.xxxx.xxxxxx.xxxx.xxx</link>
- <description><b>foo bar baz:</b> lorem ipsum dolor sit amet, foo bar eek</description>
- <guid>xxxx-xxxx-xxxx-xxxx-xxxx-xxxx</guid>
- </item>
-#endif
+ feed_rss_do_messages();
wc_printf("</channel>"
"</rss>"