From 3e3526c334e11f87d348a6a6047c46395b9832c7 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 11 Oct 1996 12:40:47 +0000 Subject: Improved options processing. svn path=/trunk/; revision=296 --- options.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/options.c b/options.c index e5d60996..c2a4445b 100644 --- a/options.c +++ b/options.c @@ -13,8 +13,8 @@ #include #include - #include + #include "getopt.h" #include "fetchmail.h" @@ -99,14 +99,10 @@ int argc; char **argv; struct hostrec *queryctl; { - int c,i; - int fflag = 0; /* TRUE when -o or -c has been specified */ + int c; + int ocount = 0; /* count of destinations specified */ int errflag = 0; /* TRUE when a syntax error is detected */ int option_index; - int got_kill = 0; /* TRUE when --kill is specified */ - - extern int optind, opterr; /* defined in getopt(2) */ - extern char *optarg; /* defined in getopt(2) */ memset(queryctl, '\0', sizeof(struct hostrec)); /* start clean */ @@ -126,12 +122,10 @@ struct hostrec *queryctl; case 'K': case LA_KILL: queryctl->keep = 0; - got_kill = 1; break; case 'k': case LA_KEEP: queryctl->keep = !0; - got_kill = 0; break; case 'v': case LA_VERBOSE: @@ -192,6 +186,7 @@ struct hostrec *queryctl; case 'm': case LA_MDA: strncpy(queryctl->mda,optarg,sizeof(queryctl->mda)); + ocount++; break; case 'P': case LA_PORT: @@ -210,12 +205,8 @@ struct hostrec *queryctl; break; case 'S': case LA_SMTPHOST: - if (fflag) - errflag++; - else { - fflag++; - strncpy(queryctl->smtphost,optarg,sizeof(queryctl->smtphost)-1); - } + strncpy(queryctl->smtphost,optarg,sizeof(queryctl->smtphost)-1); + ocount++; break; case 'L': case LA_LOGFILE: @@ -243,7 +234,7 @@ struct hostrec *queryctl; } } - if (errflag) { + if (errflag || ocount > 1) { /* squawk if syntax errors were detected */ fputs("usage: fetchmail [options] [server ...]\n", stderr); fputs(" Options are as follows:\n",stderr); -- cgit v1.2.3