#include "groupdav.h"
-/*
- * Array type for a blog post. The first message is the post; the rest are comments
- */
-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 */
-};
-
-
/*
* Generate a permalink for a post
* (Call with NULL arguments to make this function wcprintf() the permalink
}
-/*
- * Data which gets returned from a call to blogview_learn_thread_references()
- */
-struct bltr {
- int id;
- int refs;
-};
-
-
/*
* Entry point for message read operations.
*/
/*
- * Given a 'struct blogpost' containing a msgnum, populate the id
- * and refs fields by fetching them from the Citadel server
+ * Given a msgnum, populate the id and refs fields of
+ * a "struct bltr" by fetching them from the Citadel server
*/
struct bltr blogview_learn_thread_references(long msgnum)
{
{
if (!strncasecmp(ChrPtr(Buf), "msgn=", 5)) {
StrBufCutLeft(Buf, 5);
- bltr.id = abs(HashLittle(ChrPtr(Buf), StrLength(Buf)));
+ bltr.id = ThreadIdHash(Buf);
}
else if (!strncasecmp(ChrPtr(Buf), "wefw=", 5)) {
StrBufCutLeft(Buf, 5); /* trim the field name */
StrBufExtract_token(r, Buf, 0, '|');
- bltr.refs = abs(HashLittle(ChrPtr(r), StrLength(r)));
+ bltr.refs = ThreadIdHash(r);
}
}
}
bp = malloc(sizeof(struct blogpost));
if (!bp) return(200);
memset(bp, 0, sizeof (struct blogpost));
- bp->top_level_id = b.id;
+ bp->top_level_id = b.id;
Put(BLOG, (const char *)&b.id, sizeof(b.id), bp,
(DeleteHashDataFunc)blogpost_render_and_destroy);
}
/*
* Sort a list of 'struct blogpost' objects by newest-to-oldest msgnum.
- */
int blogview_sortfunc(const void *s1, const void *s2) {
long *l1 = (long *)(s1);
long *l2 = (long *)(s2);
if (*l1 < *l2) return(+1);
return(0);
}
+ */
+
+/*
+ * We have to move the render code into this function because it needs to be sorted,
+ * and possibly culled to a specific number of messages or date range...
+ */
int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
{
- /* HashList *BLOG = (HashList *) *ViewSpecific; */
-
- /*
- * No code needed here -- we render during disposition.
- * Maybe this is the location where we want to handle pretty permalinks.
- */
+ HashList *BLOG = (HashList *) *ViewSpecific;
+ HashPos *it;
+ const char *Key;
+ void *Data;
+ long len;
+ struct blogpost *bp;
+
+ it = GetNewHashPos(BLOG, 0);
+ while (GetNextHashPos(BLOG, it, &len, &Key, &Data)) {
+ bp = (struct blogpost *) Data;
+ wc_printf("Top level ID is %d\n", bp->top_level_id);
+ if (bp->num_msgs > 0) {
+ wc_printf("; top level msgnum is %ld", bp->msgs[0]);
+ }
+ wc_printf("<br>\n");
+ }
+ DeleteHashPos(&it);
return(0);
}