dovecot-2.2-pigeonhole: lib-sieve: Restructured parsing of stora...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sat Mar 14 13:49:44 UTC 2015


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/adf9baf74a4d
changeset: 2006:adf9baf74a4d
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Thu Mar 12 21:37:41 2015 +0100
description:
lib-sieve: Restructured parsing of storage options.

diffstat:

 src/lib-sieve/sieve-storage.c |  37 ++++++++++++++++++++-----------------
 1 files changed, 20 insertions(+), 17 deletions(-)

diffs (97 lines):

diff -r a58ba4e734b1 -r adf9baf74a4d src/lib-sieve/sieve-storage.c
--- a/src/lib-sieve/sieve-storage.c	Sat Mar 14 14:42:30 2015 +0100
+++ b/src/lib-sieve/sieve-storage.c	Thu Mar 12 21:37:41 2015 +0100
@@ -164,9 +164,9 @@
 	return ( storage_class == NULL ? -1 : 1 );
 }
 
-static bool sieve_storage_data_parse
+static int sieve_storage_data_parse
 (struct sieve_storage *storage, const char *data, const char **location_r,
-	const char *const **options_r, const char **error_r)
+	const char *const **options_r)
 {
 	ARRAY_TYPE(const_string) options;
 	const char *const *tmp;
@@ -174,7 +174,7 @@
 	if (*data == '\0') {
 		*options_r = NULL;
 		*location_r = data;
-		return TRUE;
+		return 0;
 	}
 
 	/* <location> */
@@ -190,8 +190,10 @@
 
 			if ( strncasecmp(option, "name=", 5) == 0 ) {
 				if ( option[5] == '\0' ) {
-					*error_r = "empty name not allowed";
-					return FALSE;
+					sieve_storage_sys_error(storage,
+						"Failed to parse storage location: "
+						"Empty name not allowed");
+					return -1;
 				}
 
 				if ( storage->script_name == NULL )
@@ -201,8 +203,10 @@
 				const char *bin_dir = option+7;
 
 				if ( bin_dir[0] == '\0' ) {
-					*error_r = "empty bindir not allowed";
-					return FALSE;
+					sieve_storage_sys_error(storage,
+						"Failed to parse storage location: "
+						"Empty bindir not allowed");
+					return -1;
 				}
 
 				if ( bin_dir[0] == '~' ) {
@@ -212,9 +216,11 @@
 					if ( home != NULL ) {
 						bin_dir = home_expand_tilde(bin_dir, home);
 					} else if ( bin_dir[1] == '/' || bin_dir[1] == '\0' ) {
-						*error_r = "bindir is relative to home directory (~/), "
-							"but home directory cannot be determined";
-						return FALSE;
+						sieve_storage_sys_error(storage,
+							"Failed to parse storage location: "
+							"bindir is relative to home directory (~/), "
+							"but home directory cannot be determined");
+						return -1;
 					}
 				}
 
@@ -228,7 +234,7 @@
 		*options_r = array_idx(&options, 0);
 	}
 
-	return TRUE;
+	return 0;
 }
 
 struct sieve_storage *sieve_storage_alloc
@@ -258,7 +264,7 @@
 {
 	struct sieve_storage *storage;
 	const char *const *options;
-	const char *location, *parse_error;
+	const char *location;
 	enum sieve_error error;
 
 	if ( error_r != NULL )
@@ -290,11 +296,8 @@
 		storage = sieve_storage_alloc
 			(svinst, storage_class, data, flags, main);
 
-		if ( !sieve_storage_data_parse
-			(storage, data, &location, &options, &parse_error) ) {
-			sieve_sys_error(svinst, "%s storage: "
-				"Failed to parse storage location: %s",
-				storage_class->driver_name, parse_error);
+		if ( sieve_storage_data_parse
+			(storage, data, &location, &options) < 0 ) {
 			*error_r = SIEVE_ERROR_TEMP_FAILURE;
 			sieve_storage_unref(&storage);
 			storage = NULL;


More information about the dovecot-cvs mailing list