// IMAP server for the Citadel system
//
-// Copyright (c) 1987-2022 by the citadel.org team
+// Copyright (c) 1987-2023 by the citadel.org team
//
// This program is open source software. Use, duplication, or disclosure
// is subject to the terms of the GNU General Public License, version 3.
#include "../../support.h"
#include "../../config.h"
#include "../../user_ops.h"
+#include "../../room_ops.h"
#include "../../database.h"
#include "../../msgbase.h"
#include "../../internet_addressing.h"
* Set up a message ID map for the current room (folder)
*/
void imap_load_msgids(void) {
- struct cdbdata *cdbfr;
citimap *Imap = IMAP;
if (Imap->selected == 0) {
imap_free_msgids(); /* If there was already a map, free it */
/* Load the message list */
- cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
- if (cdbfr != NULL) {
- Imap->msgids = (long*)cdbfr->ptr;
- Imap->num_msgs = cdbfr->len / sizeof(long);
- Imap->num_alloc = cdbfr->len / sizeof(long);
- cdbfr->ptr = NULL; // (this needs attention if we move to LMDB)
- cdbfr->len = 0;
- cdb_free(cdbfr);
- }
+ Imap->num_msgs = CtdlFetchMsgList(CC->room.QRnumber, &Imap->msgids);
+ Imap->num_alloc = Imap->num_msgs;
if (Imap->num_msgs) {
Imap->flags = malloc(Imap->num_alloc * sizeof(unsigned int));
memset(Imap->flags, 0, (Imap->num_alloc * sizeof(unsigned int)) );
}
-
imap_set_seen_flags(0);
}
long original_highest = 0L;
int i, j, jstart;
int message_still_exists;
- struct cdbdata *cdbfr;
long *msglist = NULL;
int num_msgs = 0;
int num_recent = 0;
/* Load the *current* message list from disk, so we can compare it
* to what we have in memory.
*/
- cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long));
- if (cdbfr != NULL) {
- msglist = (long*)cdbfr->ptr;
- cdbfr->ptr = NULL; // (this needs attention if we move to LMDB)
- num_msgs = cdbfr->len / sizeof(long);
- cdbfr->len = 0;
- cdb_free(cdbfr);
- }
- else {
- num_msgs = 0;
- }
+ num_msgs = CtdlFetchMsgList(CC->room.QRnumber, &msglist);
/*
* Check to see if any of the messages we know about have been expunged
IAPrintf("* %d RECENT\r\n", num_recent);
}
- if (msglist != NULL) {
- free(msglist);
- }
+ free(msglist);
Imap->last_mtime = CC->room.QRmtime;
}
// Load the message list
num_msgs = CtdlFetchMsgList(which_room->QRnumber, &msglist);
if (num_msgs <= 0) {
- if (msglist != NULL) {
- free(msglist);
- }
+ free(msglist);
return;
}
// Load the message list
num_msgs = CtdlFetchMsgList(CC->room.QRnumber, &msglist);
if (num_msgs <= 0) {
- if (msglist) free(msglist);
+ free(msglist);
if (need_to_free_re) regfree(&re);
return 0; // No messages at all? No further action.
}
/*
* GetMetaData() - Get the supplementary record for a message
*/
-void GetMetaData(struct MetaData *smibuf, long msgnum)
-{
+void GetMetaData(struct MetaData *smibuf, long msgnum) {
struct cdbdata *cdbsmi;
long TheIndex;