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

Added (not yet active) handling of implicit keep and adjusted commands accordingly.

parent 26eefd04
No related branches found
No related tags found
No related merge requests found
......@@ -56,7 +56,7 @@ Base tests and their implementation status:
Base commands and their implementation status:
require: full
if,elsif,else: full
discard: no action effect
discard: full
keep: no action effect
redirect: full
stop: trivial, full
......
......@@ -43,18 +43,6 @@ const struct sieve_opcode cmd_discard_opcode = {
opc_discard_execute
};
/* Discard action */
static int act_discard_execute
(const struct sieve_action *action, const struct sieve_action_exec_env *aenv,
void *context);
const struct sieve_action act_discard = {
"discard",
NULL, NULL, NULL,
act_discard_execute
};
/*
* Generation
*/
......@@ -79,22 +67,9 @@ static bool opc_discard_execute
{
printf(">> DISCARD\n");
sieve_result_add_action(renv, &act_discard, NULL);
sieve_result_cancel_implicit_keep(renv->result);
return TRUE;
}
/*
* Action
*/
static int act_discard_execute
(const struct sieve_action *action ATTR_UNUSED,
const struct sieve_action_exec_env *aenv, void *context)
{
return 0;
}
......@@ -64,12 +64,17 @@ static bool opc_keep_execute
const struct sieve_runtime_env *renv ATTR_UNUSED,
sieve_size_t *address ATTR_UNUSED)
{
bool added = FALSE;
printf(">> KEEP\n");
if ( renv->mailenv != NULL && renv->mailenv->inbox != NULL )
sieve_act_store_add_to_result(renv, renv->mailenv->inbox);
added = sieve_act_store_add_to_result(renv, renv->mailenv->inbox);
else
sieve_act_store_add_to_result(renv, "INBOX");
added = sieve_act_store_add_to_result(renv, "INBOX");
if ( added )
sieve_result_cancel_implicit_keep(renv->result);
return TRUE;
}
......
......@@ -145,7 +145,8 @@ static bool cmd_redirect_opcode_execute
act = p_new(pool, struct act_redirect_context, 1);
act->to_address = p_strdup(pool, str_c(redirect));
sieve_result_add_action(renv, &act_redirect, (void *) act);
if ( sieve_result_add_action(renv, &act_redirect, (void *) act) )
sieve_result_cancel_implicit_keep(renv->result);
t_pop();
return TRUE;
......@@ -189,7 +190,7 @@ static int act_redirect_execute
send_forward(msgdata, ctx->to_address)) == 0) {
i_info("msgid=%s: forwarded to <%s>",
msgdata->id == NULL ? "" : str_sanitize(msgdata->id, 80),
str_sanitize(ctx->to_address, 80));
str_sanitize(ctx->to_address, 80));
}
return res;
......
......@@ -155,7 +155,8 @@ static bool ext_fileinto_opcode_execute
printf(">> FILEINTO \"%s\"\n", str_c(folder));
sieve_act_store_add_to_result(renv, str_c(folder));
if ( sieve_act_store_add_to_result(renv, str_c(folder)) )
sieve_result_cancel_implicit_keep(renv->result);
t_pop();
return TRUE;
......
......@@ -37,7 +37,7 @@ struct sieve_result *sieve_result_create(void)
result->first_action = NULL;
result->last_action = NULL;
result->implicit_keep = 1;
result->implicit_keep = TRUE;
return result;
}
......@@ -62,6 +62,11 @@ inline pool_t sieve_result_pool(struct sieve_result *result)
return result->pool;
}
void sieve_result_cancel_implicit_keep(struct sieve_result *result)
{
result->implicit_keep = FALSE;
}
bool sieve_result_add_action
(const struct sieve_runtime_env *renv,
const struct sieve_action *action, void *context)
......@@ -132,6 +137,8 @@ bool sieve_result_print(struct sieve_result *result)
rac = rac->next;
}
printf("\nImplicit keep: %s\n", result->implicit_keep ? "yes" : "no");
return TRUE;
}
......
......@@ -16,6 +16,8 @@ bool sieve_result_add_action
bool sieve_result_print(struct sieve_result *result);
void sieve_result_cancel_implicit_keep(struct sieve_result *result);
bool sieve_result_execute
(struct sieve_result *result, const struct sieve_message_data *msgdata,
const struct sieve_mail_environment *menv);
......
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.