dovecot-2.0-pigeonhole: Implemented simple runtime trace of stri...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Thu Jul 15 01:45:50 EEST 2010
details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/534ed8c1dea2
changeset: 1332:534ed8c1dea2
user: Stephan Bosch <stephan at rename-it.nl>
date: Thu Jul 15 00:45:37 2010 +0200
description:
Implemented simple runtime trace of string value matching.
diffstat:
src/lib-sieve/sieve-comparators.h | 2 ++
src/lib-sieve/sieve-match.c | 31 ++++++++++++++++++++++++++-----
2 files changed, 28 insertions(+), 5 deletions(-)
diffs (120 lines):
diff -r a688d1de8747 -r 534ed8c1dea2 src/lib-sieve/sieve-comparators.h
--- a/src/lib-sieve/sieve-comparators.h Wed Jul 14 23:55:21 2010 +0200
+++ b/src/lib-sieve/sieve-comparators.h Thu Jul 15 00:45:37 2010 +0200
@@ -71,6 +71,8 @@
#define SIEVE_COMPARATOR_DEFAULT(definition) \
{ SIEVE_OBJECT_DEFAULT(definition), &(definition) }
+#define sieve_comparator_name(cmp) \
+ ( (cmp)->object.def->identifier )
#define sieve_comparator_is(cmp, definition) \
( (cmp)->def == &(definition) )
diff -r a688d1de8747 -r 534ed8c1dea2 src/lib-sieve/sieve-match.c
--- a/src/lib-sieve/sieve-match.c Wed Jul 14 23:55:21 2010 +0200
+++ b/src/lib-sieve/sieve-match.c Thu Jul 15 00:45:37 2010 +0200
@@ -5,6 +5,7 @@
#include "mempool.h"
#include "hash.h"
#include "array.h"
+#include "str-sanitize.h"
#include "sieve-extensions.h"
#include "sieve-commands.h"
@@ -16,6 +17,7 @@
#include "sieve-dump.h"
#include "sieve-comparators.h"
#include "sieve-match-types.h"
+#include "sieve-runtime-trace.h"
#include "sieve-match.h"
@@ -42,6 +44,10 @@
mctx->kextract = kextract;
mctx->key_list = key_list;
+ sieve_runtime_trace(renv, SIEVE_TRLVL_MATCHING,
+ " starting `:%s' match with `%s' comparator:", sieve_match_type_name(mcht),
+ sieve_comparator_name(cmp));
+
if ( mcht->def != NULL && mcht->def->match_init != NULL ) {
mcht->def->match_init(mctx);
}
@@ -50,8 +56,9 @@
}
int sieve_match_value
- (struct sieve_match_context *mctx, const char *value, size_t val_size)
+(struct sieve_match_context *mctx, const char *value, size_t val_size)
{
+ const struct sieve_runtime_env *renv = mctx->runenv;
const struct sieve_match_type *mcht = mctx->match_type;
sieve_coded_stringlist_reset(mctx->key_list);
bool ok = TRUE;
@@ -59,7 +66,10 @@
/* Reject unimplemented match-type */
if ( mcht->def == NULL || mcht->def->match == NULL )
return FALSE;
-
+
+ sieve_runtime_trace(renv, SIEVE_TRLVL_MATCHING,
+ " matching value `%s'", str_sanitize(value, 80));
+
/* Match to all key values */
if ( mcht->def->is_iterative ) {
unsigned int key_index = 0;
@@ -81,12 +91,18 @@
ret = mcht->def->match
(mctx, value, val_size, key, key_size, key_index);
+ sieve_runtime_trace(renv, SIEVE_TRLVL_MATCHING,
+ " with key `%s' => %d", str_sanitize(key, 80), ret);
+
if ( ret != 0 ) break;
}
}
} else {
ret = mcht->def->match(mctx, value, val_size, str_c(key_item),
str_len(key_item), key_index);
+
+ sieve_runtime_trace(renv, SIEVE_TRLVL_MATCHING,
+ " with key `%s' => %d", str_sanitize(str_c(key_item), 80), ret);
}
} T_END;
@@ -105,13 +121,13 @@
return TRUE;
} else {
- bool result;
+ int ret;
T_BEGIN {
- result = mcht->def->match(mctx, value, val_size, NULL, 0, -1);
+ ret = mcht->def->match(mctx, value, val_size, NULL, 0, -1);
} T_END;
- return result;
+ return ret;
}
return FALSE;
@@ -119,6 +135,7 @@
int sieve_match_end(struct sieve_match_context **mctx)
{
+ const struct sieve_runtime_env *renv = (*mctx)->runenv;
const struct sieve_match_type *mcht = (*mctx)->match_type;
int ret = FALSE;
@@ -129,6 +146,10 @@
pool_unref(&(*mctx)->pool);
*mctx = NULL;
+ sieve_runtime_trace(renv, SIEVE_TRLVL_MATCHING,
+ " finishing match with result: %s",
+ ( ret > 0 ? "true" : ( ret < 0 ? "error" : "false" ) ));
+
return ret;
}
More information about the dovecot-cvs
mailing list