aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--driver.c5
-rw-r--r--fetchmail.c11
-rw-r--r--fetchmail.h1
-rw-r--r--fetchmail.man8
-rw-r--r--options.c13
-rw-r--r--rcfile_l.l1
-rw-r--r--rcfile_y.y5
-rw-r--r--sample.rcfile2
9 files changed, 42 insertions, 7 deletions
diff --git a/NEWS b/NEWS
index d56f62b1..95b16e62 100644
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,9 @@ features --
* Received line parsing for envelope addresses now matches MX as well as
canonical DNS addresses, making multidrop routing slightly more reliable.
+* Added --fetchlimit option to limit number of messages fetched in a
+ single poll.
+
bugs --
* Fixed a FreeBSD compilation glitch involving SIGCLD (thanks to
diff --git a/driver.c b/driver.c
index 1cebf770..5cfbddd1 100644
--- a/driver.c
+++ b/driver.c
@@ -52,6 +52,7 @@
#define SMTP_PORT 25 /* standard SMTP service port */
int batchlimit; /* how often to tear down the delivery connection */
+int fetchlimit; /* how often to tear down the server connection */
int batchcount; /* count of messages sent in current batch */
int peek_capable; /* can we peek for better error recovery? */
@@ -1085,6 +1086,10 @@ const struct method *proto; /* protocol method table */
}
else if (outlevel > O_SILENT)
fprintf(stderr, " not flushed\n");
+
+ /* perhaps this as many as we're ready to handle */
+ if (ctl->fetchlimit && ctl->fetchlimit <= num)
+ break;
}
/* remove all messages flagged for deletion */
diff --git a/fetchmail.c b/fetchmail.c
index d8f42e51..65c84933 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -58,6 +58,7 @@ char *logfile; /* log file for daemon mode */
int quitmode; /* if --quit was set */
int check_only; /* if --probe was set */
int cmd_batchlimit; /* if --batchlimit was set */
+int cmd_fetchlimit; /* if --fetchlimit was set */
char *cmd_logfile; /* if --logfile was set */
/* miscellaneous global controls */
@@ -756,9 +757,15 @@ void dump_params (struct query *ctl)
ctl->norewrite ? "dis" : "en",
ctl->norewrite ? "on" : "off");
if (ctl->limit)
- printf(" Message size limit is %d bytes\n", ctl->limit);
+ printf(" Message size limit is %d bytes (--limit %d).\n",
+ ctl->limit, ctl->limit);
else if (outlevel == O_VERBOSE)
- printf(" No message size limit\n");
+ printf(" No message size limit (--limit 0).\n");
+ if (ctl->fetchlimit)
+ printf(" Received-message limit is %d (--fetchlimit %d).\n",
+ ctl->fetchlimit, ctl->fetchlimit);
+ else if (outlevel == O_VERBOSE)
+ printf(" No received-message limit (--fetchlimit 0).\n");
if (ctl->mda[0])
printf(" Messages will be delivered with '%s.'\n", visbuf(ctl->mda));
else
diff --git a/fetchmail.h b/fetchmail.h
index 36282fff..5fa4053a 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -84,6 +84,7 @@ struct query
int flush;
int norewrite;
int limit;
+ int fetchlimit;
/* unseen, previous state of mailbox (initially from .fetchids) */
struct idlist *oldsaved, *newsaved;
diff --git a/fetchmail.man b/fetchmail.man
index 27ca7ad8..2cec810f 100644
--- a/fetchmail.man
+++ b/fetchmail.man
@@ -66,7 +66,7 @@ Takes a maximum octet size argument. Messages larger than this size
will not be fetched, not be marked seen, and will be left on the
server (in foreground sessions, the progress messages will note that
they are "oversized"). The --all option overrides this one. This
-option is intended for those need to strictly control fetch time
+option is intended for those needing to strictly control fetch time
in interactive mode. It may not be used with daemon mode,
as users would never receive a notification that messages were waiting.
.TP
@@ -201,6 +201,10 @@ shut down to deliver. This may produce annoying delays when
is processing very large batches. Setting the batch limit to some
nonzero size will prevent these delays.
.TP
+.B -R, --fetchlimit
+Limit the number of messages accepted from a given server in a single
+poll. By default there is no limit.
+.TP
.B \-V, --version
Displays the version information for your copy of
.I fetchmail.
@@ -461,6 +465,8 @@ Legal user options are
noflush
nofetchall
norewrite
+ limit
+ fetchlimit
.PP
All options correspond to the obvious command-line arguments except
four: `aka', `is', `to', `password', and `envelope'.
diff --git a/options.c b/options.c
index 88af3799..bbf0236c 100644
--- a/options.c
+++ b/options.c
@@ -41,10 +41,11 @@
#define LA_REMOTEFILE 23
#define LA_SMTPHOST 24
#define LA_BATCHLIMIT 25
-#define LA_MDA 26
-#define LA_YYDEBUG 27
+#define LA_FETCHLIMIT 26
+#define LA_MDA 27
+#define LA_YYDEBUG 28
-static char *shortoptions = "?Vcsvd:NqL:f:i:p:P:A:t:u:akKFnl:r:S:b:m:y";
+static char *shortoptions = "?Vcsvd:NqL:f:i:p:P:A:t:u:akKFnl:r:S:b:B:m:y";
static struct option longoptions[] = {
{"help", no_argument, (int *) 0, LA_HELP },
{"version", no_argument, (int *) 0, LA_VERSION },
@@ -77,6 +78,7 @@ static struct option longoptions[] = {
{"remote", required_argument, (int *) 0, LA_REMOTEFILE },
{"smtphost", required_argument, (int *) 0, LA_SMTPHOST },
{"batchlimit",required_argument, (int *) 0, LA_BATCHLIMIT },
+ {"fetchlimit",required_argument, (int *) 0, LA_FETCHLIMIT },
{"mda", required_argument, (int *) 0, LA_MDA },
{"yydebug", no_argument, (int *) 0, LA_YYDEBUG },
@@ -235,6 +237,10 @@ struct query *ctl; /* option record to be initialized */
case LA_BATCHLIMIT:
cmd_batchlimit = atoi(optarg);
break;
+ case 'B':
+ case LA_FETCHLIMIT:
+ ctl->fetchlimit = atoi(optarg);
+ break;
case 'm':
case LA_MDA:
strncpy(ctl->mda,optarg,sizeof(ctl->mda));
@@ -290,6 +296,7 @@ struct query *ctl; /* option record to be initialized */
fputs(" -S, --smtphost set SMTP forwarding host\n", stderr);
fputs(" -b, --batchlimit set batch limit for SMTP connections\n", stderr);
+ fputs(" -B, --fetchlimit set fetch limit for server connections\n", stderr);
fputs(" -r, --remote specify remote folder name\n", stderr);
return(-1);
}
diff --git a/rcfile_l.l b/rcfile_l.l
index 27b7d5d1..24c027e8 100644
--- a/rcfile_l.l
+++ b/rcfile_l.l
@@ -21,6 +21,7 @@ int prc_lineno = 1;
set { return SET; }
batchlimit { return BATCHLIMIT; }
+fetchlimit { return FETCHLIMIT; }
logfile { return LOGFILE; }
defaults { return DEFAULTS; }
server { return POLL; }
diff --git a/rcfile_y.y b/rcfile_y.y
index b9a97435..3c0f0484 100644
--- a/rcfile_y.y
+++ b/rcfile_y.y
@@ -44,7 +44,7 @@ static void prc_reset();
%token DEFAULTS POLL SKIP AKA PROTOCOL AUTHENTICATE TIMEOUT KPOP KERBEROS
%token ENVELOPE USERNAME PASSWORD FOLDER SMTPHOST MDA LIMIT
%token IS HERE THERE TO MAP WILDCARD
-%token SET BATCHLIMIT LOGFILE
+%token SET BATCHLIMIT FETCHLIMIT LOGFILE
%token <proto> PROTO
%token <sval> STRING
%token <number> NUMBER
@@ -171,6 +171,7 @@ user_option : TO localnames HERE
| FETCHALL {current.fetchall = ($1==FLAG_TRUE);}
| REWRITE {current.norewrite = ($1==FLAG_TRUE);}
| LIMIT NUMBER {current.limit = $2;}
+ | FETCHLIMIT NUMBER {current.fetchlimit = $2;}
;
%%
@@ -329,6 +330,7 @@ static void prc_register(void)
FLAG_FORCE(authenticate);
FLAG_FORCE(timeout);
FLAG_FORCE(limit);
+ FLAG_FORCE(fetchlimit);
#undef FLAG_FORCE
(void) hostalloc(&current);
@@ -358,6 +360,7 @@ void optmerge(struct query *h2, struct query *h1)
FLAG_MERGE(authenticate);
FLAG_MERGE(timeout);
FLAG_MERGE(limit);
+ FLAG_MERGE(fetchlimit);
#undef FLAG_MERGE
}
diff --git a/sample.rcfile b/sample.rcfile
index a56632fa..8ee24e5f 100644
--- a/sample.rcfile
+++ b/sample.rcfile
@@ -42,6 +42,8 @@
# noflush
# nofetchall
# norewrite
+# limit -- must be followed by numeric size limit
+# fetchlimit -- must be followed by numeric msg fetch limit
#
# Legal protocol identifiers are
# pop2 (or POP2)