More work on the RSS feed generator. The fetch loop is in place, now to just tune...
authorArt Cancro <ajc@citadel.org>
Wed, 8 Sep 2010 21:52:13 +0000 (17:52 -0400)
committerArt Cancro <ajc@citadel.org>
Wed, 8 Sep 2010 21:52:13 +0000 (17:52 -0400)
message output and we'll be ready for testing...

webcit/feed_generator.c

index 107856dc550a342c01b44345b798a201f6f8a686..e7bcaa2ebee9c5db63d36ddb74687518c0d85396 100644 (file)
@@ -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
 #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>&#60;b&#62;foo bar baz:&#60;/b&#62; 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) {
 
@@ -61,15 +106,7 @@ 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>&#60;b&#62;foo bar baz:&#60;/b&#62; 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>"