]> Pileus Git - ~andy/fetchmail/blobdiff - uid.c
Attempt merging from 6.3.24.
[~andy/fetchmail] / uid.c
diff --git a/uid.c b/uid.c
index b7beedf4880250db2cdb5a004522c2ed65e2c6f0..d069d7d0484b5b2bdeb1c01170fd5187762d537b 100644 (file)
--- a/uid.c
+++ b/uid.c
@@ -1,32 +1,12 @@
 /**
- * \file uid.c -- UIDL handling for POP3 servers without LAST
+ * \file uid.c
+ * UID list handling (currently, only for POP3)
  *
  * For license terms, see the file COPYING in this directory.
- */
-
-#include "config.h"
-
-#include <sys/stat.h>
-#include <errno.h>
-#include <stdio.h>
-#include <limits.h>
-#if defined(STDC_HEADERS)
-#include <stdlib.h>
-#include <string.h>
-#endif
-#if defined(HAVE_UNISTD_H)
-#include <unistd.h>
-#endif
-
-#include "fetchmail.h"
-#include "i18n.h"
-#include "sdump.h"
-
-/*
- * Machinery for handling UID lists live here.  This is mainly to support
- * RFC1725/RFC1939-conformant POP3 servers without a LAST command, but may also
- * be useful for making the IMAP4 querying logic UID-oriented, if a future
- * revision of IMAP forces me to.
+ *
+ * Machinery for handling UID lists live here.  This is currently used
+ * by POP3, but may also be useful for making the IMAP4 querying logic
+ * UID-oriented.
  *
  * These functions are also used by the rest of the code to maintain
  * string lists.
  * Note: some comparisons (those used for DNS address lists) are caseblind!
  */
 
+#include "config.h"
+
+#include <sys/stat.h>
+#include <errno.h>
+#include <stdio.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "fetchmail.h"
+#include "gettext.h"
+#include "sdump.h"
+
 int dofastuidl = 0;
 
 #ifdef POP3_ENABLE
 /** UIDs associated with un-queried hosts */
 static struct idlist *scratchlist;
 
-/** Read saved IDs from \a idfile and attach to each host in \a hostlist. */
 static int dump_saved_uid(struct uid_db_record *rec, void *unused)
 {
     char *t;
@@ -121,6 +114,7 @@ static int dump_saved_uid(struct uid_db_record *rec, void *unused)
     return 0;
 }
 
+/** Read saved IDs from \a idfile and attach to each host in \a hostlist. */
 void initialize_saved_lists(struct query *hostlist, const char *idfile)
 {
     struct stat statbuf;
@@ -282,8 +276,6 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile)
     }
 }
 
-/** Assert that all UIDs marked deleted in query \a ctl have actually been
-expunged. */
 static int mark_as_expunged_if(struct uid_db_record *rec, void *unused)
 {
     (void)unused;
@@ -292,6 +284,8 @@ static int mark_as_expunged_if(struct uid_db_record *rec, void *unused)
     return 0;
 }
 
+/** Assert that all UIDs marked deleted in query \a ctl have actually been
+expunged. */
 void expunge_uids(struct query *ctl)
 {
     traverse_uid_db(dofastuidl ? &ctl->oldsaved : &ctl->newsaved,
@@ -324,7 +318,7 @@ static int dump_uid_db_record(struct uid_db_record *rec, void *arg)
        unsigned *n_recs;
        char *t;
 
-       n_recs = arg;
+       n_recs = (unsigned int *)arg;
        --*n_recs;
 
        t = sdump(rec->id, rec->id_len);
@@ -347,7 +341,7 @@ static void dump_uid_db(struct uid_db *db)
        traverse_uid_db(db, dump_uid_db_record, &n_recs);
 }
 
-/* finish a query */
+/** Finish a successful query */
 void uid_swap_lists(struct query *ctl)
 {
     /* debugging code */
@@ -390,7 +384,7 @@ void uid_swap_lists(struct query *ctl)
        report(stdout, GT_("not swapping UID lists, no UIDs seen this query\n"));
 }
 
-/* finish a query which had errors */
+/** Finish a query which had errors */
 void uid_discard_new_list(struct query *ctl)
 {
     /* debugging code */
@@ -439,13 +433,14 @@ static int write_uid_db_record(struct uid_db_record *rec, void *arg)
     if (!(rec->status == UID_SEEN || rec->status == UID_DELETED))
        return 0;
 
-    info = arg;
+    info = (struct write_saved_info *)arg;
     rc = fprintf(info->fp, "%s@%s %s\n",
                 info->ctl->remotename, info->ctl->server.queryname,
                 rec->id);
     return rc < 0 ? -1 : 0;
 }
 
+/** Write new list of UIDs (state) to \a idfile. */
 void write_saved_lists(struct query *hostlist, const char *idfile)
 {
     long       idcount;
@@ -502,7 +497,7 @@ void write_saved_lists(struct query *hostlist, const char *idfile)
 bailout:
            (void)fflush(tmpfp); /* return code ignored, we check ferror instead */
            errflg |= ferror(tmpfp);
-           fclose(tmpfp);
+           errflg |= fclose(tmpfp);
            /* if we could write successfully, move into place;
             * otherwise, drop */
            if (errflg) {