On Tue, Oct 14, Henrique de Moraes Holschuh wrote:

> Please try the attached patch.
> 
> It switches default behaviour to least-surprise (INTERNALDATE), adds
> -X to get the old behaviour, and enhances ipurge by adding -i to invert
> match logic.

I am a little bit late on this topic, but I also made a patch and solved it a
little bit different. Btw.: I don't like changing defaults, even if they do
not make a lot of sense.


-- 
With best regards,

Carsten Hoeger
--- imap/ipurge.c       2003/11/04 09:27:08     1.1
+++ imap/ipurge.c       2003/11/05 10:00:05
@@ -77,6 +77,7 @@
 extern int  optopt;
 
 /* globals for callback functions */
+int sent_day = 1;
 int days = -1;
 int size = -1;
 int exact = -1;
@@ -114,7 +115,7 @@
     usage(argv[0]);
   }
 
-  while ((option = getopt(argc, argv, "C:hxd:b:k:m:f")) != EOF) {
+  while ((option = getopt(argc, argv, "C:hxd:b:k:m:fR")) != EOF) {
     switch (option) {
     case 'C': /* alt config file */
       alt_config = optarg;
@@ -125,6 +126,9 @@
       }
       days = atoi(optarg) * 86400 /* nominal # of seconds in a 'day' */;
     } break;
+    case 'R': {
+       sent_day = 0;
+    } break;
     case 'b': {
       if (optarg == 0) {
        usage(argv[0]);
@@ -192,11 +196,13 @@
 
 int
 usage(char *name) {
-  printf("usage: %s [-f] [-C <alt_config>] [-x] {-d days &| -b bytes|-k Kbytes|-m 
Mbytes}\n\t[mboxpattern1 ... [mboxpatternN]]\n", name);
+  printf("usage: %s [-f] [-C <alt_config>] [-x] {-d days [-R|-S] &| -b bytes|-k 
Kbytes|-m Mbytes}\n\t[mboxpattern1 ... [mboxpatternN]]\n", name);
   printf("\tthere are no defaults and at least one of -d, -b, -k, -m\n\tmust be 
specified\n");
   printf("\tif no mboxpattern is given %s works on all mailboxes\n", name);
   printf("\t -x specifies an exact match for days or size\n");
   printf("\t -f force also to delete mail below user.* and INBOX.*\n");
+  printf("\t -R use received date to purge mails older then -d days\n");
+  printf("\t    (default is sent date)\n");
   exit(0);
 }
 
@@ -265,7 +271,11 @@
   bit32 senttime;
   bit32 msgsize;
 
-  senttime = ntohl(*((bit32 *)(buf + OFFSET_SENTDATE)));
+  if( sent_day ) {
+       senttime = ntohl(*((bit32 *)(buf + OFFSET_SENTDATE)));
+  } else {
+       senttime = ntohl(*((bit32 *)(buf + OFFSET_INTERNALDATE)));
+  }
   msgsize = ntohl(*((bit32 *)(buf + OFFSET_SIZE)));
 
   stats->total++;
--- man/ipurge.8        2003/11/04 09:37:16     1.1
+++ man/ipurge.8        2003/11/04 10:09:27
@@ -57,6 +57,9 @@
 .br
        [
 .BI \-d " days"
+[
+.B \-R
+]
 |
 .BI \-b " bytes"
 |
@@ -99,6 +102,10 @@
 .BI \-d " days"
 Age of message in \fIdays\fR.
 .TP
+.BI \-R
+Use the received date to purge mails in conjunction with \fB-d\fR instead of
+the sent date, which is the default.
+.TP
 .BI \-b " bytes"
 Size of message in \fIbytes\fR.
 .TP

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to