From ec014e8c69e65b56063735ee47cb29173cae113e Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 18 Apr 1999 18:32:03 +0000 Subject: Enable expunge to controil POP2 and POP3 checkpointing. svn path=/trunk/; revision=2439 --- NEWS | 3 +- conf.c | 2 +- driver.c | 134 +++++++++++++++++++++++++++++++----------------- fetchmail-features.html | 9 +++- fetchmail.c | 5 +- fetchmail.h | 8 ++- fetchmail.man | 17 +++--- fetchmailconf | 2 +- imap.c | 20 ++++++-- options.c | 10 ++-- rcfile_y.y | 10 ++-- 11 files changed, 141 insertions(+), 79 deletions(-) diff --git a/NEWS b/NEWS index a7393693..6ca21291 100644 --- a/NEWS +++ b/NEWS @@ -12,8 +12,9 @@ fetchmail-5.0.1 (): * Try to discover user/home via getpwuid(getuid()) before using LOGNAME/HOME. * Mike Pearce's fix for buggy DEFAULT handling in .netrc. * Keep validation errors from generating message lines that qmail will reject. +* Can now use expunge option to chop POP3 retrievals into subsessions. -There are 255 people on fetchmail-friends and 369 on fetchmail-announce. +There are 253 people on fetchmail-friends and 370 on fetchmail-announce. ------------------------------------------------------------------------------ fetchmail-5.0.0 (Mon Apr 5 11:00:24 EDT 1999): diff --git a/conf.c b/conf.c index 24f71a37..23826c8e 100644 --- a/conf.c +++ b/conf.c @@ -74,7 +74,7 @@ static void numdump(const char *name, const int num) /* dump a numeric quantity at current indent */ { indent('\0'); - fprintf(stdout, "'%s':%d,\n", name, num); + fprintf(stdout, "'%s':%d,\n", name, NUM_VALUE_OUT(num)); } static void booldump(const char *name, const int onoff) diff --git a/driver.c b/driver.c index d1ef6d48..2e123934 100644 --- a/driver.c +++ b/driver.c @@ -73,7 +73,6 @@ extern char *strstr(); /* needed on sysV68 R3V7.1. */ #endif /* strstr */ -int fetchlimit; /* how often to tear down the server connection */ int batchcount; /* count of messages sent in current batch */ flag peek_capable; /* can we peek for better error recovery? */ int pass; /* how many times have we re-polled? */ @@ -1354,10 +1353,11 @@ static void send_size_warnings(struct query *ctl) #undef OVERHD } -int do_protocol(ctl, proto) +static int do_session(ctl, proto, maxfetch) /* retrieve messages from server using given protocol method table */ struct query *ctl; /* parsed options with merged-in defaults */ const struct method *proto; /* protocol method table */ +const int maxfetch; /* maximum number of messages to fetch */ { int ok, js; #ifdef HAVE_VOLATILE @@ -1372,47 +1372,6 @@ const struct method *proto; /* protocol method table */ protocol = proto; ctl->server.base_protocol = protocol; -#ifndef KERBEROS_V4 - if (ctl->server.preauthenticate == A_KERBEROS_V4) - { - report(stderr, _("Kerberos V4 support not linked.\n")); - return(PS_ERROR); - } -#endif /* KERBEROS_V4 */ - -#ifndef KERBEROS_V5 - if (ctl->server.preauthenticate == A_KERBEROS_V5) - { - report(stderr, _("Kerberos V5 support not linked.\n")); - return(PS_ERROR); - } -#endif /* KERBEROS_V5 */ - - /* lacking methods, there are some options that may fail */ - if (!proto->is_old) - { - /* check for unsupported options */ - if (ctl->flush) { - report(stderr, - _("Option --flush is not supported with %s\n"), - proto->name); - return(PS_SYNTAX); - } - else if (ctl->fetchall) { - report(stderr, - _("Option --all is not supported with %s\n"), - proto->name); - return(PS_SYNTAX); - } - } - if (!proto->getsizes && NUM_SPECIFIED(ctl->limit)) - { - report(stderr, - _("Option --limit is not supported with %s\n"), - proto->name); - return(PS_SYNTAX); - } - pass = 0; tagnum = 0; tag[0] = '\0'; /* nuke any tag hanging out from previous query */ @@ -2067,12 +2026,12 @@ const struct method *proto; /* protocol method table */ report_complete(stdout, _(" not flushed\n")); /* perhaps this as many as we're ready to handle */ - if (NUM_NONZERO(ctl->fetchlimit) - && ctl->fetchlimit <= fetches) + if (maxfetch && maxfetch <= fetches && fetches < count) { - report(stdout, _("fetchlimit reached; %d messages left on server\n"), - count - fetches); - goto no_error; + report(stdout, _("fetchlimit %d reached; %d messages left on server\n"), + maxfetch, count - fetches); + ok = PS_MAXFETCH; + goto cleanUp; } } @@ -2145,6 +2104,7 @@ const struct method *proto; /* protocol method table */ report(stderr, _("undefined error\n")); break; } + /* no report on PS_MAXFETCH or PS_UNDEFINED */ if (ok==PS_SOCKET || ok==PS_AUTHFAIL || ok==PS_SYNTAX || ok==PS_IOERR || ok==PS_ERROR || ok==PS_PROTOCOL || ok==PS_LOCKBUSY || ok==PS_SMTP || ok==PS_DNS) @@ -2163,6 +2123,84 @@ closeUp: return(ok); } +int do_protocol(ctl, proto) +/* retrieve messages from server using given protocol method table */ +struct query *ctl; /* parsed options with merged-in defaults */ +const struct method *proto; /* protocol method table */ +{ + int ok; + +#ifndef KERBEROS_V4 + if (ctl->server.preauthenticate == A_KERBEROS_V4) + { + report(stderr, _("Kerberos V4 support not linked.\n")); + return(PS_ERROR); + } +#endif /* KERBEROS_V4 */ + +#ifndef KERBEROS_V5 + if (ctl->server.preauthenticate == A_KERBEROS_V5) + { + report(stderr, _("Kerberos V5 support not linked.\n")); + return(PS_ERROR); + } +#endif /* KERBEROS_V5 */ + + /* lacking methods, there are some options that may fail */ + if (!proto->is_old) + { + /* check for unsupported options */ + if (ctl->flush) { + report(stderr, + _("Option --flush is not supported with %s\n"), + proto->name); + return(PS_SYNTAX); + } + else if (ctl->fetchall) { + report(stderr, + _("Option --all is not supported with %s\n"), + proto->name); + return(PS_SYNTAX); + } + } + if (!proto->getsizes && NUM_SPECIFIED(ctl->limit)) + { + report(stderr, + _("Option --limit is not supported with %s\n"), + proto->name); + return(PS_SYNTAX); + } + + /* + * If no expunge limit or we do expunges within the driver, + * then just do one session, passing in any fetchlimit. + */ + if (proto->retry || !NUM_SPECIFIED(ctl->expunge)) + return(do_session(ctl, proto, NUM_VALUE_OUT(ctl->fetchlimit))); + /* + * There's an expunge limit, and it isn't handled in the driver itself. + * OK; do multiple sessions, each fetching a limited # of messages. + * Stop if the total count of retrieved messages exceeds ctl->fetchlimit + * (if it was nonzero). + */ + else + { + int totalcount = 0; + int expunge = NUM_VALUE_OUT(ctl->expunge); + int fetchlimit = NUM_VALUE_OUT(ctl->fetchlimit); + + do { + ok = do_session(ctl, proto, expunge); + totalcount += expunge; + if (NUM_SPECIFIED(ctl->fetchlimit) && totalcount >= fetchlimit) + break; + } while + (ok == PS_MAXFETCH); + + return(ok); + } +} + #if defined(HAVE_STDARG_H) void gen_send(int sock, const char *fmt, ... ) #else diff --git a/fetchmail-features.html b/fetchmail-features.html index a243bfea..ab778a90 100644 --- a/fetchmail-features.html +++ b/fetchmail-features.html @@ -10,12 +10,17 @@
Back to Fetchmail Home Page To Site Map -$Date: 1999/02/07 17:03:04 $ +$Date: 1999/04/18 18:32:01 $

Fetchmail Feature List

+

Since 5.0:

+ +

Since 4.0: