doveadm-mail-fetch.c revision c4ac0f222613903b7f8c9e0825198396e6bf793e
e59faf65ce864fe95dc00f5d52b8323cdbd0608aTimo Sirainen/* Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file */
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen ARRAY_DEFINE(fields, const struct fetch_field);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int fetch_user(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen doveadm_print(ctx->ctx.cur_mail_user->username);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int fetch_mailbox(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME, &value) < 0)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int fetch_mailbox_guid(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (mailbox_get_metadata(ctx->mail->box, MAILBOX_METADATA_GUID,
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen doveadm_print(guid_128_to_string(metadata.guid));
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int fetch_seq(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int fetch_uid(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int fetch_guid(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (mail_get_special(ctx->mail, MAIL_FETCH_GUID, &value) < 0)
e6440616c02bb1404dc35debf45d9741260c7831Timo Sirainenstatic int fetch_flags(struct fetch_cmd_context *ctx)
e6440616c02bb1404dc35debf45d9741260c7831Timo Sirainen imap_write_flags(str, mail_get_flags(ctx->mail),
e6440616c02bb1404dc35debf45d9741260c7831Timo Sirainenstatic int fetch_hdr(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const unsigned char *data;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (mail_get_hdr_stream(ctx->mail, &hdr_size, &input) < 0)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen input = i_stream_create_limit(input, hdr_size.physical_size);
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (i_stream_read_data(input, &data, &size, 0) == -1)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainenstatic int fetch_hdr_field(struct fetch_cmd_context *ctx)
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen const char *const *value, *filter, *name = ctx->cur_field->name;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen unsigned int pos;
1ac7c8e9040e0d0b7e9f849e45b94bfe919595a9Timo Sirainen if (mail_get_headers(ctx->mail, name, &value) < 0)
FALSE);
if (add_lf)
const unsigned char *data;
int ret = 0;
if (size == 0)
return ret;
const unsigned char *data;
int ret = 0;
if (size == 0)
return ret;
int ret = 0;
&block))
time_t t;
time_t t;
int tz;
char chr;
time_t t;
const char *value;
const char *value;
const char *value;
const char *value;
return &fetch_fields[i];
return NULL;
static void print_fetch_fields(void)
T_BEGIN {
} T_END;
} T_END;
const char *const args[])