]> Pileus Git - ~andy/fetchmail/blob - options.c
715902967c6e9b113e8d6ce5ca43272875d3356d
[~andy/fetchmail] / options.c
1 /*
2  * options.c -- command-line option processing
3  *
4  * Copyright 1998 by Eric S. Raymond.
5  * For license terms, see the file COPYING in this directory.
6  */
7
8 #include "config.h"
9
10 #include <stdio.h>
11 #include <pwd.h>
12 #include <string.h>
13 #include <errno.h>
14 #if defined(STDC_HEADERS)
15 #include  <stdlib.h>
16 #include  <limits.h>
17 #else
18 #include  <ctype.h>
19 #endif
20
21 #include "getopt.h"
22 #include "fetchmail.h"
23 #include "i18n.h"
24
25 enum {
26     LA_INVISIBLE = 256,
27     LA_PIDFILE,
28     LA_SYSLOG,
29     LA_NOSYSLOG,
30     LA_POSTMASTER,
31     LA_NOBOUNCE,
32     LA_AUTH,
33     LA_FETCHDOMAINS,
34     LA_BSMTP,
35     LA_LMTP,
36     LA_PLUGIN,
37     LA_PLUGOUT,
38     LA_CONFIGDUMP,
39     LA_SMTPNAME,
40     LA_SHOWDOTS,
41     LA_PRINCIPAL,
42     LA_TRACEPOLLS,
43     LA_SSL,
44     LA_SSLKEY,
45     LA_SSLCERT,
46     LA_SSLPROTO,
47     LA_SSLCERTCK,
48     LA_SSLCERTPATH,
49     LA_SSLCOMMONNAME,
50     LA_SSLFINGERPRINT,
51     LA_FETCHSIZELIMIT,
52     LA_FASTUIDL,
53     LA_LIMITFLUSH,
54     LA_IDLE,
55     LA_NOSOFTBOUNCE,
56     LA_SOFTBOUNCE,
57     LA_BADHEADER
58 };
59
60 /* options still left: CgGhHjJoORTWxXYz */
61 static const char *shortoptions = 
62         "?Vcsvd:NqL:f:i:p:UP:A:t:E:Q:u:akKFnl:r:S:Z:b:B:e:m:I:M:yw:D:";
63
64 static const struct option longoptions[] = {
65 /* this can be const because all flag fields are 0 and will never get set */
66   {"help",      no_argument,       (int *) 0, '?' },
67   {"version",   no_argument,       (int *) 0, 'V' },
68   {"check",     no_argument,       (int *) 0, 'c' },
69   {"silent",    no_argument,       (int *) 0, 's' },
70   {"verbose",   no_argument,       (int *) 0, 'v' },
71   {"daemon",    required_argument, (int *) 0, 'd' },
72   {"nodetach",  no_argument,       (int *) 0, 'N' },
73   {"quit",      no_argument,       (int *) 0, 'q' },
74   {"logfile",   required_argument, (int *) 0, 'L' },
75   {"invisible", no_argument,       (int *) 0, LA_INVISIBLE },
76   {"showdots",  no_argument,       (int *) 0, LA_SHOWDOTS },
77   {"syslog",    no_argument,       (int *) 0, LA_SYSLOG },
78   {"nosyslog",  no_argument,       (int *) 0, LA_NOSYSLOG },
79   {"fetchmailrc",required_argument,(int *) 0, 'f' },
80   {"idfile",    required_argument, (int *) 0, 'i' },
81   {"pidfile",   required_argument, (int *) 0, LA_PIDFILE },
82   {"postmaster",required_argument, (int *) 0, LA_POSTMASTER },
83   {"nobounce",  no_argument,       (int *) 0, LA_NOBOUNCE },
84   {"nosoftbounce", no_argument,    (int *) 0, LA_NOSOFTBOUNCE },
85   {"softbounce", no_argument,      (int *) 0, LA_SOFTBOUNCE },
86
87   {"protocol",  required_argument, (int *) 0, 'p' },
88   {"proto",     required_argument, (int *) 0, 'p' },
89   {"uidl",      no_argument,       (int *) 0, 'U' },
90   {"idle",      no_argument,       (int *) 0, LA_IDLE},
91   {"port",      required_argument, (int *) 0, 'P' },
92   {"service",   required_argument, (int *) 0, 'P' },
93   {"auth",      required_argument, (int *) 0, LA_AUTH},
94   {"timeout",   required_argument, (int *) 0, 't' },
95   {"envelope",  required_argument, (int *) 0, 'E' },
96   {"qvirtual",  required_argument, (int *) 0, 'Q' },
97   {"bad-header",required_argument, (int *) 0, LA_BADHEADER},
98
99   {"user",      required_argument, (int *) 0, 'u' },
100   {"username",  required_argument, (int *) 0, 'u' },
101
102   {"all",       no_argument,       (int *) 0, 'a' },
103   {"fetchall",  no_argument,       (int *) 0, 'a' },
104   {"nokeep",    no_argument,       (int *) 0, 'K' },
105   {"keep",      no_argument,       (int *) 0, 'k' },
106   {"flush",     no_argument,       (int *) 0, 'F' },
107   {"limitflush",        no_argument, (int *) 0, LA_LIMITFLUSH },
108   {"norewrite", no_argument,       (int *) 0, 'n' },
109   {"limit",     required_argument, (int *) 0, 'l' },
110   {"warnings",  required_argument, (int *) 0, 'w' },
111
112   {"folder",    required_argument, (int *) 0, 'r' },
113   {"smtphost",  required_argument, (int *) 0, 'S' },
114   {"fetchdomains",      required_argument, (int *) 0, LA_FETCHDOMAINS },
115   {"smtpaddress", required_argument, (int *) 0, 'D' },
116   {"smtpname",  required_argument, (int *) 0, LA_SMTPNAME },
117   {"antispam",  required_argument, (int *) 0, 'Z' },
118
119   {"batchlimit",required_argument, (int *) 0, 'b' },
120   {"fetchlimit",required_argument, (int *) 0, 'B' },
121   {"fetchsizelimit",required_argument, (int *) 0, LA_FETCHSIZELIMIT },
122   {"fastuidl",  required_argument, (int *) 0, LA_FASTUIDL },
123   {"expunge",   required_argument, (int *) 0, 'e' },
124   {"mda",       required_argument, (int *) 0, 'm' },
125   {"bsmtp",     required_argument, (int *) 0, LA_BSMTP },
126   {"lmtp",      no_argument,       (int *) 0, LA_LMTP },
127
128 #ifdef SSL_ENABLE
129   {"ssl",       no_argument,       (int *) 0, LA_SSL },
130   {"sslkey",    required_argument, (int *) 0, LA_SSLKEY },
131   {"sslcert",   required_argument, (int *) 0, LA_SSLCERT },
132   {"sslproto",   required_argument, (int *) 0, LA_SSLPROTO },
133   {"sslcertck", no_argument,       (int *) 0, LA_SSLCERTCK },
134   {"sslcertpath",   required_argument, (int *) 0, LA_SSLCERTPATH },
135   {"sslcommonname",    required_argument, (int *) 0, LA_SSLCOMMONNAME },
136   {"sslfingerprint",   required_argument, (int *) 0, LA_SSLFINGERPRINT },
137 #endif
138
139   {"principal", required_argument, (int *) 0, LA_PRINCIPAL },
140
141 #ifdef CAN_MONITOR
142   {"interface", required_argument, (int *) 0, 'I' },
143   {"monitor",   required_argument, (int *) 0, 'M' },
144 #endif /* CAN_MONITOR */
145   {"plugin",    required_argument, (int *) 0, LA_PLUGIN },
146   {"plugout",   required_argument, (int *) 0, LA_PLUGOUT },
147
148   {"configdump",no_argument,       (int *) 0, LA_CONFIGDUMP },
149
150   {"yydebug",   no_argument,       (int *) 0, 'y' },
151
152   {"tracepolls",no_argument,       (int *) 0, LA_TRACEPOLLS },
153
154   {(char *) 0,  no_argument,       (int *) 0, 0 }
155 };
156
157 static int xatoi(char *s, int *errflagptr)
158 /* do safe conversion from string to number */
159 {
160 #if defined (STDC_HEADERS) && defined (LONG_MAX) && defined (INT_MAX)
161     /* parse and convert numbers, but also check for invalid characters in
162      * numbers
163      */
164
165     char *endptr;
166     long value;
167
168     errno = 0;
169
170     value = strtol(s, &endptr, 0);
171
172     /* any invalid chars in string? */
173     if ( (endptr == s) || (*endptr != '\0') ) {
174         (void) fprintf(stderr, GT_("String '%s' is not a valid number string.\n"), s);
175         (*errflagptr)++;
176         return 0;
177     }
178
179     /* is the range valid? */
180     if ( (((value == LONG_MAX) || (value == LONG_MIN)) && (errno == ERANGE)) ||
181                                 (value > INT_MAX) || (value < INT_MIN)) {
182
183         (void) fprintf(stderr, GT_("Value of string '%s' is %s than %d.\n"), s,
184                                         (value < 0) ? GT_("smaller"): GT_("larger"),
185                                         (value < 0) ? INT_MIN : INT_MAX);
186         (*errflagptr)++;
187         return 0;
188     }
189
190     return (int) value;  /* shut up, I know what I'm doing */
191 #else
192     int i;
193     char *dp;
194 # if defined (STDC_HEADERS)
195     size_t      len;
196 # else
197     int         len;
198 # endif
199
200     /* We do only base 10 conversions here (atoi)! */
201
202     len = strlen(s);
203     /* check for leading white spaces */
204     for (i = 0; (i < len) && isspace((unsigned char)s[i]); i++)
205         ;
206
207     dp = &s[i];
208
209     /* check for +/- */
210     if (i < len && (s[i] == '+' || s[i] == '-'))        i++;
211
212     /* skip over digits */
213     for ( /* no init */ ; (i < len) && isdigit((unsigned char)s[i]); i++)
214         ;
215
216     /* check for trailing garbage */
217     if (i != len) {
218         (void) fprintf(stderr, GT_("String '%s' is not a valid number string.\n"), s);
219         (*errflagptr)++;
220         return 0;
221     }
222
223     /* atoi should be safe by now, except for number range over/underflow */
224     return atoi(dp);
225 #endif
226 }
227
228 /** parse and validate the command line options */
229 int parsecmdline (int argc /** argument count */,
230                   char **argv /** argument strings */,
231                   struct runctl *rctl /** global run controls to modify */,
232                   struct query *ctl /** option record to initialize */)
233 {
234     /*
235      * return value: if positive, argv index of last parsed option + 1
236      * (presumes one or more server names follows).  if zero, the
237      * command line switches are such that no server names are
238      * required (e.g. --version).  if negative, the command line is
239      * has one or more syntax errors.
240      */
241
242     int c;
243     int ocount = 0;     /* count of destinations specified */
244     int errflag = 0;    /* TRUE when a syntax error is detected */
245     int helpflag = 0;   /* TRUE when option help was explicitly requested */
246     int option_index;
247     char *buf, *cp;
248
249     rctl->poll_interval = -1;
250
251     memset(ctl, '\0', sizeof(struct query));    /* start clean */
252     ctl->smtp_socket = -1;
253
254     while (!errflag && 
255            (c = getopt_long(argc,argv,shortoptions,
256                             longoptions, &option_index)) != -1)
257     {
258         switch (c) {
259         case 'V':
260             versioninfo = TRUE;
261             break;
262         case 'c':
263             check_only = TRUE;
264             break;
265         case 's':
266             outlevel = O_SILENT;
267             break;
268         case 'v':
269             if (outlevel >= O_VERBOSE)
270                 outlevel = O_DEBUG;
271             else
272                 outlevel = O_VERBOSE;
273             break;
274         case 'd':
275             rctl->poll_interval = xatoi(optarg, &errflag);
276             break;
277         case 'N':
278             nodetach = TRUE;
279             break;
280         case 'q':
281             quitmode = TRUE;
282             quitind = optind;
283             break;
284         case 'L':
285             rctl->logfile = prependdir (optarg, currentwd);
286             break;
287         case LA_INVISIBLE:
288             rctl->invisible = FLAG_TRUE;
289             break;
290         case LA_SHOWDOTS:
291             rctl->showdots = FLAG_TRUE;
292             break;
293         case 'f':
294             xfree(rcfile);
295             rcfile = prependdir (optarg, currentwd);
296             break;
297         case 'i':
298             rctl->idfile = prependdir (optarg, currentwd);
299             break;
300         case LA_PIDFILE:
301             rctl->pidfile = prependdir (optarg, currentwd);
302             break;
303         case LA_POSTMASTER:
304             rctl->postmaster = (char *) xstrdup(optarg);
305             break;
306         case LA_NOBOUNCE:
307             rctl->bouncemail = FLAG_FALSE;
308             break;
309         case LA_NOSOFTBOUNCE:
310             rctl->softbounce = FLAG_FALSE;
311             break;
312         case LA_SOFTBOUNCE:
313             rctl->softbounce = FLAG_TRUE;
314             break;
315         case LA_BADHEADER:
316             if (strcasecmp(optarg,"accept") == 0) {
317                 ctl->server.badheader = BHACCEPT;
318             } else if (strcasecmp(optarg,"reject") == 0) {
319                 ctl->server.badheader = BHREJECT;
320             } else {
321                 fprintf(stderr,GT_("Invalid bad-header policy `%s' specified.\n"), optarg);
322                 errflag++;
323             }
324             break;
325
326         case 'p':
327             /* XXX -- should probably use a table lookup here */
328             if (strcasecmp(optarg,"auto") == 0)
329                 ctl->server.protocol = P_AUTO;
330             else if (strcasecmp(optarg,"pop2") == 0)
331                 ctl->server.protocol = P_POP2;
332 #ifdef SDPS_ENABLE
333             else if (strcasecmp(optarg,"sdps") == 0)
334             {
335                 ctl->server.protocol = P_POP3; 
336                 ctl->server.sdps = TRUE;
337             }
338 #endif /* SDPS_ENABLE */
339             else if (strcasecmp(optarg,"pop3") == 0)
340                 ctl->server.protocol = P_POP3;
341             else if (strcasecmp(optarg,"apop") == 0)
342                 ctl->server.protocol = P_APOP;
343             else if (strcasecmp(optarg,"rpop") == 0)
344                 ctl->server.protocol = P_RPOP;
345             else if (strcasecmp(optarg,"kpop") == 0)
346             {
347                 ctl->server.protocol = P_POP3;
348                 ctl->server.service = KPOP_PORT;
349 #ifdef KERBEROS_V5
350                 ctl->server.authenticate =  A_KERBEROS_V5;
351 #else
352                 ctl->server.authenticate =  A_KERBEROS_V4;
353 #endif /* KERBEROS_V5 */
354             }
355             else if (strcasecmp(optarg,"imap") == 0)
356                 ctl->server.protocol = P_IMAP;
357             else if (strcasecmp(optarg,"etrn") == 0)
358                 ctl->server.protocol = P_ETRN;
359             else if (strcasecmp(optarg,"odmr") == 0)
360                 ctl->server.protocol = P_ODMR;
361             else {
362                 fprintf(stderr,GT_("Invalid protocol `%s' specified.\n"), optarg);
363                 errflag++;
364             }
365             break;
366         case 'U':
367             ctl->server.uidl = FLAG_TRUE;
368             break;
369         case LA_IDLE:
370             ctl->idle = FLAG_TRUE;
371             break;
372         case 'P':
373             ctl->server.service = optarg;
374             break;
375         case LA_AUTH:
376             if (strcmp(optarg, "password") == 0)
377                 ctl->server.authenticate = A_PASSWORD;
378             else if (strcmp(optarg, "kerberos") == 0)
379 #ifdef KERBEROS_V5
380                 ctl->server.authenticate = A_KERBEROS_V5;
381 #else
382                 ctl->server.authenticate = A_KERBEROS_V4;
383 #endif /* KERBEROS_V5 */
384             else if (strcmp(optarg, "kerberos_v5") == 0)
385                 ctl->server.authenticate = A_KERBEROS_V5;
386             else if (strcmp(optarg, "kerberos_v4") == 0)
387                 ctl->server.authenticate = A_KERBEROS_V4;
388             else if (strcmp(optarg, "ssh") == 0)
389                 ctl->server.authenticate = A_SSH;
390             else if (strcasecmp(optarg, "external") == 0)
391                 ctl->server.authenticate = A_EXTERNAL;
392             else if (strcmp(optarg, "otp") == 0)
393                 ctl->server.authenticate = A_OTP;
394             else if (strcmp(optarg, "opie") == 0)
395                 ctl->server.authenticate = A_OTP;
396             else if (strcmp(optarg, "ntlm") == 0)
397                 ctl->server.authenticate = A_NTLM;
398             else if (strcmp(optarg, "cram") == 0)
399                 ctl->server.authenticate = A_CRAM_MD5;
400             else if (strcmp(optarg, "cram-md5") == 0)
401                 ctl->server.authenticate = A_CRAM_MD5;
402             else if (strcmp(optarg, "gssapi") == 0)
403                 ctl->server.authenticate = A_GSSAPI;
404             else if (strcmp(optarg, "any") == 0)
405                 ctl->server.authenticate = A_ANY;
406             else if (strcmp(optarg, "msn") == 0)
407                 ctl->server.authenticate = A_MSN;
408             else {
409                 fprintf(stderr,GT_("Invalid authentication `%s' specified.\n"), optarg);
410                 errflag++;
411             }
412             break;
413         case 't':
414             ctl->server.timeout = xatoi(optarg, &errflag);
415             if (ctl->server.timeout == 0)
416                 ctl->server.timeout = -1;
417             break;
418         case 'E':
419             ctl->server.envelope = xstrdup(optarg);
420             break;
421         case 'Q':    
422             ctl->server.qvirtual = xstrdup(optarg);
423             break;
424
425         case 'u':
426             ctl->remotename = xstrdup(optarg);
427             break;
428         case 'a':
429             ctl->fetchall = FLAG_TRUE;
430             break;
431         case 'K':
432             ctl->keep = FLAG_FALSE;
433             break;
434         case 'k':
435             ctl->keep = FLAG_TRUE;
436             break;
437         case 'F':
438             ctl->flush = FLAG_TRUE;
439             break;
440         case LA_LIMITFLUSH:
441             ctl->limitflush = FLAG_TRUE;
442             break;
443         case 'n':
444             ctl->rewrite = FLAG_FALSE;
445             break;
446         case 'l':
447             c = xatoi(optarg, &errflag);
448             ctl->limit = NUM_VALUE_IN(c);
449             break;
450         case 'r':
451             buf = xstrdup(optarg);
452             cp = strtok(buf, ",");
453             do {
454                 save_str(&ctl->mailboxes, cp, 0);
455             } while
456                 ((cp = strtok((char *)NULL, ",")));
457             free(buf);
458             break;
459         case 'S':
460             buf = xstrdup(optarg);
461             cp = strtok(buf, ",");
462             do {
463                 save_str(&ctl->smtphunt, cp, TRUE);
464             } while
465                 ((cp = strtok((char *)NULL, ",")));
466             free(buf);
467             ocount++;
468             break;
469         case LA_FETCHDOMAINS:
470             buf = xstrdup(optarg);
471             cp = strtok(buf, ",");
472             do {
473                 save_str(&ctl->domainlist, cp, TRUE);
474             } while
475                 ((cp = strtok((char *)NULL, ",")));
476             free(buf);
477             break;
478         case 'D':
479             ctl->smtpaddress = xstrdup(optarg);
480             break;
481         case LA_SMTPNAME:
482           ctl->smtpname = xstrdup(optarg);
483           break;
484         case 'Z':
485             buf = xstrdup(optarg);
486             cp = strtok(buf, ",");
487             do {
488                 struct idlist   *idp = save_str(&ctl->antispam, NULL, 0);;
489
490                 idp->val.status.num = xatoi(cp, &errflag);
491             } while
492                 ((cp = strtok((char *)NULL, ",")));
493             free(buf);
494             break;
495         case 'b':
496             c = xatoi(optarg, &errflag);
497             ctl->batchlimit = NUM_VALUE_IN(c);
498             break;
499         case 'B':
500             c = xatoi(optarg, &errflag);
501             ctl->fetchlimit = NUM_VALUE_IN(c);
502             break;
503         case LA_FETCHSIZELIMIT:
504             c = xatoi(optarg, &errflag);
505             ctl->fetchsizelimit = NUM_VALUE_IN(c);
506             break;
507         case LA_FASTUIDL:
508             c = xatoi(optarg, &errflag);
509             ctl->fastuidl = NUM_VALUE_IN(c);
510             break;
511         case 'e':
512             c = xatoi(optarg, &errflag);
513             ctl->expunge = NUM_VALUE_IN(c);
514             break;
515         case 'm':
516             ctl->mda = xstrdup(optarg);
517             ocount++;
518             break;
519         case LA_BSMTP:
520             ctl->bsmtp = prependdir (optarg, currentwd);
521             ocount++;
522             break;
523         case LA_LMTP:
524             ctl->listener = LMTP_MODE;
525             break;
526
527 #ifdef CAN_MONITOR
528         case 'I':
529             interface_parse(optarg, &ctl->server);
530             break;
531         case 'M':
532             ctl->server.monitor = xstrdup(optarg);
533             break;
534 #endif /* CAN_MONITOR */
535         case LA_PLUGIN:
536             ctl->server.plugin = xstrdup(optarg);
537             break;
538         case LA_PLUGOUT:
539             ctl->server.plugout = xstrdup(optarg);
540             break;
541
542 #ifdef SSL_ENABLE
543         case LA_SSL:
544             ctl->use_ssl = FLAG_TRUE;
545             break;
546
547         case LA_SSLKEY:
548             ctl->sslkey = prependdir (optarg, currentwd);
549             break;
550
551         case LA_SSLCERT:
552             ctl->sslcert = prependdir (optarg, currentwd);
553             break;
554
555         case LA_SSLPROTO:
556             ctl->sslproto = xstrdup(optarg);
557             break;
558
559         case LA_SSLCERTCK:
560             ctl->sslcertck = FLAG_TRUE;
561             break;
562
563         case LA_SSLCERTPATH:
564             ctl->sslcertpath = prependdir(optarg, currentwd);
565             break;
566
567         case LA_SSLCOMMONNAME:
568             ctl->sslcommonname = xstrdup(optarg);
569             break;
570
571         case LA_SSLFINGERPRINT:
572             ctl->sslfingerprint = xstrdup(optarg);
573             break;
574 #endif
575
576         case LA_PRINCIPAL:
577             ctl->server.principal = xstrdup(optarg);
578             break;
579
580         case 'y':
581             yydebug = TRUE;
582             break;
583
584         case 'w':
585             c = xatoi(optarg, &errflag);
586             ctl->warnings = NUM_VALUE_IN(c);
587             break;
588
589         case LA_CONFIGDUMP:
590             configdump = TRUE;
591             break;
592
593         case LA_SYSLOG:
594             rctl->use_syslog = FLAG_TRUE;
595             break;
596
597         case LA_NOSYSLOG:
598             rctl->use_syslog = FLAG_FALSE;
599             break;
600
601         case LA_TRACEPOLLS:
602             ctl->server.tracepolls = FLAG_TRUE;
603             break;
604
605         case '?':
606         default:
607             helpflag++;
608         }
609     }
610
611     if (errflag || ocount > 1 || helpflag) {
612         /* squawk if syntax errors were detected */
613 #define P(s)    fputs(s, helpflag ? stdout : stderr)
614         P(GT_("usage:  fetchmail [options] [server ...]\n"));
615         P(GT_("  Options are as follows:\n"));
616         P(GT_("  -?, --help        display this option help\n"));
617         P(GT_("  -V, --version     display version info\n"));
618
619         P(GT_("  -c, --check       check for messages without fetching\n"));
620         P(GT_("  -s, --silent      work silently\n"));
621         P(GT_("  -v, --verbose     work noisily (diagnostic output)\n"));
622         P(GT_("  -d, --daemon      run as a daemon once per n seconds\n"));
623         P(GT_("  -N, --nodetach    don't detach daemon process\n"));
624         P(GT_("  -q, --quit        kill daemon process\n"));
625         P(GT_("  -L, --logfile     specify logfile name\n"));
626         P(GT_("      --syslog      use syslog(3) for most messages when running as a daemon\n"));
627         P(GT_("      --invisible   don't write Received & enable host spoofing\n"));
628         P(GT_("  -f, --fetchmailrc specify alternate run control file\n"));
629         P(GT_("  -i, --idfile      specify alternate UIDs file\n"));
630         P(GT_("      --pidfile     specify alternate PID (lock) file\n"));
631         P(GT_("      --postmaster  specify recipient of last resort\n"));
632         P(GT_("      --nobounce    redirect bounces from user to postmaster.\n"));
633         P(GT_("      --nosoftbounce fetchmail deletes permanently undeliverable messages.\n"));
634         P(GT_("      --softbounce  keep permanently undeliverable messages on server (default).\n"));
635 #ifdef CAN_MONITOR
636         P(GT_("  -I, --interface   interface required specification\n"));
637         P(GT_("  -M, --monitor     monitor interface for activity\n"));
638 #endif
639 #if defined( SSL_ENABLE )
640         P(GT_("      --ssl         enable ssl encrypted session\n"));
641         P(GT_("      --sslkey      ssl private key file\n"));
642         P(GT_("      --sslcert     ssl client certificate\n"));
643         P(GT_("      --sslcertck   do strict server certificate check (recommended)\n"));
644         P(GT_("      --sslcertpath path to ssl certificates\n"));
645         P(GT_("      --sslcommonname  expect this CommonName from server (discouraged)\n"));
646         P(GT_("      --sslfingerprint fingerprint that must match that of the server's cert.\n"));
647         P(GT_("      --sslproto    force ssl protocol (SSL2/SSL3/TLS1)\n"));
648 #endif
649         P(GT_("      --plugin      specify external command to open connection\n"));
650         P(GT_("      --plugout     specify external command to open smtp connection\n"));
651         P(GT_("      --bad-header {reject|accept}\n"
652               "                    specify policy for handling messages with bad headers\n"));
653
654         P(GT_("  -p, --protocol    specify retrieval protocol (see man page)\n"));
655         P(GT_("  -U, --uidl        force the use of UIDLs (pop3 only)\n"));
656         P(GT_("      --port        TCP port to connect to (obsolete, use --service)\n"));
657         P(GT_("  -P, --service     TCP service to connect to (can be numeric TCP port)\n"));
658         P(GT_("      --auth        authentication type (password/kerberos/ssh/otp)\n"));
659         P(GT_("  -t, --timeout     server nonresponse timeout\n"));
660         P(GT_("  -E, --envelope    envelope address header\n"));
661         P(GT_("  -Q, --qvirtual    prefix to remove from local user id\n"));
662         P(GT_("      --principal   mail service principal\n"));
663         P(GT_("      --tracepolls  add poll-tracing information to Received header\n"));
664
665         P(GT_("  -u, --username    specify users's login on server\n"));
666         P(GT_("  -a, --[fetch]all  retrieve old and new messages\n"));
667         P(GT_("  -K, --nokeep      delete new messages after retrieval\n"));
668         P(GT_("  -k, --keep        save new messages after retrieval\n"));
669         P(GT_("  -F, --flush       delete old messages from server\n"));
670         P(GT_("      --limitflush  delete oversized messages\n"));
671         P(GT_("  -n, --norewrite   don't rewrite header addresses\n"));
672         P(GT_("  -l, --limit       don't fetch messages over given size\n"));
673         P(GT_("  -w, --warnings    interval between warning mail notification\n"));
674
675         P(GT_("  -S, --smtphost    set SMTP forwarding host\n"));
676         P(GT_("      --fetchdomains fetch mail for specified domains\n"));
677         P(GT_("  -D, --smtpaddress set SMTP delivery domain to use\n"));
678         P(GT_("      --smtpname    set SMTP full name username@domain\n"));
679         P(GT_("  -Z, --antispam,   set antispam response values\n"));
680         P(GT_("  -b, --batchlimit  set batch limit for SMTP connections\n"));
681         P(GT_("  -B, --fetchlimit  set fetch limit for server connections\n"));
682         P(GT_("      --fetchsizelimit set fetch message size limit\n"));
683         P(GT_("      --fastuidl    do a binary search for UIDLs\n"));
684         P(GT_("  -e, --expunge     set max deletions between expunges\n"));
685         P(GT_("  -m, --mda         set MDA to use for forwarding\n"));
686         P(GT_("      --bsmtp       set output BSMTP file\n"));
687         P(GT_("      --lmtp        use LMTP (RFC2033) for delivery\n"));
688         P(GT_("  -r, --folder      specify remote folder name\n"));
689         P(GT_("      --showdots    show progress dots even in logfiles\n"));
690 #undef P
691         /* undocumented:
692          * --configdump (internal use by fetchmailconf, dumps
693          *               configuration as Python source code)
694          * --yydebug    (developer use, enables parser debugging) */
695
696         if (helpflag)
697             exit(PS_SUCCESS);
698         else
699             exit(PS_SYNTAX);
700     }
701
702     return(optind);
703 }
704
705 /* options.c ends here */