aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2008-04-19 13:27:59 +0200
committerJohannes Berg <johannes@sipsolutions.net>2008-04-19 13:27:59 +0200
commit2c7f3b568203ee3010db95d6dd060ebaddfe5475 (patch)
tree05220cb95993e97f3550aecfa1b90ee4c12dd9ab
parent0ac5aca79054773d6c03bc7febc81e3f22d0292f (diff)
downloaddovecot-antispam-2c7f3b568203ee3010db95d6dd060ebaddfe5475.tar.gz
dovecot-antispam-2c7f3b568203ee3010db95d6dd060ebaddfe5475.tar.xz
dovecot-antispam-2c7f3b568203ee3010db95d6dd060ebaddfe5475.zip
add verbose debugging
Diffstat (limited to '')
-rw-r--r--Makefile4
-rw-r--r--antispam-plugin.c3
-rw-r--r--antispam-plugin.h12
-rw-r--r--antispam-storage-1.0.c14
-rw-r--r--defconfig3
5 files changed, 33 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 70b9900..b06310c 100644
--- a/Makefile
+++ b/Makefile
@@ -31,6 +31,10 @@ CFLAGS += -DCONFIG_DEBUG -DDEBUG_SYSLOG
objs += debug.o
endif
+ifeq ("$(DEBUG_VERBOSE)", "1")
+CFLAGS += -DCONFIG_DEBUG_VERBOSE
+endif
+
# dovecot version rules
objs += antispam-storage-$(DOVECOT_VERSION).o
ifeq ("$(DOVECOT_VERSION)", "1.0")
diff --git a/antispam-plugin.c b/antispam-plugin.c
index c83d225..1e58722 100644
--- a/antispam-plugin.c
+++ b/antispam-plugin.c
@@ -71,16 +71,19 @@ static bool mailbox_in_list(struct mailbox *box, char **list)
bool mailbox_is_spam(struct mailbox *box)
{
+ debug_verbose("mailbox_is_spam(%s)\n", mailbox_get_name(box));
return mailbox_in_list(box, spam_folders);
}
bool mailbox_is_trash(struct mailbox *box)
{
+ debug_verbose("mailbox_is_trash(%s)\n", mailbox_get_name(box));
return mailbox_in_list(box, trash_folders);
}
bool mailbox_is_unsure(struct mailbox *box)
{
+ debug_verbose("mailbox_is_unsure(%s)\n", mailbox_get_name(box));
return mailbox_in_list(box, unsure_folders);
}
diff --git a/antispam-plugin.h b/antispam-plugin.h
index 9869a14..8a7958d 100644
--- a/antispam-plugin.h
+++ b/antispam-plugin.h
@@ -39,7 +39,17 @@ int backend_commit(struct mailbox_transaction_context *ctx,
void debug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
#else
static void debug(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
-static inline void debug(const char *fmt, ...)
+static inline void debug(const char *fmt __attribute__((unused)), ...)
+{
+}
+#endif
+
+#if defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE)
+/* bit of an ugly short-cut */
+#define debug_verbose debug
+#else
+static void debug_verbose(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
+static inline void debug_verbose(const char *fmt __attribute__((unused)), ...)
{
}
#endif
diff --git a/antispam-storage-1.0.c b/antispam-storage-1.0.c
index 1949454..79dcdf2 100644
--- a/antispam-storage-1.0.c
+++ b/antispam-storage-1.0.c
@@ -71,6 +71,7 @@ antispam_copy(struct mailbox_transaction_context *t, struct mail *mail,
ANTISPAM_CONTEXT(t);
struct mail *copy_dest_mail;
int ret;
+ bool src_trash, dst_trash;
if (dest_mail != NULL)
copy_dest_mail = dest_mail;
@@ -88,12 +89,21 @@ antispam_copy(struct mailbox_transaction_context *t, struct mail *mail,
return -1;
}
- if (!mailbox_is_trash(mail->box) &&
- !mailbox_is_trash(t->box)) {
+ src_trash = mailbox_is_trash(mail->box);
+ dst_trash = mailbox_is_trash(t->box);
+
+ debug_verbose("mail copy: from trash: %d, to trash: %d\n",
+ src_trash, dst_trash);
+
+ if (!src_trash && !dst_trash) {
bool src_spam = mailbox_is_spam(mail->box);
bool dst_spam = mailbox_is_spam(t->box);
bool src_unsu = mailbox_is_unsure(mail->box);
+ debug_verbose("mail copy: src spam: %d, dst spam: %d,"
+ " src unsure: %d\n",
+ src_spam, dst_spam, src_unsu);
+
if ((src_spam || src_unsu) && !dst_spam)
asbox->movetype = MMT_TO_CLEAN;
else if ((!src_spam || src_unsu) && dst_spam)
diff --git a/defconfig b/defconfig
index 345d76f..02ea038 100644
--- a/defconfig
+++ b/defconfig
@@ -41,6 +41,9 @@ INSTALLDIR=/usr/lib/dovecot/modules/imap/
#DEBUG=stderr
#DEBUG=syslog
+# verbose debugging (lots of output!)
+#DEBUG_VERBOSE=1
+
# plugin name, change only if you need to rename the plugin
# (because, for example, you need two instances for different
# spam filters installed)