Only in imap-mailutil-convert-hack/: 1
Only in imap-mailutil-convert-hack/: a.out
Only in imap-mailutil-convert-hack/: foo
diff -ur imap-2004g/Makefile imap-mailutil-convert-hack/Makefile
--- imap-2004g/Makefile	2008-05-21 01:09:38.000000000 -0400
+++ imap-mailutil-convert-hack/Makefile	2008-05-21 05:41:01.000000000 -0400
@@ -533,14 +533,14 @@
 
 bundled:
 	@echo Building bundled tools...
-	$(CD) mtest;$(MAKE)
-	$(CD) ipopd;$(MAKE)
-	$(CD) imapd;$(MAKE)
+#	$(CD) mtest;$(MAKE)
+#	$(CD) ipopd;$(MAKE)
+#	$(CD) imapd;$(MAKE)
 	$(CD) mailutil;$(MAKE)
-	@$(SH) -c '(test -f /usr/include/sysexits.h ) || make sysexitwarn'
-	$(CD) mlock;$(MAKE) || true
-	$(CD) dmail;$(MAKE) || true
-	$(CD) tmail;$(MAKE) || true
+#	@$(SH) -c '(test -f /usr/include/sysexits.h ) || make sysexitwarn'
+#	$(CD) mlock;$(MAKE) || true
+#	$(CD) dmail;$(MAKE) || true
+#	$(CD) tmail;$(MAKE) || true
 
 
 sysexitwarn:
diff -ur imap-2004g/src/mailutil/mailutil.c imap-mailutil-convert-hack/src/mailutil/mailutil.c
--- imap-2004g/src/mailutil/mailutil.c	2005-02-08 18:50:49.000000000 -0500
+++ imap-mailutil-convert-hack/src/mailutil/mailutil.c	2008-05-21 08:57:47.000000000 -0400
@@ -37,6 +37,7 @@
 char *suffix = NIL;		/* suffer merge mode suffix text */
 int ddelim = -1;		/* destination delimiter */
 FILE *f = NIL;
+unsigned long copy_uid_validity, copy_uid_last = NIL;
 
 /* Merge modes */
 
@@ -189,6 +190,13 @@
   }
   if (!cmd) cmd = "";		/* prevent SEGV */
 
+  if (strcmp (cmd,"copy")) {
+    printf ("\nThis is a HACKED version of mailutil for copying mail from mbx to unix format mailboxes, while preserving UIDs. It can only be used with the 'copy' command and even then only with an mbx input and a unix output.\n\n");
+    printf ("usage: %s (copy | move) [-debug] [-verbose] old_mailbox new_mailbox\n",pgm);
+    puts   ("        ;; create new mailbox and copy/move messages");
+    exit(ret);
+  }
+
   if (!strcmp (cmd,"check")) {	/* check for new messages */
     if (!src) src = "INBOX";
     if (dst || merge || rwcopyp)
@@ -352,7 +360,7 @@
   }
 
   else {
-    printf ("usage: %s check [-debug] [-verbose] [mailbox]\n",pgm);
+/*    printf ("usage: %s check [-debug] [-verbose] [mailbox]\n",pgm);
     puts   ("        ;; report number of messages and new messages");
     printf ("       %s create [-debug] [-verbose] new_mailbox\n",pgm);
     puts   ("        ;; create new mailbox");
@@ -360,9 +368,9 @@
     puts   ("        ;; delete existing mailbox");
     printf ("       %s rename [-debug] [-verbose] source destination\n",pgm);
     puts   ("        ;; rename mailbox to a new name");
-    printf ("       %s (copy | move) [-debug] [-verbose] old_mailbox new_mailbox\n",pgm);
+*/    printf ("usage: %s (copy | move) [-debug] [-verbose] old_mailbox new_mailbox\n",pgm);
     puts   ("        ;; create new mailbox and copy/move messages");
-    printf ("       %s (append | appenddelete) [-debug] [-verbose] source destination\n",pgm);
+/*    printf ("       %s (append | appenddelete) [-debug] [-verbose] source destination\n",pgm);
     puts   ("        ;; copy/move messages to existing mailbox");
     printf ("       %s prune [-debug] [-verbose] mailbox search_criteria\n",
 	    pgm);
@@ -370,7 +378,7 @@
     printf ("       %s transfer [-debug] [-verbose] [-merge mode] source destination\n",pgm);
     puts   ("        ;; make copy of source hierarchy to destination");
     puts   ("        ;;  -merge modes are prompt, append, or suffix=xxxx");
-  }
+*/  }
 				/* close streams */
   if (source) mail_close (source);
   if (dest) mail_close (dest);
@@ -397,6 +405,10 @@
   char *ndst = NIL;
   int ret = NIL;
   trycreate = NIL;		/* no TRYCREATE yet */
+
+  copy_uid_validity = source->uid_validity;
+  copy_uid_last = source->uid_last;
+  printf("HACK: If creating unix format, will preserve UIDVALIDITY: %lu UIDLAST: %lu", copy_uid_validity, copy_uid_last);
   if (create) while (!mail_create (dest,dst) && (mode != mAPPEND)) {
     switch (mode) {
     case mPROMPT:		/* prompt user for new name */
diff -ur imap-2004g/src/mailutil/Makefile imap-mailutil-convert-hack/src/mailutil/Makefile
--- imap-2004g/src/mailutil/Makefile	2002-11-18 19:41:46.000000000 -0500
+++ imap-mailutil-convert-hack/src/mailutil/Makefile	2008-05-21 08:59:48.000000000 -0400
@@ -28,8 +28,8 @@
 CFLAGS = -I$C `cat $C/CFLAGS`
 LDFLAGS = $(CCLIENTLIB) `cat $C/LDFLAGS`
 
-mailutil: $(CCLIENTLIB) mailutil.o
-	$(CC) $(CFLAGS) -o mailutil mailutil.o $(LDFLAGS)
+mailutil-hack: $(CCLIENTLIB) mailutil.o
+	$(CC) $(CFLAGS) -static -o mailutil-hack mailutil.o $(LDFLAGS)
 
 mailutil.o: $C/mail.h $C/misc.h $C/osdep.h
 
diff -ur imap-2004g/src/osdep/unix/mbx.c imap-mailutil-convert-hack/src/osdep/unix/mbx.c
--- imap-2004g/src/osdep/unix/mbx.c	2005-03-08 21:39:08.000000000 -0500
+++ imap-mailutil-convert-hack/src/osdep/unix/mbx.c	2008-05-21 08:15:24.000000000 -0400
@@ -608,6 +608,7 @@
 {
   unsigned long i;
   char *s;
+  MESSAGECACHE *elt = mbx_elt (stream,msgno,NIL);
   *length = 0;			/* default to empty */
   if (flags & FT_UID) return "";/* UID call "impossible" */
 				/* get header position, possibly header */
@@ -623,6 +624,25 @@
     read (LOCAL->fd,s = LOCAL->buf,*length);
   }
   s[*length] = '\0';		/* tie off string */
+
+  char uid[40];
+  int uidlen;
+  if (elt->private.uid) {
+    sprintf(uid, "X-UID: %lu\r\n", elt->private.uid);
+    uidlen = strlen(uid);
+
+    if (LOCAL->buflen < *length + uidlen) {
+      char *s2 = (char *) fs_get ((LOCAL->buflen = *length + uidlen) + 1);
+      strcpy(s2, s);
+      fs_give ((void **) &LOCAL->buf);
+      s = LOCAL->buf = s2;
+    }
+    
+    strcpy(&(s[*length - 2]), uid);
+    strcpy(&(s[*length + uidlen - 2]), "\r\n");
+    s[*length + uidlen] = '\0';
+    *length = *length + uidlen;
+  }
   return s;
 }
 
Only in imap-mailutil-convert-hack/src/osdep/unix: .mbx.c.swp
diff -ur imap-2004g/src/osdep/unix/unix.c imap-mailutil-convert-hack/src/osdep/unix/unix.c
--- imap-2004g/src/osdep/unix/unix.c	2004-11-10 19:23:09.000000000 -0500
+++ imap-mailutil-convert-hack/src/osdep/unix/unix.c	2008-05-21 08:14:26.000000000 -0400
@@ -66,6 +66,8 @@
 } UNIXLOCAL;
 
 
+extern unsigned long copy_uid_validity, copy_uid_last;
+
 /* Convenient access to local data */
 
 #define LOCAL ((UNIXLOCAL *) stream->local)
@@ -321,9 +323,9 @@
       rfc822_fixed_date (s = tmp + strlen (tmp));
 				/* write the pseudo-header */
       sprintf (s += strlen (s),
-	       "\nFrom: %s <%s@%s>\nSubject: %s\nX-IMAP: %010lu 0000000000",
+	       "\nFrom: %s <%s@%s>\nSubject: %s\nX-IMAP: %010lu %010lu",
 	       pseudo_name,pseudo_from,mylocalhost (),pseudo_subject,
-	       (unsigned long) ti);
+	       copy_uid_validity, copy_uid_last);
       for (i = 0; i < NUSERFLAGS; ++i) if (default_user_flag (i))
 	sprintf (s += strlen (s)," %s",default_user_flag (i));
       sprintf (s += strlen (s),"\nStatus: RO\n\n%s\n\n",pseudo_msg);
@@ -1092,7 +1094,7 @@
 		 (tmp[5] == 's') && (tmp[6] == ':')) ||
 		(((i > 5) && (tmp[0] == 'X') && (tmp[1] == '-')) &&
 		 (((tmp[2] == 'U') && (tmp[3] == 'I') && (tmp[4] == 'D') &&
-		   (tmp[5] == ':')) ||
+		   (tmp[5] == ':') && 0 /* allow X-UID */) ||
 		  ((i > 6) && (tmp[2] == 'I') && (tmp[3] == 'M') &&
 		   (tmp[4] == 'A') && (tmp[5] == 'P') &&
 		   ((tmp[6] == ':') ||
@@ -1834,6 +1836,8 @@
   long ret,flag;
   unsigned long i,j;
   unsigned long recent = stream->recent;
+printf("\nOld UIDLAST: %lu new: %lu", stream->uid_last, copy_uid_last);
+  if (stream->uid_last < copy_uid_last) stream->uid_last = copy_uid_last;
   unsigned long size = LOCAL->pseudo ? unix_pseudo (stream,LOCAL->buf) : 0;
   if (nexp) *nexp = 0;		/* initially nothing expunged */
 				/* calculate size of mailbox after rewrite */
