}
}
+static void
+smtp_reply_write_message_one_line(string_t *out, const struct smtp_reply *reply)
+{
+ const char *const *lines;
+
+ lines = reply->text_lines;
+ while (*lines != NULL) {
+ if (str_len(out) > 0)
+ str_append_c(out, ' ');
+ str_append(out, *lines);
+ lines++;
+ }
+}
+
void smtp_reply_write_one_line(string_t *out, const struct smtp_reply *reply)
{
const char *enh_code = smtp_reply_get_enh_code(reply);
- const char *const *lines;
i_assert(reply->status < 560);
i_assert(reply->enhanced_code.x < 6);
str_append(out, enh_code);
}
- lines = reply->text_lines;
- while (*lines != NULL) {
- str_append_c(out, ' ');
- str_append(out, *lines);
- lines++;
- }
+ smtp_reply_write_message_one_line(out, reply);
}
const char *smtp_reply_log(const struct smtp_reply *reply)
{
- const char *const *lines;
string_t *msg = t_str_new(256);
if (smtp_reply_is_remote(reply)) {
}
}
- lines = reply->text_lines;
- while (*lines != NULL) {
- if (str_len(msg) > 0)
- str_append_c(msg, ' ');
- str_append(msg, *lines);
- lines++;
- }
+ smtp_reply_write_message_one_line(msg, reply);
+ return str_c(msg);
+}
+
+const char *smtp_reply_get_message(const struct smtp_reply *reply)
+{
+ string_t *msg = t_str_new(256);
+
+ smtp_reply_write_message_one_line(msg, reply);
return str_c(msg);
}
/* Create a log line from the SMTP reply. This also properly handles internal
client error replies (status_code >= 560). */
const char *smtp_reply_log(const struct smtp_reply *reply);
+/* Returns the message of the reply as a single line without status codes and
+ without CRLF.
+ */
+const char *smtp_reply_get_message(const struct smtp_reply *reply);
void smtp_reply_copy(pool_t pool, struct smtp_reply *dst,
const struct smtp_reply *src);