aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1998-06-03 14:54:31 +0000
committerEric S. Raymond <esr@thyrsus.com>1998-06-03 14:54:31 +0000
commita74d1e1c9c1826b358eb1b812349262282918094 (patch)
treec292a8192c92516dc77710092f14c61b1c9e26db
parent53f7500e1c6ebb110b93096d448ba7f75dd4995e (diff)
downloadfetchmail-a74d1e1c9c1826b358eb1b812349262282918094.tar.gz
fetchmail-a74d1e1c9c1826b358eb1b812349262282918094.tar.bz2
fetchmail-a74d1e1c9c1826b358eb1b812349262282918094.zip
Fix argument-merging.
svn path=/trunk/; revision=1879
-rw-r--r--NEWS1
-rw-r--r--design-notes.html10
-rw-r--r--fetchmail.c74
-rw-r--r--fetchmail.h1
-rw-r--r--rcfile_y.y111
5 files changed, 78 insertions, 119 deletions
diff --git a/NEWS b/NEWS
index 0035b9ef..971f0a26 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ fetchmail-4.4.9 ():
* CompuServe RPA and idfile fixes from Rich Beerman <rbeerman@pobox.com>.
* Hajimu UMEMOTO <ume@calm.imasy.or.jp> patched the address-rewrite logic to
deal with addresses of the form "John Smith (foo) <jsmith@bar.com>" better.
+* Command-line argument merging has been fixed.
There are 278 people on fetchmail-friends and 216 on fetchmail-announce.
diff --git a/design-notes.html b/design-notes.html
index cb5d5e05..5e8721d7 100644
--- a/design-notes.html
+++ b/design-notes.html
@@ -10,7 +10,7 @@
<table width="100%" cellpadding=0><tr>
<td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
<td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 1998/05/14 01:35:46 $
+<td width="30%" align=right>$Date: 1998/06/03 14:54:27 $
</table>
<HR>
<H1 ALIGN=CENTER>Design Notes On Fetchmail</H1>
@@ -313,8 +313,7 @@ following minimum steps.
the token to <code>rcfile_l</code>.
<LI>Go to <code>rcfile_y.y</code>. Add the token to the grammar. Don't
- forget the <code>%token</code> declaration. Add proper
- <code>FLAG_FORCE</code> and <code>FLAG_MERGE</code> actions.
+ forget the <code>%token</code> declaration.
<LI>Pick a long-form option name, and a one-letter short option if any
are left. Go to <code>options.c</code>. Pick a new <code>LA_<code>
@@ -327,6 +326,9 @@ following minimum steps.
<LI>Add code to dump the option value in <code>fetchmail.c:dump_params</code>.
+<LI>Add proper <code>FLAG_FORCE</code> and <code>FLAG_MERGE</code> actions
+ in fetchmail.c's optmerge function.
+
<LI>Document the option in fetchmail.man. This will require at least
two changes; one to the collected table of options, and one full
text description of the option.
@@ -475,7 +477,7 @@ all shaped the design in one way or another.<P>
<table width="100%" cellpadding=0><tr>
<td width="30%">Back to <a href="index.html">Fetchmail Home Page</a>
<td width="30%" align=center>To <a href="/~esr/sitemap.html">Site Map</a>
-<td width="30%" align=right>$Date: 1998/05/14 01:35:46 $
+<td width="30%" align=right>$Date: 1998/06/03 14:54:27 $
</table>
<P><ADDRESS>Eric S. Raymond <A HREF="mailto:esr@thyrsus.com">&lt;esr@snark.thyrsus.com&gt;</A></ADDRESS>
diff --git a/fetchmail.c b/fetchmail.c
index 47a3a63d..79563ab6 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -692,6 +692,71 @@ int main (int argc, char **argv)
exit(successes ? PS_SUCCESS : querystatus);
}
+static void optmerge(struct query *h2, struct query *h1, int force)
+/* merge two options records */
+{
+ /*
+ * If force is off, modify h2 fields only when they're empty (treat h1
+ * as defaults). If force is on, modify each h2 field whenever h1
+ * is nonempty (treat h1 as an override).
+ */
+
+ if (!force)
+ {
+ append_str_list(&h2->server.localdomains, &h1->server.localdomains);
+ append_str_list(&h2->localnames, &h1->localnames);
+ append_str_list(&h2->mailboxes, &h1->mailboxes);
+ append_str_list(&h2->smtphunt, &h1->smtphunt);
+ }
+
+#define FLAG_MERGE(fld) if (force ? !!h1->fld : !h2->fld) h2->fld = h1->fld
+ FLAG_MERGE(server.via);
+ FLAG_MERGE(server.protocol);
+#if INET6
+ FLAG_MERGE(server.service);
+ FLAG_MERGE(server.netsec);
+#else /* INET6 */
+ FLAG_MERGE(server.port);
+#endif /* INET6 */
+ FLAG_MERGE(server.interval);
+ FLAG_MERGE(server.preauthenticate);
+ FLAG_MERGE(server.timeout);
+ FLAG_MERGE(server.envelope);
+ FLAG_MERGE(server.envskip);
+ FLAG_MERGE(server.qvirtual);
+ FLAG_MERGE(server.skip);
+ FLAG_MERGE(server.dns);
+ FLAG_MERGE(server.uidl);
+
+#ifdef linux
+ FLAG_MERGE(server.interface);
+ FLAG_MERGE(server.monitor);
+ FLAG_MERGE(server.interface_pair);
+#endif /* linux */
+
+ FLAG_MERGE(remotename);
+ FLAG_MERGE(password);
+ FLAG_MERGE(mda);
+ FLAG_MERGE(smtpaddress);
+ FLAG_MERGE(antispam);
+ FLAG_MERGE(preconnect);
+
+ FLAG_MERGE(keep);
+ FLAG_MERGE(flush);
+ FLAG_MERGE(fetchall);
+ FLAG_MERGE(rewrite);
+ FLAG_MERGE(forcecr);
+ FLAG_MERGE(stripcr);
+ FLAG_MERGE(pass8bits);
+ FLAG_MERGE(dropstatus);
+ FLAG_MERGE(mimedecode);
+ FLAG_MERGE(limit);
+ FLAG_MERGE(fetchlimit);
+ FLAG_MERGE(batchlimit);
+ FLAG_MERGE(expunge);
+#undef FLAG_MERGE
+}
+
static int load_params(int argc, char **argv, int optind)
{
int implicitmode, st;
@@ -748,7 +813,7 @@ static int load_params(int argc, char **argv, int optind)
if (querylist && strcmp(querylist->server.pollname, "defaults") == 0)
{
for (ctl = querylist->next; ctl; ctl = ctl->next)
- optmerge(ctl, querylist);
+ optmerge(ctl, querylist, FALSE);
querylist = querylist->next;
}
@@ -763,7 +828,10 @@ static int load_params(int argc, char **argv, int optind)
if (configdump || (ctl->active && !(implicitmode && ctl->server.skip)))
{
/* merge in defaults */
- optmerge(ctl, &def_opts);
+ optmerge(ctl, &def_opts, FALSE);
+
+ /* force command-line options */
+ optmerge(ctl, &cmd_opts, TRUE);
/* make sure we have a nonempty host list to forward to */
if (!ctl->smtphunt)
@@ -1152,7 +1220,7 @@ void dump_params (struct runctl *runp, struct query *querylist, flag implicit)
ctl->forcecr ? "en" : "dis",
ctl->forcecr ? "on" : "off");
printf(" Interpretation of Content-Transfer-Encoding is %sabled (pass8bits %s).\n",
- ctl->pass8bits ? "en" : "dis",
+ ctl->pass8bits ? "dis" : "en",
ctl->pass8bits ? "on" : "off");
printf(" MIME decoding is %sabled (mimedecode %s).\n",
ctl->mimedecode ? "en" : "dis",
diff --git a/fetchmail.h b/fetchmail.h
index e4792fb1..e57f4c32 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -370,7 +370,6 @@ int doETRN (struct query *);
/* miscellanea */
struct query *hostalloc(struct query *);
int parsecmdline (int, char **, struct runctl *, struct query *);
-void optmerge(struct query *, struct query *);
char *MD5Digest (unsigned char *);
int POP3_auth_rpa(unsigned char *, unsigned char *, int socket);
int daemonize(const char *, void (*)(int));
diff --git a/rcfile_y.y b/rcfile_y.y
index 69a96db5..5c4f43b7 100644
--- a/rcfile_y.y
+++ b/rcfile_y.y
@@ -467,121 +467,10 @@ struct query *init; /* pointer to block containing initial values */
static void record_current(void)
/* register current parameters and append to the host list */
{
-#define FLAG_FORCE(fld) if (cmd_opts.fld) current.fld = cmd_opts.fld
- FLAG_FORCE(server.localdomains);
- FLAG_FORCE(localnames);
- FLAG_FORCE(mailboxes);
- FLAG_FORCE(smtphunt);
-
- FLAG_FORCE(server.via);
- FLAG_FORCE(server.protocol);
-#if INET6
- FLAG_FORCE(server.service);
- FLAG_FORCE(server.netsec);
-#else /* INET6 */
- FLAG_FORCE(server.port);
-#endif /* INET6 */
- FLAG_FORCE(server.interval);
- FLAG_FORCE(server.preauthenticate);
- FLAG_FORCE(server.timeout);
- FLAG_FORCE(server.envelope);
- FLAG_FORCE(server.envskip);
- FLAG_FORCE(server.qvirtual);
- FLAG_FORCE(server.skip);
- FLAG_FORCE(server.dns);
- FLAG_FORCE(server.uidl);
-
-#ifdef linux
- FLAG_FORCE(server.interface);
- FLAG_FORCE(server.monitor);
- FLAG_FORCE(server.interface_pair);
-#endif /* linux */
-
- FLAG_FORCE(remotename);
- FLAG_FORCE(password);
- FLAG_FORCE(mda);
- FLAG_FORCE(smtpaddress);
- FLAG_FORCE(antispam);
- FLAG_FORCE(preconnect);
- FLAG_FORCE(postconnect);
-
- FLAG_FORCE(keep);
- FLAG_FORCE(flush);
- FLAG_FORCE(fetchall);
- FLAG_FORCE(rewrite);
- FLAG_FORCE(forcecr);
- FLAG_FORCE(stripcr);
- FLAG_FORCE(pass8bits);
- FLAG_FORCE(dropstatus);
- FLAG_FORCE(mimedecode);
- FLAG_FORCE(limit);
- FLAG_FORCE(fetchlimit);
- FLAG_FORCE(batchlimit);
- FLAG_FORCE(expunge);
-
-#undef FLAG_FORCE
-
(void) hostalloc(&current);
-
trailer = TRUE;
}
-void optmerge(struct query *h2, struct query *h1)
-/* merge two options records; empty fields in h2 are filled in from h1 */
-{
- append_str_list(&h2->server.localdomains, &h1->server.localdomains);
- append_str_list(&h2->localnames, &h1->localnames);
- append_str_list(&h2->mailboxes, &h1->mailboxes);
- append_str_list(&h2->smtphunt, &h1->smtphunt);
-
-#define FLAG_MERGE(fld) if (!h2->fld) h2->fld = h1->fld
- FLAG_MERGE(server.via);
- FLAG_MERGE(server.protocol);
-#if INET6
- FLAG_MERGE(server.service);
- FLAG_MERGE(server.netsec);
-#else /* INET6 */
- FLAG_MERGE(server.port);
-#endif /* INET6 */
- FLAG_MERGE(server.interval);
- FLAG_MERGE(server.preauthenticate);
- FLAG_MERGE(server.timeout);
- FLAG_MERGE(server.envelope);
- FLAG_MERGE(server.envskip);
- FLAG_MERGE(server.qvirtual);
- FLAG_MERGE(server.skip);
- FLAG_MERGE(server.dns);
- FLAG_MERGE(server.uidl);
-
-#ifdef linux
- FLAG_MERGE(server.interface);
- FLAG_MERGE(server.monitor);
- FLAG_MERGE(server.interface_pair);
-#endif /* linux */
-
- FLAG_MERGE(remotename);
- FLAG_MERGE(password);
- FLAG_MERGE(mda);
- FLAG_MERGE(smtpaddress);
- FLAG_MERGE(antispam);
- FLAG_MERGE(preconnect);
-
- FLAG_MERGE(keep);
- FLAG_MERGE(flush);
- FLAG_MERGE(fetchall);
- FLAG_MERGE(rewrite);
- FLAG_MERGE(forcecr);
- FLAG_MERGE(stripcr);
- FLAG_MERGE(pass8bits);
- FLAG_MERGE(dropstatus);
- FLAG_MERGE(mimedecode);
- FLAG_MERGE(limit);
- FLAG_MERGE(fetchlimit);
- FLAG_MERGE(batchlimit);
- FLAG_MERGE(expunge);
-#undef FLAG_MERGE
-}
-
/* easier to do this than cope with variations in where the library lives */
int yywrap(void) {return 1;}