quota-dict.c revision 995c0a88e9a32e0ec1460567ce5f2ce6e7ba1f13
/* Copyright (c) 2005-2017 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "str.h"
#include "dict.h"
#include "mail-user.h"
#include "mail-namespace.h"
#include "quota-private.h"
struct dict_quota_root {
struct quota_root root;
bool disable_unset;
};
extern struct quota_backend quota_backend_dict;
static struct quota_root *dict_quota_alloc(void)
{
struct dict_quota_root *root;
}
{
}
const char **error_r)
{
struct dict_settings set;
const struct quota_param_parser dict_params[] = {
{.param_name = NULL}
};
if (p == NULL) {
*error_r = "URI missing from parameters";
return -1;
}
args = p+1;
i_unreached();
if (*username == '\0')
i_debug("dict quota: user=%s, uri=%s, noenforcing=%d",
}
/* FIXME: we should use 64bit integer as datatype instead but before
it can actually be used don't bother */
return -1;
}
return 0;
}
{
}
}
static const char *const *
{
static const char *resources[] = {
};
return resources;
}
static int
const char **error_r)
{
struct dict_transaction_context *dt;
const char *error;
"quota-dict count failed: %s", error);
return -1;
}
/* these unsets are mainly necessary for pgsql, because its
trigger otherwise increases quota without deleting it.
but some people with other databases want to store the
quota usage among other data in the same row, which
shouldn't be deleted. */
if (!root->disable_unset) {
}
i_debug("dict quota: Quota recalculated: "
}
return 1;
}
static int
const char **error_r)
{
bool want_bytes;
int ret;
want_bytes = TRUE;
want_bytes = FALSE;
else
return 0;
if (ret < 0) {
*value_r = 0;
return ret;
}
/* recalculate quota if it's negative or if it wasn't found */
tmp = -1;
if (tmp >= 0)
else
return ret;
}
{
const char *error;
}
void *context)
{
/* row doesn't exist, need to recalculate it */
i_error("dict quota: Quota update failed: %s "
}
}
static int
struct quota_transaction_context *ctx,
const char **error_r)
{
struct dict_transaction_context *dt;
return -1;
} else {
if (ctx->bytes_used != 0) {
ctx->bytes_used);
}
if (ctx->count_used != 0) {
ctx->count_used);
}
root);
}
return 0;
}
{
}
}
struct quota_backend quota_backend_dict = {
.name = "dict",
.v = {
.init = dict_quota_init,
}
};