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