]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-mail: Added message_header_line_write()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 18 Jan 2016 12:56:24 +0000 (14:56 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 18 Jan 2016 13:00:40 +0000 (15:00 +0200)
src/lib-mail/message-header-parser.c
src/lib-mail/message-header-parser.h

index 8cb2bdafaa8bb7c4f9c489e0c6c05b21b3c157e1..449667d750f7cbb896967e06ed464ad7aedec0bd 100644 (file)
@@ -394,3 +394,18 @@ void message_parse_header(struct istream *input, struct message_size *hdr_size,
        /* call after the final skipping */
        callback(NULL, context);
 }
+
+void message_header_line_write(buffer_t *output,
+                              const struct message_header_line *hdr)
+{
+       if (!hdr->continued) {
+               buffer_append(output, hdr->name, strlen(hdr->name));
+               buffer_append(output, hdr->middle, hdr->middle_len);
+       }
+       buffer_append(output, hdr->value, hdr->value_len);
+       if (!hdr->no_newline) {
+               if (hdr->crlf_newline)
+                       buffer_append_c(output, '\r');
+               buffer_append_c(output, '\n');
+       }
+}
index 9db49b0b4f75e8d2dd3a31c5f805f23572af92df..b234026a0064d3ce4bf171a6335445b5599c9736 100644 (file)
@@ -69,4 +69,9 @@ void message_parse_header(struct istream *input, struct message_size *hdr_size,
                        struct message_header_line *hdr, typeof(context))), \
                (message_header_callback_t *)callback, context)
 
+/* Write the header line to buffer exactly as it was read, including the
+   newline. */
+void message_header_line_write(buffer_t *output,
+                              const struct message_header_line *hdr);
+
 #endif