/* Copyright (c) 2010-2018 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 "imap-msgpart.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 {
/* if print() returns -1, log this error if non-NULL. otherwise log
the storage error. */
const char *print_error;
};
struct fetch_field {
const char *name;
};
{
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
&metadata) < 0)
return -1;
return 0;
}
{
return 0;
}
{
return 0;
}
{
const char *value;
return -1;
return 0;
}
{
return 0;
}
{
return 0;
}
static void
{
}
{
int ret;
return -1;
return ret;
}
{
return -1;
} else {
return -1;
}
if (add_lf)
}
/* print the header as-is */
str_truncate(str, 0);
if (add_lf)
}
else {
}
}
}
} else {
}
return 0;
}
{
bool binary;
int ret;
i_unreached(); /* we already verified this was ok */
if (binary)
return -1;
}
return ret;
}
{
int ret;
return -1;
return ret;
}
{
const char *value;
return -1;
/* [0] contains the snippet algorithm, skip over it */
return 0;
}
{
int ret;
return -1;
return ret;
}
{
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;
}
{
time_t t;
return -1;
doveadm_print(dec2str(t));
return 0;
}
{
time_t t;
int tz;
return -1;
doveadm_print(dec2str(t));
return 0;
}
{
time_t t;
return -1;
doveadm_print(dec2str(t));
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;
}
{ "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;
fprintf(stderr, "Available fetch fields: hdr.<name> body.<section> binary.<section> %s", fetch_fields[0].name);
}
{
i_zero(&body_field);
name += 4;
}
} else {
}
}
}
{
int ret = 0;
i_error("fetch(%s) failed for box=%s uid=%u: %s",
ret = -1;
}
}
return ret;
}
static int
{
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
{
int ret = 0;
ret = -1;
} T_END;
if (doveadm_mailbox_list_iter_deinit(&iter) < 0)
ret = -1;
return ret;
}
const char *const args[])
{
doveadm_mail_help_name("fetch");
}
{
}
.name = "fetch",
DOVEADM_CMD_PARAM('\0', "fieldstr", CMD_PARAM_STR, CMD_PARAM_FLAG_POSITIONAL | CMD_PARAM_FLAG_DO_NOT_EXPOSE) /* FIXME: horrible hack, remove me when possible */
};