quota.c revision 91dca97b367c54a139c268b56a0c67f564bd9197
/* Copyright (C) 2005 Timo Sirainen */
#include "lib.h"
#include "array.h"
#include "hash.h"
#include "quota-private.h"
#include "quota-fs.h"
#include <stdlib.h>
#define RULE_NAME_ALL_MAILBOXES "*"
struct quota_root_iter {
unsigned int i;
};
unsigned int quota_module_id = 0;
extern struct quota_backend quota_backend_dict;
extern struct quota_backend quota_backend_dirsize;
extern struct quota_backend quota_backend_fs;
extern struct quota_backend quota_backend_maildir;
static const struct quota_backend *quota_backends[] = {
#ifdef HAVE_FS_QUOTA
#endif
};
struct quota *quota_init(void)
{
return quota;
}
{
struct quota_root **root;
}
}
{
unsigned int i;
for (i = 0; i < QUOTA_CLASS_COUNT; i++) {
return quota_backends[i];
}
return NULL;
}
{
struct quota_root *root;
const struct quota_backend *backend;
const char *p, *args, *backend_name;
t_push();
/* <backend>[:<quota root name>[:<backend args>]] */
if (p == NULL) {
} else {
args = p + 1;
}
t_pop();
/* save root's name */
if (p == NULL) {
} else {
args = p + 1;
}
} else {
}
sizeof(void *), 5);
return NULL;
}
}
return root;
}
{
struct quota_root *const *roots;
unsigned int i, count;
for (i = 0; i < count; i++) {
}
}
static struct quota_rule *
{
struct quota_rule *rules;
unsigned int i, count;
for (i = 0; i < count; i++) {
return &rules[i];
}
return NULL;
}
const char **error_r)
{
struct quota_rule *rule;
const char **args;
int ret = 0;
if (*rule_def == '\0') {
*error_r = "Empty rule";
return -1;
}
/* <mailbox name>:<quota limits> */
t_push();
else {
}
}
else {
"Invalid rule limit: %s", *args);
ret = -1;
break;
}
}
t_pop();
return ret;
}
const char *mailbox_name,
{
struct quota_rule *rule;
bool found;
/* if default rule limits are 0, this rule applies only to specific
mailboxes */
}
return found;
}
{
struct quota_root *const *roots;
struct quota_backend **backends;
unsigned int i, j, count;
/* @UNSAFE: get different backends into one array */
for (i = 0; i < count; i++) {
break;
}
}
}
}
struct mail_storage *storage)
{
struct mail_storage *const *storages;
unsigned int i, count;
for (i = 0; i < count; i++) {
break;
}
}
}
struct quota_root_iter *
{
struct quota_root_iter *iter;
return iter;
}
{
unsigned int count;
int ret;
return NULL;
if (ret == 0) {
}
if (ret > 0) {
break;
}
}
iter->i++;
return root;
}
{
}
{
struct quota_root *const *roots;
unsigned int i, count;
for (i = 0; i < count; i++) {
return roots[i];
}
return NULL;
}
{
}
{
}
{
int ret;
&bytes_limit, &count_limit);
*limit_r = bytes_limit;
*limit_r = count_limit;
else
*limit_r = 0;
(*limit_r == 0 ? 0 : 1);
}
const char *name __attr_unused__,
{
/* the quota information comes from userdb (or even config file),
so there's really no way to support this until some major changes
are done */
return -1;
}
{
struct quota_transaction_context *ctx;
struct quota_root *const *roots;
const char *mailbox_name;
unsigned int i, count;
int ret;
/* find the lowest quota limits from all roots and use them */
for (i = 0; i < count; i++) {
if (ret > 0) {
} else if (ret < 0) {
break;
}
if (ret > 0) {
} else if (ret < 0) {
break;
}
}
return ctx;
}
{
struct quota_root *const *roots;
unsigned int i, count;
int ret = 0;
ret = -1;
else {
for (i = 0; i < count; i++) {
ret = -1;
}
}
return ret;
}
{
}
{
int ret;
if (ret <= 0)
return ret;
return 1;
}
{
}
{
struct quota_root *const *roots;
unsigned int i, count;
*too_large_r = FALSE;
return -1;
return 1;
for (i = 0; i < count; i++) {
if (!quota_root_get_rule_limits(roots[i],
&bytes_limit, &count_limit))
continue;
/* if size is bigger than any limit, then
it is bigger than the lowest limit */
if (size > bytes_limit) {
*too_large_r = TRUE;
break;
}
}
return 0;
}
{
ctx->count_used++;
}
{
ctx->count_used--;
}