dovecot-2.0-pigeonhole: Simplified error handling; in particular...
pigeonhole at rename-it.nl
pigeonhole at rename-it.nl
Sun Sep 5 15:40:33 EEST 2010
details: http://hg.rename-it.nl/dovecot-2.0-pigeonhole/rev/0dc3cce72225
changeset: 1408:0dc3cce72225
user: Stephan Bosch <stephan at rename-it.nl>
date: Sun Sep 05 14:24:19 2010 +0200
description:
Simplified error handling; in particular the changes in the preceeding commits.
diffstat:
src/lib-sieve/cmd-discard.c | 2 +-
src/lib-sieve/cmd-redirect.c | 9 +-
src/lib-sieve/ext-reject.c | 13 +-
src/lib-sieve/plugins/enotify/cmd-notify.c | 7 +-
src/lib-sieve/plugins/enotify/ext-enotify-common.c | 10 +-
src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c | 10 +-
src/lib-sieve/plugins/enotify/sieve-ext-enotify.h | 12 +
src/lib-sieve/plugins/notify/cmd-notify.c | 8 +-
src/lib-sieve/plugins/vacation/cmd-vacation.c | 27 +-
src/lib-sieve/sieve-actions.c | 20 +-
src/lib-sieve/sieve-actions.h | 2 +
src/lib-sieve/sieve-error-private.h | 106 ++---
src/lib-sieve/sieve-error.c | 521 ++++++++++++++-----------
src/lib-sieve/sieve-error.h | 63 +-
src/lib-sieve/sieve-interpreter.c | 6 +-
src/lib-sieve/sieve-result.c | 19 +-
src/lib-sieve/sieve-result.h | 7 +-
src/lib-sieve/sieve-script.c | 14 +-
src/lib-sievestorage/sieve-storage.c | 9 +-
src/plugins/lda-sieve/lda-sieve-log.c | 18 +-
src/plugins/lda-sieve/lda-sieve-plugin.c | 23 -
src/testsuite/testsuite-log.c | 15 +-
22 files changed, 498 insertions(+), 423 deletions(-)
diffs (truncated from 1926 to 300 lines):
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/cmd-discard.c
--- a/src/lib-sieve/cmd-discard.c Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/cmd-discard.c Sun Sep 05 14:24:19 2010 +0200
@@ -133,7 +133,7 @@
const struct sieve_action_exec_env *aenv,
void *tr_context ATTR_UNUSED, bool *keep)
{
- sieve_result_log(aenv,
+ sieve_result_global_log(aenv,
"marked message to be discarded if not explicitly delivered "
"(discard action)");
*keep = FALSE;
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/cmd-redirect.c
--- a/src/lib-sieve/cmd-redirect.c Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/cmd-redirect.c Sun Sep 05 14:24:19 2010 +0200
@@ -308,7 +308,8 @@
/* Just to be sure */
if ( !sieve_smtp_available(senv) ) {
- sieve_result_warning(aenv, "redirect action has no means to send mail.");
+ sieve_result_global_warning
+ (aenv, "redirect action has no means to send mail.");
return TRUE;
}
@@ -341,7 +342,7 @@
/* Close SMTP transport */
if ( !sieve_smtp_close(senv, smtp_handle) ) {
- sieve_result_error(aenv,
+ sieve_result_global_error(aenv,
"failed to redirect message to <%s> "
"(refer to server log for more information)",
str_sanitize(ctx->to_address, 80));
@@ -368,7 +369,7 @@
if (dupeid != NULL) {
/* Check whether we've seen this message before */
if (sieve_action_duplicate_check(senv, dupeid, strlen(dupeid))) {
- sieve_result_log(aenv, "discarded duplicate forward to <%s>",
+ sieve_result_global_log(aenv, "discarded duplicate forward to <%s>",
str_sanitize(ctx->to_address, 128));
return TRUE;
}
@@ -383,7 +384,7 @@
ioloop_time + CMD_REDIRECT_DUPLICATE_KEEP);
}
- sieve_result_log(aenv, "forwarded to <%s>",
+ sieve_result_global_log(aenv, "forwarded to <%s>",
str_sanitize(ctx->to_address, 128));
/* Indicate that message was successfully forwarded */
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/ext-reject.c
--- a/src/lib-sieve/ext-reject.c Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/ext-reject.c Sun Sep 05 14:24:19 2010 +0200
@@ -403,7 +403,8 @@
/* Just to be sure */
if ( !sieve_smtp_available(senv) ) {
- sieve_result_warning(aenv, "reject action has no means to send mail");
+ sieve_result_global_warning
+ (aenv, "reject action has no means to send mail");
return TRUE;
}
@@ -485,7 +486,7 @@
fprintf(f, "\r\n\r\n--%s--\r\n", boundary);
if ( !sieve_smtp_close(senv, smtp_handle) ) {
- sieve_result_error(aenv,
+ sieve_result_global_error(aenv,
"failed to send rejection message to <%s> "
"(refer to server log for more information)",
str_sanitize(sender, 80));
@@ -505,13 +506,13 @@
const char *recipient = sieve_message_get_recipient(aenv->msgctx);
if ( recipient == NULL ) {
- sieve_result_warning(aenv,
+ sieve_result_global_warning(aenv,
"reject action aborted: envelope recipient is <>");
return TRUE;
}
if ( rj_ctx->reason == NULL ) {
- sieve_result_log(aenv,
+ sieve_result_global_log(aenv,
"not sending reject message (would cause second response to sender)");
*keep = FALSE;
@@ -519,14 +520,14 @@
}
if ( sender == NULL ) {
- sieve_result_log(aenv, "not sending reject message to <>");
+ sieve_result_global_log(aenv, "not sending reject message to <>");
*keep = FALSE;
return TRUE;
}
if ( act_reject_send(aenv, rj_ctx, sender, recipient) ) {
- sieve_result_log(aenv,
+ sieve_result_global_log(aenv,
"rejected message from <%s> (%s)", str_sanitize(sender, 80),
( rj_ctx->ereject ? "ereject" : "reject" ));
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/plugins/enotify/cmd-notify.c
--- a/src/lib-sieve/plugins/enotify/cmd-notify.c Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/plugins/enotify/cmd-notify.c Sun Sep 05 14:24:19 2010 +0200
@@ -502,9 +502,8 @@
/* Runtime verification */
static int act_notify_check_duplicate
-(const struct sieve_runtime_env *renv ATTR_UNUSED,
- const struct sieve_action *act ATTR_UNUSED,
- const struct sieve_action *act_other ATTR_UNUSED)
+(const struct sieve_runtime_env *renv, const struct sieve_action *act,
+ const struct sieve_action *act_other)
{
const struct sieve_enotify_action *nact, *nact_other;
const struct sieve_enotify_method_def *nmth_def;
@@ -525,6 +524,7 @@
return 0;
memset(&nenv, 0, sizeof(nenv));
+ nenv.svinst = renv->svinst;
nenv.method = nact->method;
nenv.ehandler = sieve_prefix_ehandler_create
(sieve_result_get_error_handler(renv->result), act->location, "notify");
@@ -578,6 +578,7 @@
if ( method->def != NULL && method->def->action_execute != NULL ) {
/* Compose log structure */
memset(&nenv, 0, sizeof(nenv));
+ nenv.svinst = aenv->svinst;
nenv.method = method;
nenv.scriptenv = aenv->scriptenv;
nenv.msgdata = aenv->msgdata;
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/plugins/enotify/ext-enotify-common.c
--- a/src/lib-sieve/plugins/enotify/ext-enotify-common.c Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/plugins/enotify/ext-enotify-common.c Sun Sep 05 14:24:19 2010 +0200
@@ -305,6 +305,7 @@
}
struct _ext_enotify_option_check_context {
+ struct sieve_instance *svinst;
struct sieve_validator *valdtr;
const struct sieve_enotify_method *method;
};
@@ -323,6 +324,7 @@
/* Compose log structure */
memset(&nenv, 0, sizeof(nenv));
+ nenv.svinst = optn_context->svinst;
nenv.method = method;
nenv.ehandler = sieve_prefix_ehandler_create
(sieve_validator_error_handler(valdtr),
@@ -366,6 +368,7 @@
struct sieve_ast_argument *from_arg, struct sieve_ast_argument *options_arg)
{
const struct sieve_extension *this_ext = cmd->ext;
+ struct sieve_instance *svinst = this_ext->svinst;
const char *uri = sieve_ast_argument_strc(uri_arg);
const char *scheme;
const struct sieve_enotify_method *method;
@@ -397,6 +400,7 @@
/* Compose log structure */
memset(&nenv, 0, sizeof(nenv));
+ nenv.svinst = svinst;
nenv.method = method;
/* Check URI itself */
@@ -450,7 +454,8 @@
/* Check :options argument */
if ( result && options_arg != NULL ) {
struct sieve_ast_argument *option = options_arg;
- struct _ext_enotify_option_check_context optn_context = { valdtr, method };
+ struct _ext_enotify_option_check_context optn_context =
+ { svinst, valdtr, method };
/* Parse and check options */
result = ( sieve_ast_stringlist_map
@@ -494,6 +499,7 @@
struct sieve_enotify_env nenv;
memset(&nenv, 0, sizeof(nenv));
+ nenv.svinst = renv->svinst;
nenv.method = method;
nenv.ehandler = sieve_prefix_ehandler_create
(sieve_interpreter_get_error_handler(renv->interp),
@@ -558,6 +564,7 @@
struct sieve_enotify_env nenv;
memset(&nenv, 0, sizeof(nenv));
+ nenv.svinst = renv->svinst;
nenv.method = method;
nenv.ehandler = sieve_prefix_ehandler_create
(sieve_interpreter_get_error_handler(renv->interp),
@@ -592,6 +599,7 @@
int result = SIEVE_EXEC_OK;
memset(&nenv, 0, sizeof(nenv));
+ nenv.svinst = renv->svinst;
nenv.method = method;
nenv.ehandler = sieve_prefix_ehandler_create
(sieve_interpreter_get_error_handler(renv->interp),
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c
--- a/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/plugins/enotify/mailto/ntfy-mailto.c Sun Sep 05 14:24:19 2010 +0200
@@ -401,7 +401,7 @@
/* Just to be sure */
if ( !sieve_smtp_available(senv) ) {
- sieve_enotify_warning(nenv,
+ sieve_enotify_global_warning(nenv,
"notify mailto method has no means to send mail");
return TRUE;
}
@@ -531,11 +531,11 @@
}
if ( sieve_smtp_close(senv, smtp_handle) ) {
- sieve_enotify_info(nenv,
+ sieve_enotify_global_info(nenv,
"sent mail notification to <%s>",
str_sanitize(recipients[i].normalized, 80));
} else {
- sieve_enotify_error(nenv,
+ sieve_enotify_global_error(nenv,
"failed to send mail notification to <%s> "
"(refer to system log for more information)",
str_sanitize(recipients[i].normalized, 80));
@@ -556,7 +556,7 @@
/* Is the recipient unset?
*/
if ( recipient == NULL ) {
- sieve_enotify_warning(nenv,
+ sieve_enotify_global_warning(nenv,
"notify mailto action aborted: envelope recipient is <>");
return TRUE;
}
@@ -569,7 +569,7 @@
/* Theoretically multiple headers could exist, so lets make sure */
while ( *hdsp != NULL ) {
if ( strcasecmp(*hdsp, "no") != 0 ) {
- sieve_enotify_info(nenv,
+ sieve_enotify_global_info(nenv,
"not sending notification for auto-submitted message from <%s>",
str_sanitize(sender, 128));
return TRUE;
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/plugins/enotify/sieve-ext-enotify.h
--- a/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/plugins/enotify/sieve-ext-enotify.h Sun Sep 05 14:24:19 2010 +0200
@@ -101,6 +101,8 @@
*/
struct sieve_enotify_env {
+ struct sieve_instance *svinst;
+
const struct sieve_enotify_method *method;
struct sieve_error_handler *ehandler;
@@ -119,6 +121,8 @@
*/
struct sieve_enotify_exec_env {
+ struct sieve_instance *svinst;
+
const struct sieve_enotify_method *method;
const struct sieve_script_env *scriptenv;
@@ -154,6 +158,14 @@
#define sieve_enotify_info(ENV, ...) \
sieve_info((ENV)->ehandler, NULL, __VA_ARGS__ )
+#define sieve_enotify_global_error(ENV, ...) \
+ sieve_global_error((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
+
+#define sieve_enotify_global_warning(ENV, ...) \
+ sieve_global_warning((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
+
+#define sieve_enotify_global_info(ENV, ...) \
+ sieve_global_info((ENV)->svinst, (ENV)->ehandler, NULL, __VA_ARGS__ )
#endif /* __SIEVE_EXT_ENOTIFY_H */
diff -r 081a2c9babc0 -r 0dc3cce72225 src/lib-sieve/plugins/notify/cmd-notify.c
--- a/src/lib-sieve/plugins/notify/cmd-notify.c Sat Sep 04 14:53:35 2010 +0200
+++ b/src/lib-sieve/plugins/notify/cmd-notify.c Sun Sep 05 14:24:19 2010 +0200
@@ -703,7 +703,7 @@
/* Just to be sure */
if ( senv->smtp_open == NULL || senv->smtp_close == NULL ) {
- sieve_result_warning(aenv,
+ sieve_result_global_warning(aenv,
"notify action has no means to send mail");
return TRUE;
}
@@ -763,11 +763,11 @@
More information about the dovecot-cvs
mailing list