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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
*/
/* Extension vacation
* ------------------
*
* Authors: Stephan Bosch <stephan@rename-it.nl>
* Specification: RFC 5230
* Implementation: full
* Status: testing
*
*/
#include "lib.h"
#include "sieve-common.h"
#include "sieve-extensions.h"
#include "sieve-commands.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "sieve-dump.h"
#include "ext-vacation-common.h"
/*
* Extension
*/
static bool
ext_vacation_validator_load(const struct sieve_extension *ext,
struct sieve_validator *valdtr);
static bool
ext_vacation_interpreter_load(const struct sieve_extension *ext,
const struct sieve_runtime_env *renv,
sieve_size_t *address);
static bool
ext_vacation_validator_validate(const struct sieve_extension *ext,
struct sieve_validator *valdtr, void *context,
struct sieve_ast_argument *require_arg,
bool required);
static int
ext_vacation_interpreter_run(const struct sieve_extension *this_ext,
const struct sieve_runtime_env *renv,
void *context, bool deferred);
const struct sieve_extension_def vacation_extension = {
.name = "vacation",
.load = ext_vacation_load,
.unload = ext_vacation_unload,
.validator_load = ext_vacation_validator_load,
.interpreter_load = ext_vacation_interpreter_load,
SIEVE_EXT_DEFINE_OPERATION(vacation_operation)
};
const struct sieve_validator_extension
vacation_validator_extension = {
.ext = &vacation_extension,
.validate = ext_vacation_validator_validate
};
const struct sieve_interpreter_extension
vacation_interpreter_extension = {
.ext_def = &vacation_extension,
.run = ext_vacation_interpreter_run
};
static bool
ext_vacation_validator_load(const struct sieve_extension *ext,
struct sieve_validator *valdtr)
{
/* Register new command */
sieve_validator_register_command(valdtr, ext, &vacation_command);
sieve_validator_extension_register(valdtr, ext,
&vacation_validator_extension, NULL);
return TRUE;
}
static bool
ext_vacation_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, &vacation_interpreter_extension, NULL);
return TRUE;
}
static bool
ext_vacation_validator_validate(const struct sieve_extension *ext,
struct sieve_validator *valdtr,
void *context ATTR_UNUSED,
struct sieve_ast_argument *require_arg,
bool required)
{
if (required) {
enum sieve_compile_flags flags =
sieve_validator_compile_flags(valdtr);
if ((flags & SIEVE_COMPILE_FLAG_NO_ENVELOPE) != 0) {
sieve_argument_validate_error(
valdtr, require_arg,
"the %s extension cannot be used in this context "
"(needs access to message envelope)",
sieve_extension_name(ext));
return FALSE;
}
}
return TRUE;
}
static int
ext_vacation_interpreter_run(const struct sieve_extension *ext,
const struct sieve_runtime_env *renv,
void *context ATTR_UNUSED, bool deferred)
{
const struct sieve_execute_env *eenv = renv->exec_env;
if ((eenv->flags & SIEVE_EXECUTE_FLAG_NO_ENVELOPE) != 0) {
if (!deferred) {
sieve_runtime_error(
renv, NULL,
"the %s extension cannot be used in this context "
"(needs access to message envelope)",
sieve_extension_name(ext));
}
return SIEVE_EXEC_FAILURE;
}
return SIEVE_EXEC_OK;
}
|