aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-10-01 16:48:32 +0200
committerJohannes Berg <johannes@sipsolutions.net>2007-10-01 16:48:32 +0200
commit3e4d592e8c4993847892894a436f2626480da05d (patch)
tree63407ff2937a36dc17f1bdddd0d79bb6264f19f7
parent7ea99173fa56985a298b32d0c0db5195a6d27b17 (diff)
downloaddovecot-antispam-3e4d592e8c4993847892894a436f2626480da05d.tar.gz
dovecot-antispam-3e4d592e8c4993847892894a436f2626480da05d.tar.xz
dovecot-antispam-3e4d592e8c4993847892894a436f2626480da05d.zip
improve signature extraction API
-rw-r--r--dspam-exec.c2
-rw-r--r--signature.c24
-rw-r--r--signature.h8
3 files changed, 27 insertions, 7 deletions
diff --git a/dspam-exec.c b/dspam-exec.c
index 65f33d0..0d02a24 100644
--- a/dspam-exec.c
+++ b/dspam-exec.c
@@ -185,7 +185,7 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
struct antispam_transaction_context *ast,
struct mail *mail, bool from_spam)
{
- return signature_extract(t, mail, &ast->siglist, from_spam);
+ return signature_extract_to_list(t, mail, &ast->siglist, from_spam);
}
void backend_init(pool_t pool)
diff --git a/signature.c b/signature.c
index 228ff3f..1014ed3 100644
--- a/signature.c
+++ b/signature.c
@@ -14,9 +14,9 @@ void signature_init(void)
debug("antispam: signature header line is \"%s\"\n", signature_hdr);
}
-int signature_extract(struct mailbox_transaction_context *t,
- struct mail *mail, struct siglist **list,
- bool from_spam)
+int signature_extract_to_list(struct mailbox_transaction_context *t,
+ struct mail *mail, struct siglist **list,
+ bool from_spam)
{
const char *const *signatures;
struct siglist *item;
@@ -41,6 +41,24 @@ int signature_extract(struct mailbox_transaction_context *t,
return 0;
}
+const char *signature_extract(struct mailbox_transaction_context *t,
+ struct mail *mail)
+{
+ const char *const *signatures;
+
+ signatures = mail_get_headers(mail, signature_hdr);
+ if (!signatures || !signatures[0]) {
+ mail_storage_set_error(t->box->storage,
+ "antispam signature not found");
+ return NULL;
+ }
+
+ while (signatures[1])
+ signatures++;
+
+ return signatures[0];
+}
+
void signature_list_free(struct siglist **list)
{
struct siglist *item, *next;
diff --git a/signature.h b/signature.h
index a015fd3..9135aee 100644
--- a/signature.h
+++ b/signature.h
@@ -11,9 +11,11 @@ struct siglist {
};
void signature_init(void);
-int signature_extract(struct mailbox_transaction_context *t,
- struct mail *mail, struct siglist **list,
- bool from_spam);
+int signature_extract_to_list(struct mailbox_transaction_context *t,
+ struct mail *mail, struct siglist **list,
+ bool from_spam);
+const char *signature_extract(struct mailbox_transaction_context *t,
+ struct mail *mail);
void signature_list_free(struct siglist **list);
#endif /* _ANTISPAM_SIGNATURE_H */