void dbox_mail_close(struct mail *_mail)
{
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
index_mail_close(_mail);
/* close the dbox file only after index is closed, since it may still
int dbox_mail_metadata_read(struct dbox_mail *mail, struct dbox_file **file_r)
{
struct dbox_storage *storage =
- (struct dbox_storage *)mail->imail.mail.mail.box->storage;
+ DBOX_STORAGE(mail->imail.mail.mail.box->storage);
uoff_t offset;
if (storage->v.mail_open(mail, &offset, file_r) < 0)
int dbox_mail_get_physical_size(struct mail *_mail, uoff_t *size_r)
{
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
struct index_mail_data *data = &mail->imail.data;
struct dbox_file *file;
int dbox_mail_get_virtual_size(struct mail *_mail, uoff_t *size_r)
{
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
struct index_mail_data *data = &mail->imail.data;
const char *value;
uintmax_t size;
int dbox_mail_get_received_date(struct mail *_mail, time_t *date_r)
{
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
struct index_mail_data *data = &mail->imail.data;
const char *value;
uintmax_t time;
int dbox_mail_get_save_date(struct mail *_mail, time_t *date_r)
{
- struct dbox_storage *storage =
- (struct dbox_storage *)_mail->box->storage;
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_storage *storage = DBOX_STORAGE(_mail->box->storage);
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
struct index_mail_data *data = &mail->imail.data;
struct dbox_file *file;
struct stat st;
int dbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
const char **value_r)
{
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
int ret;
/* keep the UIDL in cache file, otherwise POP3 would open all
struct message_size *body_size,
struct istream **stream_r)
{
- struct dbox_storage *storage =
- (struct dbox_storage *)_mail->box->storage;
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_storage *storage = DBOX_STORAGE(_mail->box->storage);
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
struct index_mail_data *data = &mail->imail.data;
struct istream *input;
uoff_t offset;
uoff_t offset;
};
+#define DBOX_MAIL(s) container_of(s, struct dbox_mail, imail.mail.mail)
+
struct mail *
dbox_mail_alloc(struct mailbox_transaction_context *t,
enum mail_fetch_field wanted_fields,
{
struct mail_save_context *_ctx = &ctx->ctx;
struct mail_storage *_storage = _ctx->transaction->box->storage;
- struct dbox_storage *storage = (struct dbox_storage *)_storage;
+ struct dbox_storage *storage = DBOX_STORAGE(_storage);
struct dbox_message_header dbox_msg_hdr;
struct istream *crlf_input;
int dbox_save_continue(struct mail_save_context *_ctx)
{
- struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
+ struct dbox_save_context *ctx = DBOX_SAVECTX(_ctx);
if (ctx->failed)
return -1;
const char *orig_mailbox_name,
guid_128_t guid_128)
{
- struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
+ struct dbox_save_context *ctx = DBOX_SAVECTX(_ctx);
struct mail_save_data *mdata = &ctx->ctx.data;
struct dbox_metadata_header metadata_hdr;
const char *guid;
bool have_pop3_orders:1;
};
+#define DBOX_SAVECTX(s) container_of(s, struct dbox_save_context, ctx)
+
void dbox_save_begin(struct dbox_save_context *ctx, struct istream *input);
int dbox_save_continue(struct mail_save_context *_ctx);
void dbox_save_end(struct dbox_save_context *ctx);
struct mail_namespace *ns,
const char **error_r)
{
- struct dbox_storage *storage = (struct dbox_storage *)_storage;
+ struct dbox_storage *storage = DBOX_STORAGE(_storage);
const struct mail_storage_settings *set = _storage->set;
const char *error;
void dbox_storage_destroy(struct mail_storage *_storage)
{
- struct dbox_storage *storage = (struct dbox_storage *)_storage;
+ struct dbox_storage *storage = DBOX_STORAGE(_storage);
if (storage->attachment_fs != NULL)
fs_deinit(&storage->attachment_fs);
int dbox_mailbox_create(struct mailbox *box,
const struct mailbox_update *update, bool directory)
{
- struct dbox_storage *storage = (struct dbox_storage *)box->storage;
+ struct dbox_storage *storage = DBOX_STORAGE(box->storage);
const char *alt_path;
struct stat st;
int ret;
int dbox_mailbox_create_indexes(struct mailbox *box,
const struct mailbox_update *update)
{
- struct dbox_storage *storage = (struct dbox_storage *)box->storage;
+ struct dbox_storage *storage = DBOX_STORAGE(box->storage);
struct mail_index_sync_ctx *sync_ctx;
struct mail_index_view *view;
struct mail_index_transaction *trans;
const char *attachment_dir;
};
+#define DBOX_STORAGE(s) container_of(s, struct dbox_storage, storage)
+
void dbox_storage_get_list_settings(const struct mail_namespace *ns,
struct mailbox_list_settings *set);
int dbox_storage_create(struct mail_storage *storage,
mdbox_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
const char **value_r)
{
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
struct mdbox_mailbox *mbox =
(struct mdbox_mailbox *)_mail->transaction->box;
struct mdbox_map_mail_index_record rec;
void mdbox_save_cancel(struct mail_save_context *_ctx)
{
- struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
+ struct dbox_save_context *ctx = DBOX_SAVECTX(_ctx);
ctx->failed = TRUE;
(void)mdbox_save_finish(_ctx);
static int
sdbox_copy_hardlink(struct mail_save_context *_ctx, struct mail *mail)
{
- struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
+ struct dbox_save_context *ctx = DBOX_SAVECTX(_ctx);
struct sdbox_mailbox *dest_mbox =
(struct sdbox_mailbox *)_ctx->transaction->box;
struct sdbox_mailbox *src_mbox;
const char **value_r)
{
struct sdbox_mailbox *mbox = (struct sdbox_mailbox *)_mail->box;
- struct dbox_mail *mail = (struct dbox_mail *)_mail;
+ struct dbox_mail *mail = DBOX_MAIL(_mail);
struct stat st;
switch (field) {
void sdbox_save_cancel(struct mail_save_context *_ctx)
{
- struct dbox_save_context *ctx = (struct dbox_save_context *)_ctx;
+ struct dbox_save_context *ctx = DBOX_SAVECTX(_ctx);
ctx->failed = TRUE;
(void)sdbox_save_finish(_ctx);
struct mail_namespace *ns,
const char **error_r)
{
- struct dbox_storage *storage = (struct dbox_storage *)_storage;
+ struct dbox_storage *storage = DBOX_STORAGE(_storage);
enum fs_properties props;
if (dbox_storage_create(_storage, ns, error_r) < 0)