Use MSG4 instead of MSG0 to output RSS feeds
authorArt Cancro <ajc@uncensored.citadel.org>
Thu, 26 May 2011 15:53:09 +0000 (11:53 -0400)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 4 Sep 2011 20:53:55 +0000 (20:53 +0000)
webcit/feed_generator.c

index f0c34059c46324a1ace8fd7758632fd1d29bfb52..c4072f365b3644089f6d69d9b1f26386253a9f79 100644 (file)
 void feed_rss_one_message(long msgnum) {
        char buf[1024];
        int in_body = 0;
+       int in_messagetext = 0;
        int found_title = 0;
        char pubdate[128];
        StrBuf *messagetext = NULL;
 
        /* FIXME if this is a blog room we only want to include top-level messages */
 
-       serv_printf("MSG0 %ld", msgnum);                /* FIXME we want msg4 eventually */
+       serv_printf("MSG4 %ld", msgnum);
        serv_getln(buf, sizeof buf);
        if (buf[0] != '1') return;
 
@@ -45,8 +46,13 @@ void feed_rss_one_message(long msgnum) {
 
        while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
                if (in_body) {
-                       StrBufAppendBufPlain(messagetext, buf, -1, 0);
-                       StrBufAppendBufPlain(messagetext, HKEY("\r\n"), 0);
+                       if (in_messagetext) {
+                               StrBufAppendBufPlain(messagetext, buf, -1, 0);
+                               StrBufAppendBufPlain(messagetext, HKEY("\r\n"), 0);
+                       }
+                       else if (IsEmptyStr(buf)) {
+                               in_messagetext = 1;
+                       }
                }
                else if (!strncasecmp(buf, "subj=", 5)) {
                        wc_printf("<title>");