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