duplicate.c revision 76b43e4417bab52e913da39b5f5bc2a130d3f149
/* Copyright (c) 2005-2008 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "istream.h"
#include "ostream.h"
#include "home-expand.h"
#include "file-dotlock.h"
#include "hash.h"
#include "duplicate.h"
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#define DUPLICATE_PATH "~/.dovecot.lda-dupes"
#define COMPRESS_PERCENTAGE 10
#define DUPLICATE_BUFSIZE 4096
#define DUPLICATE_VERSION 2
struct duplicate {
const void *id;
unsigned int id_size;
const char *user;
};
struct duplicate_file_header {
};
struct duplicate_record_header {
};
struct duplicate_file {
struct hash_table *hash;
const char *path;
int new_fd;
unsigned int changed:1;
};
static struct dotlock_settings duplicate_dotlock_set = {
};
{
}
static unsigned int duplicate_hash(const void *p)
{
/* a char* hash function from ASU -- from glib */
const struct duplicate *d = p;
unsigned int g, h = 0;
while (s != end) {
h = (h << 4) + *s;
if ((g = h & 0xf0000000UL)) {
h = h ^ (g >> 24);
h = h ^ g;
}
s++;
}
return h ^ strcase_hash(d->user);
}
static int
unsigned int record_size)
{
const unsigned char *data;
struct duplicate_record_header hdr;
unsigned int change_count;
change_count = 0;
if (record_size == sizeof(hdr))
else {
/* FIXME: backwards compatibility with v1.0 */
}
return -1;
}
return -1;
}
/* still valid, save it */
struct duplicate *d;
void *new_id;
} else {
change_count++;
}
}
return 0;
}
{
struct duplicate_file_header hdr;
const unsigned char *data;
int fd;
unsigned int record_size = 0;
if (fd == -1) {
return 0;
return -1;
}
/* <timestamp> <id_size> <user_size> <id> <user> */
/* FIXME: backwards compatibility with v1.0 */
record_size = sizeof(struct duplicate_record_header);
}
}
if (record_size == 0 ||
}
return 0;
}
{
struct duplicate_file *file;
(void)duplicate_read(file);
return file;
}
{
}
{
struct duplicate d;
if (duplicate_file == NULL)
}
{
struct duplicate *d;
void *new_id;
if (duplicate_file == NULL)
}
void duplicate_flush(void)
{
struct duplicate_file_header hdr;
struct duplicate_record_header rec;
struct hash_iterate_context *iter;
return;
}
}
void duplicate_init(void)
{
}
void duplicate_deinit(void)
{
if (duplicate_file != NULL) {
}
}