dovecot-2.0-pigeonhole: Sieve tools: added support for extended ...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Sun Jul 11 18:06:37 EEST 2010


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/843ba8e66e1b
changeset: 1327:843ba8e66e1b
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Sun Jul 11 17:06:31 2010 +0200
description:
Sieve tools: added support for extended trace debugging and updated man pages.

diffstat:

 doc/man/sieve-filter.1                             |   4 +-
 doc/man/sieve-test.1                               |  52 ++++++++++++++++++++++---
 doc/man/sievec.1                                   |   4 +-
 doc/man/sieved.1                                   |   4 +-
 src/lib-sieve/plugins/include/ext-include-common.c |   8 ++--
 src/lib-sieve/sieve-interpreter.c                  |   4 +-
 src/lib-sieve/sieve-runtime-trace.h                |  21 ++++++----
 src/lib-sieve/sieve-runtime.h                      |   2 +-
 src/lib-sieve/sieve-types.h                        |  22 +++++++----
 src/sieve-tools/sieve-test.c                       |  51 +++++++++++++++++++++----
 src/testsuite/cmd-test.c                           |   4 +-
 src/testsuite/testsuite-script.c                   |   2 +-
 src/testsuite/testsuite.c                          |   2 +-
 13 files changed, 132 insertions(+), 48 deletions(-)

diffs (truncated from 510 to 300 lines):

diff -r cdd4c08c2f85 -r 843ba8e66e1b doc/man/sieve-filter.1
--- a/doc/man/sieve-filter.1	Sun Jul 11 12:40:00 2010 +0200
+++ b/doc/man/sieve-filter.1	Sun Jul 11 17:06:31 2010 +0200
@@ -6,7 +6,7 @@
 features! The behavior described in this manual page represents the design and not necessarily what the tool currently implements.
 
 .SH SYNOPSIS
-sieve\-filter [\fB\-c\fR \fIconfig-file\fR] [\fIoptions\fR] \fIscript\-file\fR \fIsource\-location\fR \fIsource\-mailbox\fR [\fIinbox\-namespace\fR [\fInamespace\fR ...]]
+sieve\-filter [\fB\-c\fR \fIconfig\-file\fR] [\fIoptions\fR] \fIscript\-file\fR \fIsource\-location\fR \fIsource\-mailbox\fR [\fIinbox\-namespace\fR [\fInamespace\fR ...]]
 .TP
 \fInamepace\fR = [prefix=]location[;option=value,option=value,...]
 .TP
@@ -66,7 +66,7 @@
 
 .SH OPTIONS
 .TP
-\fB\-c\fP \fIconfig-file\fP
+\fB\-c\fP \fIconfig\-file\fP
 Alternative Dovecot configuration file path.
 .TP 
 \fB\-D\fP \fIsource\-action\fP
diff -r cdd4c08c2f85 -r 843ba8e66e1b doc/man/sieve-test.1
--- a/doc/man/sieve-test.1	Sun Jul 11 12:40:00 2010 +0200
+++ b/doc/man/sieve-test.1	Sun Jul 11 17:06:31 2010 +0200
@@ -3,7 +3,7 @@
 sieve\-test \- Sieve script tester for the Dovecot secure IMAP server
 .SH SYNOPSIS
 sieve\-test
-[\fB\-c\fR \fIconfig-file\fR]
+[\fB\-c\fR \fIconfig\-file\fR]
 [\fB\-C\fR]
 [\fB\-D\fR]
 [\fB\-d\fR \fIdump\-file\fR]
@@ -13,7 +13,7 @@
 [\fB\-m\fR \fIdefault\-mailbox\fR]
 [\fB\-r\fR \fIrecipient\-address\fR]
 [\fB\-s\fR \fIscript\-file\fR]
-[\fB\-t\fR]
+[\fB\-t\fR \fItrace\-option\fR]
 [\fB\-x\fR "\fIextension extension ...\fR"]
 \fIscript\-file\fR \fImail\-file\fR
 .SH DESCRIPTION
@@ -45,7 +45,7 @@
 behavior by forcing the script to be compiled into a new binary.  
 .SH OPTIONS
 .TP 
-\fB\-c\fP \fIconfig-file\fP
+\fB\-c\fP \fIconfig\-file\fP
 Alternative Dovecot configuration file path.
 .TP
 \fB\-C\fP
@@ -91,9 +91,9 @@
 allowed and the specified scripts are executed sequentially in the order specified at the command
 line.
 .TP
-\fB\-t\fP
-Enable simple trace debugging; prints all encountered byte code instructions to \fBstdout\fP. This is
-currently only intelligible for developers.
+\fB\-t\fP \fItrace\-option\fP
+Configure runtime trace debugging. Trace debugging provides detailed insight in the operations performed
+by the Sieve script. Refer to the trace debugging section below. 
 .TP
 \fB\-x\fP "\fIextension extension ...\fP"
 Set the available extensions. The parameter is a space\-separated list of the active extensions. By
@@ -105,7 +105,45 @@
 
 For example \fB\-x\fP "+imapflags \-enotify" will enable the deprecated imapflags extension along with all
 extensions that are available by default, except for the enotify extension.
-.SH DEBUG SUPPORT
+
+.SH RUNTIME TRACE DEBUGGING
+.PP
+Using the \fB-t\fP option, the \fBsieve\-test\fP tool can be configured to print detailed information on
+the Sieve script execution. For example, the encountered commands, the performed tests and the matched 
+values can be printed. 
+.PP
+The \fB\-t\fP option can be specified multiple times. It can be used as follows:
+
+.TP 2
+\fB\-tlevel=...\fP
+Set the verbosity level of the trace debugging. One of the following values can be supplied:
+.RS 2
+.TP 3 
+\fInone\fP (default)
+No trace debugging.
+.TP 
+\fIactions\fP
+Only print executed action commands, like keep, fileinto, reject and redirect.
+.TP
+\fIcommands\fP
+Print any command, excluding tests.
+.TP
+\fItests\fP
+Print all commands and performed tests.
+.TP
+\fImatching\fP
+Print all commands, performed tests and the values matched for those tests. 
+.RE
+.TP 2
+\fB\-tdebug\fP
+Print debug messages as well. This is usually only useful for developers and produces messy output.
+.TP
+\fB\-taddresses\fP
+Print byte code addresses for the current trace output. Normally, only the current Sieve source code 
+position is printed. The byte code addresses are equal to those listed in a binary dump produced
+using the \fB\-d\fP option or by the \fBsieved(1)\fP command.
+
+.SH DEBUG SIEVE EXTENSION
 .PP
 To improve script debugging, the Sieve command line tools such as \fBsieve\-test\fP support a custom
 Sieve language extension called 'vnd.dovecot.debug'. It adds the \fBdebug_print\fP command that allows
diff -r cdd4c08c2f85 -r 843ba8e66e1b doc/man/sievec.1
--- a/doc/man/sievec.1	Sun Jul 11 12:40:00 2010 +0200
+++ b/doc/man/sievec.1	Sun Jul 11 17:06:31 2010 +0200
@@ -2,7 +2,7 @@
 .SH NAME
 sievec \- Sieve script compiler for the Dovecot secure IMAP server
 .SH SYNOPSIS
-sievec [\fB\-c\fR \fIconfig-file\fR] [\fB\-d\fR] [\fB\-x\fR "\fIextension extension ...\fR"] \fIscript\-file\fR [\fIout\-file\fR]
+sievec [\fB\-c\fR \fIconfig\-file\fR] [\fB\-d\fR] [\fB\-x\fR "\fIextension extension ...\fR"] \fIscript\-file\fR [\fIout\-file\fR]
 .SH DESCRIPTION
 .PP
 The \fBsievec\fP command is part of the Pigeonhole Sieve implementation for the Dovecot secure 
@@ -43,7 +43,7 @@
 binaries.
 .SH OPTIONS
 .TP
-\fB\-c\fP \fIconfig-file\fP
+\fB\-c\fP \fIconfig\-file\fP
 Alternative Dovecot configuration file path.
 .TP 
 \fB\-d\fP 
diff -r cdd4c08c2f85 -r 843ba8e66e1b doc/man/sieved.1
--- a/doc/man/sieved.1	Sun Jul 11 12:40:00 2010 +0200
+++ b/doc/man/sieved.1	Sun Jul 11 17:06:31 2010 +0200
@@ -2,7 +2,7 @@
 .SH NAME
 sieved \- Sieve script binary dump tool for the Dovecot secure IMAP server
 .SH SYNOPSIS
-sieved [\fB\-c\fR \fIconfig-file\fR] [\fB\-x\fR "\fIextension extension ...\fR"] \fIsieve\-binary\fR [\fIout\-file\fR]
+sieved [\fB\-c\fR \fIconfig\-file\fR] [\fB\-x\fR "\fIextension extension ...\fR"] \fIsieve\-binary\fR [\fIout\-file\fR]
 .br
 .SH DESCRIPTION
 .PP
@@ -34,7 +34,7 @@
 on the language extensions used when compiling the binary. 
 .SH OPTIONS
 .TP
-\fB\-c\fP \fIconfig-file\fP
+\fB\-c\fP \fIconfig\-file\fP
 Alternative Dovecot configuration file path.
 .TP
 \fB\-x\fP "\fIextension extension ...\fP"
diff -r cdd4c08c2f85 -r 843ba8e66e1b src/lib-sieve/plugins/include/ext-include-common.c
--- a/src/lib-sieve/plugins/include/ext-include-common.c	Sun Jul 11 12:40:00 2010 +0200
+++ b/src/lib-sieve/plugins/include/ext-include-common.c	Sun Jul 11 17:06:31 2010 +0200
@@ -566,12 +566,12 @@
 
 	/* If :once modifier is specified, check for duplicate include */
 	if ( ext_include_runtime_include_mark(ctx, included, once) ) {
-		sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
+		sieve_runtime_trace(renv, SIEVE_TRLVL_NONE,
 			"include: start script '%s' [inc id: %d, block: %d]", 
 			sieve_script_name(included->script), include_id, block_id);
 	} else {
 		/* skip */
-		sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM, 
+		sieve_runtime_trace(renv, SIEVE_TRLVL_NONE, 
 			"include: skipped include for script '%s' [inc id: %d, block: %d]; "
 			"already run once", 
 			sieve_script_name(included->script), include_id, block_id);
@@ -636,7 +636,7 @@
 					curctx = curctx->parent;
 					sieve_interpreter_free(&subinterp);
 
-					sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
+					sieve_runtime_trace(renv, SIEVE_TRLVL_NONE,
 						"include: script '%s' ended [inc id: %d, block: %d]",  
 						sieve_script_name(ended_script->script), ended_script->id,
 						sieve_binary_block_get_id(ended_script->block));
@@ -697,7 +697,7 @@
 			/* This kills curctx too */
 			sieve_interpreter_free(&killed_interp);
 
-			sieve_runtime_trace(renv, SIEVE_TRLVL_MINIMUM,
+			sieve_runtime_trace(renv, SIEVE_TRLVL_NONE,
 				"include: script '%s' ended [id: %d, block: %d]",  
 				sieve_script_name(ended_script->script),
 				ended_script->id, sieve_binary_block_get_id(ended_script->block));
diff -r cdd4c08c2f85 -r 843ba8e66e1b src/lib-sieve/sieve-interpreter.c
--- a/src/lib-sieve/sieve-interpreter.c	Sun Jul 11 12:40:00 2010 +0200
+++ b/src/lib-sieve/sieve-interpreter.c	Sun Jul 11 17:06:31 2010 +0200
@@ -100,7 +100,7 @@
 	interp->runenv.msgdata = msgdata;
 	interp->runenv.scriptenv = senv;
 	interp->runenv.trace_stream = senv->trace_stream;
-	interp->runenv.trace_level = senv->trace_level;
+	interp->runenv.trace_config = senv->trace_config;
 
 	if ( senv->exec_status == NULL ) 
 		interp->runenv.exec_status = p_new(interp->pool, struct sieve_exec_status, 1);
@@ -509,7 +509,7 @@
 		ret = sieve_interpreter_operation_execute(interp);
 
 		if ( ret != SIEVE_EXEC_OK ) {
-			sieve_runtime_trace(&interp->runenv, SIEVE_TRLVL_MINIMUM, 
+			sieve_runtime_trace(&interp->runenv, SIEVE_TRLVL_NONE, 
 				"[[EXECUTION ABORTED]]");
 		}
 	}
diff -r cdd4c08c2f85 -r 843ba8e66e1b src/lib-sieve/sieve-runtime-trace.h
--- a/src/lib-sieve/sieve-runtime-trace.h	Sun Jul 11 12:40:00 2010 +0200
+++ b/src/lib-sieve/sieve-runtime-trace.h	Sun Jul 11 17:06:31 2010 +0200
@@ -13,7 +13,8 @@
 static inline bool sieve_runtime_trace_active
 (const struct sieve_runtime_env *renv, sieve_trace_level_t trace_level) 
 {
-	return ( renv->trace_stream != NULL && trace_level <= renv->trace_level );
+	return ( renv->trace_stream != NULL && 
+		trace_level <= renv->trace_config.level );
 }
 
 /* Trace errors */
@@ -39,7 +40,8 @@
 	va_list args;
 	
 	va_start(args, fmt);
-	if ( renv->trace_stream != NULL )
+	if ( renv->trace_stream != NULL && 
+		renv->trace_config.level > SIEVE_TRLVL_NONE )
 		_sieve_runtime_trace_error(renv, fmt, args);	
 	va_end(args);
 }
@@ -51,7 +53,8 @@
 	va_list args;
 	
 	va_start(args, fmt);
-	if ( renv->trace_stream != NULL )
+	if ( renv->trace_stream != NULL && 
+		renv->trace_config.level > SIEVE_TRLVL_NONE )
 		_sieve_runtime_trace_operand_error(renv, oprnd, field_name, fmt, args);
 	va_end(args);
 }
@@ -73,7 +76,7 @@
 
 	va_start(args, fmt);
 
-	if ( renv->trace_stream != NULL && trace_level <= renv->trace_level ) {
+	if ( renv->trace_stream != NULL && trace_level <= renv->trace_config.level ) {
 		_sieve_runtime_trace(renv, fmt, args);
 	}
 
@@ -96,7 +99,7 @@
 
 	va_start(args, fmt);
 
-	if ( renv->trace_stream != NULL && trace_level <= renv->trace_level ) {
+	if ( renv->trace_stream != NULL && trace_level <= renv->trace_config.level ) {
 		_sieve_runtime_trace_address(renv, address, fmt, args);
 	}
 
@@ -111,7 +114,7 @@
 
 	va_start(args, fmt);
 
-	if ( renv->trace_stream != NULL && trace_level <= renv->trace_level ) {
+	if ( renv->trace_stream != NULL && trace_level <= renv->trace_config.level ) {
 		_sieve_runtime_trace_address(renv, renv->pc, fmt, args);
 	}
 
@@ -126,14 +129,16 @@
 static inline void sieve_runtime_trace_begin
 (const struct sieve_runtime_env *renv)
 {
-	if ( renv->trace_stream != NULL )
+	if ( renv->trace_stream != NULL && 
+		renv->trace_config.level > SIEVE_TRLVL_NONE )
 		_sieve_runtime_trace_begin(renv);
 }
 
 static inline void sieve_runtime_trace_end
 (const struct sieve_runtime_env *renv)
 {
-	if ( renv->trace_stream != NULL )
+	if ( renv->trace_stream != NULL && 
+		renv->trace_config.level > SIEVE_TRLVL_NONE )
 		_sieve_runtime_trace_end(renv);
 }
 
diff -r cdd4c08c2f85 -r 843ba8e66e1b src/lib-sieve/sieve-runtime.h
--- a/src/lib-sieve/sieve-runtime.h	Sun Jul 11 12:40:00 2010 +0200
+++ b/src/lib-sieve/sieve-runtime.h	Sun Jul 11 17:06:31 2010 +0200
@@ -37,7 +37,7 @@
 
 	/* Runtime tracing */
 	struct ostream *trace_stream;
-	sieve_trace_level_t trace_level;
+	struct sieve_trace_config trace_config;
 };
 


More information about the dovecot-cvs mailing list