serv_nntp.c: move to new API
authorArt Cancro <ajc@citadel.org>
Thu, 17 Aug 2023 22:13:33 +0000 (13:13 -0900)
committerArt Cancro <ajc@citadel.org>
Thu, 17 Aug 2023 22:13:33 +0000 (13:13 -0900)
citadel/server/modules/nntp/serv_nntp.c
citadel/server/room_ops.c

index 9ea78f11a1e417ccfc15392ecabdb13b546a6f21..30be5027bfe2b92f026f0169953af465838d0336 100644 (file)
@@ -288,15 +288,8 @@ struct nntp_msglist nntp_fetch_msglist(struct ctdlroom *qrbuf) {
        struct nntp_msglist nm;
        struct cdbdata *cdbfr;
 
-       cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf->QRnumber, sizeof(long));
-       if (cdbfr != NULL) {
-               nm.msgnums = (long*)cdbfr->ptr;
-               cdbfr->ptr = NULL;                      // (this needs attention if we move to LMDB)
-               nm.num_msgs = cdbfr->len / sizeof(long);
-               cdbfr->len = 0;
-               cdb_free(cdbfr);
-       }
-       else {
+       nm.num_msgs = CtdlFetchMsgList(qrbuf->QRnumber, &nm.msgnums);
+       if (nm.msgnums < 0) {
                nm.num_msgs = 0;
                nm.msgnums = NULL;
        }
index 344c6b97d47741d17fd7496438b82730bd712d5e..5eb5e69fa67b91b86b23358f4d83100d78feec0f 100644 (file)
@@ -620,6 +620,17 @@ int CtdlFetchMsgList(long roomnum, long **msgs) {
        memcpy(*msgs, cdbfr->ptr, cdbfr->len);
                num_msgs = cdbfr->len / sizeof(long);
                cdb_free(cdbfr);
+       // BEGIN diagnostic section remove this
+       syslog(LOG_DEBUG, "\033[7mCtdlFetchMsgList(%ld) %d messages\033[0m", roomnum, num_msgs);
+       int i;
+       long *p = *msgs;
+       long msgnum;
+       if (num_msgs>0) for (i=0; i<num_msgs; ++i) {
+               memcpy(&msgnum, p, sizeof(long));
+               p++;
+               syslog(LOG_DEBUG, "\033[7m%ld\033[0m", msgnum);
+       }
+       // END diagnostic section remove this
        return(num_msgs);
 }