dovecot-2.0-pigeonhole: Restructured and cleaned up trace debugg...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sun May 16 15:43:54 EEST 2010
details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/325c959af6f7
changeset: 1287:325c959af6f7
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun May 16 14:43:43 2010 +0200
description:
Restructured and cleaned up trace debugging and optional operand fetching.
diffstat:
src/lib-sieve/Makefile.am | 3 +
src/lib-sieve/cmd-discard.c | 6 +-
src/lib-sieve/cmd-keep.c | 21 +-
src/lib-sieve/cmd-redirect.c | 27 +-
src/lib-sieve/cmd-stop.c | 2 +-
src/lib-sieve/ext-envelope.c | 27 +-
src/lib-sieve/ext-fileinto.c | 19 +-
src/lib-sieve/ext-reject.c | 43 +-
src/lib-sieve/plugins/body/ext-body-common.c | 5 +-
src/lib-sieve/plugins/body/tst-body.c | 58 +-
src/lib-sieve/plugins/date/ext-date-common.c | 3 +-
src/lib-sieve/plugins/date/tst-date.c | 66 ++--
src/lib-sieve/plugins/enotify/cmd-notify.c | 160 ++++-----
src/lib-sieve/plugins/enotify/ext-enotify-common.c | 4 +-
src/lib-sieve/plugins/enotify/tst-notify-method-capability.c | 33 +-
src/lib-sieve/plugins/enotify/tst-valid-notify-method.c | 7 +-
src/lib-sieve/plugins/environment/tst-environment.c | 30 +-
src/lib-sieve/plugins/imap4flags/cmd-flag.c | 51 +-
src/lib-sieve/plugins/imap4flags/ext-imap4flags-common.c | 10 +-
src/lib-sieve/plugins/imap4flags/tag-flags.c | 15 +-
src/lib-sieve/plugins/imap4flags/tst-hasflag.c | 65 ++-
src/lib-sieve/plugins/include/cmd-global.c | 10 +-
src/lib-sieve/plugins/include/cmd-include.c | 2 +-
src/lib-sieve/plugins/include/cmd-return.c | 2 -
src/lib-sieve/plugins/include/ext-include-common.c | 50 +-
src/lib-sieve/plugins/mailbox/tst-mailboxexists.c | 7 +-
src/lib-sieve/plugins/notify/cmd-denotify.c | 127 +++----
src/lib-sieve/plugins/notify/cmd-notify.c | 145 ++++----
src/lib-sieve/plugins/notify/ext-notify-common.c | 2 +-
src/lib-sieve/plugins/spamvirustest/ext-spamvirustest-common.c | 42 +-
src/lib-sieve/plugins/spamvirustest/tst-spamvirustest.c | 41 +-
src/lib-sieve/plugins/vacation/cmd-vacation.c | 177 ++++------
src/lib-sieve/plugins/variables/cmd-set.c | 17 +-
src/lib-sieve/plugins/variables/ext-variables-modifiers.h | 8 +-
src/lib-sieve/plugins/variables/ext-variables-operands.c | 33 +-
src/lib-sieve/plugins/variables/sieve-ext-variables.h | 9 +-
src/lib-sieve/plugins/variables/tst-string.c | 29 +-
src/lib-sieve/sieve-actions.c | 75 ++++
src/lib-sieve/sieve-actions.h | 12 +
src/lib-sieve/sieve-address-parts.c | 123 ++++---
src/lib-sieve/sieve-address-parts.h | 9 +-
src/lib-sieve/sieve-code-dumper.c | 132 +++----
src/lib-sieve/sieve-code.c | 162 ++++++----
src/lib-sieve/sieve-code.h | 72 +++-
src/lib-sieve/sieve-common.h | 4 +-
src/lib-sieve/sieve-dump.h | 14 +-
src/lib-sieve/sieve-interpreter.c | 234 ++++++-------
src/lib-sieve/sieve-interpreter.h | 82 +----
src/lib-sieve/sieve-match.c | 95 ++---
src/lib-sieve/sieve-match.h | 4 +-
src/lib-sieve/sieve-runtime-trace.c | 139 ++++++++
src/lib-sieve/sieve-runtime-trace.h | 132 ++++++++
src/lib-sieve/sieve-runtime.h | 43 ++
src/lib-sieve/sieve-types.h | 16 +-
src/lib-sieve/sieve.c | 5 +-
src/lib-sieve/tst-address.c | 20 +-
src/lib-sieve/tst-exists.c | 17 +-
src/lib-sieve/tst-header.c | 37 +-
src/lib-sieve/tst-size.c | 25 +-
src/sieve-tools/debug/cmd-debug-print.c | 6 +-
src/sieve-tools/sieve-test.c | 1 +
src/testsuite/cmd-test-binary.c | 23 +-
src/testsuite/cmd-test-config.c | 30 +-
src/testsuite/cmd-test-fail.c | 7 +-
src/testsuite/cmd-test-mailbox.c | 16 +-
src/testsuite/cmd-test-message.c | 30 +-
src/testsuite/cmd-test-set.c | 7 +-
src/testsuite/cmd-test.c | 9 +-
src/testsuite/testsuite-script.c | 8 +-
src/testsuite/testsuite.c | 9 +-
src/testsuite/tst-test-error.c | 53 +-
src/testsuite/tst-test-multiscript.c | 7 +-
src/testsuite/tst-test-result-execute.c | 2 +-
src/testsuite/tst-test-result.c | 53 +-
src/testsuite/tst-test-script-compile.c | 9 +-
src/testsuite/tst-test-script-run.c | 68 ++--
76 files changed, 1769 insertions(+), 1377 deletions(-)
diffs (truncated from 5662 to 300 lines):
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/Makefile.am
--- a/src/lib-sieve/Makefile.am Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/Makefile.am Sun May 16 14:43:43 2010 +0200
@@ -84,6 +84,7 @@
sieve-validator.c \
sieve-generator.c \
sieve-interpreter.c \
+ sieve-runtime-trace.c \
sieve-code-dumper.c \
sieve-binary-dumper.c \
sieve-result.c \
@@ -125,6 +126,8 @@
sieve-validator.h \
sieve-generator.h \
sieve-interpreter.h \
+ sieve-runtime-trace.h \
+ sieve-runtime.h \
sieve-code-dumper.h \
sieve-binary-dumper.h \
sieve-dump.h \
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/cmd-discard.c
--- a/src/lib-sieve/cmd-discard.c Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/cmd-discard.c Sun May 16 14:43:43 2010 +0200
@@ -94,7 +94,7 @@
sieve_code_dumpf(denv, "DISCARD");
sieve_code_descend(denv);
- return sieve_code_dumper_print_optional_operands(denv, address);
+ return ( sieve_action_opr_optional_dump(denv, address, NULL) == 0 );
}
/*
@@ -108,9 +108,9 @@
unsigned int source_line;
/* Source line */
- source_line = sieve_runtime_get_source_location(renv, renv->oprtn.address);
+ source_line = sieve_runtime_get_command_location(renv);
- sieve_runtime_trace(renv, "DISCARD action");
+ sieve_runtime_trace(renv, SIEVE_TRLVL_ACTIONS, "discard action");
return ( sieve_result_add_action
(renv, NULL, &act_discard, NULL, source_line, NULL, 0) >= 0 );
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/cmd-keep.c
--- a/src/lib-sieve/cmd-keep.c Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/cmd-keep.c Sun May 16 14:43:43 2010 +0200
@@ -73,7 +73,7 @@
sieve_code_dumpf(denv, "KEEP");
sieve_code_descend(denv);
- return sieve_code_dumper_print_optional_operands(denv, address);
+ return ( sieve_action_opr_optional_dump(denv, address, NULL) == 0 );
}
/*
@@ -85,17 +85,24 @@
{
struct sieve_side_effects_list *slist = NULL;
unsigned int source_line;
- int ret = 0;
+ int ret = 0;
+
+ /*
+ * Read data
+ */
/* Source line */
- source_line = sieve_runtime_get_source_location(renv, renv->oprtn.address);
+ source_line = sieve_runtime_get_command_location(renv);
/* Optional operands (side effects only) */
- if ( (ret=sieve_interpreter_handle_optional_operands
- (renv, address, &slist)) <= 0 )
- return ret;
+ if ( (ret=sieve_action_opr_optional_read(renv, address, NULL, &slist)) != 0 )
+ return SIEVE_EXEC_BIN_CORRUPT;
- sieve_runtime_trace(renv, "KEEP action");
+ /*
+ * Perform operation
+ */
+
+ sieve_runtime_trace(renv, SIEVE_TRLVL_ACTIONS, "keep action");
/* Add keep action to result.
*/
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/cmd-redirect.c
--- a/src/lib-sieve/cmd-redirect.c Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/cmd-redirect.c Sun May 16 14:43:43 2010 +0200
@@ -176,14 +176,14 @@
sieve_code_dumpf(denv, "REDIRECT");
sieve_code_descend(denv);
- if ( !sieve_code_dumper_print_optional_operands(denv, address) )
+ if ( sieve_action_opr_optional_dump(denv, address, NULL) != 0 )
return FALSE;
return sieve_opr_string_dump(denv, address, "reason");
}
/*
- * Intepretation
+ * Code execution
*/
static int cmd_redirect_operation_execute
@@ -197,24 +197,29 @@
pool_t pool;
int ret = 0;
+ /*
+ * Read data
+ */
+
/* Source line */
- source_line = sieve_runtime_get_source_location(renv, renv->oprtn.address);
+ source_line = sieve_runtime_get_command_location(renv);
- /* Optional operands (side effects) */
- if ( (ret=sieve_interpreter_handle_optional_operands
- (renv, address, &slist)) <= 0 )
- return ret;
+ /* Optional operands (side effects only) */
+ if ( (ret=sieve_action_opr_optional_read(renv, address, NULL, &slist)) < 0 )
+ return SIEVE_EXEC_BIN_CORRUPT;
/* Read the address */
- if ( !sieve_opr_string_read(renv, address, &redirect) ) {
- sieve_runtime_trace_error(renv, "invalid address string");
+ if ( !sieve_opr_string_read(renv, address, "address", &redirect) )
return SIEVE_EXEC_BIN_CORRUPT;
- }
+
+ /*
+ * Perform operation
+ */
/* FIXME: perform address normalization if the string is not a string literal
*/
- sieve_runtime_trace(renv, "REDIRECT action (\"%s\")",
+ sieve_runtime_trace(renv, SIEVE_TRLVL_ACTIONS, "redirect action (\"%s\")",
str_sanitize(str_c(redirect), 64));
/* Add redirect action to the result */
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/cmd-stop.c
--- a/src/lib-sieve/cmd-stop.c Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/cmd-stop.c Sun May 16 14:43:43 2010 +0200
@@ -77,7 +77,7 @@
static int opc_stop_execute
(const struct sieve_runtime_env *renv, sieve_size_t *address ATTR_UNUSED)
{
- sieve_runtime_trace(renv, "STOP");
+ sieve_runtime_trace(renv, SIEVE_TRLVL_COMMANDS, "STOP");
sieve_interpreter_interrupt(renv->interp);
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/ext-envelope.c
--- a/src/lib-sieve/ext-envelope.c Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/ext-envelope.c Sun May 16 14:43:43 2010 +0200
@@ -308,7 +308,7 @@
sieve_code_descend(denv);
/* Handle any optional arguments */
- if ( !sieve_addrmatch_default_dump_optionals(denv, address) )
+ if ( sieve_addrmatch_opr_optional_dump(denv, address, NULL) != 0 )
return FALSE;
return
@@ -426,24 +426,27 @@
/*
* Read operands
*/
-
- sieve_runtime_trace(renv, "ENVELOPE test");
- if ( (ret=sieve_addrmatch_default_get_optionals
- (renv, address, &addrp, &mcht, &cmp)) <= 0 )
- return ret;
+ /* Read optional operands */
+ if ( (ret=sieve_addrmatch_opr_optional_read
+ (renv, address, NULL, &addrp, &mcht, &cmp)) < 0 )
+ return SIEVE_EXEC_BIN_CORRUPT;
/* Read envelope-part */
- if ( (envp_list=sieve_opr_stringlist_read(renv, address)) == NULL ) {
- sieve_runtime_trace_error(renv, "invalid envelope-part operand");
+ if ( (envp_list=sieve_opr_stringlist_read(renv, address, "envelope-part"))
+ == NULL )
return SIEVE_EXEC_BIN_CORRUPT;
- }
/* Read key-list */
- if ( (key_list=sieve_opr_stringlist_read(renv, address)) == NULL ) {
- sieve_runtime_trace_error(renv, "invalid key-list operand");
+ if ( (key_list=sieve_opr_stringlist_read(renv, address, "key-list"))
+ == NULL )
return SIEVE_EXEC_BIN_CORRUPT;
- }
+
+ /*
+ * Perform test
+ */
+
+ sieve_runtime_trace(renv, SIEVE_TRLVL_TESTS, "envelope test");
/* Initialize match */
mctx = sieve_match_begin(renv->interp, &mcht, &cmp, NULL, key_list);
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/ext-fileinto.c
--- a/src/lib-sieve/ext-fileinto.c Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/ext-fileinto.c Sun May 16 14:43:43 2010 +0200
@@ -139,9 +139,8 @@
sieve_code_dumpf(denv, "FILEINTO");
sieve_code_descend(denv);
- if ( !sieve_code_dumper_print_optional_operands(denv, address) ) {
+ if ( sieve_action_opr_optional_dump(denv, address, NULL) != 0 )
return FALSE;
- }
return sieve_opr_string_dump(denv, address, "folder");
}
@@ -164,25 +163,23 @@
*/
/* Source line */
- source_line = sieve_runtime_get_source_location(renv, renv->oprtn.address);
+ source_line = sieve_runtime_get_command_location(renv);
- /* Optional operands */
- if ( (ret=sieve_interpreter_handle_optional_operands(renv, address, &slist))
- <= 0 )
- return ret;
+ /* Optional operands (side effects only) */
+ if ( (ret=sieve_action_opr_optional_read(renv, address, NULL, &slist)) < 0 )
+ return SIEVE_EXEC_BIN_CORRUPT;
/* Folder operand */
- if ( !sieve_opr_string_read(renv, address, &folder) ) {
- sieve_runtime_trace_error(renv, "invalid folder operand");
+ if ( !sieve_opr_string_read(renv, address, "folder", &folder) )
return SIEVE_EXEC_BIN_CORRUPT;
- }
/*
* Perform operation
*/
mailbox = str_sanitize(str_c(folder), 64);
- sieve_runtime_trace(renv, "FILEINTO action (\"%s\")", mailbox);
+ sieve_runtime_trace(renv, SIEVE_TRLVL_ACTIONS,
+ "fileinto action (\"%s\")", mailbox);
/* Add action to result */
ret = sieve_act_store_add_to_result
diff -r 6c9d1a295517 -r 325c959af6f7 src/lib-sieve/ext-reject.c
--- a/src/lib-sieve/ext-reject.c Fri May 14 22:57:06 2010 +0200
+++ b/src/lib-sieve/ext-reject.c Sun May 16 14:43:43 2010 +0200
@@ -246,12 +246,10 @@
static bool ext_reject_operation_dump
(const struct sieve_dumptime_env *denv, sieve_size_t *address)
{
- const struct sieve_operation *op = &denv->oprtn;
-
- sieve_code_dumpf(denv, "%s", sieve_operation_mnemonic(op));
+ sieve_code_dumpf(denv, "%s", sieve_operation_mnemonic(denv->oprtn));
sieve_code_descend(denv);
- if ( !sieve_code_dumper_print_optional_operands(denv, address) )
+ if ( sieve_action_opr_optional_dump(denv, address, NULL) != 0 )
return FALSE;
return sieve_opr_string_dump(denv, address, "reason");
@@ -264,8 +262,8 @@
static int ext_reject_operation_execute
(const struct sieve_runtime_env *renv, sieve_size_t *address)
{
- const struct sieve_operation *op = &renv->oprtn;
- const struct sieve_extension *this_ext = op->ext;
+ const struct sieve_operation *oprtn = renv->oprtn;
+ const struct sieve_extension *this_ext = oprtn->ext;
struct sieve_side_effects_list *slist = NULL;
struct act_reject_context *act;
string_t *reason;
@@ -273,28 +271,37 @@
pool_t pool;
int ret;
+ /*
+ * Read data
+ */
+
/* Source line */
- source_line = sieve_runtime_get_source_location(renv, op->address);
-
- /* Optional operands (side effects) */
- if ( (ret=sieve_interpreter_handle_optional_operands
- (renv, address, &slist)) <= 0 )
- return ret;
More information about the dovecot-cvs
mailing list