subscription-file.c revision c485524d09c650ff6e6c552129d4257ac6145a8b
/* Copyright (C) 2002-2003 Timo Sirainen */
#include "lib.h"
#include "istream.h"
#include "ostream.h"
#include "nfs-workarounds.h"
#include "file-dotlock.h"
#include "mail-storage-private.h"
#include "subscription-file.h"
#include <unistd.h>
#include <fcntl.h>
#define MAX_MAILBOX_LENGTH PATH_MAX
#define SUBSCRIPTION_FILE_LOCK_TIMEOUT 120
#define SUBSCRIPTION_FILE_CHANGE_TIMEOUT 30
struct subsfile_list_context {
struct mail_storage *storage;
const char *path;
bool failed;
};
{
else {
"%s failed with subscription file %s: %m",
}
}
bool ignore_estale)
{
const char *line;
return NULL;
switch (i_stream_read(input)) {
case -1:
if (input->stream_errno != 0 &&
"read()", path);
}
return NULL;
case -2:
/* mailbox name too large */
"Subscription file %s contains lines longer "
"than %u characters", path,
return NULL;
}
}
return line;
}
{
struct dotlock_settings dotlock_set;
const char *line;
name = "INBOX";
if (fd_out == -1) {
"Timeout waiting for subscription file lock");
} else {
"file_dotlock_open()", path);
}
return -1;
}
(void)file_dotlock_delete(&dotlock);
return -1;
}
if (!set)
continue;
}
path);
break;
}
}
/* append subscription */
}
}
if (file_dotlock_delete(&dotlock) < 0) {
"file_dotlock_delete()", path);
}
} else {
enum dotlock_replace_flags flags =
"file_dotlock_replace()", path);
}
}
return failed ? -1 : 0;
}
struct subsfile_list_context *
{
struct subsfile_list_context *ctx;
int fd;
return NULL;
}
return ctx;
}
{
bool failed;
return failed ? -1 : 0;
}
{
const char *line;
unsigned int i;
int fd;
return NULL;
for (i = 0;; i++) {
break;
/* Reopen the subscription file and re-send everything.
this isn't the optimal behavior, but it's allowed by
IMAP and this way we don't have to read everything into
memory or try to play any guessing games. */
if (fd == -1) {
/* In case of ENOENT all the subscriptions got lost.
Just return end of subscriptions list in that
case. */
"open()",
}
return NULL;
}
}
return line;
}