コード例 #1
0
static void cmd_quota_get_root(struct quota_root *root)
{
	const char *const *res;
	uint64_t value, limit;
	int ret;

	res = quota_root_get_resources(root);
	for (; *res != NULL; res++) {
		ret = quota_get_resource(root, "", *res, &value, &limit);
		doveadm_print(root->set->name);
		doveadm_print(*res);
		if (ret > 0) {
			doveadm_print_num(value);
			doveadm_print_num(limit);
			if (limit > 0)
				doveadm_print_num(value*100 / limit);
			else
				doveadm_print("0");
		} else if (ret == 0) {
			doveadm_print_num(value);
			doveadm_print("-");
			doveadm_print("0");
		} else {
			doveadm_print("error");
			doveadm_print("error");
			doveadm_print("error");
		}
	}
}
コード例 #2
0
static void
quota_reply_write(string_t *str, struct mail_user *user,
		  struct mail_user *owner, struct quota_root *root)
{
        const char *name, *const *list;
	unsigned int i;
	uint64_t value, limit;
	int ret = 0;

	str_append(str, "* QUOTA ");
	name = imap_quota_root_get_name(user, owner, root);
	imap_quote_append_string(str, name, FALSE);

	str_append(str, " (");
	list = quota_root_get_resources(root);
	for (i = 0; *list != NULL; list++) {
		ret = quota_get_resource(root, "", *list, &value, &limit);
		if (ret < 0)
			break;
		if (ret > 0) {
			if (i > 0)
				str_append_c(str, ' ');
			str_printfa(str, "%s %llu %llu", *list,
				    (unsigned long long)value,
				    (unsigned long long)limit);
			i++;
		}
	}
	str_append(str, ")\r\n");

	if (ret < 0)
		str_append(str, "* BAD Internal quota calculation error\r\n");
}