doveadm-mail-fetch.c revision 7d56dc75f70aaea4369f4bfcffb0cd1b5abe1ca9
/* Copyright (c) 2010-2015 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "istream.h"
#include "ostream.h"
#include "str.h"
#include "message-address.h"
#include "message-size.h"
#include "message-parser.h"
#include "message-header-decode.h"
#include "message-decoder.h"
#include "imap-util.h"
#include "mail-user.h"
#include "mail-storage.h"
#include "mail-search.h"
#include "mail-namespace.h"
#include "doveadm-print.h"
#include "doveadm-mail.h"
#include "doveadm-mailbox-list-iter.h"
#include "doveadm-mail-iter.h"
#include <stdio.h>
struct fetch_cmd_context {
struct doveadm_mail_cmd_context ctx;
const struct fetch_field *cur_field;
};
struct fetch_field {
const char *name;
};
{
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
struct mailbox_metadata metadata;
&metadata) < 0)
return -1;
return 0;
}
{
return 0;
}
{
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
return 0;
}
{
return 0;
}
{
struct message_size hdr_size;
int ret;
return -1;
return ret;
}
{
return -1;
} else {
return -1;
}
if (add_lf)
}
/* print the header as-is */
struct message_address *addr;
str_truncate(str, 0);
if (add_lf)
}
else {
}
}
}
} else {
}
return 0;
}
{
struct message_size hdr_size;
return -1;
return doveadm_print_istream(input);
}
{
const char *value;
return -1;
/* [0] contains the snippet algorithm, skip over it */
return 0;
}
{
return -1;
return doveadm_print_istream(input);
}
{
struct message_parser_ctx *parser;
struct message_decoder_context *decoder;
struct message_part *parts;
int ret = 0;
return -1;
0);
&block))
continue;
else {
}
}
}
doveadm_print_stream("", 0);
if (input->stream_errno != 0) {
return -1;
}
return 0;
}
{
return -1;
return 0;
}
{
return -1;
return 0;
}
{
time_t t;
return -1;
return 0;
}
{
time_t t;
int tz;
char chr;
return -1;
return 0;
}
{
time_t t;
return -1;
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
const char *value;
return -1;
return 0;
}
static const struct fetch_field fetch_fields[] = {
{ "user", 0, fetch_user },
{ "mailbox", 0, fetch_mailbox },
{ "mailbox-guid", 0, fetch_mailbox_guid },
{ "seq", 0, fetch_seq },
{ "uid", 0, fetch_uid },
{ "guid", 0, fetch_guid },
{ "modseq", 0, fetch_modseq },
{ "text", MAIL_FETCH_STREAM_HEADER |
{ "text.utf8", MAIL_FETCH_STREAM_HEADER |
};
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(fetch_fields); i++) {
return &fetch_fields[i];
}
return NULL;
}
static void print_fetch_fields(void)
{
unsigned int i;
}
{
const struct fetch_field *field;
struct fetch_field hdr_field;
name += 4;
} else {
}
}
}
}
{
const struct fetch_field *field;
int ret = 0;
i_error("fetch(%s) failed for box=%s uid=%u: %s",
ret = -1;
}
}
return ret;
}
static int
{
struct doveadm_mail_iter *iter;
int ret = 0;
&iter) < 0)
return -1;
T_BEGIN {
if (cmd_fetch_mail(ctx) < 0)
ret = -1;
} T_END;
}
if (doveadm_mail_iter_deinit(&iter) < 0)
ret = -1;
return ret;
}
static int
{
const enum mailbox_list_iter_flags iter_flags =
struct doveadm_mailbox_list_iter *iter;
const struct mailbox_info *info;
int ret = 0;
ret = -1;
} T_END;
if (doveadm_mailbox_list_iter_deinit(&iter) < 0)
ret = -1;
return ret;
}
const char *const args[])
{
const char *fetch_fields = args[0];
doveadm_mail_help_name("fetch");
}
static struct doveadm_mail_cmd_context *cmd_fetch_alloc(void)
{
struct fetch_cmd_context *ctx;
doveadm_print_init("pager");
}
struct doveadm_mail_cmd cmd_fetch = {
};