dovecot-2.0-pigeonhole: Changed result execution logging to use ...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Wed Apr 28 17:31:21 EEST 2010


details:   http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/6885f0782b96
changeset: 1263:6885f0782b96
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Wed Apr 28 16:31:03 2010 +0200
description:
Changed result execution logging to use a var_expand_table created by liblda to avoid code duplication (patch by Timo Sirainen).

diffstat:

 src/lib-sieve/Makefile.am    |   1 +
 src/lib-sieve/sieve-result.c |  46 ++++------------------------------------------
 src/managesieve/Makefile.am  |   4 ++--
 src/sieve-tools/Makefile.am  |   4 ++--
 src/testsuite/Makefile.am    |   4 ++--
 5 files changed, 11 insertions(+), 48 deletions(-)

diffs (122 lines):

diff -r 2e3bbb0fc95c -r 6885f0782b96 src/lib-sieve/Makefile.am
--- a/src/lib-sieve/Makefile.am	Wed Apr 28 16:26:14 2010 +0200
+++ b/src/lib-sieve/Makefile.am	Wed Apr 28 16:31:03 2010 +0200
@@ -4,6 +4,7 @@
 
 AM_CPPFLAGS = \
 	$(LIBDOVECOT_INCLUDE) \
+	$(LIBDOVECOT_LDA_INCLUDE) \
 	-DMODULEDIR=\""$(dovecot_moduledir)"\"
 
 tests = \
diff -r 2e3bbb0fc95c -r 6885f0782b96 src/lib-sieve/sieve-result.c
--- a/src/lib-sieve/sieve-result.c	Wed Apr 28 16:26:14 2010 +0200
+++ b/src/lib-sieve/sieve-result.c	Wed Apr 28 16:31:03 2010 +0200
@@ -10,6 +10,7 @@
 #include "str-sanitize.h"
 #include "var-expand.h"
 #include "message-address.h"
+#include "mail-deliver.h"
 
 #include "sieve-common.h"
 #include "sieve-limits.h"
@@ -846,53 +847,14 @@
  * Result execution
  */
 
-static const char *_get_from_address(struct mail *mail)
-{
-	struct message_address *addr;
-	const char *str;
-
-	if ( mail_get_first_header(mail, "from", &str) <= 0 )
-		return NULL;
-
-	addr = message_address_parse
-		(pool_datastack_create(), (const unsigned char *)str, strlen(str), 1, 
-			FALSE);
-
-	return addr == NULL || addr->mailbox == NULL || addr->domain == NULL ||
-		*addr->mailbox == '\0' || *addr->domain == '\0' ?
-		NULL : t_strconcat(addr->mailbox, "@", addr->domain, NULL);
-}
-
 static void _sieve_result_prepare_execution(struct sieve_result *result)
 {
 	const struct sieve_message_data *msgdata = result->action_env.msgdata;
 	const struct sieve_script_env *senv = result->action_env.scriptenv;
-	const struct var_expand_table static_tab[] = {
-		{ 'm', NULL, "msgid" },
-		{ 's', NULL, "subject" },
-		{ 'f', NULL, "from" },
-		{ '\0', NULL, NULL }
-	};
-	const char *msgid = msgdata->id;
-	struct var_expand_table *tab;
-	unsigned int i;
+	const struct var_expand_table *tab;
 
-	tab = t_malloc(sizeof(static_tab));
-	memcpy(tab, static_tab, sizeof(static_tab));
-
-	msgid = ( msgid == NULL ? "unspecified" : str_sanitize(msgid, 80) );
-
-	/* Fill in substitution items */
-	tab[0].value = msgid;
-	(void)mail_get_first_header_utf8(msgdata->mail, "Subject", &tab[1].value);
-	tab[2].value = _get_from_address(msgdata->mail);
-	tab[3].value = "";
-
-	/* Sanitize substitution items */
-	for (i = 0; tab[i].key != '\0'; i++)
-		tab[i].value = str_sanitize(tab[i].value, 80);
-
-	result->action_env.exec_status = 
+	tab = mail_deliver_get_log_var_expand_table(msgdata->mail, NULL);
+	result->action_env.exec_status =
 		( senv->exec_status == NULL ? 
 			t_new(struct sieve_exec_status, 1) : senv->exec_status );
 
diff -r 2e3bbb0fc95c -r 6885f0782b96 src/managesieve/Makefile.am
--- a/src/managesieve/Makefile.am	Wed Apr 28 16:26:14 2010 +0200
+++ b/src/managesieve/Makefile.am	Wed Apr 28 16:31:03 2010 +0200
@@ -27,9 +27,9 @@
 	$(top_srcdir)/src/lib-sievestorage/libsievestorage.a \
 	$(top_srcdir)/src/lib-sieve/libdovecot-sieve.la
 
-managesieve_LDADD = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT)
+managesieve_LDADD = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT_LDA) $(LIBDOVECOT)
 
-managesieve_DEPENDENCIES = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS)
+managesieve_DEPENDENCIES = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_LDA_DEPS) $(LIBDOVECOT_DEPS)
 
 cmds = \
 	cmd-capability.c \
diff -r 2e3bbb0fc95c -r 6885f0782b96 src/sieve-tools/Makefile.am
--- a/src/sieve-tools/Makefile.am	Wed Apr 28 16:26:14 2010 +0200
+++ b/src/sieve-tools/Makefile.am	Wed Apr 28 16:31:03 2010 +0200
@@ -18,8 +18,8 @@
 	$(top_srcdir)/src/lib-sieve-tool/libsieve-tool.la \
 	./debug/libsieve_ext_debug.la
 
-libs_ldadd = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT)
-libs_deps = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS)
+libs_ldadd = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT_LDA) $(LIBDOVECOT)
+libs_deps = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_LDA_DEPS) $(LIBDOVECOT_DEPS)
 
 # Sieve Compile Tool
 
diff -r 2e3bbb0fc95c -r 6885f0782b96 src/testsuite/Makefile.am
--- a/src/testsuite/Makefile.am	Wed Apr 28 16:26:14 2010 +0200
+++ b/src/testsuite/Makefile.am	Wed Apr 28 16:31:03 2010 +0200
@@ -12,8 +12,8 @@
 	$(top_srcdir)/src/lib-sieve/libdovecot-sieve.la \
 	$(top_srcdir)/src/lib-sieve-tool/libsieve-tool.la
 
-testsuite_LDADD = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT)
-testsuite_DEPENDENCIES = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_DEPS)
+testsuite_LDADD = $(libs) $(LIBDOVECOT_STORAGE) $(LIBDOVECOT_LDA) $(LIBDOVECOT)
+testsuite_DEPENDENCIES = $(libs) $(LIBDOVECOT_STORAGE_DEPS) $(LIBDOVECOT_LDA_DEPS) $(LIBDOVECOT_DEPS)
 
 commands = \
 	cmd-test.c \


More information about the dovecot-cvs mailing list