* RSS feed generator -- do one message
*/
void feed_rss_one_message(long msgnum) {
- char buf[1024];
int in_body = 0;
int in_messagetext = 0;
int found_title = 0;
int found_guid = 0;
char pubdate[128];
StrBuf *messagetext = NULL;
+ int is_top_level_post = 1;
+ const char *BufPtr = NULL;
+ StrBuf *Line = NewStrBufPlain(NULL, 1024);
+ char buf[1024];
/* FIXME if this is a blog room we only want to include top-level messages */
serv_printf("MSG4 %ld", msgnum);
serv_getln(buf, sizeof buf);
if (buf[0] != '1') return;
+ StrBuf *ServerResponse = NewStrBuf();
+ while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ StrBufAppendPrintf(ServerResponse, "%s\n", buf);
+ }
wc_printf("<item>");
wc_printf("<link>%s/readfwd?go=", ChrPtr(site_prefix));
urlescputs(ChrPtr(WC->CurRoom.name));
wc_printf("?start_reading_at=%ld</link>", msgnum);
- while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
+ while (StrBufSipLine(Line, ServerResponse, &BufPtr), ((BufPtr!=StrBufNOTNULL)&&(BufPtr!=NULL)) ) {
+ safestrncpy(buf, ChrPtr(Line), sizeof buf);
if (in_body) {
if (in_messagetext) {
StrBufAppendBufPlain(messagetext, buf, -1, 0);
http_datestring(pubdate, sizeof pubdate, atol(&buf[5]));
wc_printf("<pubDate>%s</pubDate>", pubdate);
}
+ else if (!strncasecmp(buf, "wefw=", 5)) {
+ is_top_level_post = 0; /* presence of references means it's a reply/comment */
+ }
else if (!strncasecmp(buf, "text", 4)) {
if (!found_title) {
wc_printf("<title>Message #%ld</title>", msgnum);
}
wc_printf("</item>");
+ FreeStrBuf(&Line);
+ FreeStrBuf(&ServerResponse);
+ return;
}
/*