zlib-plugin.c revision b9efa6340aade86385e40b446cbdc306c64dec6d
/* Copyright (c) 2005-2010 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "istream.h"
#include "ostream.h"
#include "mail-user.h"
#include "index-storage.h"
#include "index-mail.h"
#include "istream-zlib.h"
#include "ostream-zlib.h"
#include "zlib-plugin.h"
#include <stdlib.h>
#include <fcntl.h>
#define ZLIB_PLUGIN_DEFAULT_LEVEL 6
#define ZLIB_CONTEXT(obj) \
#define ZLIB_MAIL_CONTEXT(obj) \
#define ZLIB_USER_CONTEXT(obj) \
#ifndef HAVE_ZLIB
# define i_stream_create_zlib NULL
# define o_stream_create_zlib NULL
#endif
#ifndef HAVE_BZLIB
# define i_stream_create_bzlib NULL
# define o_stream_create_bzlib NULL
#endif
struct zlib_transaction_context {
};
struct zlib_user {
const struct zlib_handler *save_handler;
int save_level;
};
const char *zlib_plugin_version = DOVECOT_VERSION;
{
const unsigned char *data;
/* Peek in to the stream and see if it looks like it's compressed
(based on its header). This also means that users can try to exploit
security holes in the uncompression library by APPENDing a specially
crafted mail. So let's hope zlib is free of holes. */
return FALSE;
}
{
const unsigned char *data;
return FALSE;
return FALSE;
return FALSE;
return FALSE;
}
{
unsigned int i;
return &zlib_handlers[i];
}
return NULL;
}
{
unsigned int i;
return &zlib_handlers[i];
}
return NULL;
}
{
continue;
return &zlib_handlers[i];
}
return NULL;
}
struct message_size *hdr_size,
struct message_size *body_size,
{
const struct zlib_handler *handler;
stream_r);
}
return -1;
"zlib plugin: Detected %s compression "
return -1;
}
}
}
static struct mail *
struct mailbox_header_lookup_ctx *wanted_headers)
{
union mail_module_context *zmail;
struct mail_private *mail;
return _mail;
}
static struct mailbox_transaction_context *
{
struct mailbox_transaction_context *t;
struct zlib_transaction_context *zt;
return t;
}
static void
{
}
static int
struct mail_transaction_commit_changes *changes_r)
{
int ret;
return ret;
}
static int
{
NULL);
}
}
}
{
return -1;
return -1;
"Saving mails compressed by client isn't supported");
return -1;
}
return 0;
}
static int
{
return -1;
zuser->save_level);
return 0;
}
{
/* a bit kludgy: zlib ostreams' offset is actually the
uncompressed offset */
}
{
} else {
}
}
{
const struct zlib_handler *handler;
int fd;
return 0;
/* looks like a compressed single file mailbox. we should be
able to handle this. */
if (fd == -1) {
return -1;
}
}
return 0;
}
{
MAIL_STORAGE_CLASS_FLAG_OPEN_STREAMS) != 0) {
if (zlib_mailbox_open_input(box) < 0)
return -1;
}
}
{
union mailbox_module_context *zbox;
}
{
const char *name;
}
i_error("zlib_save_level: Level must be between 1..9");
zuser->save_level = 0;
}
}
if (zuser->save_level == 0)
}
static struct mail_storage_hooks zlib_mail_storage_hooks = {
};
{
}
void zlib_plugin_deinit(void)
{
}
const struct zlib_handler zlib_handlers[] = {
};