Skip to content
Snippets Groups Projects
Commit b0354cc1 authored by Stephan Bosch's avatar Stephan Bosch Committed by Stephan Bosch
Browse files

sieve-tools: sieve-test - Use the new result message amendment callback rather...

sieve-tools: sieve-test - Use the new result message amendment callback rather than the prefix error handler.
parent 9712e4dd
No related branches found
No related tags found
No related merge requests found
......@@ -126,6 +126,29 @@ static void duplicate_mark
i_info("marked duplicate for user %s.\n", senv->user->username);
}
/*
* Result logging
*/
static const char *
result_amend_log_message(const struct sieve_script_env *senv,
enum log_type log_type, const char *message)
{
const struct sieve_message_data *msgdata = senv->script_context;
string_t *str;
if (log_type == LOG_TYPE_DEBUG)
return message;
str = t_str_new(256);
str_printfa(str, "msgid=%s", (msgdata->id == NULL ?
"unspecified" : msgdata->id));
str_append(str, ": ");
str_append(str, message);
return str_c(str);
}
/*
* Tool implementation
*/
......@@ -143,7 +166,7 @@ int main(int argc, char **argv)
struct sieve_message_data msgdata;
struct sieve_script_env scriptenv;
struct sieve_exec_status estatus;
struct sieve_error_handler *ehandler, *action_ehandler;
struct sieve_error_handler *ehandler;
struct ostream *teststream = NULL;
struct sieve_trace_log *trace_log = NULL;
bool force_compile = FALSE, execute = FALSE;
......@@ -153,7 +176,7 @@ int main(int argc, char **argv)
sieve_tool = sieve_tool_init
("sieve-test", &argc, &argv, "r:a:f:m:d:l:s:eCt:T:DP:x:u:", FALSE);
ehandler = action_ehandler = NULL;
ehandler = NULL;
t_array_init(&scriptfiles, 16);
/* Parse arguments */
......@@ -299,13 +322,8 @@ int main(int argc, char **argv)
/* Create streams for test and trace output */
if ( !execute ) {
action_ehandler = NULL;
teststream = o_stream_create_fd(1, 0);
o_stream_set_no_error_handling(teststream, TRUE);
} else {
action_ehandler = sieve_prefix_ehandler_create
(ehandler, NULL, t_strdup_printf("msgid=%s",
( msgdata.id == NULL ? "unspecified" : msgdata.id )));
}
if ( tracefile != NULL ) {
......@@ -327,8 +345,10 @@ int main(int argc, char **argv)
scriptenv.smtp_finish = sieve_smtp_finish;
scriptenv.duplicate_mark = duplicate_mark;
scriptenv.duplicate_check = duplicate_check;
scriptenv.result_amend_log_message = result_amend_log_message;
scriptenv.trace_log = trace_log;
scriptenv.trace_config = trace_config;
scriptenv.script_context = &msgdata;
i_zero(&estatus);
scriptenv.exec_status = &estatus;
......@@ -343,7 +363,7 @@ int main(int argc, char **argv)
/* Execute/Test script */
if ( execute ) {
ret = sieve_execute(sbin, &msgdata, &scriptenv,
ehandler, action_ehandler, 0, NULL);
ehandler, ehandler, 0, NULL);
} else {
ret = sieve_test(sbin, &msgdata, &scriptenv,
ehandler, teststream, 0, NULL);
......@@ -390,7 +410,7 @@ int main(int argc, char **argv)
/* Execute/Test script */
more = sieve_multiscript_run(mscript, sbin,
ehandler, action_ehandler, 0);
ehandler, ehandler, 0);
}
/* Execute/Test main script */
......@@ -451,8 +471,6 @@ int main(int argc, char **argv)
}
/* Cleanup error handler */
if (action_ehandler != NULL)
sieve_error_handler_unref(&action_ehandler);
sieve_error_handler_unref(&ehandler);
sieve_tool_deinit(&sieve_tool);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.