1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
/* Copyright (c) 2002-2016 Pigeonhole authors, see the included COPYING file
*/
#include "lib.h"
#include "managesieve-common.h"
#include "managesieve-commands.h"
#include "sieve.h"
#include "sieve-script.h"
#include "sieve-storage.h"
#include "managesieve-client.h"
#include "managesieve-quota.h"
bool cmd_havespace(struct client_command_context *cmd)
{
struct client *client = cmd->client;
const struct managesieve_arg *args;
const char *scriptname;
uoff_t size;
/* <scriptname> <size> */
if ( !client_read_args(cmd, 2, 0, TRUE, &args) )
return FALSE;
if ( !managesieve_arg_get_string(&args[0], &scriptname) ) {
client_send_no(client, "Invalid string for scriptname.");
return TRUE;
}
if ( !managesieve_arg_get_number(&args[1], &size) ) {
client_send_no(client, "Invalid scriptsize argument.");
return TRUE;
}
if ( !sieve_script_name_is_valid(scriptname) ) {
client_send_no(client, "Invalid script name.");
return TRUE;
}
if ( size == 0 ) {
client_send_no(client, "Cannot upload empty script.");
return TRUE;
}
if ( !managesieve_quota_check_all(client, scriptname, size) )
return TRUE;
client_send_ok(client, "Putscript would succeed.");
return TRUE;
}
|