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