Maildir patch

"Jessica Brennan [staff]" <[email protected]>
Newsgroups gmane.network.tin.devel
Message-ID <[email protected]>
I added the following patch to src/misc.c so that if the mailbox is a 
maildir it will properly check to see if there is new mail.

--- src/misc.c.orig     2005-08-19 14:01:31.000000000 -0400
+++ src/misc.c  2005-08-17 18:03:20.000000000 -0400
@@ -51,6 +51,21 @@
  #      include "rfc2046.h"
  #endif /* !RFC2046_H */

+#ifdef HAVE_CONFIG_H
+#       ifdef HAVE_DIRENT_H
+#               include <dirent.h>
+#               define DIR_BUF  struct dirent
+#       else
+#               ifdef HAVE_SYS_DIR_H
+#                       include <sys/dir.h>
+#               endif /* HAVE_SYS_DIR_H */
+#               ifdef HAVE_SYS_NDIR_H
+#                       include <sys/ndir.h>
+#               endif /* HAVE_SYS_NDIR_H */
+#               define DIR_BUF  struct direct
+#       endif /* HAVE_DIRENT_H */
+#endif /* HAVE_CONFIG_H */
+
  /*
   * defines to control GNKSA-checks behavior:
   * - ENFORCE_RFC1034
@@ -907,6 +922,10 @@
  {
         const char *mailbox_name;
         struct stat buf;
+        DIR *dirp;
+        struct dirent *dp;
+        char maildir_box[100];
+
  #ifdef M_AMIGA
         static long mbox_size = 0;
  #endif /* M_AMIGA */
@@ -951,8 +970,30 @@
                 }
         }
  #else
-       if (mailbox_name != 0 && stat(mailbox_name, &buf) >= 0 && 
buf.st_atime < buf.st_mtime && buf.st_size > 0)
+       if (mailbox_name != 0 && stat(mailbox_name, &buf) >= 0)
+        {
+           /* For a maildir setup */
+           if((int) (buf.st_mode & S_IFMT) == (int) S_IFDIR)
+           {
+              strncpy(maildir_box,  mailbox_name, 100);
+              strcat(maildir_box, "/new");
+              dirp = opendir(maildir_box);
+              if(dirp == NULL)
+                 return FALSE;
+
+              while((dp = readdir(dirp)) != NULL)
+              {
+                 if((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, 
"..")))
+                 {
+                    closedir(dirp);
+                    return TRUE;
+                 }
+              }
+              closedir(dirp);
+           }
+           else if(buf.st_atime < buf.st_mtime && buf.st_size > 0)
                 return TRUE;
+        }
  #endif /* M_AMIGA */
         return FALSE;
  }

-Jessica

~~~~~~~~~~~~~~
[email protected]
Panix Staff
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.