25 |
#include "headers.h" |
#include "headers.h" |
26 |
#include <getopt.h> |
#include <getopt.h> |
27 |
#include "extern.h" |
#include "extern.h" |
28 |
|
#include "rcfile.h" |
29 |
|
|
30 |
#ifdef HAVE_PAM |
#ifdef HAVE_PAM |
31 |
pam_handle_t *pamh; |
pam_handle_t *pamh; |
36 |
#endif /* HAVE_PAM */ |
#endif /* HAVE_PAM */ |
37 |
|
|
38 |
static int gindex = 0; |
static int gindex = 0; |
39 |
|
|
40 |
|
#define OPT_VERSION 257 |
41 |
|
#define OPT_HELP 258 |
42 |
|
#define OPT_ALTRC 259 |
43 |
|
#define OPT_NORC 260 |
44 |
|
|
45 |
static struct option gopt[] = |
static struct option gopt[] = |
46 |
{ |
{ |
47 |
{"bind", 1, 0, 'b'}, |
{"bind", required_argument, 0, 'b'}, |
48 |
{"remote-mta", 1, 0, 'r'}, |
{"remote-mta", required_argument, 0, 'r'}, |
49 |
{"local-mta", 1, 0, 'l'}, |
{"local-mta", required_argument, 0, 'l'}, |
50 |
{"foreground", 0, 0, 'f'}, |
{"foreground", no_argument, 0, 'f'}, |
51 |
{"stdio", 0, 0, 'i'}, |
{"stdio", no_argument, 0, 'i'}, |
52 |
{"silent", 0, 0, 's'}, |
{"silent", no_argument, 0, 's'}, |
53 |
{"verbose", 0, 0, 'v'}, |
{"verbose", no_argument, 0, 'v'}, |
54 |
{"debug", 0, 0, 'D'}, |
{"debug", no_argument, 0, 'D'}, |
55 |
{"version", 0, 0, 0}, |
{"version", no_argument, 0, OPT_VERSION}, |
56 |
{"help", 0, 0, 0}, |
{"help", no_argument, 0, OPT_HELP}, |
57 |
{"altrc", 1, 0, 0}, |
{"altrc", required_argument, 0, OPT_ALTRC}, |
58 |
{"norc", 0, 0, 0}, |
{"norc", no_argument, 0, OPT_NORC}, |
59 |
|
{"check-config",optional_argument, 0, 'c'}, |
60 |
{0, 0, 0, 0} |
{0, 0, 0, 0} |
61 |
}; |
}; |
62 |
|
|
66 |
int c; |
int c; |
67 |
|
|
68 |
while ((c = getopt_long(argc, argv, "b:r:l:fisvD?", |
while ((c = getopt_long(argc, argv, "b:r:l:fisvD?", |
69 |
gopt, &gindex)) != EOF) |
gopt, &gindex)) != EOF) |
70 |
{ |
{ |
71 |
switch (c) |
switch (c) |
72 |
{ |
{ |
73 |
case 0: |
case OPT_HELP: |
74 |
if (strcmp(gopt[gindex].name, "help") == 0) |
print_usage(); |
75 |
print_usage(); |
break; |
76 |
if (strcmp(gopt[gindex].name, "version") == 0) |
|
77 |
print_version(); |
case OPT_VERSION: |
78 |
if (strcmp(gopt[gindex].name, "norc") == 0) |
print_version(); |
79 |
topt |= T_NORC; |
break; |
80 |
if (strcmp(gopt[gindex].name, "altrc") == 0) { |
|
81 |
options.altrc = optarg; |
case OPT_NORC: |
82 |
topt |= T_ALTRC; |
topt |= T_NORC; |
|
} |
|
83 |
break; |
break; |
84 |
|
|
85 |
|
case OPT_ALTRC: |
86 |
|
options.altrc = optarg; |
87 |
|
topt |= T_ALTRC; |
88 |
|
break; |
89 |
|
|
90 |
|
case 'c': |
91 |
|
rc_set_debug_level(optarg); |
92 |
|
topt |= T_CHECK_CONFIG; |
93 |
|
break; |
94 |
|
|
95 |
case 'b': /* daemon's port number, host name */ |
case 'b': /* daemon's port number, host name */ |
96 |
parse_mtahost(optarg, session.tunnel, |
parse_mtahost(optarg, session.tunnel, |
97 |
&session.tunnel_port); |
&session.tunnel_port); |
98 |
if (strlen(session.tunnel) != 0) |
if (strlen(session.tunnel) != 0) |
99 |
topt |= T_NAMES; |
topt |= T_NAMES; |
100 |
break; |
break; |
101 |
|
|
102 |
case 'r': /* a remote SMTP host name or IP address */ |
case 'r': /* a remote SMTP host name or IP address */ |
103 |
parse_mtaport(optarg, session.mta, &session.mta_port); |
parse_mtaport(optarg, session.mta, &session.mta_port); |
104 |
break; |
break; |