quota-dirsize.c revision 26a8b7deb3a5b6f26f9c4d71538e1248f680e4be
/* Copyright (C) 2005-2006 Timo Sirainen */
/* Quota reporting based on simply summing sizes of all files in mailbox
together. */
#include "lib.h"
#include "array.h"
#include "str.h"
#include "quota-private.h"
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
struct quota_count_path {
const char *path;
bool is_file;
};
extern struct quota_backend quota_backend_dirsize;
static struct quota_root *dirsize_quota_alloc(void)
{
}
{
}
static const char *const *
{
return resources;
}
{
struct dirent *d;
unsigned int path_pos;
int ret;
return 0;
return -1;
}
ret = 0;
if (d->d_name[0] == '.' &&
/* skip . and .. */
continue;
}
continue;
ret = -1;
break;
ret = -1;
break;
}
} else {
}
}
return ret;
}
{
if (is_file) {
return 0;
return -1;
}
} else {
return -1;
}
return 0;
}
{
struct quota_count_path *count_path;
unsigned int i, count;
for (i = 0; i < count; i++) {
/* this path has already been counted */
return;
}
/* the new path contains the existing path */
count_path += i;
break;
}
}
if (i == count)
}
static int
{
struct mail_storage *const *storages;
const struct quota_count_path *count_paths;
unsigned int i, count;
const char *path;
bool is_file;
t_push();
for (i = 0; i < count; i++) {
/* INBOX may be in different path. */
&is_file);
}
/* now sum up the found paths */
for (i = 0; i < count; i++) {
value_r) < 0) {
t_pop();
return -1;
}
}
t_pop();
return 0;
}
static int
{
return 0;
return -1;
*value_r /= 1024;
return 1;
}
static int
{
return 0;
}
struct quota_backend quota_backend_dirsize = {
"dirsize",
{
NULL,
NULL,
}
};