doveadm-mail-fetch.c revision 46d283ef537885386ab3fc72d1831054ea5f986b
25757faf029c369a8318349dafe952e2358df1d8Timo Sirainen/* Copyright (c) 2010-2011 Dovecot authors, see the included COPYING file */
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen ARRAY_DEFINE(fields, const struct fetch_field);
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainenstatic int fetch_user(struct fetch_cmd_context *ctx)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen doveadm_print(ctx->ctx.cur_mail_user->username);
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainenstatic int fetch_mailbox(struct fetch_cmd_context *ctx)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen if (mail_get_special(ctx->mail, MAIL_FETCH_MAILBOX_NAME, &value) < 0)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainenstatic int fetch_mailbox_guid(struct fetch_cmd_context *ctx)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen if (mailbox_get_metadata(ctx->mail->box, MAILBOX_METADATA_GUID,
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainen doveadm_print(guid_128_to_string(metadata.guid));
137ea7ca34005345aa2304a940149b7f3774d727Timo Sirainenstatic int fetch_seq(struct fetch_cmd_context *ctx)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainenstatic int fetch_uid(struct fetch_cmd_context *ctx)
12aad74464367f7e8be11eafe1af985bf7b1adecTimo Sirainenstatic int fetch_guid(struct fetch_cmd_context *ctx)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen if (mail_get_special(ctx->mail, MAIL_FETCH_GUID, &value) < 0)
0727e38ac12efb8963a339daf56255e2be1f29fcTimo Sirainenstatic int fetch_flags(struct fetch_cmd_context *ctx)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen imap_write_flags(str, mail_get_flags(ctx->mail),
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenstatic int fetch_hdr(struct fetch_cmd_context *ctx)
1f1e81aab38d833d1c9cdc244c91fd762e0080d4Timo Sirainen const unsigned char *data;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen if (mail_get_hdr_stream(ctx->mail, &hdr_size, &input) < 0)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen input = i_stream_create_limit(input, hdr_size.physical_size);
70cb37c37e4dce8f57cd3f882f7444e76b918befTimo Sirainen if (i_stream_read_data(input, &data, &size, 0) == -1)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainenstatic int fetch_hdr_field(struct fetch_cmd_context *ctx)
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen const char *const *value;
e9503210d3521a6833ed62dc332fc42ffb0e7a13Timo Sirainen if (mail_get_headers(ctx->mail, ctx->cur_field->name, &value) < 0)
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))
return ret;
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[])