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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
/* Copyright (c) 2002-2016 Pigeonhole authors, see the included COPYING file
*/
/* Extension imap4flags
* --------------------
*
* Authors: Stephan Bosch
* Specification: RFC 5232
* Implementation: full
* Status: testing
*
*/
#include "lib.h"
#include "mempool.h"
#include "str.h"
#include "sieve-common.h"
#include "sieve-code.h"
#include "sieve-extensions.h"
#include "sieve-actions.h"
#include "sieve-commands.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "ext-imap4flags-common.h"
/*
* Operations
*/
const struct sieve_operation_def *imap4flags_operations[] = {
&setflag_operation,
&addflag_operation,
&removeflag_operation,
&hasflag_operation
};
/*
* Extension
*/
static bool ext_imap4flags_validator_load
(const struct sieve_extension *ext, struct sieve_validator *valdtr);
static bool ext_imap4flags_interpreter_load
(const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
sieve_size_t *address);
const struct sieve_extension_def imap4flags_extension = {
.name = "imap4flags",
.validator_load = ext_imap4flags_validator_load,
.interpreter_load = ext_imap4flags_interpreter_load,
SIEVE_EXT_DEFINE_OPERATIONS(imap4flags_operations),
SIEVE_EXT_DEFINE_OPERAND(flags_side_effect_operand)
};
static bool ext_imap4flags_validator_load
(const struct sieve_extension *ext, struct sieve_validator *valdtr)
{
/* Register commands */
sieve_validator_register_command(valdtr, ext, &cmd_setflag);
sieve_validator_register_command(valdtr, ext, &cmd_addflag);
sieve_validator_register_command(valdtr, ext, &cmd_removeflag);
sieve_validator_register_command(valdtr, ext, &tst_hasflag);
/* Attach :flags tag to keep and fileinto commands */
ext_imap4flags_attach_flags_tag(valdtr, ext, "keep");
ext_imap4flags_attach_flags_tag(valdtr, ext, "fileinto");
/* Attach flags side-effect to keep and fileinto actions */
sieve_ext_imap4flags_register_side_effect(valdtr, ext, "keep");
sieve_ext_imap4flags_register_side_effect(valdtr, ext, "fileinto");
return TRUE;
}
static bool ext_imap4flags_interpreter_load
(const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
sieve_size_t *address ATTR_UNUSED)
{
sieve_interpreter_extension_register
(renv->interp, ext, &imap4flags_interpreter_extension, NULL);
return TRUE;
}
|