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

Added inbox location to mail environment and made keep command use it to generate its store action.

parent fcaeb9e7
No related branches found
No related tags found
No related merge requests found
......@@ -66,8 +66,11 @@ static bool opc_keep_execute
{
printf(">> KEEP\n");
sieve_act_store_add_to_result(renv, "INBOX");
if ( renv->mailenv != NULL && renv->mailenv->inbox != NULL )
sieve_act_store_add_to_result(renv, renv->mailenv->inbox);
else
sieve_act_store_add_to_result(renv, "INBOX");
return TRUE;
}
......
......@@ -151,14 +151,15 @@ void sieve_dump(struct sieve_binary *binary)
}
bool sieve_test
(struct sieve_binary *binary, const struct sieve_message_data *msgdata)
(struct sieve_binary *binary, const struct sieve_message_data *msgdata,
const struct sieve_mail_environment *menv)
{
struct sieve_result *sres = sieve_result_create();
struct sieve_interpreter *interp = sieve_interpreter_create(binary);
bool result = TRUE;
printf("Code Execute:\n\n");
result = sieve_interpreter_run(interp, msgdata, NULL, &sres);
result = sieve_interpreter_run(interp, msgdata, menv, &sres);
if ( result ) {
printf("Script executed successfully.\n\n");
......
......@@ -15,6 +15,8 @@ struct sieve_message_data {
};
struct sieve_mail_environment {
const char *inbox;
/* Interface for sending mail (callbacks if you like) */
int (*send_rejection)
(const struct sieve_message_data *msgdata, const char *recipient,
......@@ -29,7 +31,9 @@ void sieve_deinit(void);
struct sieve_binary *sieve_compile(int fd, bool verbose);
void sieve_dump(struct sieve_binary *binary);
bool sieve_test
(struct sieve_binary *binary, const struct sieve_message_data *msgdata);
(struct sieve_binary *binary, const struct sieve_message_data *msgdata,
const struct sieve_mail_environment *menv);
bool sieve_execute
(struct sieve_binary *binary, const struct sieve_message_data *msgdata,
const struct sieve_mail_environment *menv);
......
......@@ -97,6 +97,7 @@ int main(int argc, char **argv)
(void)mail_get_first_header(mailr->mail, "Message-ID", &msgdata.id);
memset(&mailenv, 0, sizeof(mailenv));
mailenv.inbox = "INBOX";
mailenv.send_forward = sieve_send_forward;
mailenv.send_rejection = sieve_send_rejection;
......
......@@ -18,7 +18,7 @@ int main(int argc, char **argv)
struct mail_raw *mailr;
struct sieve_binary *sbin;
struct sieve_message_data msgdata;
struct sieve_mail_environment mailenv;
bin_init();
if ( argc < 2 ) {
......@@ -76,9 +76,14 @@ int main(int argc, char **argv)
msgdata.to_address = "sirius+sieve@rename-it.nl";
msgdata.auth_user = "stephan";
(void)mail_get_first_header(mailr->mail, "Message-ID", &msgdata.id);
memset(&mailenv, 0, sizeof(mailenv));
mailenv.inbox = "INBOX";
mailenv.send_forward = NULL;
mailenv.send_rejection = NULL;
/* Run the test */
(void) sieve_test(sbin, &msgdata);
(void) sieve_test(sbin, &msgdata, &mailenv);
sieve_deinit();
......
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.