aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--driver.c4
-rw-r--r--fetchmail.c25
-rw-r--r--fetchmail.h8
-rw-r--r--options.c10
-rw-r--r--rcfile_y.y38
6 files changed, 49 insertions, 39 deletions
diff --git a/NEWS b/NEWS
index 4b30e3c5..198317b0 100644
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ features --
* Support for ESMTP ETRN extension.
+* It is now possible to turn off option flags in individual server entries
+ that had been turned on in a `defaults' entry.
+
bugs --
* The bug that displayed incorrect sizes for POP3 connections has been fixed.
diff --git a/driver.c b/driver.c
index adf5a989..6ef30419 100644
--- a/driver.c
+++ b/driver.c
@@ -115,7 +115,7 @@ static int is_host_alias(const char *name, struct query *ctl)
return(TRUE);
else if (strcmp(name, ctl->server.canonical_name) == 0)
return(TRUE);
- else if (ctl->server.no_dns)
+ else if (!ctl->server.dns)
return(FALSE);
/*
@@ -469,7 +469,7 @@ char *realname; /* real name of host */
break;
}
- if (!ctl->no_rewrite)
+ if (ctl->rewrite)
reply_hack(line, realname);
if (!headers)
diff --git a/fetchmail.c b/fetchmail.c
index 76df73d0..1caf1d98 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -630,9 +630,20 @@ static int load_params(int argc, char **argv, int optind)
ctl->server.lead_server = &(ctl->server);
no_new_server:;
- /* if stripcr hasn't been set, default it asccording to MDA */
- if (ctl->stripcr == -1)
- ctl->stripcr = (ctl->mda != (char *)NULL);
+ /* this code enables flags to be turned off */
+#define DEFAULT(flag, dflt) if (flag == FLAG_TRUE)\
+ flag = TRUE;\
+ else if (flag == FLAG_FALSE)\
+ flag = FALSE;\
+ else\
+ flag = (dflt)
+ DEFAULT(ctl->keep, FALSE);
+ DEFAULT(ctl->flush, FALSE);
+ DEFAULT(ctl->fetchall, FALSE);
+ DEFAULT(ctl->rewrite, TRUE);
+ DEFAULT(ctl->stripcr, (ctl->mda != (char *)NULL));
+ DEFAULT(ctl->server.dns, TRUE);
+#undef DEFAULT
/* plug in the semi-standard way of indicating a mail address */
if (ctl->server.envelope == (char *)NULL)
@@ -831,8 +842,8 @@ void dump_params (struct query *ctl)
ctl->flush ? "" : " not",
ctl->flush ? "on" : "off");
printf(" Rewrite of server-local addresses is %sabled (--norewrite %s).\n",
- ctl->no_rewrite ? "dis" : "en",
- ctl->no_rewrite ? "on" : "off");
+ ctl->rewrite ? "en" : "dis",
+ ctl->rewrite ? "off" : "on");
printf(" Carriage-return stripping is %sabled (--stripcr %s).\n",
ctl->stripcr ? "en" : "dis",
ctl->stripcr ? "on" : "off");
@@ -883,8 +894,8 @@ void dump_params (struct query *ctl)
}
printf(" DNS lookup for multidrop addresses is %sabled.\n",
- ctl->server.no_dns ? "dis" : "en",
- ctl->server.no_dns ? "on" : "off");
+ ctl->server.dns ? "en" : "dis",
+ ctl->server.dns ? "off" : "on");
if (count > 1)
printf(" Envelope header is assumed to be: %s\n", ctl->server.envelope);
diff --git a/fetchmail.h b/fetchmail.h
index c43bfee2..baba9198 100644
--- a/fetchmail.h
+++ b/fetchmail.h
@@ -47,6 +47,10 @@
#define SIZETICKER 1024 /* print 1 dot per this many bytes */
+/* we need to use zero as a flag-uninitialized value */
+#define FLAG_TRUE 2
+#define FLAG_FALSE 1
+
struct idlist
{
char *id;
@@ -70,7 +74,7 @@ struct hostdata /* shared among all user connections to given server */
int timeout;
char *envelope;
int skip;
- int no_dns;
+ int dns;
#ifdef linux
char *interface;
@@ -106,7 +110,7 @@ struct query
int keep;
int fetchall;
int flush;
- int no_rewrite;
+ int rewrite;
int stripcr;
int limit;
int fetchlimit;
diff --git a/options.c b/options.c
index 54644237..a723a7cd 100644
--- a/options.c
+++ b/options.c
@@ -219,23 +219,23 @@ struct query *ctl; /* option record to be initialized */
break;
case 'a':
case LA_ALL:
- ctl->fetchall = TRUE;
+ ctl->fetchall = FLAG_TRUE;
break;
case 'K':
case LA_KILL:
- ctl->keep = FALSE;
+ ctl->keep = FLAG_FALSE;
break;
case 'k':
case LA_KEEP:
- ctl->keep = TRUE;
+ ctl->keep = FLAG_TRUE;
break;
case 'F':
case LA_FLUSH:
- ctl->flush = TRUE;
+ ctl->flush = FLAG_TRUE;
break;
case 'n':
case LA_NOREWRITE:
- ctl->no_rewrite = TRUE;
+ ctl->rewrite = FLAG_TRUE;
break;
case 'l':
case LA_LIMIT:
diff --git a/rcfile_y.y b/rcfile_y.y
index 583261fc..3a22895b 100644
--- a/rcfile_y.y
+++ b/rcfile_y.y
@@ -51,10 +51,6 @@ static void user_reset();
%token <number> NUMBER
%token <flag> KEEP FLUSH FETCHALL REWRITE STRIPCR DNS PORT
-/* these are actually used by the lexer */
-%token FLAG_TRUE 2
-%token FLAG_FALSE 1
-
%%
rcfile : /* empty */
@@ -79,15 +75,12 @@ statement : SET LOGFILE MAP STRING {logfile = xstrdup($4);}
;
define_server : POLL STRING {memset(&current,'\0',sizeof(current));
- current.stripcr = -1;
save_str(&current.server.names, -1,$2);
current.server.skip = FALSE;}
| SKIP STRING {memset(&current,'\0',sizeof(current));
- current.stripcr = -1;
save_str(&current.server.names, -1,$2);
current.server.skip = TRUE;}
| DEFAULTS {memset(&current,'\0',sizeof(current));
- current.stripcr = -1;
save_str(&current.server.names, -1,"defaults");}
;
@@ -130,7 +123,7 @@ serv_option : AKA alias_list
fprintf(stderr, "fetchmail: monitor option is only supported under Linux\n");
#endif /* linux */
}
- | DNS {current.server.no_dns = ($1==FLAG_FALSE);}
+ | DNS {current.server.dns = $1;}
;
/*
@@ -184,18 +177,18 @@ user_option : TO localnames HERE
| IS localnames
| IS STRING THERE {current.remotename = xstrdup($2);}
- | PASSWORD STRING {current.password = xstrdup($2);}
- | FOLDER STRING {current.mailbox = xstrdup($2);}
- | SMTPHOST STRING {current.smtphost = xstrdup($2);}
- | MDA STRING {current.mda = xstrdup($2);}
+ | PASSWORD STRING {current.password = xstrdup($2);}
+ | FOLDER STRING {current.mailbox = xstrdup($2);}
+ | SMTPHOST STRING {current.smtphost = xstrdup($2);}
+ | MDA STRING {current.mda = xstrdup($2);}
| PRECONNECT STRING {current.preconnect = xstrdup($2);}
- | KEEP {current.keep = ($1==FLAG_TRUE);}
- | FLUSH {current.flush = ($1==FLAG_TRUE);}
- | FETCHALL {current.fetchall = ($1==FLAG_TRUE);}
- | REWRITE {current.no_rewrite =($1==FLAG_FALSE);}
- | STRIPCR {current.stripcr = ($1==FLAG_TRUE);}
- | LIMIT NUMBER {current.limit = $2;}
+ | KEEP {current.keep = $1;}
+ | FLUSH {current.flush = $1;}
+ | FETCHALL {current.fetchall = $1;}
+ | REWRITE {current.rewrite = $1;}
+ | STRIPCR {current.stripcr = $1;}
+ | LIMIT NUMBER {current.limit = $2;}
| FETCHLIMIT NUMBER {current.fetchlimit = $2;}
| BATCHLIMIT NUMBER {current.batchlimit = $2;}
;
@@ -299,7 +292,6 @@ static void user_reset(void)
save = current.server;
memset(&current, '\0', sizeof(current));
- current.stripcr = -1;
current.server = save;
}
@@ -335,7 +327,7 @@ static void record_current(void)
FLAG_FORCE(server.timeout);
FLAG_FORCE(server.envelope);
FLAG_FORCE(server.skip);
- FLAG_FORCE(server.no_dns);
+ FLAG_FORCE(server.dns);
#ifdef linux
FLAG_FORCE(server.interface);
@@ -353,7 +345,7 @@ static void record_current(void)
FLAG_FORCE(keep);
FLAG_FORCE(flush);
FLAG_FORCE(fetchall);
- FLAG_FORCE(no_rewrite);
+ FLAG_FORCE(rewrite);
FLAG_FORCE(stripcr);
FLAG_FORCE(limit);
FLAG_FORCE(fetchlimit);
@@ -377,7 +369,7 @@ void optmerge(struct query *h2, struct query *h1)
FLAG_MERGE(server.timeout);
FLAG_MERGE(server.envelope);
FLAG_MERGE(server.skip);
- FLAG_MERGE(server.no_dns);
+ FLAG_MERGE(server.dns);
#ifdef linux
FLAG_MERGE(server.interface);
@@ -395,7 +387,7 @@ void optmerge(struct query *h2, struct query *h1)
FLAG_MERGE(keep);
FLAG_MERGE(flush);
FLAG_MERGE(fetchall);
- FLAG_MERGE(no_rewrite);
+ FLAG_MERGE(rewrite);
FLAG_MERGE(stripcr);
FLAG_MERGE(limit);
FLAG_MERGE(fetchlimit);