X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=uid.c;h=d069d7d0484b5b2bdeb1c01170fd5187762d537b;hb=a23a8cf8ee1da51c4392b9f52e6b72b0c01e3b5e;hp=b69e662d52a410f76afbe08a97419a2e66e9033d;hpb=98bdc445738682c067752f8d467c2b0841fc6306;p=~andy%2Ffetchmail diff --git a/uid.c b/uid.c index b69e662d..d069d7d0 100644 --- a/uid.c +++ b/uid.c @@ -1,28 +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 -#include -#include -#include -#include -#include -#include - -#include "fetchmail.h" -#include "gettext.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. @@ -97,13 +81,26 @@ * Note: some comparisons (those used for DNS address lists) are caseblind! */ +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include + +#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; @@ -117,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; @@ -278,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; @@ -288,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, @@ -343,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 */ @@ -386,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 */ @@ -442,6 +440,7 @@ static int write_uid_db_record(struct uid_db_record *rec, void *arg) 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; @@ -498,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) {