aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-24 16:56:30 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-24 17:05:53 +0300
commit19f41d6c5bcebc79cfa80bf39e242e4b5e8e7a6c (patch)
treeadf4dfd289968afaf8c2e43dd38d7a5632b56d9a /src
parent1b07ddac6d91db6b051b7272262069850b4cf136 (diff)
downloadmailfromd-19f41d6c5bcebc79cfa80bf39e242e4b5e8e7a6c.tar.gz
mailfromd-19f41d6c5bcebc79cfa80bf39e242e4b5e8e7a6c.tar.bz2
Improve third-party interfaces to process arbitrary messages (not only current one).
* NEWS: Updated. * doc/functions.texi: Reflect changes in sieve, clamav and sa (spamc) functions. * mflib/Makefile.am: Build sa.h * mflib/sa.mf (SA_SYMBOLS, SA_REPORT) (SA_LEARN_SPAM,SA_LEARN_HAM,SA_FORGET): New constants. (sa): Wrapper over spamc for backward compatibility. * src/builtin/Makefile.am (builtin.h): Depends on builtin.def * src/builtin/body.bi (current_message): Use MF_STREAM_TO_MESSAGE. * src/builtin/builtin.c: Add more includes. (_builtin_stream_cleanup): New function. (_builtin_mu_stream_to_message): New function. * src/builtin/builtin.def (_builtin_stream_cleanup) (_builtin_mu_stream_to_message): New protos. * src/builtin/dspam.bi: Use _builtin_stream_cleanup for stream cleanups. * src/builtin/msg.bi (message_from_stream): Use MF_STREAM_TO_MESSAGE. * src/builtin/sa.bi (open_connection): Register returned stream for cleanup. (sa): Rewrite as spamc function. (clamav): Take message descriptor as the first argument. * src/builtin/sieve.bi (sieve): Take message descriptor as the first argument. Use cleanups. * src/builtin/snarf.m4 (MF_STREAM_TO_MESSAGE): New macro. * src/main.c (options): Remove "debug" option, handled by srvcfg.c * tests/bctx00.at: Use current_message function. * tests/bctx01.at: Likewise. * tests/fctx00.at: Likewise. * tests/fctx01.at: Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/builtin/Makefile.am2
-rw-r--r--src/builtin/body.bi7
-rw-r--r--src/builtin/builtin.c33
-rw-r--r--src/builtin/builtin.def20
-rw-r--r--src/builtin/dspam.bi11
-rw-r--r--src/builtin/msg.bi7
-rw-r--r--src/builtin/sa.bi244
-rw-r--r--src/builtin/sieve.bi70
-rw-r--r--src/builtin/snarf.m44
-rw-r--r--src/main.c2
10 files changed, 240 insertions, 160 deletions
diff --git a/src/builtin/Makefile.am b/src/builtin/Makefile.am
index 904cd02b..8a93e340 100644
--- a/src/builtin/Makefile.am
+++ b/src/builtin/Makefile.am
@@ -80,7 +80,7 @@ INCLUDES = \
-I$(top_srcdir)\
$(DSPAM_CFLAGS)
-builtin.h: Makefile.am
+builtin.h: Makefile.am builtin.def
$(BI_FILES:.bi=.c): snarf.m4 init.m4
diff --git a/src/builtin/body.bi b/src/builtin/body.bi
index 26695cb5..f684801b 100644
--- a/src/builtin/body.bi
+++ b/src/builtin/body.bi
@@ -44,12 +44,7 @@ MF_DEFUN(current_message, NUMBER)
rc = bi_get_current_message(env);
if (rc < 0) {
- rc = mu_stream_to_message(mstr, &msg);
- MF_ASSERT(rc == 0,
- mfe_failure,
- "mu_stream_to_message: %s",
- mu_strerror(rc));
- mu_stream_unref(mstr);
+ msg = MF_STREAM_TO_MESSAGE(mstr);
rc = bi_message_register(env, NULL, msg, 1);
MF_ASSERT(rc >= 0,
mfe_failure,
diff --git a/src/builtin/builtin.c b/src/builtin/builtin.c
index cf5f9989..6b858ca4 100644
--- a/src/builtin/builtin.c
+++ b/src/builtin/builtin.c
@@ -20,9 +20,12 @@
#include <stdlib.h>
#include <string.h>
#include <mailutils/error.h>
+#include <mailutils/stream.h>
#include <gettext.h>
#define DEFINE_BUILTIN_MODULE
+#include "mailfromd.h"
+#include "prog.h"
#include "builtin.h"
void
@@ -63,3 +66,33 @@ builtin_module_trace(unsigned idx)
{
return idx < BUILTIN_IDX_MAX && builtin_module[idx].trace;
}
+
+void
+_builtin_stream_cleanup(void *ptr)
+{
+ mu_stream_t str = ptr;
+ mu_stream_unref(str);
+}
+
+
+mu_message_t
+_builtin_mu_stream_to_message(mu_stream_t mstr, eval_environ_t env,
+ const char *func_name)
+{
+ int rc;
+ mu_header_t hdr;
+ mu_message_t msg;
+
+ rc = mu_stream_to_message(mstr, &msg);
+ if (rc)
+ env_throw_bi(env, mfe_failure,
+ func_name,
+ "cannot obtain stream reference: %s",
+ mu_strerror(rc));
+ mu_stream_unref(mstr);
+ /* FIXME: This works over a bug in mailutils 2.99.92
+ <= release-2.2-378-g6060ab1 */
+ mu_message_get_header(msg, &hdr);
+ return msg;
+}
+
diff --git a/src/builtin/builtin.def b/src/builtin/builtin.def
index 366d2648..9ad3a53c 100644
--- a/src/builtin/builtin.def
+++ b/src/builtin/builtin.def
@@ -1,3 +1,19 @@
+/* This file is part of Mailfromd.
+ Copyright (C) 2010, 2011 Sergey Poznyakoff
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
MF_BEGIN_OUTPUT
struct builtin_module {
@@ -19,3 +35,7 @@ void builtin_setup(void);
void builtin_set_module_trace(const char *name, size_t len, int val);
void builtin_set_all_module_trace(int val);
int builtin_module_trace(unsigned idx);
+void _builtin_stream_cleanup(void *);
+mu_message_t _builtin_mu_stream_to_message(mu_stream_t str,
+ eval_environ_t env,
+ const char *func_name);
diff --git a/src/builtin/dspam.bi b/src/builtin/dspam.bi
index 8afea8e2..72c41b79 100644
--- a/src/builtin/dspam.bi
+++ b/src/builtin/dspam.bi
@@ -120,13 +120,6 @@ translate_flags(struct transtab *tab, size_t count, int num)
}
static void
-stream_cleanup(void *ptr)
-{
- mu_stream_t str = ptr;
- mu_stream_unref(str);
-}
-
-static void
ctx_cleanup(void *ptr)
{
DSPAM_CTX *ctx = ptr;
@@ -457,14 +450,14 @@ MF_DEFUN(dspam, NUMBER, NUMBER nmsg, NUMBER mode_flags, OPTIONAL, NUMBER class_s
mfe_failure,
"mu_static_memory_stream_create: %s",
mu_strerror(rc));
- MF_DCL_CLEANUP(msgstr, stream_cleanup);
+ MF_DCL_CLEANUP(msgstr, _builtin_stream_cleanup);
rc = mu_message_get_streamref(msg, &instr);
MF_ASSERT(rc == 0,
mfe_failure,
"mu_message_get_streamref: %s",
mu_strerror(rc));
- MF_DCL_CLEANUP(instr, stream_cleanup);
+ MF_DCL_CLEANUP(instr, _builtin_stream_cleanup);
rc = mu_stream_copy(msgstr, instr, msgsize, NULL);
MF_ASSERT(rc == 0,
diff --git a/src/builtin/msg.bi b/src/builtin/msg.bi
index bd633e9e..aa25b1f4 100644
--- a/src/builtin/msg.bi
+++ b/src/builtin/msg.bi
@@ -591,12 +591,7 @@ MF_DEFUN(message_from_stream, NUMBER, NUMBER fd, OPTIONAL,
src = flt;
}
- rc = mu_stream_to_message(src, &msg);
- mu_stream_unref(src);
- MF_ASSERT(rc == 0,
- mfe_failure,
- "mu_stream_to_message: %s",
- mu_strerror(rc));
+ msg = MF_STREAM_TO_MESSAGE(src);
rc = bi_message_register(env, NULL, msg, 0);
if (rc < 0) {
diff --git a/src/builtin/sa.bi b/src/builtin/sa.bi
index 231ad00e..d4b823e8 100644
--- a/src/builtin/sa.bi
+++ b/src/builtin/sa.bi
@@ -22,6 +22,11 @@
#include <string.h>
#include <signal.h>
+#include <mailutils/stream.h>
+
+#include "msg.h"
+#include "mflib/sa.h"
+
MF_VAR(sa_score, NUMBER);
MF_VAR(sa_threshold, NUMBER);
MF_VAR(sa_keywords, STRING);
@@ -300,7 +305,7 @@ open_connection(eval_environ_t env, char *urlstr, char **phost)
}
rc = spamd_connect(env, &str, path, port);
-
+ MF_DCL_CLEANUP(str, _builtin_stream_cleanup);
if (rc == 0 && phost) {
if (port)
*phost = path;
@@ -311,11 +316,12 @@ open_connection(eval_environ_t env, char *urlstr, char **phost)
}
MF_DSEXP
-MF_STATE(eom)
-MF_CAPTURE(mstr)
-MF_DEFUN(sa, NUMBER, STRING urlstr, NUMBER prec, OPTIONAL, NUMBER report)
+MF_DEFUN(spamc, NUMBER, NUMBER nmsg, STRING urlstr, NUMBER prec, NUMBER command)
{
+ mu_message_t msg;
+ mu_stream_t mstr;
mu_off_t msize;
+ size_t lines;
mu_stream_t ostr;
signal_handler_fn handler;
char *buffer = NULL;
@@ -326,9 +332,17 @@ MF_DEFUN(sa, NUMBER, STRING urlstr, NUMBER prec, OPTIONAL, NUMBER report)
long version;
int result;
long score, threshold;
- int report_mode = MF_OPTVAL(report);
+ char *cmdstr;
int rc;
+ msg = bi_message_from_descr(env, nmsg);
+ rc = mu_message_get_streamref(msg, &mstr);
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ "mu_stream_get_streamref: %s",
+ mu_strerror (rc));
+ MF_DCL_CLEANUP(mstr, _builtin_stream_cleanup);
+
rc = mu_stream_size(mstr, &msize);
MF_ASSERT(rc == 0,
mfe_failure,
@@ -336,94 +350,136 @@ MF_DEFUN(sa, NUMBER, STRING urlstr, NUMBER prec, OPTIONAL, NUMBER report)
mu_strerror (rc));
ostr = open_connection(env, urlstr, NULL);
-
- msize += env_get_line_count(env);
- mu_stream_printf(ostr,
- report_mode ? "REPORT SPAMC/1.2\n"
- : "SYMBOLS SPAMC/1.2\n");
+
+ /* And that, finally, gets the number of lines */
+ rc = mu_message_lines(msg, &lines);
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ "mu_message_lines: %s",
+ mu_strerror (rc));
+ msize += lines;
+
+ switch (command) {
+ case SA_REPORT:
+ cmdstr = "REPORT";
+ break;
+ case SA_SYMBOLS:
+ cmdstr = "SYMBOLS";
+ break;
+ case SA_LEARN_SPAM:
+ case SA_LEARN_HAM:
+ case SA_FORGET:
+ cmdstr = "TELL";
+ break;
+ default:
+ MF_THROW(mfe_failure,
+ "unknown flag: %ld", command);
+ }
+ mu_stream_printf(ostr, "%s SPAMC/1.2\n", cmdstr);
+
+ switch (command) {
+ case SA_LEARN_SPAM:
+ mu_stream_printf(ostr,
+ "Message-class: spam\n"
+ "Set: local\n");
+ break;
+ case SA_LEARN_HAM:
+ mu_stream_printf(ostr,
+ "Message-class: ham\n"
+ "Set: local\n");
+ break;
+ case SA_FORGET:
+ mu_stream_printf(ostr,
+ "Remove: local\n");
+ }
+
mu_stream_printf(ostr, "Content-length: %lu\n",
(unsigned long) msize);
/*FIXME: spamd_send_command(ostr, "User: %s", ??) */
got_sigpipe = 0;
handler = set_signal_handler(SIGPIPE, sigpipe_handler);
mu_stream_write(ostr, "\n", 1, NULL);
- if (rc = spamd_send_stream(ostr, mstr)) {
- mu_stream_destroy(&ostr);
- MF_THROW(mfe_failure,
- _("send stream failed: %s"),
- mu_strerror (rc));
- }
+ rc = spamd_send_stream(ostr, mstr);
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ _("send stream failed: %s"),
+ mu_strerror(rc));
+
mu_stream_shutdown(ostr, MU_STREAM_WRITE);
set_signal_handler(SIGPIPE, handler);
-
+
+ MF_DCL_CLEANUP(buffer);
spamd_get_line(ostr, &buffer, &bufsize);
- if (got_sigpipe) {
- mu_stream_destroy(&ostr);
- free(buffer);
+ if (got_sigpipe)
MF_THROW(mfe_failure, _("remote side has closed connection"));
- }
- if (sscanf(buffer, "SPAMD/%18s %d %*s", version_str, &result) != 2) {
- mu_stream_destroy(&ostr);
- free(buffer);
- MF_THROW(mfe_failure,
- _("spamd responded with bad string '%s'"),
- buffer);
- }
+ MF_ASSERT(sscanf(buffer, "SPAMD/%18s %d %*s", version_str,
+ &result) == 2,
+ mfe_failure,
+ _("spamd responded with bad string '%s'"),
+ buffer);
decode_float(&version, version_str, 1);
- if (version < 10) {
- mu_stream_destroy(&ostr);
- free(buffer);
- MF_THROW(mfe_failure,
- _("unsupported SPAMD version: %s"),
- version_str);
- }
+ MF_ASSERT(version >= 10,
+ mfe_failure,
+ _("unsupported SPAMD version: %s"),
+ version_str);
- if (result) {
- mu_stream_destroy(&ostr);
- free(buffer);
- MF_THROW(mfe_failure, "%s", buffer);
- }
+ MF_ASSERT(result == 0, mfe_failure, "%s", buffer);
spamd_get_line(ostr, &buffer, &bufsize);
- if (sscanf (buffer, "Spam: %5s ; %20s / %20s",
- spam_str, score_str, threshold_str) != 3) {
- mu_stream_destroy(&ostr);
- free(buffer);
- MF_THROW(mfe_failure,
- _("spamd responded with bad Spam header '%s'"),
- buffer);
- }
- result = decode_boolean(spam_str);
- decode_float(&score, score_str, prec);
- decode_float(&threshold, threshold_str, prec);
-
- MF_VAR_REF(sa_score, score);
- MF_VAR_REF(sa_threshold, threshold);
+ switch (command) {
+ case SA_REPORT:
+ case SA_SYMBOLS:
+ MF_ASSERT(sscanf(buffer, "Spam: %5s ; %20s / %20s",
+ spam_str, score_str, threshold_str) == 3,
+ mfe_failure,
+ _("spamd responded with bad Spam header '%s'"),
+ buffer);
+
+ result = decode_boolean(spam_str);
+ decode_float(&score, score_str, prec);
+ decode_float(&threshold, threshold_str, prec);
+
+ MF_VAR_REF(sa_score, score);
+ MF_VAR_REF(sa_threshold, threshold);
- /* Skip newline */
- spamd_get_line(ostr, &buffer, &bufsize);
- if (report_mode) {
+ /* Skip newline */
+ spamd_get_line(ostr, &buffer, &bufsize);
+ break;
+
+ case SA_LEARN_SPAM:
+ case SA_LEARN_HAM:
+ result = !!strcmp(buffer, "DidSet: local");
+ break;
+
+ case SA_FORGET:
+ result = !!strcmp(buffer, "DidRemove: local");
+ break;
+ }
+
+ switch (command) {
+ case SA_REPORT:
MF_OBSTACK_BEGIN();
while (mu_stream_getline(ostr, &buffer, &bufsize, &n) == 0
&& n > 0)
MF_OBSTACK_GROW(buffer, n);
MF_OBSTACK_1GROW(0);
MF_VAR_REF(sa_keywords, MF_OBSTACK_FINISH);
- } else {
+ break;
+
+ case SA_SYMBOLS:
/* Read symbol list */
spamd_get_line(ostr, &buffer, &bufsize);
-
MF_VAR_SET_STRING(sa_keywords, buffer);
-
- while (mu_stream_getline(ostr, &buffer, &bufsize, &n) == 0
- && n > 0)
- /* Drain input */;
}
- mu_stream_destroy(&ostr);
- free(buffer);
+
+ /* Just in case */
+ while (mu_stream_getline(ostr, &buffer, &bufsize, &n) == 0
+ && n > 0)
+ /* Drain input */;
+
MF_RETURN(result);
}
END
@@ -446,10 +502,10 @@ clamav_open_data_stream(mu_stream_t *retstr, const char *host, unsigned port)
}
MF_DSEXP
-MF_STATE(eom)
-MF_CAPTURE(mstr)
-MF_DEFUN(clamav, NUMBER, STRING urlstr)
+MF_DEFUN(clamav, NUMBER, NUMBER nmsg, STRING urlstr)
{
+ mu_message_t msg;
+ mu_stream_t mstr;
mu_stream_t cstr, dstr;
char *buffer = NULL;
size_t bufsize = 0;
@@ -459,44 +515,45 @@ MF_DEFUN(clamav, NUMBER, STRING urlstr)
signal_handler_fn handler;
char *p;
- cstr = open_connection(env, urlstr, &host);
+ msg = bi_message_from_descr(env, nmsg);
+ rc = mu_message_get_streamref(msg, &mstr);
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ "mu_stream_get_streamref: %s",
+ mu_strerror (rc));
+ MF_DCL_CLEANUP(mstr, _builtin_stream_cleanup);
+ MF_DCL_CLEANUP(buffer);
+ cstr = open_connection(env, urlstr, &host);
+
mu_stream_printf(cstr, "STREAM\n");
spamd_get_line(cstr, &buffer, &bufsize);
- if (sscanf(buffer, "PORT %hu", &port) != 1) {
- mu_stream_destroy(&cstr);
- free(buffer);
- MF_THROW(mfe_failure,
- _("bad response from clamav: expected `PORT' but found `%s'"),
- buffer);
- }
+ MF_ASSERT(sscanf(buffer, "PORT %hu", &port) == 1,
+ mfe_failure,
+ _("bad response from clamav: expected `PORT' but found `%s'"),
+ buffer);
if (!host)
host = strdup("127.0.0.1"); /* FIXME */
rc = clamav_open_data_stream(&dstr, host, port);
free(host);
- if (rc) {
- mu_stream_destroy(&cstr);
- MF_THROW(mfe_failure,
- "mu_tcp_stream_create: %s",
- mu_strerror(rc));
- }
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ "mu_tcp_stream_create: %s",
+ mu_strerror(rc));
handler = set_signal_handler(SIGPIPE, sigpipe_handler);
rc = spamd_send_stream(dstr, mstr);
mu_stream_shutdown(dstr, MU_STREAM_WRITE);
mu_stream_destroy(&dstr);
set_signal_handler(SIGPIPE, handler);
- if (rc) {
- mu_stream_destroy(&cstr);
- free(buffer);
- MF_THROW(mfe_failure,
- _("sending to stream failed: %s"),
- mu_strerror (rc));
- }
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ _("sending to stream failed: %s"),
+ mu_strerror(rc));
rc = spamd_get_line(cstr, &buffer, &bufsize);
- mu_stream_destroy(&cstr);
+ MF_CLEANUP(cstr);
MF_ASSERT(rc == 0, mfe_failure, _("error reading clamav response: %s"),
mu_strerror(rc));
@@ -523,17 +580,12 @@ MF_DEFUN(clamav, NUMBER, STRING urlstr)
rc = 1;
} else if (strncmp(p, "ERROR", 5) == 0) {
/* FIXME: mf code */
- free(buffer);
- MF_THROW(mfe_failure,
- _("clamav error: %s"),
- buffer);
+ MF_THROW(mfe_failure, _("clamav error: %s"), buffer);
} else {
- free(buffer);
MF_THROW(mfe_failure,
_("unknown clamav response: %s"),
buffer);
}
- free(buffer);
MF_RETURN(rc);
}
END
diff --git a/src/builtin/sieve.bi b/src/builtin/sieve.bi
index eff0693b..3b4f5879 100644
--- a/src/builtin/sieve.bi
+++ b/src/builtin/sieve.bi
@@ -16,6 +16,7 @@
#include <mailutils/mailutils.h>
#include <mflib/sieve.h>
+#include "msg.h"
static void
_sieve_text_action_log(void *env_ptr,
@@ -58,9 +59,14 @@ _sieve_file_action_log(void *env_ptr,
_("sieve called from here"));
}
-MF_STATE(eom)
-MF_CAPTURE(mstr)
-MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER flags,
+static void
+mach_cleanup(void *ptr)
+{
+ mu_sieve_machine_t mach = ptr;
+ mu_sieve_machine_destroy(&mach);
+}
+
+MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags,
STRING file, NUMBER line)
{
mu_sieve_machine_t mach;
@@ -68,12 +74,15 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER flags,
int rc;
int retval = 0;
int f = MF_OPTVAL(flags);
+ mu_attribute_t attr;
+ mu_message_t msg;
rc = mu_sieve_machine_init(&mach);
MF_ASSERT(rc == 0, mfe_failure,
_("failed to initialize sieve machine: %s"),
mu_strerror(rc));
-
+ MF_DCL_CLEANUP(mach, mach_cleanup);
+
if (f & MF_SIEVE_DEBUG_TRACE)
sieve_debug_flags |= MU_SIEVE_DEBUG_TRACE;
if (f & MF_SIEVE_DEBUG_INSTR)
@@ -83,53 +92,34 @@ MF_DEFUN(sieve, NUMBER, STRING script, OPTIONAL, NUMBER flags,
mu_sieve_set_data(mach, env);
+ if (f & MF_SIEVE_LOG)
+ mu_sieve_set_logger(mach, _sieve_text_action_log);
if (f & MF_SIEVE_TEXT) {
struct locus locus;
env_get_locus(env, &locus);
- if (f & MF_SIEVE_LOG)
- mu_sieve_set_logger(mach, _sieve_text_action_log);
rc = mu_sieve_compile_buffer(mach, script, strlen(script),
MF_OPTVAL(file, locus.file),
MF_OPTVAL(line, locus.line));
} else {
- if (f & MF_SIEVE_LOG)
- mu_sieve_set_logger(mach, _sieve_file_action_log);
rc = mu_sieve_compile(mach, script);
}
- if (rc == 0) {
- mu_attribute_t attr;
- mu_message_t msg;
-
- rc = mu_stream_to_message(mstr, &msg);
- if (rc) {
- mu_sieve_machine_destroy(&mach);
- MF_THROW(mfe_failure,
- _("cannot translate stream to message: %s"),
- mu_strerror (rc));
- }
+
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ _("compilation of Sieve script %s failed"),
+ script);
+
+ msg = bi_message_from_descr(env, nmsg);
- mu_message_get_attribute(msg, &attr);
- mu_attribute_unset_deleted(attr);
- rc = mu_sieve_message(mach, msg);
- if (rc == 0)
- retval = !(mu_attribute_is_deleted(attr) == 0);
- /* Destroy the message. This also indirectly unrefs the mstr,
- bringing its refcount back to its initial value. */
- mu_message_destroy(&msg, mu_message_get_owner(msg));
- if (rc) {
- mu_sieve_machine_destroy(&mach);
- MF_THROW(mfe_failure,
- _("sieving failed: %s"),
- mu_strerror(rc));
- }
- } else {
- MF_THROW(mfe_failure,
- _("compilation of Sieve script %s failed"),
- script);
- }
-
- mu_sieve_machine_destroy(&mach);
+ mu_message_get_attribute(msg, &attr);
+ mu_attribute_unset_deleted(attr);
+ rc = mu_sieve_message(mach, msg);
+ MF_ASSERT(rc == 0,
+ mfe_failure,
+ _("sieving failed: %s"),
+ mu_strerror(rc));
+ retval = !(mu_attribute_is_deleted(attr) == 0);
MF_RETURN(retval);
}
diff --git a/src/builtin/snarf.m4 b/src/builtin/snarf.m4
index 1605db7a..b07ee7c8 100644
--- a/src/builtin/snarf.m4
+++ b/src/builtin/snarf.m4
@@ -640,6 +640,10 @@ m4_ifdef([<__MF_CAPTURE__>],[<
"__MF_FUNCTION__", NULL), m4_shift($@))
)>])
+m4_define([<MF_STREAM_TO_MESSAGE>],[<m4_dnl
+_builtin_mu_stream_to_message($1, env, m4_ifdef([<__MF_FUNCTION__>],m4_dnl
+"__MF_FUNCTION__", NULL))>])
+
/* MF_ASSERT(cond, exception, ...)
*/
m4_define([<MF_ASSERT>],[<m4_dnl
diff --git a/src/main.c b/src/main.c
index 637bad4f..c277aa45 100644
--- a/src/main.c
+++ b/src/main.c
@@ -400,8 +400,6 @@ static struct argp_option options[] = {
#define GRP 40
{ NULL, 0, NULL, 0,
N_("Informational and debugging options"), GRP },
- { "debug", 'd', N_("LEVEL"), 0,
- N_("set debugging level"), GRP+1 },
{ "location-column", OPTION_LOCATION_COLUMN, NULL, 0,
N_("print location column numbers in compiler diagnostics messages"),
GRP+1 },

Return to:

Send suggestions and report system problems to the System administrator.