changeset 372:fb20c515ea76

Add customheaders to digests as well
author mmj
date Mon, 15 Nov 2004 21:17:45 +1100
parents 4f66c36c1fb4
children a85d10945dc7
files src/send_digest.c
diffstat 1 files changed, 28 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/send_digest.c	Mon Nov 15 19:45:06 2004 +1100
+++ b/src/send_digest.c	Mon Nov 15 21:17:45 2004 +1100
@@ -42,13 +42,11 @@
 int send_digest(const char *listdir, int firstindex, int lastindex,
 		const char *addr, const char *mlmmjsend)
 {
-	int i;
-	int fd, archivefd;
+	int i, fd, archivefd, status, hdrfd;
 	char buf[45];
-	char *tmp, *queuename = NULL, *archivename;
+	char *tmp, *queuename = NULL, *archivename, *fromstr;
 	char *boundary, *listaddr, *listname, *listfqdn;
 	pid_t childpid, pid;
-	int status;
 
 	if (addr) {
 		errno = 0;
@@ -75,6 +73,10 @@
 		return -1;
 	}
 
+	tmp = concatstr(2, listdir, "/control/customheaders");
+	hdrfd = open(tmp, O_RDONLY);
+	myfree(tmp);
+
 	boundary = random_str();
 
 	listaddr = getlistaddr(listdir);
@@ -87,20 +89,35 @@
 	} else {
 		snprintf(buf, sizeof(buf), " (%d-%d)", firstindex, lastindex);
 	}
-	tmp = concatstr(10,	"From: ", listname, "+help@", listfqdn,
-				"\nMIME-Version: 1.0"
+
+	fromstr = concatstr(4, "From: ", listname, "+help@", listfqdn);
+	fromstr[6] = RECIPDELIM;
+	tmp = concatstr(6, "\nMIME-Version: 1.0"
 				"\nContent-Type: multipart/" DIGESTMIMETYPE "; "
 					"boundary=", boundary,
-				"\nSubject: Digest of ", listname, buf,
-				"\n\n");
+			    "\nSubject: Digest of ", listname, buf, "\n\n");
 	myfree(listfqdn);
 
-	if (writen(fd, tmp, strlen(tmp)) == -1) {
+	if (writen(fd, fromstr, strlen(fromstr)) < -1)
+		goto errdighdrs;
+
+	myfree(fromstr);
+	
+	if(dumpfd2fd(hdrfd, fd) < 0) {
+		close(hdrfd);
+		goto errdighdrs;
+	}
+
+	close(hdrfd);
+
+	if (writen(fd, tmp, strlen(tmp)) < -1) {
+errdighdrs:
 		log_error(LOG_ARGS, "Could not write digest headers to '%s'",
 				queuename);
 		close(fd);
 		unlink(queuename);
 		myfree(boundary);
+		myfree(fromstr);
 		myfree(tmp);
 		myfree(queuename);
 		myfree(listname);