+
+#include "dav.h"
+
+CtxType CTX_BLOGPOST = CTX_NONE;
+
+typedef struct __BLOG {
+ HashList *BLOGPOSTS;
+ long p;
+ int gotonext;
+ long firstp;
+ long maxp;
+ StrBuf *Charset;
+ StrBuf *Buf;
+ const StrBuf *FilterTag;
+} BLOG;
+
+/*
+ * Array type for a blog post. The first message is the post; the rest are comments
+ */
+typedef struct _blogpost {
+ int top_level_id;
+ long *msgs; /* Array of msgnums for messages we are displaying */
+ int num_msgs; /* Number of msgnums stored in 'msgs' */
+ int alloc_msgs; /* Currently allocated size of array */
+ int unread_oments;
+}blogpost;
+
+
+/*
+ * XML sitemap generator -- go through the message list for a Blog room
+ */
+void sitemap_do_blog(void) {
+ wcsession *WCC = WC;
+ blogpost oneBP;
+ int num_msgs = 0;
+ int i;
+ SharedMessageStatus Stat;
+ message_summary *Msg = NULL;
+ StrBuf *Buf = NewStrBuf();
+ StrBuf *FoundCharset = NewStrBuf();
+ WCTemplputParams SubTP;
+
+ memset(&Stat, 0, sizeof Stat);
+ memset(&oneBP, 0, sizeof(blogpost));
+ memset(&SubTP, 0, sizeof(WCTemplputParams));
+ StackContext(NULL, &SubTP, &oneBP, CTX_BLOGPOST, 0, NULL);
+
+ Stat.maxload = INT_MAX;
+ Stat.lowest_found = (-1);
+ Stat.highest_found = (-1);
+ num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
+ if (num_msgs < 1) return;
+
+ for (i=0; i<num_msgs; ++i) {
+ Msg = GetMessagePtrAt(i, WCC->summ);
+ if (Msg != NULL) {
+ ReadOneMessageSummary(Msg, FoundCharset, Buf);
+ /* Show only top level posts, not comments */
+ if ((Msg->reply_inreplyto_hash != 0) && (Msg->reply_references_hash == 0)) {
+ oneBP.top_level_id = Msg->reply_inreplyto_hash;
+ DoTemplate(HKEY("view_blog_sitemap"), WCC->WBuf, &SubTP);
+ }
+ }
+ }
+ UnStackContext(&SubTP);
+ FreeStrBuf(&Buf);
+ FreeStrBuf(&FoundCharset);
+}
+