- }
-
- if (num_printed > 0) {
- StrBufAppendPrintf(sj, "</ul>");
- }
-}
-
-#if 0
-
-// Threaded view (entry point)
-//
-void threaded_view(struct http_transaction *h, struct ctdlsession *c, char *which)
-{
- int num_msgs = 0;
- int num_alloc = 0;
- struct mthread *m;
- char buf[1024];
- char refs[1024];
- int i, j, k;
-
- ctdl_printf(c, "MSGS ALL|||9"); // 9 == headers + thread references
- ctdl_readline(c, buf, sizeof(buf));
- if (buf[0] != '1') {
- do_404(h);
- return;
- }
-
- StrBuf *sj = NewStrBuf();
- StrBufAppendPrintf(sj, "<html><body>\r\n");
-
- while (ctdl_readline(c, buf, sizeof buf), strcmp(buf,"000")) {
-
- ++num_msgs;
- if (num_msgs > num_alloc) {
- if (num_alloc == 0) {
- num_alloc = 100;
- m = malloc(num_alloc * sizeof(struct mthread));
- }
- else {
- num_alloc *= 2;
- m = realloc(m, (num_alloc * sizeof(struct mthread)));
- }
- }
-
- memset(&m[num_msgs-1], 0, sizeof(struct mthread));
- m[num_msgs-1].msgnum = extract_long(buf, 0);
- m[num_msgs-1].datetime = extract_long(buf, 1);
- extract_token(m[num_msgs-1].from, buf, 2, '|', sizeof m[num_msgs-1].from);
- m[num_msgs-1].threadhash = extract_int(buf, 6);
- extract_token(refs, buf, 7, '|', sizeof refs);
-
- char *t;
- char *r = refs;
- i = 0;
- while ((t = strtok_r(r, ",", &r))) {
- if (i == 0) {
- m[num_msgs-1].refhashes[0] = atoi(t); // always keep the first one
- }
- else {
- memcpy(&m[num_msgs-1].refhashes[1], &m[num_msgs-1].refhashes[2], sizeof(int)*8 ); // shift the rest
- m[num_msgs-1].refhashes[9] = atoi(t);
- }
- ++i;
- }
-
- }
-
- // Sort by thread. I did read jwz's sorting algorithm and it looks pretty good, but jwz is a self-righteous asshole so we do it our way.
- for (i=0; i<num_msgs; ++i) {
- for (j=9; (j>=0)&&(m[i].parent==0); --j) {
- for (k=0; (k<num_msgs)&&(m[i].parent==0); ++k) {
- if (m[i].refhashes[j] == m[k].threadhash) {
- m[i].parent = k;
- }
- }