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