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