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