zlib-plugin.c revision 0b69aadbda25d9b8a81797280f26e206e8ea5875
/* 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 "dbox-single/sdbox-storage.h"
#include "dbox-multi/mdbox-storage.h"
#include "maildir/maildir-storage.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_gz NULL
# define o_stream_create_gz NULL
#endif
#ifndef HAVE_BZLIB
# define i_stream_create_bz2 NULL
# define o_stream_create_bz2 NULL
#endif
struct zlib_transaction_context {
};
struct zlib_user {
const struct zlib_handler *save_handler;
unsigned 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;
/* don't uncompress input when we are reading a mail that we're just
in the middle of saving, and we didn't do the compression ourself.
in such situation we're probably checking if the user-given input
looks compressed */
stream_r);
}
return -1;
"zlib plugin: Detected %s compression "
return -1;
}
}
}
{
union mail_module_context *zmail;
return;
}
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;
}
static void
{
} 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;
v->open = zlib_mailbox_open;
}
{
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[] = {
};