dovecot-1.2-sieve: Variables extension: removed public dependenc...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Tue Jan 12 17:05:12 EET 2010


details:   http://hg.rename-it.nl/dovecot-1.2-sieve/rev/fdbf4a73935d
changeset: 1199:fdbf4a73935d
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Tue Jan 12 11:47:18 2010 +0100
description:
Variables extension: removed public dependency on ext-variables-limits.h.

diffstat:

 src/lib-sieve/plugins/include/ext-include-variables.c     |   8 ++++----
 src/lib-sieve/plugins/variables/cmd-set.c                 |   9 +++++----
 src/lib-sieve/plugins/variables/ext-variables-arguments.c |   6 +++---
 src/lib-sieve/plugins/variables/ext-variables-common.c    |  20 +++++++++++++++-----
 src/lib-sieve/plugins/variables/ext-variables-limits.h    |  10 +++++-----
 src/lib-sieve/plugins/variables/ext-variables-name.c      |   4 ++--
 src/lib-sieve/plugins/variables/ext-variables-operands.c  |   5 +++--
 src/lib-sieve/plugins/variables/sieve-ext-variables.h     |   6 +++++-
 8 files changed, 42 insertions(+), 26 deletions(-)

diffs (227 lines):

diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/include/ext-include-variables.c
--- a/src/lib-sieve/plugins/include/ext-include-variables.c	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/include/ext-include-variables.c	Tue Jan 12 11:47:18 2010 +0100
@@ -46,7 +46,7 @@
 		sieve_command_validate_error(valdtr, cmd,
 			"declaration of new global variable '%s' exceeds the limit "
 			"(max variables: %u)", 
-			variable, SIEVE_VARIABLES_MAX_SCOPE_SIZE);
+			variable, sieve_variables_get_max_scope_size());
 		return NULL;
 	}
 	
@@ -107,10 +107,10 @@
 		return FALSE;
 	}
 
-	if ( count > SIEVE_VARIABLES_MAX_SCOPE_SIZE ) {
+	if ( count > sieve_variables_get_max_scope_size() ) {
 		sieve_sys_error("include: global variable scope size of binary %s "
 			"exceeds the limit (%u > %u)", sieve_binary_path(sbin),
-			count, SIEVE_VARIABLES_MAX_SCOPE_SIZE );
+			count, sieve_variables_get_max_scope_size() );
 		return FALSE;
 	}
 
@@ -228,7 +228,7 @@
 		sieve_argument_validate_error(valdtr, arg, 
 			"(implicit) declaration of new global variable '%s' exceeds the limit "
 			"(max variables: %u)", variable, 
-			SIEVE_VARIABLES_MAX_SCOPE_SIZE);
+			sieve_variables_get_max_scope_size());
 		return FALSE;
 	}
 	
diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/variables/cmd-set.c
--- a/src/lib-sieve/plugins/variables/cmd-set.c	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/variables/cmd-set.c	Tue Jan 12 11:47:18 2010 +0100
@@ -19,6 +19,7 @@
 #include "sieve-dump.h"
 
 #include "ext-variables-common.h"
+#include "ext-variables-limits.h"
 #include "ext-variables-modifiers.h"
 
 /* 
@@ -316,8 +317,8 @@
 	sieve_runtime_trace(renv, "SET action");
 
 	/* Hold value within limits */
-	if ( str_len(value) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE )
-		str_truncate(value, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+	if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+		str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 
 	T_BEGIN {
 		/* Apply modifiers if necessary (sorted during code generation already) */
@@ -346,8 +347,8 @@
 						break;
 
 					/* Hold value within limits */
-					if ( str_len(value) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE )
-						str_truncate(value, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+					if ( str_len(value) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+						str_truncate(value, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 				}
 			}
 		}	
diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/variables/ext-variables-arguments.c
--- a/src/lib-sieve/plugins/variables/ext-variables-arguments.c	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/variables/ext-variables-arguments.c	Tue Jan 12 11:47:18 2010 +0100
@@ -48,7 +48,7 @@
 		sieve_argument_validate_error(valdtr, arg, 
 			"(implicit) declaration of new variable '%s' exceeds the limit "
 			"(max variables: %u)", variable, 
-			SIEVE_VARIABLES_MAX_SCOPE_SIZE);
+			EXT_VARIABLES_MAX_SCOPE_SIZE);
 		return FALSE;
 	}
 	
@@ -114,10 +114,10 @@
 		return FALSE;
 	}
 
-	if ( index > SIEVE_VARIABLES_MAX_MATCH_INDEX ) {
+	if ( index > EXT_VARIABLES_MAX_MATCH_INDEX ) {
 		sieve_argument_validate_error(valdtr, arg, 
 			"match value index %u out of range (max: %u)", index, 
-			SIEVE_VARIABLES_MAX_MATCH_INDEX);
+			EXT_VARIABLES_MAX_MATCH_INDEX);
 		return FALSE;
 	} 
 
diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/variables/ext-variables-common.c
--- a/src/lib-sieve/plugins/variables/ext-variables-common.c	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/variables/ext-variables-common.c	Tue Jan 12 11:47:18 2010 +0100
@@ -21,10 +21,20 @@
 #include "sieve-interpreter.h"
 
 #include "ext-variables-common.h"
+#include "ext-variables-limits.h"
 #include "ext-variables-name.h"
 #include "ext-variables-modifiers.h"
 
 /*
+ * Limits
+ */
+
+unsigned int sieve_variables_get_max_scope_size(void)
+{ 
+	return EXT_VARIABLES_MAX_SCOPE_SIZE;
+}
+
+/*
  * Variable scope 
  */
 
@@ -95,7 +105,7 @@
 	new_var = p_new(scope->pool, struct sieve_variable, 1);
 	new_var->ext = scope->ext;
 
-	if ( array_count(&scope->variable_index) >= SIEVE_VARIABLES_MAX_SCOPE_SIZE ) {
+	if ( array_count(&scope->variable_index) >= EXT_VARIABLES_MAX_SCOPE_SIZE ) {
 		if ( scope->error_var == NULL ) {
 			new_var->identifier = "@ERROR@";
 			new_var->index = 0;
@@ -311,8 +321,8 @@
 	str_append_str(varval, value);
 
 	/* Just a precaution, caller should prevent this in the first place */
-	if ( str_len(varval) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE )
-		str_truncate(varval, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+	if ( str_len(varval) > EXT_VARIABLES_MAX_VARIABLE_SIZE )
+		str_truncate(varval, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 
 	return TRUE;
 }
@@ -510,9 +520,9 @@
 		return FALSE;
 	}
 
-	if ( scope_size > SIEVE_VARIABLES_MAX_SCOPE_SIZE ) {
+	if ( scope_size > EXT_VARIABLES_MAX_SCOPE_SIZE ) {
 		sieve_sys_error("variables: scope size exceeds the limit (%u > %u)", 
-			scope_size, SIEVE_VARIABLES_MAX_SCOPE_SIZE );
+			scope_size, EXT_VARIABLES_MAX_SCOPE_SIZE );
 		return FALSE;
 	}
 	
diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/variables/ext-variables-limits.h
--- a/src/lib-sieve/plugins/variables/ext-variables-limits.h	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/variables/ext-variables-limits.h	Tue Jan 12 11:47:18 2010 +0100
@@ -24,11 +24,11 @@
  *  as a syntax error, which SHOULD be discovered at compile-time.
  */
 
-#define SIEVE_VARIABLES_MAX_SCOPE_SIZE              255
-#define SIEVE_VARIABLES_MAX_VARIABLE_NAME_LEN       64
-#define SIEVE_VARIABLES_MAX_VARIABLE_SIZE           (4 * 1024)
-#define SIEVE_VARIABLES_MAX_NAMESPACE_ELEMENTS      4
+#define EXT_VARIABLES_MAX_SCOPE_SIZE              255
+#define EXT_VARIABLES_MAX_VARIABLE_NAME_LEN       64
+#define EXT_VARIABLES_MAX_VARIABLE_SIZE           (4 * 1024)
+#define EXT_VARIABLES_MAX_NAMESPACE_ELEMENTS      4
 
-#define SIEVE_VARIABLES_MAX_MATCH_INDEX             SIEVE_MAX_MATCH_VALUES
+#define EXT_VARIABLES_MAX_MATCH_INDEX             SIEVE_MAX_MATCH_VALUES
 
 #endif /* __EXT_VARIABLES_LIMITS_H */
diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/variables/ext-variables-name.c
--- a/src/lib-sieve/plugins/variables/ext-variables-name.c	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/variables/ext-variables-name.c	Tue Jan 12 11:47:18 2010 +0100
@@ -26,7 +26,7 @@
 
 		/* Acquire current position in the array */
 
-		if ( array_count(vname) >= SIEVE_VARIABLES_MAX_NAMESPACE_ELEMENTS )
+		if ( array_count(vname) >= EXT_VARIABLES_MAX_NAMESPACE_ELEMENTS )
 			return -1;
 
 		cur_element = array_append_space(vname);
@@ -42,7 +42,7 @@
 			p++;
 		
 			while ( p < strend && (*p == '_' || i_isalnum(*p)) ) {
-				if ( str_len(cur_ident) >= SIEVE_VARIABLES_MAX_VARIABLE_NAME_LEN )
+				if ( str_len(cur_ident) >= EXT_VARIABLES_MAX_VARIABLE_NAME_LEN )
 					return -1;
 				str_append_c(cur_ident, *p);
 				p++;
diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/variables/ext-variables-operands.c
--- a/src/lib-sieve/plugins/variables/ext-variables-operands.c	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/variables/ext-variables-operands.c	Tue Jan 12 11:47:18 2010 +0100
@@ -19,6 +19,7 @@
 #include "sieve-interpreter.h"
 
 #include "ext-variables-common.h"
+#include "ext-variables-limits.h"
 #include "ext-variables-name.h"
 #include "ext-variables-dump.h"
 #include "ext-variables-operands.h"
@@ -242,8 +243,8 @@
 		
 			if ( *str == NULL ) 
 				*str = t_str_new(0);
-			else if ( str_len(*str) > SIEVE_VARIABLES_MAX_VARIABLE_SIZE ) 
-				str_truncate(*str, SIEVE_VARIABLES_MAX_VARIABLE_SIZE);
+			else if ( str_len(*str) > EXT_VARIABLES_MAX_VARIABLE_SIZE ) 
+				str_truncate(*str, EXT_VARIABLES_MAX_VARIABLE_SIZE);
 		}
 		return TRUE;
 	}
diff -r dbd1fc78eb6b -r fdbf4a73935d src/lib-sieve/plugins/variables/sieve-ext-variables.h
--- a/src/lib-sieve/plugins/variables/sieve-ext-variables.h	Tue Jan 12 00:07:21 2010 +0100
+++ b/src/lib-sieve/plugins/variables/sieve-ext-variables.h	Tue Jan 12 11:47:18 2010 +0100
@@ -13,7 +13,11 @@
 #include "sieve-objects.h"
 #include "sieve-code.h"
 
-#include "ext-variables-limits.h"
+/*
+ * Limits
+ */
+
+unsigned int sieve_variables_get_max_scope_size(void);
 
 /*
  * Variable extension


More information about the dovecot-cvs mailing list