maildir-mail.c revision 838e367716bbd5e44b4a1691db9cbf72af53e9f0
/* Copyright (c) 2003-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "istream.h"
#include "index-mail.h"
#include "maildir-storage.h"
#include "maildir-filename.h"
#include "maildir-uidlist.h"
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
static int
{
if (*fd != -1)
return 1;
return 0;
"open(%s) failed: %m", path);
return -1;
}
static int
{
return 1;
return 0;
"stat(%s) failed: %m", path);
return -1;
}
static struct istream *
bool *deleted_r)
{
const char *path;
int fd = -1;
return NULL;
} else {
return NULL;
}
if (fd == -1) {
return NULL;
}
}
{
const char *path;
/* we're going to open the mail anyway */
}
"fstat(maildir) failed: %m");
return -1;
}
if (ret <= 0) {
if (ret == 0)
return -1;
}
} else {
"stat(%s) failed: %m", path);
return -1;
}
}
return 0;
}
{
return 0;
return -1;
return 0;
}
{
return 0;
return -1;
}
static bool
const char **fname_r)
{
return FALSE;
}
return TRUE;
}
{
const struct mail_cache_field *fields;
bool not_pop3_only = FALSE;
if (mail->pop3_state_set)
return mail->pop3_state;
/* if this mail itself has non-pop3 fields we know we're not
pop3-only */
/* get vsize decisions */
if (not_pop3_only) {
} else {
/* also check if there are any non-[pv]size cached fields */
&count);
for (i = 0; i < count; i++) {
else if (dec != MAIL_CACHE_DECISION_NO &&
}
}
if (!not_pop3_only) {
/* either nothing is cached, or only vsize is cached. */
} else if (vsize_dec != MAIL_CACHE_DECISION_YES) {
/* if virtual size isn't cached permanently,
POP3 isn't being used */
} else {
mail->pop3_state = 0;
}
return mail->pop3_state;
}
{
char *p;
return -1;
} else {
}
/* size can be included in filename */
size_r))
return 1;
/* size can be included in uidlist entry */
key);
if (*p == '\0') {
return 1;
}
}
}
return 0;
}
static void
bool vsize)
{
enum mail_fetch_field field;
int pop3_state;
return;
/* already in filename / uidlist. don't add it anywhere,
including to the uidlist if it's already in filename. */
return;
}
/* 1 = pop3-only, 0 = mixed, -1 = no pop3 */
/* if size is wanted permanently, store it to uidlist
so that in case cache file gets lost we can get it quickly */
}
}
{
return 0;
}
return -1;
return 0;
}
/* fallback to reading the file */
return -1;
return 0;
}
{
const char *path;
int ret;
return 0;
}
return -1;
return 0;
}
if (ret <= 0) {
if (ret == 0)
return -1;
}
} else {
/* saved mail which hasn't been committed yet */
"stat(%s) failed: %m", path);
return -1;
}
}
return 0;
}
static int
const char **value_r)
{
if (field == MAIL_FETCH_UIDL_FILE_NAME) {
return -1;
} else {
}
return 0;
}
}
struct message_size *hdr_size,
struct message_size *body_size,
{
bool deleted;
if (deleted)
return -1;
}
}
}
struct mail_vfuncs maildir_mail_vfuncs = {
};