]> Pileus Git - ~andy/fetchmail/commitdiff
Added `fetchlimit'.
authorEric S. Raymond <esr@thyrsus.com>
Wed, 18 Dec 1996 05:06:19 +0000 (05:06 -0000)
committerEric S. Raymond <esr@thyrsus.com>
Wed, 18 Dec 1996 05:06:19 +0000 (05:06 -0000)
svn path=/trunk/; revision=657

NEWS
driver.c
fetchmail.c
fetchmail.h
fetchmail.man
options.c
rcfile_l.l
rcfile_y.y
sample.rcfile

diff --git a/NEWS b/NEWS
index d56f62b113a41f3f40594f0fa83fb18215288113..95b16e62ca1348b3ad8f1685be1284cdf2039dbc 100644 (file)
--- 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
index 1cebf770c61fae4b5322b8fb03f438c8e6c928fe..5cfbddd15c97057c551e9c9644aa864d37518444 100644 (file)
--- 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 */
index d8f42e51955ce057239f9b57c1154cfd9fba1588..65c84933412fd053546a331eb11eb101a679b89c 100644 (file)
@@ -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
index 36282fffde36dbb35ac1e7fb81597fe1346f228b..5fa4053af6adc8b0b8f03caab3ac06551962660b 100644 (file)
@@ -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;
index 27ca7ad8e830dbc2eb2c518b787575abfb0fe1fc..2cec810f25ff39b2ce594f4a691f75e0b8281a21 100644 (file)
@@ -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'.
index 88af3799c7f9a944585bbcb1d32ab29ca292a8e9..bbf0236caa57c9f4032a70d4cdcfb776b3319a59 100644 (file)
--- a/options.c
+++ b/options.c
 #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);
     }
index 27b7d5d11447e6c36008ed449e0171759d2250a0..24c027e825ee01d86a4576c3ce6d18002f4dc2b9 100644 (file)
@@ -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; }
index b9a9743568dd026a29c4615e701504842bc9e91c..3c0f0484562c0d9914ee0731cec86cfc05ca0f78 100644 (file)
@@ -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
 }
 
index a56632fa15deb22ace9e8eba058ca3e656bbb639..8ee24e5f66bb0cada3b6b4e972691ae16732e56b 100644 (file)
@@ -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)