Subject: Patch for dmail: add '-s' option (flag as '\Seen')

From: Michael Schaap <[email-masked]>
Date: Sat, 30 Aug 2003 16:36:23 +0200

Hi,

A while ago, I modified dmail to support an '-s' flag which files a 
message flagged as '\Seen'. (I use this to file outgoing messages 
appropriately from procmail.)

I've attached the patch for this to this message. Feel free to include 
in the IMAP toolkit distribution.

Best regards,

– Michael
diff -u ORIG/dmail.1 ./dmail.1
--- ORIG/dmail.1	Thu May  9 16:36:18 2002
+++ ./dmail.1	Sun Jan 19 21:20:06 2003
@@ -4,7 +4,7 @@
 .nh
 .SH SYNOPSIS
 .B dmail
-.I [\-D] [\-f from_name] [user][+folder]
+.I [\-D] [\-f from_name] [-s] [user][+folder]
 .SH DESCRIPTION
 .I dmail
 delivers mail to a user's INBOX or a designated folder.
@@ -62,6 +62,8 @@
    Return-Path: <\fIfrom_name\fR> 
 .br 
 is prepended to the message before delivery.  
+.PP
+The \fB-s\fR flag specifies that the message will be flagged '\\Seen'.
 .SH RESTRICTIONS
 Absolute pathnames and 
 .I ~user
diff -u ORIG/dmail.c ./dmail.c
--- ORIG/dmail.c	Mon Jul 15 00:48:51 2002
+++ ./dmail.c	Sun Jan 19 21:20:57 2003
@@ -35,6 +35,7 @@
 
 char *version = "2002(12)";	/* dmail release version */
 int debug = NIL;		/* debugging (don't fork) */
+int flagSeen = NIL;		/* flag message as '\Seen' */
 int trycreate = NIL;		/* flag saying gotta create before appending */
 int critical = NIL;		/* flag saying in critical code */
 char *sender = NIL;		/* message origin */
@@ -140,6 +141,9 @@
     if (argc--) sender = cpystr (*++argv);
     else _exit (fail ("missing argument to -r",EX_USAGE));
     break;
+  case 's':
+    flagSeen = T;
+    break;
   default:			/* anything else */
     _exit (fail ("unknown switch",EX_USAGE));
   }
@@ -364,7 +368,7 @@
 	   ((sbuf.st_mode & S_IFMT) == S_IFDIR) ? "directory" : "file",path);
   mm_dlog (tmp);
 				/* do the append now! */
-  if (!mail_append (prt,mailbox,st)) {
+  if (!mail_append_full (prt,mailbox,(flagSeen?"\\Seen":NIL),NIL,st)) {
     sprintf (tmp,"message delivery failed to %.80s",path);
     return fail (tmp,EX_CANTCREAT);
   }

---

From: Mark Crispin <[email-masked]>
Date: Tue, 2 Sep 2003 14:13:58 -0700 (Pacific Daylight Time)

Thank you very much for your suggested patch.

After careful consideration, I have decided that this patch is generally
useful and should be adopted.  With minor cosmetic differences, it will be
in imap-2003.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.