I don't care about systems where atimes are broken.
[apps/madmutt.git] / buffy.c
diff --git a/buffy.c b/buffy.c
index 2b77b2d..5fdf725 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -30,127 +30,6 @@ static time_t ImapBuffyTime = 0;        /* last time we started checking for mai
 static short BuffyCount = 0;    /* how many boxes with new mail */
 static short BuffyNotify = 0;   /* # of unnotified new boxes */
 
-#ifdef BUFFY_SIZE
-
-/* Find the last message in the file. 
- * upon success return 0. If no message found - return -1 */
-
-static int fseeko_last_message (FILE * f)
-{
-  LOFF_T pos;
-  char buffer[BUFSIZ + 9];      /* 7 for "\n\nFrom " */
-  int bytes_read;
-  int i;                        /* Index into `buffer' for scanning.  */
-
-  p_clear(buffer, 1);
-  fseeko (f, 0, SEEK_END);
-  pos = ftello (f);
-
-  /* Set `bytes_read' to the size of the last, probably partial, buffer; 0 <
-   * `bytes_read' <= `BUFSIZ'.  */
-  bytes_read = pos % BUFSIZ;
-  if (bytes_read == 0)
-    bytes_read = BUFSIZ;
-  /* Make `pos' a multiple of `BUFSIZ' (0 if the file is short), so that all
-   * reads will be on block boundaries, which might increase efficiency.  */
-  while ((pos -= bytes_read) >= 0) {
-    /* we save in the buffer at the end the first 7 chars from the last read */
-    strncpy (buffer + BUFSIZ, buffer, 5 + 2);   /* 2 == 2 * m_strlen(CRLF) */
-    fseeko (f, pos, SEEK_SET);
-    bytes_read = fread (buffer, sizeof (char), bytes_read, f);
-    if (bytes_read == -1)
-      return -1;
-    for (i = bytes_read; --i >= 0;)
-      if (!m_strncmp(buffer + i, "\n\nFrom ", m_strlen("\n\nFrom "))) { /* found it - go to the beginning of the From */
-        fseeko (f, pos + i + 2, SEEK_SET);
-        return 0;
-      }
-    bytes_read = BUFSIZ;
-  }
-
-  /* here we are at the beginning of the file */
-  if (!m_strncmp("From ", buffer, 5)) {
-    fseeko (f, 0, 0);
-    return (0);
-  }
-
-  return (-1);
-}
-
-/* Return 1 if the last message is new */
-static int test_last_status_new (FILE * f)
-{
-  HEADER *hdr;
-  ENVELOPE *tmp_envelope;
-  int result = 0;
-
-  if (fseeko_last_message (f) == -1)
-    return (0);
-
-  hdr = header_new();
-  tmp_envelope = mutt_read_rfc822_header (f, hdr, 0, 0);
-  if (!(hdr->read || hdr->old))
-    result = 1;
-
-  envelope_delete(&tmp_envelope);
-  header_delete(&hdr);
-
-  return result;
-}
-
-static int test_new_folder (const char *path)
-{
-  FILE *f;
-  int rc = 0;
-  int typ;
-
-  typ = mx_get_magic (path);
-
-  if (typ != M_MBOX && typ != M_MMDF)
-    return 0;
-
-  if ((f = fopen (path, "rb"))) {
-    rc = test_last_status_new (f);
-    fclose (f);
-  }
-
-  return rc;
-}
-
-BUFFY *buffy_find_mailbox (const char *path)
-{
-  struct stat sb;
-  struct stat tmp_sb;
-  int i = 0;
-
-  if (stat (path, &sb) != 0)
-    return NULL;
-
-  if (!list_empty(Incoming)) {
-    for (i = 0; i < Incoming->length; i++) {
-      if (stat (Incoming->data[i], &tmp_sb) == 0 &&
-          sb.st_dev == tmp_sb.st_dev && sb.st_ino == tmp_sb.st_ino)
-        return ((BUFFY*) Incoming->data[i]);
-    }
-  }
-  return (NULL);
-}
-
-void buffy_update_mailbox (BUFFY * b)
-{
-  struct stat sb;
-
-  if (!b)
-    return;
-
-  if (stat (b->path, &sb) == 0)
-    b->size = (long) sb.st_size;
-  else
-    b->size = 0;
-  return;
-}
-#endif
-
 /* func to free buffy for list_del() */
 static inline void buffy_free (BUFFY** p) {
   p_delete(&(*p)->path);
@@ -178,9 +57,6 @@ int buffy_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data,
   BUFFY* tmp;
   char buf[_POSIX_PATH_MAX];
   int i = 0;
-#ifdef BUFFY_SIZE
-  struct stat sb;
-#endif /* BUFFY_SIZE */
 
   while (MoreArgs (s)) {
     mutt_extract_token (path, s, 0);
@@ -219,30 +95,11 @@ int buffy_parse_mailboxes (BUFFER * path, BUFFER * s, unsigned long data,
     tmp->notified = 1;
     tmp->newly_created = 0;
 
-#ifdef BUFFY_SIZE
-    /* for buffy_size, it is important that if the folder is new (tested by
-     * reading it), the size is set to 0 so that later when we check we see
-     * that it increased .  without buffy_size we probably don't care.
-     */
-    if (stat (tmp->path, &sb) == 0 && !test_new_folder (tmp->path)) {
-      /* some systems out there don't have an off_t type */
-      tmp->size = (long) sb.st_size;
-    }
-    else
-      tmp->size = 0;
-#endif /* BUFFY_SIZE */
   }
   return 0;
 }
 
-#ifdef BUFFY_SIZE
-/* people use buffy_size on systems where modified time attributes are BADLY
- * broken. Ignore them.
- */
-#define STAT_CHECK (sb.st_size > tmp->size)
-#else
 #define STAT_CHECK (sb.st_mtime > sb.st_atime || (tmp->newly_created && sb.st_ctime == sb.st_mtime && sb.st_ctime == sb.st_atime))
-#endif /* BUFFY_SIZE */
 
 /* values for force:
  * 0    don't force any checks + update sidebar
@@ -302,9 +159,6 @@ int buffy_check (int force)
        * be ready for when it does. */
       tmp->newly_created = 1;
       tmp->magic = -1;
-#ifdef BUFFY_SIZE
-      tmp->size = 0;
-#endif
       continue;
     }
 
@@ -323,12 +177,6 @@ int buffy_check (int force)
               BuffyCount++;
               tmp->new = 1;
             }
-#ifdef BUFFY_SIZE
-            else {
-              /* some other program has deleted mail from the folder */
-              tmp->size = (long) sb.st_size;
-            }
-#endif
           }
           else if (STAT_CHECK || tmp->msgcount == 0) {
             /* sidebar visible */
@@ -458,10 +306,6 @@ int buffy_check (int force)
 
       }
     }
-#ifdef BUFFY_SIZE
-    else if (Context && Context->path)
-      tmp->size = (long) sb.st_size;    /* update the size */
-#endif
 
     if (tmp->new <= 0)
       tmp->notified = 0;