Mercurial > dovecot > core-2.2
diff src/lib-storage/index/mbox/mbox-expunge.c @ 0:3b1985cbc908 HEAD
Initial revision
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Fri, 09 Aug 2002 12:15:38 +0300 |
parents | |
children | 82b7de533f98 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/lib-storage/index/mbox/mbox-expunge.c Fri Aug 09 12:15:38 2002 +0300 @@ -0,0 +1,35 @@ +/* Copyright (C) 2002 Timo Sirainen */ + +#include "lib.h" +#include "mbox-storage.h" + +int mbox_expunge_locked(IndexMailbox *ibox, + MailExpungeFunc expunge_func, void *user_data) +{ + MailIndexRecord *rec; + unsigned int seq, uid; + + /* FIXME: open the mbox file, lock it, and remove the deleted + blocks. probably better to do it in small blocks than to + memmove() megabytes of data.. */ + + rec = index_expunge_seek_first(ibox, &seq); + while (rec != NULL) { + if (rec->msg_flags & MAIL_DELETED) { + /* save UID before deletion */ + uid = rec->uid; + + if (!ibox->index->expunge(ibox->index, rec, + seq, FALSE)) + return FALSE; + + if (expunge_func != NULL) + expunge_func(&ibox->box, seq, uid, user_data); + seq--; + } + rec = ibox->index->next(ibox->index, rec); + seq++; + } + + return TRUE; +}