static void pop3c_mail_close(struct mail *_mail)
{
struct pop3c_mail *pmail = (struct pop3c_mail *)_mail;
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
/* wait for any prefetch to finish before closing the mail */
while (pmail->prefetching)
static int pop3c_mail_get_received_date(struct mail *_mail, time_t *date_r)
{
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
int tz;
if (mbox->storage->set->pop3c_quick_received_date) {
static int pop3c_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
{
struct index_mail *mail = (struct index_mail *)_mail;
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
struct message_size hdr_size, body_size;
struct istream *input;
static bool pop3c_mail_prefetch(struct mail *_mail)
{
struct pop3c_mail *pmail = (struct pop3c_mail *)_mail;
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
enum pop3c_capability capa;
const char *cmd;
{
struct pop3c_mail *pmail = (struct pop3c_mail *)_mail;
struct index_mail *mail = &pmail->imail;
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
enum pop3c_capability capa;
const char *name, *cmd, *error;
struct istream *input;
pop3c_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
const char **value_r)
{
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)_mail->box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(_mail->box);
switch (field) {
case MAIL_FETCH_UIDL_BACKEND:
struct mail_namespace *ns,
const char **error_r)
{
- struct pop3c_storage *storage = (struct pop3c_storage *)_storage;
+ struct pop3c_storage *storage = POP3C_STORAGE(_storage);
storage->set = mail_namespace_get_driver_settings(ns, _storage);
if (storage->set->pop3c_host[0] == '\0') {
mbox->box.storage = storage;
mbox->box.list = list;
mbox->box.mail_vfuncs = &pop3c_mail_vfuncs;
- mbox->storage = (struct pop3c_storage *)storage;
+ mbox->storage = POP3C_STORAGE(storage);
index_storage_mailbox_alloc(&mbox->box, vname, flags, MAIL_INDEX_PREFIX);
return &mbox->box;
static int pop3c_mailbox_open(struct mailbox *box)
{
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(box);
if (strcmp(box->name, "INBOX") != 0) {
mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
static void pop3c_mailbox_close(struct mailbox *box)
{
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(box);
if (mbox->uidl_pool != NULL)
pool_unref(&mbox->uidl_pool);
enum mailbox_status_items items,
struct mailbox_status *status_r)
{
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(box);
if (index_storage_get_status(box, items, status_r) < 0)
return -1;
static bool pop3c_storage_is_inconsistent(struct mailbox *box)
{
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(box);
return index_storage_is_inconsistent(box) ||
!pop3c_client_is_connected(mbox->client);
bool prefetching_body:1;
};
+#define POP3C_STORAGE(s) container_of(s, struct pop3c_storage, storage)
+#define POP3C_MAILBOX(s) container_of(s, struct pop3c_mailbox, box)
+
struct mail *
pop3c_mail_alloc(struct mailbox_transaction_context *t,
enum mail_fetch_field wanted_fields,
struct mailbox_sync_context *
pop3c_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags)
{
- struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box;
+ struct pop3c_mailbox *mbox = POP3C_MAILBOX(box);
int ret = 0;
if ((flags & MAILBOX_SYNC_FLAG_FULL_READ) != 0 &&