/* Copyright (c) 2002-2018 Dovecot authors, see the included COPYING file */
#include "pop3-common.h"
#include "array.h"
#include "istream.h"
#include "ostream.h"
#include "hash.h"
#include "str.h"
#include "var-expand.h"
#include "message-size.h"
#include "mail-storage.h"
#include "mail-storage-settings.h"
#include "mail-search-build.h"
#include "pop3-capability.h"
#include "pop3-commands.h"
};
{
}
{
unsigned int num;
"-ERR Invalid message number: %s", args);
return NULL;
}
"-ERR Message number too large: %s", args);
return NULL;
}
"-ERR Noise after message number: %s", args);
return NULL;
}
"-ERR There's no message %u.", num);
return NULL;
}
num--;
return NULL;
}
}
return args;
}
{
args);
return NULL;
}
args);
return NULL;
}
return NULL;
}
return args;
}
{
return 1;
}
{
unsigned int msgnum;
return -1;
}
client->deleted_count++;
return 1;
}
struct cmd_list_context {
unsigned int msgnum;
};
{
break;
if (POP3_CLIENT_OUTPUT_FULL(client)) {
/* buffer full */
return;
}
continue;
}
}
}
{
if (*args == '\0') {
} else {
unsigned int msgnum;
return -1;
}
return 1;
}
{
return 1;
}
{
return 1;
}
static struct mail_search_args *
{
if (seq == 0) {
} else {
}
return search_args;
}
{
i_error("Message ordering changed unexpectedly "
"(msg #%u: storage seq %u -> %u)",
return -1;
}
return 0;
}
{
case POP3_DELETE_TYPE_EXPUNGE:
break;
case POP3_DELETE_TYPE_FLAG:
break;
}
}
{
/* silently ignore */
return TRUE;
}
/* translate msgnums to sequences (in case POP3 ordering is
different) */
}
}
}
}
}
client->seen_change_count = 0;
if (mailbox_search_deinit(&ctx) < 0)
return ret;
}
{
if (!client_update_mails(client)) {
"Storage error during logout.");
return 1;
}
}
return 1;
} else {
}
else
return 1;
}
struct fetch_context {
unsigned char last;
};
{
}
{
const unsigned char *data;
unsigned char add;
int ret;
if (size > 4096)
size = 4096;
add = '\0';
for (i = 0; i < size; i++) {
}
if (data[i] == '\n') {
/* missing CR */
add = '\r';
break;
}
if (--ctx->body_lines == 0) {
i++;
break;
}
}
} else if (data[i] == '.' &&
/* escape the dot */
add = '.';
break;
} else if (data[i] == '\0' &&
WORKAROUND_OUTLOOK_NO_NULS) != 0) {
add = 0x80;
break;
}
}
if (i > 0) {
break;
}
break;
if (ret == 0) {
/* continue later */
return;
}
}
if (add != '\0') {
break;
if (add == 0x80)
}
}
/* didn't end with CRLF */
}
/* Add the missing end of headers line. */
}
*ctx->byte_counter +=
}
{
/* client tried to fetch an expunged message again.
treat this as error so we'll eventually disconnect the
client instead of letting it loop forever. */
return -1;
}
return 1;
}
{
int ret;
return ret;
}
/* mark the message seen with RETR command */
}
}
} else {
}
return 1;
}
{
unsigned int msgnum;
return -1;
client->lowest_retr_pop3_msn == 0)
client->retr_count++;
}
{
client->last_seen_pop3_msn = 0;
client->deleted_count = 0;
client->deleted_size = 0;
}
if (client->seen_change_count > 0) {
client->seen_change_count = 0;
}
/* remove all \Seen flags (as specified by RFC 1460) */
(void)mailbox_search_deinit(&search_ctx);
__func__);
}
return 1;
}
{
return 1;
}
{
unsigned int msgnum;
return -1;
return -1;
}
struct cmd_uidl_context {
bool list_all;
};
static int
bool *permanent_uidl_r)
{
const char *uidl;
*uidl != '\0') {
/* UIDL is already permanent */
*permanent_uidl_r = TRUE;
return 0;
}
return 0;
}
i_unreached();
}
&hdr_md5) < 0) {
i_error("UIDL: Header MD5 lookup failed: %s",
return -1;
} else if (hdr_md5[0] == '\0') {
i_error("UIDL: Header MD5 not found "
"(pop3_uidl_format=%%m not supported by storage?)");
return -1;
}
}
&filename) < 0) {
i_error("UIDL: File name lookup failed: %s",
return -1;
} else if (filename[0] == '\0') {
i_error("UIDL: File name not found "
"(pop3_uidl_format=%%f not supported by storage?)");
return -1;
}
}
&guid) < 0) {
i_error("UIDL: Message GUID lookup failed: %s",
return -1;
} else if (guid[0] == '\0') {
i_error("UIDL: Message GUID not found "
"(pop3_uidl_format=%%g not supported by storage?)");
return -1;
}
}
};
const char *error;
i_error("UIDL: Failed to expand pop3_uidl_format=%s: %s",
return -1;
}
return 0;
}
static bool
{
continue;
}
break;
if (POP3_CLIENT_OUTPUT_FULL(client)) {
/* output is being buffered, continue when there's
more space */
return FALSE;
}
}
/* finished */
return found;
}
{
break;
}
continue;
}
str_truncate(str, 0);
break;
}
break;
/* output is being buffered, continue when there's
more space */
return FALSE;
}
}
/* finished */
if (failed)
}
{
}
HASH_TABLE_DEFINE_TYPE(uidl_counter, char *, void *);
static void
{
char *key;
void *value;
unsigned int counter;
/* duplicate. the value contains the number of duplicates. */
/* the second lookup really should return NULL, but just in
case of some weird UIDLs do this as many times as needed */
}
}
{
const char **seq_uidls;
char *uidl;
wanted_fields = 0;
strcmp);
/* first read all the UIDLs into a temporary [seq] array */
str_truncate(str, 0);
break;
}
}
(void)mailbox_search_deinit(&search_ctx);
if (failed) {
return;
}
/* map UIDLs to msgnums (in case POP3 sort ordering is different) */
}
}
static struct cmd_uidl_context *
{
client->messages_count > 0)
wanted_fields = 0;
}
if (seq == 0) {
}
return ctx;
}
{
if (*args == '\0') {
} else {
unsigned int msgnum;
return -1;
}
return 1;
}
{
/* keep the command uppercased */
switch (*name) {
case 'C':
break;
case 'D':
break;
case 'L':
break;
case 'N':
break;
case 'Q':
break;
case 'R':
break;
case 'S':
break;
case 'T':
break;
case 'U':
break;
}
return -1;
}