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

testsuite: Reformat testsuite-message.c.

parent 1bcf28c8
No related branches found
No related tags found
No related merge requests found
......@@ -52,10 +52,9 @@ testsuite_message_get_address(struct mail *mail, const char *header)
if (mail_get_first_header(mail, header, &str) <= 0)
return NULL;
addr = message_address_parse(pool_datastack_create(),
(const unsigned char *)str,
strlen(str), 1, 0);
if ( addr == NULL ||
addr->mailbox == NULL || *addr->mailbox == '\0' )
(const unsigned char *)str,
strlen(str), 1, 0);
if (addr == NULL || addr->mailbox == NULL || *addr->mailbox == '\0')
return NULL;
return smtp_address_create_temp(addr->mailbox, addr->domain);
}
......@@ -87,18 +86,18 @@ static void testsuite_message_set_data(struct mail *mail)
/* Get recipient address */
recipient = testsuite_message_get_address(mail, "Envelope-To");
if ( recipient == NULL )
if (recipient == NULL)
recipient = testsuite_message_get_address(mail, "To");
if ( recipient == NULL )
if (recipient == NULL)
recipient = &default_recipient;
/* Get sender address */
sender = testsuite_message_get_address(mail, "Return-path");
if ( sender == NULL )
if (sender == NULL)
sender = testsuite_message_get_address(mail, "Sender");
if ( sender == NULL )
if (sender == NULL)
sender = testsuite_message_get_address(mail, "From");
if ( sender == NULL )
if (sender == NULL)
sender = &default_sender;
env_mail_from = smtp_address_clone(default_pool, sender);
......@@ -126,12 +125,13 @@ void testsuite_message_init(void)
string_t *default_message = str_new(message_pool, 1024);
str_append(default_message, _default_message_data);
testsuite_mail = sieve_tool_open_data_as_mail(sieve_tool, default_message);
testsuite_mail =
sieve_tool_open_data_as_mail(sieve_tool, default_message);
testsuite_message_set_data(testsuite_mail);
}
void testsuite_message_set_string
(const struct sieve_runtime_env *renv, string_t *message)
void testsuite_message_set_string(const struct sieve_runtime_env *renv,
string_t *message)
{
sieve_message_context_reset(renv->msgctx);
......@@ -139,8 +139,8 @@ void testsuite_message_set_string
testsuite_message_set_data(testsuite_mail);
}
void testsuite_message_set_file
(const struct sieve_runtime_env *renv, const char *file_path)
void testsuite_message_set_file(const struct sieve_runtime_env *renv,
const char *file_path)
{
sieve_message_context_reset(renv->msgctx);
......@@ -148,8 +148,8 @@ void testsuite_message_set_file
testsuite_message_set_data(testsuite_mail);
}
void testsuite_message_set_mail
(const struct sieve_runtime_env *renv, struct mail *mail)
void testsuite_message_set_mail(const struct sieve_runtime_env *renv,
struct mail *mail)
{
sieve_message_context_reset(renv->msgctx);
......@@ -165,9 +165,8 @@ void testsuite_message_deinit(void)
pool_unref(&message_pool);
}
void testsuite_envelope_set_sender_address
(const struct sieve_runtime_env *renv,
const struct smtp_address *address)
void testsuite_envelope_set_sender_address(const struct sieve_runtime_env *renv,
const struct smtp_address *address)
{
sieve_message_context_reset(renv->msgctx);
......@@ -177,16 +176,16 @@ void testsuite_envelope_set_sender_address
testsuite_msgdata.envelope.mail_from = env_mail_from;
}
void testsuite_envelope_set_sender
(const struct sieve_runtime_env *renv, const char *value)
void testsuite_envelope_set_sender(const struct sieve_runtime_env *renv,
const char *value)
{
struct smtp_address *address = NULL;
const char *error;
if (smtp_address_parse_path(pool_datastack_create(), value,
SMTP_ADDRESS_PARSE_FLAG_ALLOW_EMPTY |
SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL,
&address, &error) < 0) {
(SMTP_ADDRESS_PARSE_FLAG_ALLOW_EMPTY |
SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL),
&address, &error) < 0) {
e_error(testsuite_sieve_instance->event,
"testsuite: envelope sender address "
"`%s' is invalid: %s", value, error);
......@@ -194,8 +193,8 @@ void testsuite_envelope_set_sender
testsuite_envelope_set_sender_address(renv, address);
}
void testsuite_envelope_set_recipient_address
(const struct sieve_runtime_env *renv,
void testsuite_envelope_set_recipient_address(
const struct sieve_runtime_env *renv,
const struct smtp_address *address)
{
sieve_message_context_reset(renv->msgctx);
......@@ -209,16 +208,16 @@ void testsuite_envelope_set_recipient_address
testsuite_rcpt_params.orcpt.addr = env_orig_rcpt_to;
}
void testsuite_envelope_set_recipient
(const struct sieve_runtime_env *renv, const char *value)
void testsuite_envelope_set_recipient(const struct sieve_runtime_env *renv,
const char *value)
{
struct smtp_address *address = NULL;
const char *error;
if (smtp_address_parse_path(pool_datastack_create(), value,
SMTP_ADDRESS_PARSE_FLAG_ALLOW_LOCALPART |
SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL,
&address, &error) < 0) {
(SMTP_ADDRESS_PARSE_FLAG_ALLOW_LOCALPART |
SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL),
&address, &error) < 0) {
e_error(testsuite_sieve_instance->event,
"testsuite: envelope recipient address "
"`%s' is invalid: %s", value, error);
......@@ -226,8 +225,8 @@ void testsuite_envelope_set_recipient
testsuite_envelope_set_recipient_address(renv, address);
}
void testsuite_envelope_set_orig_recipient_address
(const struct sieve_runtime_env *renv,
void testsuite_envelope_set_orig_recipient_address(
const struct sieve_runtime_env *renv,
const struct smtp_address *address)
{
sieve_message_context_reset(renv->msgctx);
......@@ -238,16 +237,16 @@ void testsuite_envelope_set_orig_recipient_address
testsuite_rcpt_params.orcpt.addr = env_orig_rcpt_to;
}
void testsuite_envelope_set_orig_recipient
(const struct sieve_runtime_env *renv, const char *value)
void testsuite_envelope_set_orig_recipient(const struct sieve_runtime_env *renv,
const char *value)
{
struct smtp_address *address = NULL;
const char *error;
if (smtp_address_parse_path(pool_datastack_create(), value,
SMTP_ADDRESS_PARSE_FLAG_ALLOW_LOCALPART |
SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL,
&address, &error) < 0) {
(SMTP_ADDRESS_PARSE_FLAG_ALLOW_LOCALPART |
SMTP_ADDRESS_PARSE_FLAG_BRACKETS_OPTIONAL),
&address, &error) < 0) {
e_error(testsuite_sieve_instance->event,
"testsuite: envelope recipient address "
"`%s' is invalid: %s", value, error);
......@@ -255,8 +254,8 @@ void testsuite_envelope_set_orig_recipient
testsuite_envelope_set_orig_recipient_address(renv, address);
}
void testsuite_envelope_set_auth_user
(const struct sieve_runtime_env *renv, const char *value)
void testsuite_envelope_set_auth_user(const struct sieve_runtime_env *renv,
const char *value)
{
sieve_message_context_reset(renv->msgctx);
......@@ -265,4 +264,3 @@ void testsuite_envelope_set_auth_user
env_auth = i_strdup(value);
testsuite_msgdata.auth_user = env_auth;
}
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.