From 33e5062bb64192d721c9be93bfb321da554791d6 Mon Sep 17 00:00:00 2001 From: Art Cancro Date: Fri, 10 Sep 2010 10:38:49 -0400 Subject: [PATCH] Rewrote the message reading loop of feed_generator.c using load_msg_ptrs() --- webcit/feed_generator.c | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/webcit/feed_generator.c b/webcit/feed_generator.c index a73906763..b9f3ac54d 100644 --- a/webcit/feed_generator.c +++ b/webcit/feed_generator.c @@ -80,38 +80,30 @@ void feed_rss_one_message(long msgnum) { * RSS feed generator -- go through the message list */ void feed_rss_do_messages(void) { - char buf[1024]; - long *msgs = NULL; + wcsession *WCC = WC; int num_msgs = 0; - int num_msgs_alloc = 0; int i; + SharedMessageStatus Stat; + message_summary *Msg = NULL; - serv_puts("MSGP text/html|text/plain"); /* identify our preferred mime types */ - serv_getln(buf, sizeof buf); /* don't care about the result */ - - serv_puts("MSGS ALL"); /* ask for all messages in the room */ - 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); - } + memset(&Stat, 0, sizeof Stat); + Stat.maxload = INT_MAX; + Stat.lowest_found = (-1); + Stat.highest_found = (-1); + num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL); + if (num_msgs < 1) return; i = num_msgs; /* convention is to feed newest-to-oldest */ while (i > 0) { - feed_rss_one_message(msgs[i-1]); + Msg = GetMessagePtrAt(i-1, WCC->summ); + if (Msg != NULL) { + feed_rss_one_message(Msg->msgnum); + } --i; } - - free(msgs); - } + /* * Entry point for RSS feed generator */ -- 2.39.2