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