]> Pileus Git - ~andy/fetchmail/commitdiff
Fix bad UID/fetchlimit interaction.
authorEric S. Raymond <esr@thyrsus.com>
Tue, 17 Feb 1998 22:58:54 +0000 (22:58 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Tue, 17 Feb 1998 22:58:54 +0000 (22:58 -0000)
svn path=/trunk/; revision=1645

NEWS
driver.c
fetchmail.h
uid.c

diff --git a/NEWS b/NEWS
index f5d2afd2a3249179e0a06fd5b827ca0278ef4f3f..9cba63db6b09d901cacf0d9f368466066936b556 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,7 @@ fetchmail-4.3.7 ()
 * Minor port patches from Philippe De Muyter.
 * Patch by Chun-Chung Chen <cjj@u.washington.edu> to handle quotes in .netrc
 * IPv6 and IPSEC support patches from Craig Metz.
+* Fix bad interaction between UID handling and fetchmail.
 
 fetchmail-4.3.6 (Fri Jan 23 00:25:57 EST 1998)
 * Improved RPM packaging with correct grouping and an icon.
index cdfa866dd2f0c59b5f0f9efa9f5fd19017c63143..7afe9d3d1ef95a435f3c1e693945c98596ac2cbd 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -2069,6 +2069,12 @@ const struct method *proto;      /* protocol method table */
                         * now.
                         */
 
+                       /* tell the UID code we've seen this */
+                       if (ctl->newsaved)
+                           for (idp = ctl->newsaved; idp; idp = idp->next)
+                               if (idp->val.num == num)
+                                   MARK_SEEN(idp->val.num);
+
                        /* maybe we delete this message now? */
                        if (retained)
                        {
index 50ce5640a95a64e753333576ae193e3bbf1a2bfd..3347889f7925da28b5e5284d8ad54d1fb2e938ea 100644 (file)
@@ -159,10 +159,6 @@ struct query
     int        batchlimit;             /* max # msgs to pass in single SMTP session */
     int        expunge;                /* max # msgs to pass between expunges */
 
-    /* unseen, previous state of mailbox (initially from .fetchids) */
-#define UID_KEPT       0       /* this was remembered from a previous run */
-#define UID_DELETED    -1      /* this message has been deleted */
-#define UID_EXPUNGED   -2      /* this message has been expunged */ 
     struct idlist *oldsaved, *newsaved;
 
     /* internal use */
@@ -174,6 +170,17 @@ struct query
     struct query *next;                /* next query control block in chain */
 };
 
+/*
+ * UID-index information.  If the sign bit is on, this means the 
+ * message UID has been seen or expunged and should be written
+ * out to .fetchids at end of run.
+ */
+#define UID_KEPT       0               /* remembered from a previous run */
+#define UID_DELETED    INT_MIN         /* this message has been deleted */
+#define UID_EXPUNGED   INT_MAX         /* this message has been expunged */ 
+#define SAVE_UID(n)    ((n) < 0)       /* must this UID be saved? */
+#define MARK_SEEN(n)   n *= -1         /* mark a UID seen */
+
 /*
  * Numeric option handling.  Numeric option value of zero actually means
  * it's unspecified.  Value less than zero is zero.
diff --git a/uid.c b/uid.c
index 54d415894f96bdba3f38ed1bec3a834a0ec1cb80..1a9046563040d0caa29ed0f7a5524f5c1130ceda 100644 (file)
--- a/uid.c
+++ b/uid.c
@@ -7,6 +7,7 @@
 #include "config.h"
 
 #include <stdio.h>
+#include <limits.h>
 #if defined(STDC_HEADERS)
 #include <stdlib.h>
 #include <string.h>
@@ -44,6 +45,8 @@
  * Each time a message is fetched, we can check its UID against the
  * `oldsaved' list to see if it is old.
  *
+ * Each time a message-id is seen, we mark it with MARK_SEEN.
+ *
  * Each time a message is deleted, we mark its id UID_DELETED in the
  * `newsaved' member.  When we want to assert that an expunge has been
  * done on the server, we call expunge_uid() to register that all
  * At the end of the query, the `newsaved' member becomes the
  * `oldsaved' list.  The old `oldsaved' list is freed.
  *
- * At the end of the fetchmail run, non-EXPUNGED members of all
+ * At the end of the fetchmail run, seen and non-EXPUNGED members of all
  * current `oldsaved' lists are flushed out to the .fetchids file to
- * be picked up by the next run.  (The UID_EXPUNGED test means that a
- * message marked UID_DELETED may still have its ID go to disk if
- * there has been no intervening expunge operation.  This typically
- * comes up if the query was aborted by a line hit before a quit or
- * expunge was sent to the server.)  If there are no un-expunged
+ * be picked up by the next run.  If there are no un-expunged
  * messages, the file is deleted.
  *
  * Note: all comparisons are caseblind!
@@ -195,8 +194,8 @@ int str_nr_in_list( struct idlist **idl, const char *str )
     return -1;
 }
 
-int str_nr_last_in_list( struct idlist **idl, const char *str )
-  /* return the last position of str in idl */
+int str_nr_last_in_list( struct idlist **idl, const char *str)
+/* return the last position of str in idl */
 {
     int nr, ret = -1;
     struct idlist *walk;
@@ -208,16 +207,16 @@ int str_nr_last_in_list( struct idlist **idl, const char *str )
     return ret;
 }
 
-int count_list( struct idlist **idl )
-  /* count the number of elements in the list */
+int count_list( struct idlist **idl)
+/* count the number of elements in the list */
 {
   if( !*idl )
     return 0;
   return 1 + count_list( &(*idl)->next );
 }
 
-char* str_from_nr_list( struct idlist **idl, int number )
-  /* return the number'th string in idl */
+char *str_from_nr_list(struct idlist **idl, int number)
+/* return the number'th string in idl */
 {
     if( !*idl  || number < 0)
         return 0;
@@ -331,7 +330,7 @@ void write_saved_lists(struct query *hostlist, const char *idfile)
        if ((tmpfp = fopen(idfile, "w")) != (FILE *)NULL) {
            for (ctl = hostlist; ctl; ctl = ctl->next) {
                for (idp = ctl->oldsaved; idp; idp = idp->next)
-                   if (idp->val.num != UID_EXPUNGED)
+                   if (SAVE_UID(idp->val.num))
                        fprintf(tmpfp, "%s@%s %s\n", 
                            ctl->remotename, ctl->server.truename, idp->id);
            }