From 4f576f76d29458796938c5f8b942d845182ec2d5 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Sun, 7 Sep 2008 14:00:27 +0200
Subject: [PATCH] Added support for per-script extension intialization.

---
 src/lib-sieve/ext-encoded-character.c         |  2 +-
 src/lib-sieve/ext-envelope.c                  |  2 +-
 src/lib-sieve/ext-fileinto.c                  |  2 +-
 src/lib-sieve/ext-reject.c                    |  2 +-
 src/lib-sieve/plugins/body/ext-body.c         |  2 +-
 .../ext-cmp-i-ascii-numeric.c                 |  2 +-
 src/lib-sieve/plugins/copy/ext-copy.c         |  2 +-
 .../plugins/imapflags/ext-imapflags.c         |  9 ++--
 src/lib-sieve/plugins/include/ext-include.c   |  8 ++--
 src/lib-sieve/plugins/regex/ext-regex.c       |  2 +-
 .../plugins/relational/ext-relational.c       |  2 +-
 .../plugins/subaddress/ext-subaddress.c       |  2 +-
 src/lib-sieve/plugins/vacation/ext-vacation.c |  2 +-
 .../variables/ext-variables-arguments.c       |  6 +--
 .../plugins/variables/ext-variables-common.c  | 41 +++++++++++++++++--
 .../plugins/variables/ext-variables-common.h  | 17 +++++++-
 .../plugins/variables/ext-variables.c         | 13 ++----
 src/lib-sieve/sieve-address-parts.c           |  2 +-
 src/lib-sieve/sieve-code-dumper.c             | 23 +++++++----
 src/lib-sieve/sieve-comparators.c             |  2 +-
 src/lib-sieve/sieve-extensions.c              |  4 +-
 src/lib-sieve/sieve-extensions.h              | 17 +++++---
 src/lib-sieve/sieve-interpreter.c             |  5 ++-
 src/lib-sieve/sieve-match-types.c             |  2 +-
 src/testsuite/ext-testsuite.c                 |  2 +-
 25 files changed, 118 insertions(+), 55 deletions(-)

diff --git a/src/lib-sieve/ext-encoded-character.c b/src/lib-sieve/ext-encoded-character.c
index 5eac00c70..85532885e 100644
--- a/src/lib-sieve/ext-encoded-character.c
+++ b/src/lib-sieve/ext-encoded-character.c
@@ -35,7 +35,7 @@ struct sieve_extension encoded_character_extension = {
 	&ext_my_id,
 	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 5dba8dd29..17705faa9 100644
--- a/src/lib-sieve/ext-envelope.c
+++ b/src/lib-sieve/ext-envelope.c
@@ -52,7 +52,7 @@ const struct sieve_extension envelope_extension = {
 	&ext_my_id,
 	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 4c22fd996..3e8ef2f4e 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 = {
 	&ext_my_id,
 	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 69521b338..0dd89812b 100644
--- a/src/lib-sieve/ext-reject.c
+++ b/src/lib-sieve/ext-reject.c
@@ -54,7 +54,7 @@ struct sieve_extension reject_extension = {
 	&ext_my_id,
 	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 2c5d6cce8..1369e934f 100644
--- a/src/lib-sieve/plugins/body/ext-body.c
+++ b/src/lib-sieve/plugins/body/ext-body.c
@@ -58,7 +58,7 @@ const struct sieve_extension body_extension = {
 	&ext_body_my_id,
 	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 21ef63c00..609de1ccf 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
@@ -46,7 +46,7 @@ const struct sieve_extension comparator_i_ascii_numeric_extension = {
 	&ext_my_id,
 	ext_cmp_i_ascii_numeric_load,
 	ext_cmp_i_ascii_numeric_validator_load,
-	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_NO_OPERATIONS, 
 	SIEVE_EXT_DEFINE_OPERAND(my_comparator_operand)
 };
diff --git a/src/lib-sieve/plugins/copy/ext-copy.c b/src/lib-sieve/plugins/copy/ext-copy.c
index 2548c8aa7..3b2ac17a1 100644
--- a/src/lib-sieve/plugins/copy/ext-copy.c
+++ b/src/lib-sieve/plugins/copy/ext-copy.c
@@ -45,7 +45,7 @@ const struct sieve_extension copy_extension = {
 	&ext_my_id,
 	ext_copy_load,
 	ext_copy_validator_load, 
-	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_NO_OPERATIONS,
 	SIEVE_EXT_DEFINE_OPERAND(copy_side_effect_operand)
 };
diff --git a/src/lib-sieve/plugins/imapflags/ext-imapflags.c b/src/lib-sieve/plugins/imapflags/ext-imapflags.c
index f2629e186..0bb7c4724 100644
--- a/src/lib-sieve/plugins/imapflags/ext-imapflags.c
+++ b/src/lib-sieve/plugins/imapflags/ext-imapflags.c
@@ -44,7 +44,8 @@ const struct sieve_operation *imapflags_operations[] = {
 
 static bool ext_imapflags_load(int ext_id);
 static bool ext_imapflags_validator_load(struct sieve_validator *valdtr);
-static bool ext_imapflags_interpreter_load(struct sieve_interpreter *interp);
+static bool ext_imapflags_interpreter_load
+	(const struct sieve_runtime_env *renv, sieve_size_t *address);
 
 int ext_imapflags_my_id;
 
@@ -55,7 +56,7 @@ const struct sieve_extension imapflags_extension = {
 	ext_imapflags_validator_load, 
 	NULL, 
 	ext_imapflags_interpreter_load, 
-	NULL, NULL,
+	NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_OPERATIONS(imapflags_operations), 
 	SIEVE_EXT_DEFINE_OPERAND(flags_side_effect_operand)
 };
@@ -84,10 +85,10 @@ static bool ext_imapflags_validator_load
 }
 
 static bool ext_imapflags_interpreter_load
-(struct sieve_interpreter *interp)
+(const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED)
 {
 	sieve_interpreter_extension_register
-        (interp, &imapflags_interpreter_extension, NULL);
+        (renv->interp, &imapflags_interpreter_extension, NULL);
 
 	return TRUE;
 }
diff --git a/src/lib-sieve/plugins/include/ext-include.c b/src/lib-sieve/plugins/include/ext-include.c
index dabcf913c..d5cd70839 100644
--- a/src/lib-sieve/plugins/include/ext-include.c
+++ b/src/lib-sieve/plugins/include/ext-include.c
@@ -51,7 +51,8 @@ static bool ext_include_load(int ext_id);
 static bool ext_include_validator_load(struct sieve_validator *validator);
 static bool ext_include_generator_load(const struct sieve_codegen_env *cgenv);
 static bool ext_include_binary_load(struct sieve_binary *sbin);
-static bool ext_include_interpreter_load(struct sieve_interpreter *interp);
+static bool ext_include_interpreter_load
+	(const struct sieve_runtime_env *renv, sieve_size_t *address);
 
 /* Extension objects */
 
@@ -66,6 +67,7 @@ const struct sieve_extension include_extension = {
 	ext_include_interpreter_load,
 	ext_include_binary_load, 
 	ext_include_binary_dump,
+	NULL,
 	SIEVE_EXT_DEFINE_OPERATIONS(ext_include_operations),
 	SIEVE_EXT_DEFINE_NO_OPERANDS
 };
@@ -98,9 +100,9 @@ static bool ext_include_generator_load(const struct sieve_codegen_env *cgenv)
 }
 
 static bool ext_include_interpreter_load
-(struct sieve_interpreter *interp)
+(const struct sieve_runtime_env *renv, sieve_size_t *address)
 {
-	ext_include_interpreter_context_init(interp);
+	ext_include_interpreter_context_init(renv->interp);
 	
 	return TRUE;
 }
diff --git a/src/lib-sieve/plugins/regex/ext-regex.c b/src/lib-sieve/plugins/regex/ext-regex.c
index 6e246d776..c35f414cb 100644
--- a/src/lib-sieve/plugins/regex/ext-regex.c
+++ b/src/lib-sieve/plugins/regex/ext-regex.c
@@ -53,7 +53,7 @@ const struct sieve_extension regex_extension = {
 	&ext_my_id,
 	ext_regex_load,
 	ext_regex_validator_load,
-	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_NO_OPERATIONS, 
 	SIEVE_EXT_DEFINE_OPERAND(regex_match_type_operand)
 };
diff --git a/src/lib-sieve/plugins/relational/ext-relational.c b/src/lib-sieve/plugins/relational/ext-relational.c
index 8570982de..8f6533179 100644
--- a/src/lib-sieve/plugins/relational/ext-relational.c
+++ b/src/lib-sieve/plugins/relational/ext-relational.c
@@ -42,7 +42,7 @@ const struct sieve_extension relational_extension = {
 	&ext_relational_my_id,
 	ext_relational_load,
 	ext_relational_validator_load,
-	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_NO_OPERATIONS, 
 	SIEVE_EXT_DEFINE_OPERAND(rel_match_type_operand)
 };
diff --git a/src/lib-sieve/plugins/subaddress/ext-subaddress.c b/src/lib-sieve/plugins/subaddress/ext-subaddress.c
index 4020b3c93..b96b89596 100644
--- a/src/lib-sieve/plugins/subaddress/ext-subaddress.c
+++ b/src/lib-sieve/plugins/subaddress/ext-subaddress.c
@@ -56,7 +56,7 @@ const struct sieve_extension subaddress_extension = {
 	&ext_my_id,
 	ext_subaddress_load,
 	ext_subaddress_validator_load,
-	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_NO_OPERATIONS, 
 	SIEVE_EXT_DEFINE_OPERAND(subaddress_operand)
 };
diff --git a/src/lib-sieve/plugins/vacation/ext-vacation.c b/src/lib-sieve/plugins/vacation/ext-vacation.c
index da214e396..b2747119a 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 = {
 	&ext_my_id,
 	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-arguments.c b/src/lib-sieve/plugins/variables/ext-variables-arguments.c
index 194382ec8..9cdebcf30 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-arguments.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-arguments.c
@@ -24,7 +24,7 @@
  * Common error messages
  */
 
-static inline void _ext_variables_scope_size_eror
+static inline void _ext_variables_scope_size_error
 (struct sieve_validator *valdtr, struct sieve_command_context *cmd,
 	const char *variable)
 {
@@ -113,7 +113,7 @@ static bool _sieve_variable_argument_activate
 					(validator, str_c(cur_element->identifier), TRUE);
 
 				if ( var == NULL ) {
-					_ext_variables_scope_size_eror
+					_ext_variables_scope_size_error
 						(validator, cmd, str_c(cur_element->identifier));
 				} else {
 					arg->argument = &variable_argument;
@@ -373,7 +373,7 @@ static bool arg_variable_string_validate
 							if ( strarg != NULL )
 								sieve_ast_arg_list_add(arglist, strarg);
 							else {
-								_ext_variables_scope_size_eror
+								_ext_variables_scope_size_error
 									(validator, cmd, str_c(cur_element->identifier));
 								result = FALSE;
 								break;
diff --git a/src/lib-sieve/plugins/variables/ext-variables-common.c b/src/lib-sieve/plugins/variables/ext-variables-common.c
index 7d8d5c298..3477fc6f1 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-common.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.c
@@ -382,6 +382,33 @@ bool sieve_ext_variables_is_active(struct sieve_validator *valdtr)
 	return ( ext_variables_validator_context_get(valdtr) != NULL );
 }
 
+/*
+ * Code generation
+ */
+ 
+bool ext_variables_generator_load(const struct sieve_codegen_env *cgenv)
+{
+	(void) sieve_binary_emit_integer(cgenv->sbin, 0);
+	
+	return TRUE;
+}
+
+/*
+ * Code dump
+ */
+ 
+bool ext_variables_code_dump
+(const struct sieve_dumptime_env *denv, sieve_size_t *address)
+{
+	unsigned int scope_size;
+
+	if ( sieve_binary_read_integer(denv->sbin, address, &scope_size) ) {
+		sieve_code_dumpf(denv, "SCOPE (size: %d)", scope_size);
+	}
+	
+	return TRUE;
+}
+
 /* 
  * Interpreter context 
  */
@@ -407,15 +434,23 @@ ext_variables_interpreter_context_create(struct sieve_interpreter *interp)
 	return ctx;
 }
 
-void ext_variables_interpreter_initialize(struct sieve_interpreter *interp)
+bool ext_variables_interpreter_load
+	(const struct sieve_runtime_env *renv, sieve_size_t *address)
 {
 	struct ext_variables_interpreter_context *ctx;
+	unsigned int var_count;
 	
 	/* Create our context */
-	ctx = ext_variables_interpreter_context_create(interp);
+	ctx = ext_variables_interpreter_context_create(renv->interp);
+	
+	if ( sieve_binary_read_integer(renv->sbin, address, &var_count) ) {
+		
+	}
 	
 	/* Enable support for match values */
-	(void) sieve_match_values_set_enabled(interp, TRUE);
+	(void) sieve_match_values_set_enabled(renv->interp, TRUE);
+	
+	return TRUE;
 }
 
 static inline struct ext_variables_interpreter_context *
diff --git a/src/lib-sieve/plugins/variables/ext-variables-common.h b/src/lib-sieve/plugins/variables/ext-variables-common.h
index 6108abf5e..cd22b3737 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-common.h
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.h
@@ -68,11 +68,26 @@ ext_variables_validator_context_get(struct sieve_validator *valdtr)
 struct sieve_variable *ext_variables_validator_get_variable
 	(struct sieve_validator *validator, const char *variable, bool declare);
 
+/*
+ * Code generation
+ */
+ 
+bool ext_variables_generator_load
+	(const struct sieve_codegen_env *cgenv);
+
+/*
+ * Code dump
+ */
+ 
+bool ext_variables_code_dump
+	(const struct sieve_dumptime_env *denv, sieve_size_t *address);
+
 /*
  * Interpreter context
  */	
 
-void ext_variables_interpreter_initialize(struct sieve_interpreter *interp);
+bool ext_variables_interpreter_load
+(const struct sieve_runtime_env *renv, sieve_size_t *address);
 
 /* 
  * Variable coding 
diff --git a/src/lib-sieve/plugins/variables/ext-variables.c b/src/lib-sieve/plugins/variables/ext-variables.c
index 8a94a0364..57e1fc8c1 100644
--- a/src/lib-sieve/plugins/variables/ext-variables.c
+++ b/src/lib-sieve/plugins/variables/ext-variables.c
@@ -59,7 +59,6 @@ const struct sieve_operand *ext_variables_operands[] = {
 
 static bool ext_variables_load(int ext_id);
 static bool ext_variables_validator_load(struct sieve_validator *validator);
-static bool ext_variables_interpreter_load(struct sieve_interpreter *interp);
 
 static int ext_my_id;
 	
@@ -68,9 +67,10 @@ struct sieve_extension variables_extension = {
 	&ext_my_id,
 	ext_variables_load,
 	ext_variables_validator_load, 
-	NULL,
+	ext_variables_generator_load,
 	ext_variables_interpreter_load,
-	NULL, NULL,
+	NULL, NULL, 
+	ext_variables_code_dump,
 	SIEVE_EXT_DEFINE_OPERATIONS(ext_variables_operations), 
 	SIEVE_EXT_DEFINE_OPERANDS(ext_variables_operands)
 };
@@ -95,10 +95,3 @@ static bool ext_variables_validator_load
 	return TRUE;
 }
 
-static bool ext_variables_interpreter_load
-	(struct sieve_interpreter *interp)
-{
-	ext_variables_interpreter_initialize(interp);
-
-	return TRUE;
-}
diff --git a/src/lib-sieve/sieve-address-parts.c b/src/lib-sieve/sieve-address-parts.c
index a3550140c..b30e60cd0 100644
--- a/src/lib-sieve/sieve-address-parts.c
+++ b/src/lib-sieve/sieve-address-parts.c
@@ -50,7 +50,7 @@ const struct sieve_extension address_part_extension = {
 	&ext_my_id,
 	addrp_extension_load,
 	addrp_validator_load,
-	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_NO_OPERATIONS,
 	SIEVE_EXT_DEFINE_NO_OPERANDS /* Defined as core operand */
 };
diff --git a/src/lib-sieve/sieve-code-dumper.c b/src/lib-sieve/sieve-code-dumper.c
index 358227f4f..5b16d0175 100644
--- a/src/lib-sieve/sieve-code-dumper.c
+++ b/src/lib-sieve/sieve-code-dumper.c
@@ -1,3 +1,6 @@
+/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file
+ */
+
 #include <stdio.h>
 #include <string.h>
 
@@ -187,15 +190,21 @@ void sieve_code_dumper_run(struct sieve_code_dumper *dumper)
 			
 			sieve_code_mark(denv);
 			
-			if ( !sieve_binary_read_extension(sbin, &dumper->pc, &code, &ext) ) 
-			{
-        success = FALSE;
-        break;
-      }
+			if ( !sieve_binary_read_extension(sbin, &dumper->pc, &code, &ext) ) {
+				success = FALSE;
+				break;
+			}
       	
-      sieve_code_dumpf(denv, "%s", ext->name);
+			sieve_code_dumpf(denv, "%s", ext->name);
       
-			/* Load ? */ 
+			if ( ext->code_dump != NULL ) {
+				sieve_code_descend(denv);
+				if ( !ext->code_dump(denv, &dumper->pc) ) {
+					success = FALSE;
+					break;
+				}
+				sieve_code_ascend(denv);
+			}
 		}
 		
 		sieve_code_ascend(denv);
diff --git a/src/lib-sieve/sieve-comparators.c b/src/lib-sieve/sieve-comparators.c
index e34b4a1d5..4cb06c844 100644
--- a/src/lib-sieve/sieve-comparators.c
+++ b/src/lib-sieve/sieve-comparators.c
@@ -52,7 +52,7 @@ const struct sieve_extension comparator_extension = {
 	&ext_my_id,
 	cmp_extension_load,
 	cmp_validator_load,
-	NULL, NULL, NULL, NULL,
+	NULL, NULL, NULL, NULL, NULL,
 	SIEVE_EXT_DEFINE_NO_OPERATIONS,
 	SIEVE_EXT_DEFINE_NO_OPERANDS    /* Defined as core operand */
 };
diff --git a/src/lib-sieve/sieve-extensions.c b/src/lib-sieve/sieve-extensions.c
index 2738d8399..e73be96ec 100644
--- a/src/lib-sieve/sieve-extensions.c
+++ b/src/lib-sieve/sieve-extensions.c
@@ -38,14 +38,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, 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, NULL, NULL, 
 	SIEVE_EXT_DEFINE_NO_OPERATIONS, 
 	SIEVE_EXT_DEFINE_NO_OPERANDS
 };
diff --git a/src/lib-sieve/sieve-extensions.h b/src/lib-sieve/sieve-extensions.h
index e1a862332..8f1738b38 100644
--- a/src/lib-sieve/sieve-extensions.h
+++ b/src/lib-sieve/sieve-extensions.h
@@ -26,12 +26,19 @@ struct sieve_extension {
 	
 	bool (*load)(int ext_id);
 
-	bool (*validator_load)(struct sieve_validator *validator);	
-	bool (*generator_load)(const struct sieve_codegen_env *cgenv);
-	bool (*interpreter_load)(struct sieve_interpreter *interpreter);
+	bool (*validator_load)
+		(struct sieve_validator *validator);	
+	bool (*generator_load)
+		(const struct sieve_codegen_env *cgenv);
+	bool (*interpreter_load)
+		(const struct sieve_runtime_env *renv, sieve_size_t *address);
+	bool (*binary_load)
+		(struct sieve_binary *binary);
 	
-	bool (*binary_load)(struct sieve_binary *binary);
-	bool (*binary_dump)(struct sieve_dumptime_env *denv);
+	bool (*binary_dump)
+		(struct sieve_dumptime_env *denv);
+	bool (*code_dump)
+		(const struct sieve_dumptime_env *denv, sieve_size_t *address);
 
 	struct sieve_extension_obj_registry operations;
 	struct sieve_extension_obj_registry operands;
diff --git a/src/lib-sieve/sieve-interpreter.c b/src/lib-sieve/sieve-interpreter.c
index 21988f6ef..40f958275 100644
--- a/src/lib-sieve/sieve-interpreter.c
+++ b/src/lib-sieve/sieve-interpreter.c
@@ -96,7 +96,7 @@ struct sieve_interpreter *sieve_interpreter_create
 		const struct sieve_extension *ext = sieve_preloaded_extensions[i];
 		
 		if ( ext->interpreter_load != NULL )
-			(void)ext->interpreter_load(interp);		
+			(void)ext->interpreter_load(&interp->runenv, &interp->pc);		
 	}
 
 	/* Load other extensions listed in code */
@@ -110,7 +110,8 @@ struct sieve_interpreter *sieve_interpreter_create
         break;
       }
  
-			if ( ext->interpreter_load != NULL && !ext->interpreter_load(interp) ) {
+			if ( ext->interpreter_load != NULL && 
+				!ext->interpreter_load(&interp->runenv, &interp->pc) ) {
 				success = FALSE;
 				break;
 			}
diff --git a/src/lib-sieve/sieve-match-types.c b/src/lib-sieve/sieve-match-types.c
index f010855b1..18d9b2dd1 100644
--- a/src/lib-sieve/sieve-match-types.c
+++ b/src/lib-sieve/sieve-match-types.c
@@ -60,7 +60,7 @@ const struct sieve_extension match_type_extension = {
 	&ext_my_id,
 	mtch_extension_load,
 	mtch_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/testsuite/ext-testsuite.c b/src/testsuite/ext-testsuite.c
index 222b018a8..e648fa29e 100644
--- a/src/testsuite/ext-testsuite.c
+++ b/src/testsuite/ext-testsuite.c
@@ -90,7 +90,7 @@ const struct sieve_extension testsuite_extension = {
 	ext_testsuite_generator_load,
 	NULL,
 	ext_testsuite_binary_load, 
-	NULL, 
+	NULL, NULL,
 	SIEVE_EXT_DEFINE_OPERATIONS(testsuite_operations),
 	SIEVE_EXT_DEFINE_OPERAND(testsuite_object_operand)
 };
-- 
GitLab