dovecot-2.0-pigeonhole: Made global system error handler state p...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sat Sep 4 15:54:48 EEST 2010


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/cda3b3fe04b0
changeset: 1406:cda3b3fe04b0
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sat Sep 04 14:51:35 2010 +0200
description:
Made global system error handler state part of Sieve instance.

diffstat:

 src/lib-sieve-tool/sieve-tool.c                                |   16 +-
 src/lib-sieve/plugins/include/ext-include-binary.c             |   16 +-
 src/lib-sieve/plugins/include/ext-include-common.c             |    4 +-
 src/lib-sieve/plugins/include/ext-include-variables.c          |    3 +-
 src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c |   33 +-
 src/lib-sieve/plugins/variables/ext-variables-common.c         |   21 +-
 src/lib-sieve/plugins/variables/sieve-ext-variables.h          |    4 +-
 src/lib-sieve/sieve-binary-file.c                              |  134 +++++----
 src/lib-sieve/sieve-binary-private.h                           |    4 +-
 src/lib-sieve/sieve-common.h                                   |    3 +
 src/lib-sieve/sieve-error-private.h                            |   12 +-
 src/lib-sieve/sieve-error.c                                    |  188 +++++++++-----
 src/lib-sieve/sieve-error.h                                    |   28 +-
 src/lib-sieve/sieve-extensions.c                               |   11 +-
 src/lib-sieve/sieve-message.c                                  |   22 +-
 src/lib-sieve/sieve-script.c                                   |    4 +-
 src/lib-sieve/sieve-settings.c                                 |   10 +-
 src/lib-sieve/sieve.c                                          |   38 +-
 src/lib-sieve/sieve.h                                          |    2 +-
 src/lib-sieve/tst-size.c                                       |    2 +-
 src/lib-sievestorage/sieve-storage.c                           |    2 +-
 src/managesieve/cmd-putscript.c                                |    4 +-
 src/plugins/lda-sieve/lda-sieve-log.c                          |    5 +-
 src/plugins/lda-sieve/lda-sieve-log.h                          |    3 +-
 src/plugins/lda-sieve/lda-sieve-plugin.c                       |  132 +++++----
 src/sieve-tools/sieve-test.c                                   |    9 +-
 src/testsuite/cmd-test-binary.c                                |    6 +-
 src/testsuite/testsuite-log.c                                  |   29 +-
 src/testsuite/testsuite-mailstore.c                            |    6 +-
 29 files changed, 450 insertions(+), 301 deletions(-)

diffs (truncated from 2269 to 300 lines):

diff -r 2b7290f6307c -r cda3b3fe04b0 src/lib-sieve-tool/sieve-tool.c
--- a/src/lib-sieve-tool/sieve-tool.c	Fri Sep 03 17:58:23 2010 +0200
+++ b/src/lib-sieve-tool/sieve-tool.c	Sat Sep 04 14:51:35 2010 +0200
@@ -41,7 +41,7 @@
 
 	char *username;
 	char *homedir;
-	
+
 	char *sieve_extensions;
 	ARRAY_TYPE(const_string) sieve_plugins;
 
@@ -515,8 +515,8 @@
 {
 	struct sieve_error_handler *ehandler;
 	struct sieve_binary *sbin;
-	
-	ehandler = sieve_stderr_ehandler_create(0);
+
+	ehandler = sieve_stderr_ehandler_create(svinst, 0);
 	sieve_error_handler_accept_infolog(ehandler, TRUE);
 
 	if ( (sbin = sieve_compile(svinst, filename, name, ehandler, NULL)) == NULL )
@@ -526,14 +526,14 @@
 
 	return sbin;
 }
-	
+
 struct sieve_binary *sieve_tool_script_open
 (struct sieve_instance *svinst, const char *filename)
 {
 	struct sieve_error_handler *ehandler;
 	struct sieve_binary *sbin;
-	
-	ehandler = sieve_stderr_ehandler_create(0);
+
+	ehandler = sieve_stderr_ehandler_create(svinst, 0);
 	sieve_error_handler_accept_infolog(ehandler, TRUE);
 
 	if ( (sbin = sieve_open(svinst, filename, NULL, ehandler, NULL)) == NULL ) {
@@ -542,7 +542,7 @@
 	}
 
 	sieve_error_handler_unref(&ehandler);
-		
+
 	sieve_save(sbin, NULL, FALSE, NULL);
 	return sbin;
 }
@@ -561,7 +561,7 @@
 		i_fatal("Failed to create stream for sieve code dump.");
 	}
 }
-	
+
 /*
  * Commandline option parsing
  */
diff -r 2b7290f6307c -r cda3b3fe04b0 src/lib-sieve/plugins/include/ext-include-binary.c
--- a/src/lib-sieve/plugins/include/ext-include-binary.c	Fri Sep 03 17:58:23 2010 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-binary.c	Sat Sep 04 14:51:35 2010 +0200
@@ -233,6 +233,7 @@
 static bool ext_include_binary_open
 (const struct sieve_extension *ext, struct sieve_binary *sbin, void *context)
 {
+	struct sieve_instance *svinst = ext->svinst;
 	struct ext_include_binary_context *binctx = 
 		(struct ext_include_binary_context *) context;
 	struct sieve_binary_block *sblock;
@@ -245,7 +246,8 @@
 	offset = 0;	
 		
 	if ( !sieve_binary_read_unsigned(sblock, &offset, &depcount) ) {
-		sieve_sys_error("include: failed to read include count "
+		sieve_sys_error(svinst, 
+			"include: failed to read include count "
 			"for dependency block %d of binary %s", block_id, 
 			sieve_binary_path(sbin));
 		return FALSE;
@@ -253,7 +255,8 @@
 	
 	/* Check include limit */	
 	if ( depcount > EXT_INCLUDE_MAX_INCLUDES ) {
-		sieve_sys_error("include: binary %s includes too many scripts (%u > %u)",
+		sieve_sys_error(svinst,
+			"include: binary %s includes too many scripts (%u > %u)",
 			sieve_binary_path(sbin), depcount, EXT_INCLUDE_MAX_INCLUDES); 
 		return FALSE;
 	}
@@ -272,14 +275,16 @@
 			!sieve_binary_read_byte(sblock, &offset, &location) ||
 			!sieve_binary_read_string(sblock, &offset, &script_name) ) {
 			/* Binary is corrupt, recompile */
-			sieve_sys_error("include: failed to read included script "
+			sieve_sys_error(svinst,
+				"include: failed to read included script "
 				"from dependency block %d of binary %s", block_id, 
 				sieve_binary_path(sbin)); 
 			return FALSE;
 		}
 
 		if ( (inc_block=sieve_binary_block_get(sbin, inc_block_id)) == NULL ) {
-			sieve_sys_error("include: failed to find block %d for included script "
+			sieve_sys_error(svinst,
+				"include: failed to find block %d for included script "
 				"from dependency block %d of binary %s", inc_block_id, block_id, 
 				sieve_binary_path(sbin)); 
 
@@ -288,7 +293,8 @@
 		
 		if ( location >= EXT_INCLUDE_LOCATION_INVALID ) {
 			/* Binary is corrupt, recompile */
-			sieve_sys_error("include: dependency block %d of binary %s "
+			sieve_sys_error(svinst,
+				"include: dependency block %d of binary %s "
 				"reports invalid script location (id %d)", 
 				block_id, sieve_binary_path(sbin), location); 
 			return FALSE;
diff -r 2b7290f6307c -r cda3b3fe04b0 src/lib-sieve/plugins/include/ext-include-common.c
--- a/src/lib-sieve/plugins/include/ext-include-common.c	Fri Sep 03 17:58:23 2010 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-common.c	Sat Sep 04 14:51:35 2010 +0200
@@ -84,7 +84,7 @@
 
 		if ( sieve_dir == NULL ) {
 			if ( home == NULL )	{		
-				sieve_sys_error(
+				sieve_sys_error(svinst,
 					"include: sieve_dir and home not set for :personal script include "	
 					"(wanted script '%s')", str_sanitize(script_name, 80));
 				return NULL;
@@ -101,7 +101,7 @@
 		sieve_dir = sieve_setting_get(svinst, "sieve_global_dir");
 
 		if (sieve_dir == NULL) {
-			sieve_sys_error(
+			sieve_sys_error(svinst,
 				"include: sieve_global_dir not set for :global script include "	
 				"(wanted script '%s')", str_sanitize(script_name, 80));
 			return NULL;
diff -r 2b7290f6307c -r cda3b3fe04b0 src/lib-sieve/plugins/include/ext-include-variables.c
--- a/src/lib-sieve/plugins/include/ext-include-variables.c	Fri Sep 03 17:58:23 2010 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-variables.c	Sat Sep 04 14:51:35 2010 +0200
@@ -104,7 +104,8 @@
 	/* Sanity assert */
 	i_assert( *global_vars_r == NULL );
 
-	*global_vars_r = sieve_variable_scope_binary_read(this_ext, sblock, offset);
+	*global_vars_r = sieve_variable_scope_binary_read
+		(this_ext->svinst, this_ext, sblock, offset);
 
 	return ( *global_vars_r != NULL );
 }
diff -r 2b7290f6307c -r cda3b3fe04b0 src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c
--- a/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c	Fri Sep 03 17:58:23 2010 +0200
+++ b/src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c	Sat Sep 04 14:51:35 2010 +0200
@@ -248,8 +248,8 @@
 (const struct sieve_extension *ext, void **context)
 {
 	struct ext_spamvirustest_data *ext_data =
-        (struct ext_spamvirustest_data *) *context;
-    struct sieve_instance *svinst = ext->svinst;
+		(struct ext_spamvirustest_data *) *context;
+	struct sieve_instance *svinst = ext->svinst;
 	const char *ext_name, *status_header, *max_header, *status_type, 
 		*max_value;
 	enum ext_spamvirustest_status_type type;
@@ -300,7 +300,8 @@
 	} else if ( strcmp(status_type, "text") == 0 ) {
 		type = EXT_SPAMVIRUSTEST_STATUS_TYPE_TEXT;
 	} else {
-		sieve_sys_error("%s: invalid status type '%s'", ext_name, status_type);
+		sieve_sys_error(svinst, 
+			"%s: invalid status type '%s'", ext_name, status_type);
 		return FALSE;
 	}
 
@@ -309,24 +310,28 @@
 	if ( type != EXT_SPAMVIRUSTEST_STATUS_TYPE_TEXT ) {
 
 		if ( max_header != NULL && max_value != NULL ) {
-			sieve_sys_error("%s: sieve_%s_max_header and sieve_%s_max_value "
+			sieve_sys_error(svinst,
+				"%s: sieve_%s_max_header and sieve_%s_max_value "
 				"cannot both be configured", ext_name, ext_name, ext_name);
 			return TRUE;
 		}
 
 		if ( max_header == NULL && max_value == NULL ) {
-			sieve_sys_error("%s: none of sieve_%s_max_header or sieve_%s_max_value "
+			sieve_sys_error(svinst,
+				"%s: none of sieve_%s_max_header or sieve_%s_max_value "
 				"is configured", ext_name, ext_name, ext_name);
 			return TRUE;
 		}
 	} else {
 		if ( max_header != NULL ) {
-			sieve_sys_warning("%s: setting sieve_%s_max_header has no meaning "
+			sieve_sys_warning(svinst,
+				"%s: setting sieve_%s_max_header has no meaning "
 				"for sieve_%s_status_type=text", ext_name, ext_name, ext_name);
 		}
 
 		if ( max_value != NULL ) {
-			sieve_sys_warning("%s: setting sieve_%s_max_value has no meaning "
+			sieve_sys_warning(svinst,
+				"%s: setting sieve_%s_max_value has no meaning "
 				"for sieve_%s_status_type=text", ext_name, ext_name, ext_name);
 		}	
 	}
@@ -339,7 +344,8 @@
 
 	if ( !ext_spamvirustest_header_spec_parse
 		(&ext_data->status_header, ext_data->pool, status_header, &error) ) {
-		sieve_sys_error("%s: invalid status header specification "
+		sieve_sys_error(svinst,
+			"%s: invalid status header specification "
 			"'%s': %s", ext_name, status_header, error);
 		result = FALSE;
 	}
@@ -350,7 +356,8 @@
 
 			if ( max_header != NULL && !ext_spamvirustest_header_spec_parse
 				(&ext_data->max_header, ext_data->pool, max_header, &error) ) {
-				sieve_sys_error("%s: invalid max header specification "
+				sieve_sys_error(svinst,
+					"%s: invalid max header specification "
 					"'%s': %s", ext_name, max_header, error);
 				result = FALSE;
 			}
@@ -360,7 +367,8 @@
 			if ( result && max_value != NULL ) {
 				if ( !ext_spamvirustest_parse_decimal_value
 					(max_value, &ext_data->max_value, &error) ) {
-					sieve_sys_error("%s: invalid max value specification "
+					sieve_sys_error(svinst,
+						"%s: invalid max value specification "
 						"'%s': %s", ext_name, max_value, error);
 					result = FALSE;
 				}
@@ -387,8 +395,9 @@
 	if ( result ) {
 		*context = (void *) ext_data;
 	} else {
-		sieve_sys_warning("%s: extension not configured, "
-			"tests will always match against \"0\"", ext_name);
+		sieve_sys_warning(svinst, 
+			"%s: extension not configured, tests will always match against \"0\"",
+			ext_name);
 		ext_spamvirustest_unload(ext);
 		*context = NULL;
 	}
diff -r 2b7290f6307c -r cda3b3fe04b0 src/lib-sieve/plugins/variables/ext-variables-common.c
--- a/src/lib-sieve/plugins/variables/ext-variables-common.c	Fri Sep 03 17:58:23 2010 +0200
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.c	Sat Sep 04 14:51:35 2010 +0200
@@ -301,8 +301,8 @@
 }
 
 struct sieve_variable_scope_binary *sieve_variable_scope_binary_read
-(const struct sieve_extension *ext, struct sieve_binary_block *sblock,
-	sieve_size_t *address)
+(struct sieve_instance *svinst, const struct sieve_extension *ext,
+	struct sieve_binary_block *sblock, sieve_size_t *address)
 {
 	struct sieve_variable_scope *scope;
 	struct sieve_variable_scope_binary *scpbin;
@@ -314,13 +314,15 @@
 
 	/* Read scope size */	
 	if ( !sieve_binary_read_unsigned(sblock, address, &scope_size) ) {
-		sieve_sys_error("%s: variable scope: failed to read size", ext_name);
+		sieve_sys_error
+			(svinst, "%s: variable scope: failed to read size", ext_name);
 		return NULL;
 	}
 
 	/* Check size limit */
 	if ( scope_size > EXT_VARIABLES_MAX_SCOPE_SIZE ) {
-		sieve_sys_error("%s: variable scope: size exceeds the limit (%u > %u)", 
+		sieve_sys_error(svinst,
+			"%s: variable scope: size exceeds the limit (%u > %u)", 
 			ext_name, scope_size, EXT_VARIABLES_MAX_SCOPE_SIZE );
 		return NULL;
 	}
@@ -328,7 +330,8 @@
 	/* Read offset */
 	pc = *address;	
 	if ( !sieve_binary_read_offset(sblock, address, &end_offset) ) {
-		sieve_sys_error("%s: variable scope: failed to read end offset", ext_name);
+		sieve_sys_error(svinst,
+			"%s: variable scope: failed to read end offset", ext_name);
 		return NULL;
 	}
 	
@@ -349,6 +352,7 @@
 (struct sieve_variable_scope_binary *scpbin)
 {
 	const struct sieve_extension *ext = scpbin->scope->ext;
+	struct sieve_instance *svinst = ext->svinst;
 	const char *ext_name = 


More information about the dovecot-cvs mailing list