pop3-commands.c revision 905320d3d49ad827bf48aede4dd8b7ea5a686af5
/* Copyright (c) 2002-2014 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"
static enum mail_sort_type pop3_sort_program[] = {
};
{
}
unsigned int *msgnum)
{
num = 0;
"-ERR Invalid message number: %s", args);
return NULL;
}
"-ERR Message number too large: %s", args);
return NULL;
}
args++;
}
"-ERR There's no message %u.", num);
return NULL;
}
num--;
return NULL;
}
}
return args;
}
{
num = 0;
args);
return NULL;
}
args);
return NULL;
}
args++;
}
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;
}
}
}
{
struct cmd_list_context *ctx;
if (*args == '\0') {
} else {
unsigned int msgnum;
return -1;
}
return 1;
}
{
return 1;
}
{
return 1;
}
static struct mail_search_args *
{
struct mail_search_args *search_args;
struct mail_search_arg *sarg;
if (seq == 0) {
} else {
}
return search_args;
}
{
i_error("Message ordering changed unexpectedly "
"(msg #%u: storage seq %u -> %u)",
return -1;
}
return 0;
}
{
else
client->expunged_count++;
}
{
struct mail_search_args *search_args;
struct mail_search_context *ctx;
/* silently ignore */
return TRUE;
}
/* translate msgnums to sequences (in case POP3 ordering is
different) */
}
}
}
}
msgnum = 0;
}
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
return 1;
}
struct fetch_context {
unsigned char last;
bool cr_skipped, in_body;
};
{
}
{
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;
}
{
struct fetch_context *ctx;
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++;
}
{
struct mail_search_context *search_ctx;
struct mail_search_args *search_args;
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);
}
return 1;
}
{
return 1;
}
{
unsigned int msgnum;
return -1;
return -1;
}
struct cmd_uidl_context {
struct mail_search_context *search_ctx;
bool list_all;
};
static int
bool *permanent_uidl_r)
{
static struct var_expand_table static_tab[] = {
};
struct var_expand_table *tab;
char uid_str[MAX_INT_STRLEN];
const char *uidl;
*uidl != '\0') {
/* UIDL is already permanent */
*permanent_uidl_r = TRUE;
return 0;
}
return 0;
}
i_unreached();
}
i_error("UIDL: Header MD5 lookup failed: %s",
return -1;
i_error("UIDL: Header MD5 not found "
"(pop3_uidl_format=%%m not supported by storage?)");
return -1;
}
}
i_error("UIDL: File name lookup failed: %s",
return -1;
i_error("UIDL: File name not found "
"(pop3_uidl_format=%%f not supported by storage?)");
return -1;
}
}
i_error("UIDL: Message GUID lookup failed: %s",
return -1;
i_error("UIDL: Message GUID not found "
"(pop3_uidl_format=%%g not supported by storage?)");
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 */
}
}
{
struct mail_search_context *search_ctx;
struct mail_search_args *search_args;
const char **seq_uidls;
char *uidl;
wanted_fields = 0;
/* 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 *
{
struct cmd_uidl_context *ctx;
struct mail_search_args *search_args;
wanted_fields = 0;
}
if (seq == 0) {
}
return ctx;
}
{
struct cmd_uidl_context *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;
}