Skip to content

Commit

Permalink
lib-smtp: server: Add ability to determine whether command reply was …
Browse files Browse the repository at this point in the history
…created using smtp_server_reply_create_forward().
  • Loading branch information
stephanbosch authored and cmouse committed Oct 10, 2018
1 parent 51c917f commit 46a6901
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib-smtp/smtp-server-command.c
Expand Up @@ -506,6 +506,25 @@ bool smtp_server_command_is_replied(struct smtp_server_command *cmd)
return TRUE;
}

bool smtp_server_command_reply_is_forwarded(struct smtp_server_command *cmd)
{
unsigned int i;

if (!array_is_created(&cmd->replies))
return FALSE;

for (i = 0; i < cmd->replies_expected; i++) {
const struct smtp_server_reply *reply =
array_idx(&cmd->replies, i);
if (!reply->submitted)
return FALSE;
if (reply->forwarded)
return TRUE;
}

return FALSE;
}

struct smtp_server_reply *
smtp_server_command_get_reply(struct smtp_server_command *cmd,
unsigned int idx)
Expand Down
1 change: 1 addition & 0 deletions src/lib-smtp/smtp-server-private.h
Expand Up @@ -71,6 +71,7 @@ struct smtp_server_reply {

bool submitted:1;
bool sent:1;
bool forwarded:1;
};

struct smtp_server_command_reg {
Expand Down
2 changes: 2 additions & 0 deletions src/lib-smtp/smtp-server-reply.c
Expand Up @@ -70,6 +70,7 @@ static void smtp_server_reply_clear(struct smtp_server_reply *reply)
reply->command->replies_submitted--;
}
reply->submitted = FALSE;
reply->forwarded = FALSE;
}

static struct smtp_server_reply *
Expand Down Expand Up @@ -156,6 +157,7 @@ smtp_server_reply_create_forward(struct smtp_server_command *cmd,
reply = smtp_server_reply_create_index(cmd, index,
from->status, smtp_reply_get_enh_code(from));
smtp_reply_write(reply->content->text, from);
reply->forwarded = TRUE;

return reply;
}
Expand Down
1 change: 1 addition & 0 deletions src/lib-smtp/smtp-server.h
Expand Up @@ -466,6 +466,7 @@ smtp_server_command_get_reply(struct smtp_server_command *cmd,
bool smtp_server_command_reply_status_equals(struct smtp_server_command *cmd,
unsigned int status);
bool smtp_server_command_is_replied(struct smtp_server_command *cmd);
bool smtp_server_command_reply_is_forwarded(struct smtp_server_command *cmd);
bool smtp_server_command_replied_success(struct smtp_server_command *cmd);

void smtp_server_command_input_lock(struct smtp_server_cmd_ctx *cmd);
Expand Down

0 comments on commit 46a6901

Please sign in to comment.