--- /dev/null
+/* Copyright (C) 2003 Timo Sirainen */
+
+#include "common.h"
+#include "mail-storage.h"
+#include "imap-expunge.h"
+
+int imap_expunge(struct mailbox *box, int notify)
+{
+ struct mail_expunge_context *ctx;
+ struct mail *mail;
+ int failed = FALSE;
+
+ ctx = box->expunge_init(box, 0, FALSE);
+ if (ctx == NULL)
+ return FALSE;
+
+ while ((mail = box->expunge_fetch_next(ctx)) != NULL) {
+ if (!mail->expunge(mail, ctx, NULL, notify)) {
+ failed = TRUE;
+ break;
+ }
+ }
+
+ if (!box->expunge_deinit(ctx))
+ return FALSE;
+
+ return !failed;
+}
+
--- /dev/null
+#ifndef __IMAP_EXPUNGE_H
+#define __IMAP_EXPUNGE_H
+
+int imap_expunge(struct mailbox *box, int notify);
+
+#endif
--- /dev/null
+#ifndef __INDEX_EXPUNGE_H
+#define __INDEX_EXPUNGE_H
+
+#include "mail-storage.h"
+#include "index-mail.h"
+
+struct mail_expunge_context {
+ struct index_mailbox *ibox;
+ struct index_mail mail;
+ int expunge_all, fetch_next, failed;
+
+ unsigned int seq;
+ struct mail_index_record *rec;
+
+ unsigned int first_seq, last_seq;
+ struct mail_index_record *first_rec, *last_rec;
+};
+
+struct mail_expunge_context *
+index_storage_expunge_init(struct mailbox *box,
+ enum mail_fetch_field wanted_fields,
+ int expunge_all);
+int index_storage_expunge_deinit(struct mail_expunge_context *ctx);
+struct mail *index_storage_expunge_fetch_next(struct mail_expunge_context *ctx);
+int index_storage_expunge(struct mail *mail, struct mail_expunge_context *ctx,
+ unsigned int *seq_r, int notify);
+
+#endif