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 */
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.
#include "config.h"
#include <stdio.h>
+#include <limits.h>
#if defined(STDC_HEADERS)
#include <stdlib.h>
#include <string.h>
* 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!
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;
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;
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);
}