Skip to contentSkip to conversation

Text part in digests

PATCH New Morten K. Poulsen 1 participant 1 message Mar 23, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Text part in digests

Attached is a patch which adds support for a text/plain part in digest mails.

If the listtext "digest" exists, the digest function will try to get a subject from it.

If the option "nodigesttext" is not set, and the listtext "digest" exists, the digest function vi add a text/plain part at the beginning of the digest mail.

There is a few extra keywords which will be substituded:
- $digestfirst$ the archive index of the first mail (eg. "234")
- $digestlast$ the archive index of the last mail (eg. "245")
- $digestinterval$ the archive index interval (eg. "234-245" or "255")
- $digestissue$ the issue number (increments at each digest)
- $digestsubjects$ a ezmlmish thread list

The issue number is stored in the lastdigest file. If you don't want it to begin at 1, append ":882" to the first line, where 822 is the number ONE BELOW the next issue number.

The patch does not handle any kind of encoding of Subject: and From: headers. I will add that soon, but I think that some people (hi Andrea :) would like to have this patch now.

It would be nice if someone would translate the listtexts/digest file.

Also, I would be grateful if someone could try it out before I commit it. I have tested it and I think it is stable, and it doesn't leak any memory, AFIK.

Morten

Signature · 2 lines
Morten K. Poulsen <[email protected]>
http://www.afdelingp.dk/
include/send_digest.h +1 -1
@@ -25,6 +25,6 @@
 #define SEND_DIGEST_H
 
 int send_digest(const char *listdir, int lastindex, int index,
-		const char *addr, const char *mlmmjsend);
+		int issue, const char *addr, const char *mlmmjsend);
 
 #endif /* SEND_DIGEST_H */
src/Makefile.am +2 -1
@@ -49,7 +49,8 @@
 mlmmj_maintd_SOURCES = mlmmj-maintd.c print-version.c log_error.c mygetline.c \
 		       strgen.c random-int.c chomp.c writen.c memory.c \
 		       ctrlvalue.c send_digest.c getlistaddr.c dumpfd2fd.c \
-		       mylocking.c log_oper.c
+		       mylocking.c log_oper.c prepstdreply.c statctrl.c \
+		       gethdrline.c
 
 mlmmj_list_SOURCES = mlmmj-list.c strgen.c writen.c print-version.c memory.c \
 		     log_error.c random-int.c
src/mlmmj-maintd.c +17 -7
@@ -724,12 +724,12 @@
 
 int run_digests(const char *listdir, const char *mlmmjsend)
 {
-	char *lasttimestr, *lastindexstr;
+	char *lasttimestr, *lastindexstr, *lastissuestr;
 	char *digestname, *indexname;
 	char *digestintervalstr, *digestmaxmailsstr;
 	char *s1, *s2, *s3;
 	time_t digestinterval, t, lasttime;
-	long digestmaxmails, lastindex, index;
+	long digestmaxmails, lastindex, index, lastissue;
 	int fd, indexfd, lock;
 	size_t lenbuf, lenstr;
 	
@@ -767,9 +767,15 @@
 
 	s1 = mygetline(fd);
 
-	/* Syntax is lastindex:lasttime */
+	/* Syntax is lastindex:lasttime or lastindex:lasttime:lastissue */
 	if (s1 && (lasttimestr = strchr(s1, ':'))) {
 		*(lasttimestr++) = '\0';
+		if ((lastissuestr = strchr(lasttimestr, ':'))) {
+			*(lastissuestr++) = '\0';
+			lastissue = atol(lastissuestr);
+		} else {
+			lastissue = 0;
+		}
 		lasttime = atol(lasttimestr);
 		lastindexstr = s1;
 		lastindex = atol(lastindexstr);
@@ -785,6 +791,7 @@
 		/* If lastdigest is empty, we start from scratch */
 		lasttime = 0;
 		lastindex = 0;
+		lastissue = 0;
 	}
 	
 	indexname = concatstr(2, listdir, "/index");
@@ -818,15 +825,18 @@
 		if (index > lastindex+digestmaxmails)
 			index = lastindex+digestmaxmails;
 
-		send_digest(listdir, lastindex+1, index, NULL, mlmmjsend);
+		if (index > lastindex) {
+			lastissue++;
+			send_digest(listdir, lastindex+1, index, lastissue, NULL, mlmmjsend);
+		}
 
 		if (lseek(fd, 0, SEEK_SET) < 0) {
 			log_error(LOG_ARGS, "Could not seek '%s'", digestname);
 		} else {
-			/* index + ':' + time + '\n' + '\0' */
-			lenbuf = 20 + 1 + 20 + 2;
+			/* index + ':' + time + ':' + issue + '\n' + '\0' */
+			lenbuf = 20 + 1 + 20 + 1 + 20 + 2;
 			s3 = mymalloc(lenbuf);
-			lenstr = snprintf(s3, lenbuf, "%ld:%ld\n", index, (long)t);
+			lenstr = snprintf(s3, lenbuf, "%ld:%ld:%ld\n", index, (long)t, lastissue);
 			if (lenstr >= lenbuf)
 				lenstr = lenbuf - 1;
 			if (writen(fd, s3, lenstr) == -1) {
src/send_digest.c +241 -8

292 lines not on this page · raw message

Subject: Digest of $listaddr$ issue $digestissue$ ($digestinterval$)

Topics (messages $digestfirst$ throught $digestlast$):

$digestsubjects$