subscription-file.c revision 7c424aa51c956c628e3512055841aa2f9eef4833
/* Copyright (C) 2002 Timo Sirainen */
/* ugly code here - text files are annoying to manage */
#include "lib.h"
#include "file-lock.h"
#include "mmap-util.h"
#include "write-full.h"
#include "imap-match.h"
#include "mail-storage.h"
#include "subscription-file.h"
#include <unistd.h>
#include <fcntl.h>
#define SUBSCRIPTION_FILE_NAME ".subscriptions"
{
"%s failed with subscription file %s: %m",
return FALSE;
}
{
int fd;
if (fd == -1) {
return -1;
}
return -2;
}
/* FIXME: we should work without locking, rename() would be easiest
but .lock would work too */
return -1;
}
if (*mmap_base == MAP_FAILED) {
return -1;
}
return fd;
}
const char *path)
{
char *buf;
/* @UNSAFE */
buf[0] = '\n';
if (prefix_lf)
len += 2;
else {
buf++;
len++;
}
return FALSE;
}
return TRUE;
}
{
void *mmap_base;
const char *path;
char *subscriptions, *end, *p;
name = "INBOX";
if (fd == -1)
return FALSE;
if (subscriptions == NULL)
p = NULL;
else {
for (p = subscriptions; p != end; p++) {
/* make sure beginning and end matches too */
break;
}
}
if (p == end)
p = NULL;
}
/* remove it */
path);
}
/* append it */
prefix_lf = mmap_length > 0 &&
}
}
}
return !failed;
}
{
struct imap_match_glob *glob;
void *mmap_base;
if (fd < 0) {
/* -2 = no subscription file, ignore */
}
while (ret) {
t_push();
if (*p == '\n')
break;
}
t_pop();
if (p == end)
break;
start = p+1;
}
return ret;
}