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
|
/* Copyright (c) 2002-2018 Pigeonhole authors, see the included COPYING file
*/
/* Extension include
* -----------------
*
* Authors: Stephan Bosch
* Specification: RFC 6609
* Implementation: full
* Status: testing
*
*/
/* FIXME: Current include implementation does not allow for parts of the script
* to be located in external binaries; all included scripts are recompiled and
* the resulting byte code is imported into the main binary in separate blocks.
*/
#include "lib.h"
#include "sieve-common.h"
#include "sieve-extensions.h"
#include "sieve-validator.h"
#include "sieve-generator.h"
#include "sieve-interpreter.h"
#include "sieve-binary.h"
#include "sieve-dump.h"
#include "sieve-ext-variables.h"
#include "ext-include-common.h"
#include "ext-include-binary.h"
#include "ext-include-variables.h"
/*
* Operations
*/
static const struct sieve_operation_def *ext_include_operations[] = {
&include_operation,
&return_operation,
&global_operation
};
/*
* Extension
*/
/* Forward declaration */
static bool ext_include_validator_load
(const struct sieve_extension *ext, struct sieve_validator *validator);
static bool ext_include_generator_load
(const struct sieve_extension *ext, const struct sieve_codegen_env *cgenv);
static bool ext_include_interpreter_load
(const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
sieve_size_t *address);
static bool ext_include_binary_load
(const struct sieve_extension *ext, struct sieve_binary *binary);
/* Extension objects */
const struct sieve_extension_def include_extension = {
.name = "include",
.version = 1,
.load = ext_include_load,
.unload = ext_include_unload,
.validator_load = ext_include_validator_load,
.generator_load = ext_include_generator_load,
.interpreter_load = ext_include_interpreter_load,
.binary_load = ext_include_binary_load,
.binary_dump = ext_include_binary_dump,
.code_dump = ext_include_code_dump,
SIEVE_EXT_DEFINE_OPERATIONS(ext_include_operations)
};
static bool ext_include_validator_load
(const struct sieve_extension *ext, struct sieve_validator *valdtr)
{
/* Register new commands */
sieve_validator_register_command(valdtr, ext, &cmd_include);
sieve_validator_register_command(valdtr, ext, &cmd_return);
sieve_validator_register_command(valdtr, ext, &cmd_global);
/* DEPRICATED */
sieve_validator_register_command(valdtr, ext, &cmd_import);
sieve_validator_register_command(valdtr, ext, &cmd_export);
/* Initialize global variables namespace */
ext_include_variables_global_namespace_init(ext, valdtr);
return TRUE;
}
static bool ext_include_generator_load
(const struct sieve_extension *ext, const struct sieve_codegen_env *cgenv)
{
ext_include_register_generator_context(ext, cgenv);
return TRUE;
}
static bool ext_include_interpreter_load
(const struct sieve_extension *ext, const struct sieve_runtime_env *renv,
sieve_size_t *address ATTR_UNUSED)
{
ext_include_interpreter_context_init(ext, renv->interp);
return TRUE;
}
static bool ext_include_binary_load
(const struct sieve_extension *ext, struct sieve_binary *sbin)
{
(void)ext_include_binary_get_context(ext, sbin);
return TRUE;
}
|