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