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