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