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