aboutsummaryrefslogtreecommitdiffstats
path: root/mailtrain.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes@sipsolutions.net>2007-10-01 22:16:00 +0200
committerJohannes Berg <johannes@sipsolutions.net>2007-10-01 22:16:00 +0200
commitb359532647ccd3ac3221dcb37dca7bdb4cbb2e58 (patch)
tree19d4cf35186177294a565f06aafd6b918d20506d /mailtrain.c
parent6ea8c069b7df7cc37b8c8daa8cd220ad3ca1d57e (diff)
downloaddovecot-antispam-b359532647ccd3ac3221dcb37dca7bdb4cbb2e58.tar.gz
dovecot-antispam-b359532647ccd3ac3221dcb37dca7bdb4cbb2e58.tar.xz
dovecot-antispam-b359532647ccd3ac3221dcb37dca7bdb4cbb2e58.zip
use 'enum classification' instead of 'bool from_spam'
Diffstat (limited to '')
-rw-r--r--mailtrain.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/mailtrain.c b/mailtrain.c
index ec8f066..cdb522e 100644
--- a/mailtrain.c
+++ b/mailtrain.c
@@ -35,12 +35,21 @@ static const char *hamaddr = NULL;
static const char *sendmail_binary = "/usr/sbin/sendmail";
static const char *tmpdir = "/tmp";
-static int run_sendmail(int mailfd, bool from_spam)
+static int run_sendmail(int mailfd, enum classification wanted)
{
- const char *dest = from_spam ? hamaddr : spamaddr;
+ const char *dest;
pid_t pid;
int status;
+ switch (wanted) {
+ case CLASS_SPAM:
+ dest = spamaddr;
+ break;
+ case CLASS_NOTSPAM:
+ dest = hamaddr;
+ break;
+ }
+
if (!dest)
return -1;
@@ -96,7 +105,7 @@ static int process_tmpdir(struct mailbox_transaction_context *ctx,
int cnt = ast->count;
int fd;
char *buf;
- bool from_spam;
+ enum classification wanted;
t_push();
@@ -108,9 +117,9 @@ static int process_tmpdir(struct mailbox_transaction_context *ctx,
ast->tmpdir, cnt);
fd = open(buf, O_RDONLY);
- read(fd, &from_spam, sizeof(bool));
+ read(fd, &wanted, sizeof(wanted));
- if (run_sendmail(fd, from_spam)) {
+ if (run_sendmail(fd, wanted)) {
mail_storage_set_error(ctx->box->storage,
"failed to send mail");
return -1;
@@ -174,7 +183,7 @@ int backend_commit(struct mailbox_transaction_context *ctx,
int backend_handle_mail(struct mailbox_transaction_context *t,
struct antispam_transaction_context *ast,
- struct mail *mail, bool from_spam)
+ struct mail *mail, enum classification wanted)
{
struct istream *mailstream;
struct ostream *outstream;
@@ -224,8 +233,8 @@ int backend_handle_mail(struct mailbox_transaction_context *t,
goto out_close;
}
- if (o_stream_send(outstream, &from_spam, sizeof(from_spam))
- != sizeof(from_spam)) {
+ if (o_stream_send(outstream, &wanted, sizeof(wanted))
+ != sizeof(wanted)) {
ret = -1;
mail_storage_set_error(t->box->storage,
"Failed to write marker to temp file");