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