diff --git a/src/lib-sieve/ext-envelope.c b/src/lib-sieve/ext-envelope.c index dad3a86161b5078568de9ef03d27e7d1589d813d..ac962a720f4b90edf70c507fcad9cbe8bf9b4d7e 100644 --- a/src/lib-sieve/ext-envelope.c +++ b/src/lib-sieve/ext-envelope.c @@ -52,8 +52,7 @@ const struct sieve_extension envelope_extension = { "envelope", ext_envelope_load, ext_envelope_validator_load, - NULL, - NULL, + NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPCODE(envelope_opcode), NULL }; diff --git a/src/lib-sieve/ext-fileinto.c b/src/lib-sieve/ext-fileinto.c index 5cb29aa4acc0e29c97d7bfe70258b667819de6d9..d86c638f10689e72e799eb13e86aedf31fc49c19 100644 --- a/src/lib-sieve/ext-fileinto.c +++ b/src/lib-sieve/ext-fileinto.c @@ -44,8 +44,7 @@ const struct sieve_extension fileinto_extension = { "fileinto", ext_fileinto_load, ext_fileinto_validator_load, - NULL, - NULL, + NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPCODE(fileinto_opcode), NULL }; diff --git a/src/lib-sieve/ext-reject.c b/src/lib-sieve/ext-reject.c index 509481b208210e83b1395816415d4981ce21549d..ff7af5004ff5f2d33f5a3f88796c8f06105d2db8 100644 --- a/src/lib-sieve/ext-reject.c +++ b/src/lib-sieve/ext-reject.c @@ -43,8 +43,7 @@ struct sieve_extension reject_extension = { "reject", ext_reject_load, ext_reject_validator_load, - NULL, - NULL, + NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPCODE(reject_opcode), NULL }; 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 c9a3a88e65f5048206104219a67b5c12f5073823..a8944b3d1befaf5dcdea2846807302fdfb4fbe0b 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 @@ -34,7 +34,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, ext_cmp_i_ascii_numeric_interpreter_load, SIEVE_EXT_DEFINE_NO_OPCODES, NULL diff --git a/src/lib-sieve/plugins/imapflags/ext-imapflags.c b/src/lib-sieve/plugins/imapflags/ext-imapflags.c index fa7ba2f90c9f2cc1c78a751ab51457a8192be9ab..04361bd36f6c8fc1734c940e8934f2da03d537b0 100644 --- a/src/lib-sieve/plugins/imapflags/ext-imapflags.c +++ b/src/lib-sieve/plugins/imapflags/ext-imapflags.c @@ -57,7 +57,7 @@ const struct sieve_extension imapflags_extension = { "imap4flags", ext_imapflags_load, ext_imapflags_validator_load, - NULL, + NULL, NULL, ext_imapflags_interpreter_load, SIEVE_EXT_DEFINE_OPCODES(imapflags_opcodes), NULL diff --git a/src/lib-sieve/plugins/regex/ext-regex.c b/src/lib-sieve/plugins/regex/ext-regex.c index 242d0400f7a724923687278888974ce63723ac1d..3e66ba9914b650ec3f53d3f04f664a8cef94a193 100644 --- a/src/lib-sieve/plugins/regex/ext-regex.c +++ b/src/lib-sieve/plugins/regex/ext-regex.c @@ -56,7 +56,7 @@ const struct sieve_extension regex_extension = { "regex", ext_regex_load, ext_regex_validator_load, - NULL, + NULL, NULL, ext_regex_interpreter_load, SIEVE_EXT_DEFINE_NO_OPCODES, NULL diff --git a/src/lib-sieve/plugins/relational/ext-relational.c b/src/lib-sieve/plugins/relational/ext-relational.c index ea5724ddac717be0e54858d598dc846e9f421319..4860009a0bb1a2e076e0756da916c58922621777 100644 --- a/src/lib-sieve/plugins/relational/ext-relational.c +++ b/src/lib-sieve/plugins/relational/ext-relational.c @@ -70,7 +70,7 @@ const struct sieve_extension relational_extension = { "relational", ext_relational_load, ext_relational_validator_load, - NULL, + NULL, NULL, ext_relational_interpreter_load, SIEVE_EXT_DEFINE_NO_OPCODES, NULL diff --git a/src/lib-sieve/plugins/subaddress/ext-subaddress.c b/src/lib-sieve/plugins/subaddress/ext-subaddress.c index 8e1d6de248df57d56713d27148ab43e345b59803..cdb73012d47470203025774ad6cfabce57a5787b 100644 --- a/src/lib-sieve/plugins/subaddress/ext-subaddress.c +++ b/src/lib-sieve/plugins/subaddress/ext-subaddress.c @@ -42,7 +42,7 @@ const struct sieve_extension subaddress_extension = { "subaddress", ext_subaddress_load, ext_subaddress_validator_load, - NULL, + NULL, NULL, ext_subaddress_interpreter_load, SIEVE_EXT_DEFINE_NO_OPCODES, NULL diff --git a/src/lib-sieve/plugins/vacation/ext-vacation.c b/src/lib-sieve/plugins/vacation/ext-vacation.c index 3da21bc8f3080a35b110252d3772b8010f5e57ef..3cf0b47ac4e56fe2d5b6ce022601e3d92444d0ce 100644 --- a/src/lib-sieve/plugins/vacation/ext-vacation.c +++ b/src/lib-sieve/plugins/vacation/ext-vacation.c @@ -49,8 +49,7 @@ const struct sieve_extension vacation_extension = { "vacation", ext_vacation_load, ext_vacation_validator_load, - NULL, - NULL, + NULL, NULL, NULL, SIEVE_EXT_DEFINE_OPCODE(vacation_opcode), NULL }; diff --git a/src/lib-sieve/sieve-address-parts.c b/src/lib-sieve/sieve-address-parts.c index 6274a99d7d2fb38807b357785e117300c83498a8..bc347ab665486f502de546980e00a9bb7458729b 100644 --- a/src/lib-sieve/sieve-address-parts.c +++ b/src/lib-sieve/sieve-address-parts.c @@ -40,10 +40,10 @@ static bool addrp_validator_load(struct sieve_validator *validator); static bool addrp_interpreter_load(struct sieve_interpreter *interp); const struct sieve_extension address_part_extension = { - "@address-part", + "@address-parts", addrp_extension_load, addrp_validator_load, - NULL, + NULL, NULL, addrp_interpreter_load, SIEVE_EXT_DEFINE_NO_OPCODES, NULL diff --git a/src/lib-sieve/sieve-binary.c b/src/lib-sieve/sieve-binary.c index 1ba09a62863c4cf69498c9c619981a8aa94157db..251783e5e08065fc2719f2fd46d7372faec800fa 100644 --- a/src/lib-sieve/sieve-binary.c +++ b/src/lib-sieve/sieve-binary.c @@ -38,33 +38,45 @@ struct sieve_binary *sieve_binary_create_new(void) sbin->data = buffer_create_dynamic(pool, 256); - p_array_init(&sbin->extensions, pool, sieve_extensions_get_count()); + p_array_init(&sbin->extensions, pool, 5); p_array_init(&sbin->extension_index, pool, sieve_extensions_get_count()); return sbin; } -void sieve_binary_ref(struct sieve_binary *binary) +void sieve_binary_ref(struct sieve_binary *sbin) { - pool_ref(binary->pool); + pool_ref(sbin->pool); } -void sieve_binary_unref(struct sieve_binary **binary) +void sieve_binary_unref(struct sieve_binary **sbin) { - if ( binary != NULL && *binary != NULL ) { - pool_unref(&((*binary)->pool)); + if ( sbin != NULL && *sbin != NULL ) { + pool_unref(&((*sbin)->pool)); } - *binary = NULL; + *sbin = NULL; } -inline sieve_size_t sieve_binary_get_code_size(struct sieve_binary *binary) +inline sieve_size_t sieve_binary_get_code_size(struct sieve_binary *sbin) { - return buffer_get_used_size(binary->data); + return buffer_get_used_size(sbin->data); } -void sieve_binary_commit(struct sieve_binary *binary) +void sieve_binary_load(struct sieve_binary *sbin) { - binary->code = buffer_get_data(binary->data, &(binary->code_size)); + unsigned int i; + + /* Currently only memory binary support */ + sbin->code = buffer_get_data(sbin->data, &(sbin->code_size)); + + for ( i = 0; i < array_count(&sbin->extensions); i++ ) { + struct sieve_binary_extension * const *aext = + array_idx(&sbin->extensions, i); + const struct sieve_extension *ext = (*aext)->extension; + + if ( ext->binary_load != NULL ) + ext->binary_load(sbin); + } } /* Extension handling */ @@ -128,7 +140,6 @@ int sieve_binary_extensions_count(struct sieve_binary *sbin) return (int) array_count(&sbin->extensions); } - /* * Emission functions */ diff --git a/src/lib-sieve/sieve-binary.h b/src/lib-sieve/sieve-binary.h index 49440d1ce5d668beb5652576fa975d8d54a7b621..174a7c3e37b161130126c2d0118792f45a70f095 100644 --- a/src/lib-sieve/sieve-binary.h +++ b/src/lib-sieve/sieve-binary.h @@ -9,10 +9,10 @@ struct sieve_binary; struct sieve_binary *sieve_binary_create_new(void); -void sieve_binary_ref(struct sieve_binary *binary); -void sieve_binary_unref(struct sieve_binary **binary); +void sieve_binary_ref(struct sieve_binary *sbin); +void sieve_binary_unref(struct sieve_binary **sbin); -void sieve_binary_commit(struct sieve_binary *binary); +void sieve_binary_load(struct sieve_binary *sbin); /* * Extension handling diff --git a/src/lib-sieve/sieve-comparators.c b/src/lib-sieve/sieve-comparators.c index 7cb799515ba69359d5dfc1365882745b7f650aa1..321553fa6c796f0cad75aa5298f99ba2b1647c70 100644 --- a/src/lib-sieve/sieve-comparators.c +++ b/src/lib-sieve/sieve-comparators.c @@ -55,10 +55,10 @@ static bool cmp_validator_load(struct sieve_validator *validator); static bool cmp_interpreter_load(struct sieve_interpreter *interp); const struct sieve_extension comparator_extension = { - "@comparator", + "@comparators", cmp_extension_load, cmp_validator_load, - NULL, + NULL, NULL, cmp_interpreter_load, SIEVE_EXT_DEFINE_NO_OPCODES, NULL diff --git a/src/lib-sieve/sieve-extensions.c b/src/lib-sieve/sieve-extensions.c index aefccd4b0398561e4217cadb4f349b3a99537c58..f5345b9d94d73bd0a31d5ea0dacaa6c325f7eac7 100644 --- a/src/lib-sieve/sieve-extensions.c +++ b/src/lib-sieve/sieve-extensions.c @@ -27,14 +27,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, SIEVE_EXT_DEFINE_NO_OPCODES, NULL }; static const struct sieve_extension comparator_i_ascii_casemap_extension = { "comparator-i;ascii-casemap", - NULL, NULL, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, SIEVE_EXT_DEFINE_NO_OPCODES, NULL }; diff --git a/src/lib-sieve/sieve-extensions.h b/src/lib-sieve/sieve-extensions.h index 16f97a96ca4f5e918eec01f1726b5808dae8486f..346835b2d4935dcf0421083ec5ea26612d408648 100644 --- a/src/lib-sieve/sieve-extensions.h +++ b/src/lib-sieve/sieve-extensions.h @@ -8,9 +8,11 @@ struct sieve_extension { const char *name; bool (*load)(int ext_id); - + bool (*validator_load)(struct sieve_validator *validator); bool (*generator_load)(struct sieve_generator *generator); + + bool (*binary_load)(struct sieve_binary *binary); bool (*interpreter_load)(struct sieve_interpreter *interpreter); /* Extension can introduce a single or multiple opcodes */ diff --git a/src/lib-sieve/sieve-interpreter.c b/src/lib-sieve/sieve-interpreter.c index 9033e6ba90e0dacbda0eefd447ea440e4e4b0f06..e45995b3a27261bcbde9c220611bc6b045ca9632 100644 --- a/src/lib-sieve/sieve-interpreter.c +++ b/src/lib-sieve/sieve-interpreter.c @@ -46,7 +46,7 @@ struct sieve_interpreter *sieve_interpreter_create(struct sieve_binary *sbin) interp->runenv.sbin = sbin; sieve_binary_ref(sbin); - sieve_binary_commit(sbin); + sieve_binary_load(sbin); interp->pc = 0; diff --git a/src/lib-sieve/sieve-match-types.c b/src/lib-sieve/sieve-match-types.c index 3b7865d22436a30abbd3c8811d60a2fe655d0869..19e0e9c261de3223395cd0b820ced8f73e91b03d 100644 --- a/src/lib-sieve/sieve-match-types.c +++ b/src/lib-sieve/sieve-match-types.c @@ -39,10 +39,10 @@ static bool mtch_validator_load(struct sieve_validator *validator); static bool mtch_interpreter_load(struct sieve_interpreter *interp); const struct sieve_extension match_type_extension = { - "@match-type", + "@match-types", mtch_extension_load, mtch_validator_load, - NULL, + NULL, NULL, mtch_interpreter_load, SIEVE_EXT_DEFINE_NO_OPCODES, NULL