aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2016-12-12 10:15:55 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2016-12-12 10:18:10 +0200
commitdb77ffd15fc36c41e5d35deb6af5cad1defe379b (patch)
treed901d8f13fbb6a1f090d0eb2804e10b44a1da9e4 /src
parentb6bbeeceb6ebc39156808babbc4c303e78449d73 (diff)
downloadmailfromd-db77ffd15fc36c41e5d35deb6af5cad1defe379b.tar.gz
mailfromd-db77ffd15fc36c41e5d35deb6af5cad1defe379b.tar.bz2
Use new Sieve API
* src/builtin/sieve.bi: Change to use new Sieve API * configure.ac: Version 8.0.90. Require MU 3.0.90 * NEWS: Update.
Diffstat (limited to 'src')
-rw-r--r--src/builtin/sieve.bi38
1 files changed, 22 insertions, 16 deletions
diff --git a/src/builtin/sieve.bi b/src/builtin/sieve.bi
index cbb52466..ea531a83 100644
--- a/src/builtin/sieve.bi
+++ b/src/builtin/sieve.bi
@@ -16,20 +16,20 @@
#include <mailutils/mailutils.h>
#include <mflib/sieve.h>
#include "msg.h"
static void
-_sieve_text_action_log(void *env_ptr,
- mu_stream_t stream, size_t msgno,
- mu_message_t msg,
+_sieve_text_action_log(mu_sieve_machine_t mach,
const char *action, const char *fmt, va_list ap)
{
- eval_environ_t env = env_ptr;
+ mu_stream_t stream;
+ eval_environ_t env = mu_sieve_get_data (mach);
const char *id;
-
+
+ mu_sieve_get_diag_stream(mach, &stream);
mu_stream_printf(stream, "\033s<%d>", MU_LOG_NOTICE);
id = mailfromd_msgid(env_get_context(env));
if (id && id[0])
/* ID includes trailing semicolon */
mu_stream_printf(stream, "%s", id);
mu_stream_printf(stream, "%s", action);
@@ -38,22 +38,22 @@ _sieve_text_action_log(void *env_ptr,
mu_stream_vprintf(stream, fmt, ap);
}
mu_stream_printf(stream, "\n");
}
static void
-_sieve_file_action_log(void *env_ptr,
- mu_stream_t stream, size_t msgno,
- mu_message_t msg,
+_sieve_file_action_log(mu_sieve_machine_t mach,
const char *action, const char *fmt, va_list ap)
{
- eval_environ_t env = env_ptr;
+ mu_stream_t stream;
+ eval_environ_t env = mu_sieve_get_data(mach);
struct locus locus;
- _sieve_text_action_log(env_ptr, stream, msgno, msg, action, fmt, ap);
+ _sieve_text_action_log(mach, action, fmt, ap);
+ mu_sieve_get_diag_stream(mach, &stream);
env_get_locus(env, &locus);
mu_stream_printf(stream, "\033f<%lu>%s\033l<%lu>\033s<%d>\033O<%d>%s\n",
(unsigned long) strlen(locus.file), locus.file,
locus.line,
MU_LOG_NOTICE,
MU_LOGMODE_LOCUS|MU_LOGMODE_SEVERITY,
@@ -64,35 +64,41 @@ static void
mach_cleanup(void *ptr)
{
mu_sieve_machine_t mach = ptr;
mu_sieve_machine_destroy(&mach);
}
+static void
+modify_debug_flags(mu_debug_level_t set, mu_debug_level_t clr)
+{
+ mu_debug_level_t lev;
+
+ mu_debug_get_category_level(mu_sieve_debug_handle, &lev);
+ mu_debug_set_category_level(mu_sieve_debug_handle, (lev & ~clr) | set);
+}
+
MF_DEFUN(sieve, NUMBER, NUMBER nmsg, STRING script, OPTIONAL, NUMBER flags,
STRING file, NUMBER line)
{
mu_sieve_machine_t mach;
- int sieve_debug_flags = 0;
int rc;
int retval = 0;
int f = MF_OPTVAL(flags);
mu_attribute_t attr;
mu_message_t msg;
- rc = mu_sieve_machine_init(&mach);
+ rc = mu_sieve_machine_create(&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;
+ modify_debug_flags(MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE4), 0);
if (f & MF_SIEVE_DEBUG_INSTR)
- sieve_debug_flags |= MU_SIEVE_DEBUG_INSTR;
-
- mu_sieve_set_debug_level(mach, sieve_debug_flags);
+ modify_debug_flags(MU_DEBUG_LEVEL_MASK(MU_DEBUG_TRACE9), 0);
mu_sieve_set_data(mach, env);
if (f & MF_SIEVE_TEXT) {
struct locus locus;

Return to:

Send suggestions and report system problems to the System administrator.