changeset 10287:147627c8433a HEAD

lmtp client: Added support for writing given string as headers.
author Timo Sirainen <tss@iki.fi>
date Mon, 09 Nov 2009 20:04:28 -0500
parents 353a30947b91
children c11324abe1a8
files src/lib-lda/lmtp-client.c src/lib-lda/lmtp-client.h
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-lda/lmtp-client.c	Mon Nov 09 20:03:42 2009 -0500
+++ b/src/lib-lda/lmtp-client.c	Mon Nov 09 20:04:28 2009 -0500
@@ -49,6 +49,7 @@
 	struct io *io;
 	int fd;
 
+	const char *data_header;
 	ARRAY_DEFINE(recipients, struct lmtp_rcpt);
 	unsigned int rcpt_next_receive_idx;
 	unsigned int rcpt_next_data_idx;
@@ -348,6 +349,8 @@
 		}
 		client->input_state++;
 		o_stream_cork(client->output);
+		if (client->data_header != NULL)
+			o_stream_send_str(client->output, client->data_header);
 		lmtp_client_send_data(client);
 		o_stream_uncork(client->output);
 		break;
@@ -441,6 +444,11 @@
 	return 0;
 }
 
+void lmtp_client_set_data_header(struct lmtp_client *client, const char *str)
+{
+	client->data_header = p_strdup(client->pool, str);
+}
+
 static void lmtp_client_send_rcpts(struct lmtp_client *client)
 {
 	const struct lmtp_rcpt *rcpt;
--- a/src/lib-lda/lmtp-client.h	Mon Nov 09 20:03:42 2009 -0500
+++ b/src/lib-lda/lmtp-client.h	Mon Nov 09 20:04:28 2009 -0500
@@ -22,6 +22,9 @@
 			    enum lmtp_client_protocol protocol,
 			    const char *host, unsigned int port);
 
+/* Add headers from given string before the rest of the data. The string must
+   use CRLF line feeds and end with CRLF. */
+void lmtp_client_set_data_header(struct lmtp_client *client, const char *str);
 /* Add recipient to the session. rcpt_to_callback is called once LMTP server
    replies with RCPT TO. If RCPT TO was a succees, data_callback is called
    when DATA replies. */