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