diff --git a/src/lib-sieve/ext-encoded-character.c b/src/lib-sieve/ext-encoded-character.c index 3c5c7aa48ed0eb64f7893afd9aac012c85732246..d23a59a7dab3e604c59ac95cb1f5f201aece5b11 100644 --- a/src/lib-sieve/ext-encoded-character.c +++ b/src/lib-sieve/ext-encoded-character.c @@ -28,7 +28,7 @@ struct sieve_extension encoded_character_extension = { "encoded-character", ext_encoded_character_load, ext_encoded_character_validator_load, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, SIEVE_EXT_DEFINE_NO_OPERANDS }; diff --git a/src/lib-sieve/ext-envelope.c b/src/lib-sieve/ext-envelope.c index 4da197ff631de7acb96a6c1abc1d05d2895987c1..035288e51544a30ced9e64f636e931a77b15897b 100644 --- a/src/lib-sieve/ext-envelope.c +++ b/src/lib-sieve/ext-envelope.c @@ -54,7 +54,7 @@ const struct sieve_extension envelope_extension = { "envelope", ext_envelope_load, ext_envelope_validator_load, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPERATION(envelope_operation), SIEVE_EXT_DEFINE_NO_OPERANDS }; diff --git a/src/lib-sieve/ext-fileinto.c b/src/lib-sieve/ext-fileinto.c index ff8f4ecfdc5e727cbf13267286e45d989011e15f..0f88ed512984aa76aa4ca4061276223312837ffa 100644 --- a/src/lib-sieve/ext-fileinto.c +++ b/src/lib-sieve/ext-fileinto.c @@ -48,7 +48,7 @@ const struct sieve_extension fileinto_extension = { "fileinto", ext_fileinto_load, ext_fileinto_validator_load, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPERATION(fileinto_operation), SIEVE_EXT_DEFINE_NO_OPERANDS }; diff --git a/src/lib-sieve/ext-reject.c b/src/lib-sieve/ext-reject.c index f64c992fe5c0eb2598879aade6992d46ee6e27d1..bd044cbbc5e4c0ad3d7c3008cb4fe77392946ec2 100644 --- a/src/lib-sieve/ext-reject.c +++ b/src/lib-sieve/ext-reject.c @@ -54,7 +54,7 @@ struct sieve_extension reject_extension = { "reject", ext_reject_load, ext_reject_validator_load, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPERATION(reject_operation), SIEVE_EXT_DEFINE_NO_OPERANDS }; diff --git a/src/lib-sieve/plugins/body/ext-body.c b/src/lib-sieve/plugins/body/ext-body.c index c64a75beb80c3b0f8a142d61d254ba8f03ecbd4a..1b6d218ac496c23c95543aa426c0947569b816f3 100644 --- a/src/lib-sieve/plugins/body/ext-body.c +++ b/src/lib-sieve/plugins/body/ext-body.c @@ -66,7 +66,7 @@ const struct sieve_extension body_extension = { "body", ext_body_load, ext_body_validator_load, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPERATION(body_operation), SIEVE_EXT_DEFINE_NO_OPERANDS }; diff --git a/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c b/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c index ff70366acef770d7c29816de207405b26a46f968..5ccd18c9ef26feab1c7fd1c9d4b1ab3b2edd5a7b 100644 --- a/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c +++ b/src/lib-sieve/plugins/comparator-i-ascii-numeric/ext-cmp-i-ascii-numeric.c @@ -33,8 +33,7 @@ const struct sieve_extension comparator_i_ascii_numeric_extension = { "comparator-i;ascii-numeric", ext_cmp_i_ascii_numeric_load, ext_cmp_i_ascii_numeric_validator_load, - NULL, - NULL, + NULL, NULL, NULL, ext_cmp_i_ascii_numeric_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/lib-sieve/plugins/copy/ext-copy.c b/src/lib-sieve/plugins/copy/ext-copy.c index ce4faa81b531808b9dbaee1f2787e72110138e52..a7e659deee8b4512f543eeb53f0887ea0d6ad5e5 100644 --- a/src/lib-sieve/plugins/copy/ext-copy.c +++ b/src/lib-sieve/plugins/copy/ext-copy.c @@ -35,8 +35,7 @@ const struct sieve_extension copy_extension = { "copy", ext_copy_load, ext_copy_validator_load, - NULL, - NULL, + NULL, NULL, NULL, ext_copy_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/lib-sieve/plugins/imapflags/ext-imapflags.c b/src/lib-sieve/plugins/imapflags/ext-imapflags.c index 8dcfcd4e8da962c2c5b929bc0ffd1bf480ed0ccc..7fa2c3f6fd47cc193929c6b4cf6f3ca5a43697bc 100644 --- a/src/lib-sieve/plugins/imapflags/ext-imapflags.c +++ b/src/lib-sieve/plugins/imapflags/ext-imapflags.c @@ -59,7 +59,7 @@ const struct sieve_extension imapflags_extension = { "imap4flags", ext_imapflags_load, ext_imapflags_validator_load, - NULL, + NULL, NULL, ext_imapflags_runtime_load, ext_imapflags_binary_load, NULL, diff --git a/src/lib-sieve/plugins/include/ext-include-common.c b/src/lib-sieve/plugins/include/ext-include-common.c index 6b1c4ccd3892719c716ce8a10d831e9da55488c3..c32890662ba29e72b0dc6a582a318f2e3bfd4a90 100644 --- a/src/lib-sieve/plugins/include/ext-include-common.c +++ b/src/lib-sieve/plugins/include/ext-include-common.c @@ -167,18 +167,19 @@ static inline struct ext_include_interpreter_context * return ctx; } -void ext_include_runtime_context_init -(const struct sieve_runtime_env *renv) +void ext_include_interpreter_context_init +(struct sieve_interpreter *interp) { struct ext_include_interpreter_context *ctx = - ext_include_get_interpreter_context(renv->interp); + ext_include_get_interpreter_context(interp); + struct sieve_script *script = sieve_interpreter_script(interp); if ( ctx == NULL ) { ctx = ext_include_create_interpreter_context - (renv->interp, NULL, renv->script, SBIN_SYSBLOCK_MAIN_PROGRAM); + (interp, NULL, script, SBIN_SYSBLOCK_MAIN_PROGRAM); sieve_interpreter_extension_set_context - (renv->interp, ext_include_my_id, (void *) ctx); + (interp, ext_include_my_id, (void *) ctx); } } diff --git a/src/lib-sieve/plugins/include/ext-include-common.h b/src/lib-sieve/plugins/include/ext-include-common.h index 35a2b80944ec5c67c40ba78600951acb39929cc8..2845de5bf6ef63840383e8c08717bae684b10e84 100644 --- a/src/lib-sieve/plugins/include/ext-include-common.h +++ b/src/lib-sieve/plugins/include/ext-include-common.h @@ -55,7 +55,7 @@ bool ext_include_generate_include /* Interpreter */ -void ext_include_runtime_context_init(const struct sieve_runtime_env *renv); +void ext_include_interpreter_context_init(struct sieve_interpreter *interp); bool ext_include_execute_include (const struct sieve_runtime_env *renv, unsigned int block_id); diff --git a/src/lib-sieve/plugins/include/ext-include.c b/src/lib-sieve/plugins/include/ext-include.c index d9eb0cfb33c9aa3ae7b30a6200b8bbeb0d4ba881..4592de5885666d85e1332a62e600d5a00b07d8a8 100644 --- a/src/lib-sieve/plugins/include/ext-include.c +++ b/src/lib-sieve/plugins/include/ext-include.c @@ -33,7 +33,7 @@ static bool ext_include_load(int ext_id); static bool ext_include_validator_load(struct sieve_validator *validator); static bool ext_include_generator_load(struct sieve_generator *gentr); static bool ext_include_binary_load(struct sieve_binary *sbin); -static bool ext_include_runtime_load(const struct sieve_runtime_env *renv); +static bool ext_include_interpreter_load(struct sieve_interpreter *interp); /* Operations */ @@ -54,7 +54,8 @@ const struct sieve_extension include_extension = { ext_include_load, ext_include_validator_load, ext_include_generator_load, - ext_include_runtime_load, + ext_include_interpreter_load, + NULL, ext_include_binary_load, ext_include_binary_dump, SIEVE_EXT_DEFINE_OPERATIONS(ext_include_operations), @@ -92,10 +93,10 @@ static bool ext_include_generator_load(struct sieve_generator *gentr) /* Load extension into interpreter */ -static bool ext_include_runtime_load -(const struct sieve_runtime_env *renv) +static bool ext_include_interpreter_load +(struct sieve_interpreter *interp) { - ext_include_runtime_context_init(renv); + ext_include_interpreter_context_init(interp); return TRUE; } diff --git a/src/lib-sieve/plugins/regex/ext-regex.c b/src/lib-sieve/plugins/regex/ext-regex.c index 28ce14413e860808c261b659def0a4c525744b30..e3fb99bce7c8b027aa3b1ad378e095d7d90fa558 100644 --- a/src/lib-sieve/plugins/regex/ext-regex.c +++ b/src/lib-sieve/plugins/regex/ext-regex.c @@ -51,8 +51,7 @@ const struct sieve_extension regex_extension = { "regex", ext_regex_load, ext_regex_validator_load, - NULL, - NULL, + NULL, NULL, NULL, ext_regex_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/lib-sieve/plugins/relational/ext-relational.c b/src/lib-sieve/plugins/relational/ext-relational.c index fdecfe5e9aa0cce1b896aecb0f9eac973ec8f4da..220c5e5780c29f945523cbeaa8b30c10a1c5e791 100644 --- a/src/lib-sieve/plugins/relational/ext-relational.c +++ b/src/lib-sieve/plugins/relational/ext-relational.c @@ -48,8 +48,7 @@ const struct sieve_extension relational_extension = { "relational", ext_relational_load, ext_relational_validator_load, - NULL, - NULL, + NULL, NULL, NULL, ext_relational_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/lib-sieve/plugins/subaddress/ext-subaddress.c b/src/lib-sieve/plugins/subaddress/ext-subaddress.c index 8a38511366a5153412ccd44970c89686dbe81605..369eb54d64c358d459d98ea5f3219bbde188d73b 100644 --- a/src/lib-sieve/plugins/subaddress/ext-subaddress.c +++ b/src/lib-sieve/plugins/subaddress/ext-subaddress.c @@ -41,8 +41,7 @@ const struct sieve_extension subaddress_extension = { "subaddress", ext_subaddress_load, ext_subaddress_validator_load, - NULL, - NULL, + NULL, NULL, NULL, ext_subaddress_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/lib-sieve/plugins/vacation/ext-vacation.c b/src/lib-sieve/plugins/vacation/ext-vacation.c index d3f7cf64d60cc3d0df373bb04af8a98bb6e35765..dad01342ce18cad281593f4e701f51d0a01f7147 100644 --- a/src/lib-sieve/plugins/vacation/ext-vacation.c +++ b/src/lib-sieve/plugins/vacation/ext-vacation.c @@ -39,7 +39,7 @@ const struct sieve_extension vacation_extension = { "vacation", ext_vacation_load, ext_vacation_validator_load, - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPERATION(vacation_operation), SIEVE_EXT_DEFINE_NO_OPERANDS }; diff --git a/src/lib-sieve/plugins/variables/ext-variables.c b/src/lib-sieve/plugins/variables/ext-variables.c index 4edfa9b6d17bc67dca6cfd3555235042954ad84e..a147e4211d54912d6234a73cf91e41f875322505 100644 --- a/src/lib-sieve/plugins/variables/ext-variables.c +++ b/src/lib-sieve/plugins/variables/ext-variables.c @@ -36,7 +36,7 @@ static bool ext_variables_load(int ext_id); static bool ext_variables_validator_load(struct sieve_validator *validator); static bool ext_variables_binary_load(struct sieve_binary *sbin); -static bool ext_variables_runtime_load(const struct sieve_runtime_env *renv); +static bool ext_variables_interpreter_load(struct sieve_interpreter *interp); /* Commands */ @@ -70,7 +70,8 @@ struct sieve_extension variables_extension = { ext_variables_load, ext_variables_validator_load, NULL, - ext_variables_runtime_load, + ext_variables_interpreter_load, + NULL, ext_variables_binary_load, NULL, SIEVE_EXT_DEFINE_OPERATIONS(ext_variables_operations), @@ -111,10 +112,10 @@ static bool ext_variables_binary_load /* Load extension into interpreter */ -static bool ext_variables_runtime_load - (const struct sieve_runtime_env *renv) +static bool ext_variables_interpreter_load + (struct sieve_interpreter *interp) { - ext_variables_interpreter_initialize(renv->interp); + ext_variables_interpreter_initialize(interp); return TRUE; } diff --git a/src/lib-sieve/sieve-actions.c b/src/lib-sieve/sieve-actions.c index 844f9760d6432899efa7212f86db3013baef02bb..c5cb0f7e7e943aad251aaf76906df69b4a1c48d6 100644 --- a/src/lib-sieve/sieve-actions.c +++ b/src/lib-sieve/sieve-actions.c @@ -43,7 +43,7 @@ static bool seffect_binary_load(struct sieve_binary *sbin); const struct sieve_extension side_effects_extension = { "@side-effects", seffect_extension_load, - NULL, NULL, NULL, + NULL, NULL, NULL, NULL, seffect_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, /* Opcode is hardcoded */ diff --git a/src/lib-sieve/sieve-address-parts.c b/src/lib-sieve/sieve-address-parts.c index 9d72a66f413491f75c1dd86cab19b04222f6512e..e52b07a7d6e9f43f336e4836e4e5c58db89613ee 100644 --- a/src/lib-sieve/sieve-address-parts.c +++ b/src/lib-sieve/sieve-address-parts.c @@ -58,8 +58,7 @@ const struct sieve_extension address_part_extension = { "@address-parts", addrp_extension_load, addrp_validator_load, - NULL, - NULL, + NULL, NULL, NULL, addrp_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/lib-sieve/sieve-comparators.c b/src/lib-sieve/sieve-comparators.c index 198840bf32f3203b7ece9bd7c5f1c1e5a0ce4184..ae49a4399c36d46ec752d2900f9a801122756c1f 100644 --- a/src/lib-sieve/sieve-comparators.c +++ b/src/lib-sieve/sieve-comparators.c @@ -69,8 +69,7 @@ const struct sieve_extension comparator_extension = { "@comparators", cmp_extension_load, cmp_validator_load, - NULL, - NULL, + NULL, NULL, NULL, cmp_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/lib-sieve/sieve-extensions.c b/src/lib-sieve/sieve-extensions.c index c349db5dcf21145cc94cc491ed36c585d4758554..f86b6e67e61933492cbb8845fbf6ba1b0d624537 100644 --- a/src/lib-sieve/sieve-extensions.c +++ b/src/lib-sieve/sieve-extensions.c @@ -30,14 +30,14 @@ const unsigned int sieve_preloaded_extensions_count = static const struct sieve_extension comparator_i_octet_extension = { "comparator-i;octet", - NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, SIEVE_EXT_DEFINE_NO_OPERANDS }; static const struct sieve_extension comparator_i_ascii_casemap_extension = { "comparator-i;ascii-casemap", - NULL, NULL, NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, SIEVE_EXT_DEFINE_NO_OPERANDS }; @@ -202,8 +202,8 @@ static bool _list_extension(const struct sieve_extension *ext) if ( *ext->name == '@' ) return FALSE; if ( ext->validator_load == NULL && ext->generator_load == NULL && - ext->binary_load == NULL && ext->runtime_load == NULL && - ext->load == NULL && + ext->binary_load == NULL && ext->interpreter_load == NULL && + ext->runtime_load == NULL && ext->load == NULL && ext->operations.count == 0 && ext->operands.count == 0 ) { return FALSE; } diff --git a/src/lib-sieve/sieve-extensions.h b/src/lib-sieve/sieve-extensions.h index 0f5bff4152080070b437fe9b2234134cbbb7e69f..d60dc9067d4bec3cf07bff1e4ac01092a24201de 100644 --- a/src/lib-sieve/sieve-extensions.h +++ b/src/lib-sieve/sieve-extensions.h @@ -20,6 +20,7 @@ struct sieve_extension { bool (*validator_load)(struct sieve_validator *validator); bool (*generator_load)(struct sieve_generator *generator); + bool (*interpreter_load)(struct sieve_interpreter *interpreter); bool (*runtime_load)(const struct sieve_runtime_env *renv); diff --git a/src/lib-sieve/sieve-interpreter.c b/src/lib-sieve/sieve-interpreter.c index 067a5b56ce5b9a6e37baedc512624912923d3ed0..15e3b43d9996768ac3eddbed089fd6026d7cc836 100644 --- a/src/lib-sieve/sieve-interpreter.c +++ b/src/lib-sieve/sieve-interpreter.c @@ -48,6 +48,9 @@ struct sieve_interpreter { struct sieve_interpreter *sieve_interpreter_create (struct sieve_binary *sbin, struct sieve_error_handler *ehandler) { + unsigned int i; + int idx; + pool_t pool; struct sieve_interpreter *interp; @@ -66,6 +69,23 @@ struct sieve_interpreter *sieve_interpreter_create interp->pc = 0; p_array_init(&interp->ext_contexts, pool, 4); + + /* Pre-load core language features implemented as 'extensions' */ + for ( i = 0; i < sieve_preloaded_extensions_count; i++ ) { + const struct sieve_extension *ext = sieve_preloaded_extensions[i]; + + if ( ext->interpreter_load != NULL ) + (void)ext->interpreter_load(interp); + } + + /* Load other extensions listed in the binary */ + for ( idx = 0; idx < sieve_binary_extensions_count(sbin); idx++ ) { + const struct sieve_extension *ext = + sieve_binary_extension_get_by_index(sbin, idx, NULL); + + if ( ext->interpreter_load != NULL ) + ext->interpreter_load(interp); + } return interp; } diff --git a/src/lib-sieve/sieve-match-types.c b/src/lib-sieve/sieve-match-types.c index 8a710e4c3314ada56b3dbf35b14e71888d3bef99..437dbb26a4c27cd9955ac88721b3d7b0b4a23e86 100644 --- a/src/lib-sieve/sieve-match-types.c +++ b/src/lib-sieve/sieve-match-types.c @@ -55,8 +55,7 @@ const struct sieve_extension match_type_extension = { "@match-types", mtch_extension_load, mtch_validator_load, - NULL, - NULL, + NULL, NULL, NULL, mtch_binary_load, NULL, SIEVE_EXT_DEFINE_NO_OPERATIONS, diff --git a/src/testsuite/ext-testsuite.c b/src/testsuite/ext-testsuite.c index 7bccc2a3380716cabf72516f17efc7db10e88b62..bc2ccaec44479167c49a69dea0d53ab992375531 100644 --- a/src/testsuite/ext-testsuite.c +++ b/src/testsuite/ext-testsuite.c @@ -62,7 +62,7 @@ const struct sieve_extension testsuite_extension = { ext_testsuite_load, ext_testsuite_validator_load, ext_testsuite_generator_load, - NULL, + NULL, NULL, ext_testsuite_binary_load, NULL, SIEVE_EXT_DEFINE_OPERATIONS(testsuite_operations),