version 1.35, 1997/08/06 17:35:42 |
version 1.36, 1997/09/04 04:37:16 |
|
|
/* $OpenBSD$ */ |
/* $OpenBSD$ */ |
/* $NetBSD: main.c,v 1.23 1997/07/20 09:45:58 lukem Exp $ */ |
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ |
|
|
/* |
/* |
* Copyright (c) 1985, 1989, 1993, 1994 |
* Copyright (c) 1985, 1989, 1993, 1994 |
|
|
int ch, top, rval; |
int ch, top, rval; |
long port; |
long port; |
struct passwd *pw = NULL; |
struct passwd *pw = NULL; |
char *cp, homedir[MAXPATHLEN]; |
char *cp, *ep, homedir[MAXPATHLEN]; |
int dumb_terminal = 0; |
int dumb_terminal = 0; |
int outfd = -1; |
int outfd = -1; |
|
|
|
|
httpport = htons(HTTP_PORT); /* good fallback */ |
httpport = htons(HTTP_PORT); /* good fallback */ |
else |
else |
httpport = sp->s_port; |
httpport = sp->s_port; |
|
gateport = 0; |
|
cp = getenv("FTPSERVERPORT"); |
|
if (cp != NULL) { |
|
port = strtol(cp, &ep, 10); |
|
if (port < 1 || port > USHRT_MAX || *ep != '\0') |
|
warnx("bad FTPSERVERPORT port number: %s (ignored)", |
|
cp); |
|
else |
|
gateport = htons(port); |
|
} |
|
if (gateport == 0) { |
|
sp = getservbyname("ftpgate", "tcp"); |
|
if (sp == 0) |
|
gateport = htons(GATE_PORT); |
|
else |
|
gateport = sp->s_port; |
|
} |
doglob = 1; |
doglob = 1; |
interactive = 1; |
interactive = 1; |
autologin = 1; |
autologin = 1; |
|
|
preserve = 1; |
preserve = 1; |
verbose = 0; |
verbose = 0; |
progress = 0; |
progress = 0; |
|
gatemode = 0; |
#ifndef SMALL |
#ifndef SMALL |
editing = 0; |
editing = 0; |
el = NULL; |
el = NULL; |
|
|
cp = (cp == NULL) ? argv[0] : cp + 1; |
cp = (cp == NULL) ? argv[0] : cp + 1; |
if (strcmp(cp, "pftp") == 0) |
if (strcmp(cp, "pftp") == 0) |
passivemode = 1; |
passivemode = 1; |
|
else if (strcmp(cp, "gate-ftp") == 0) |
|
gatemode = 1; |
|
|
|
gateserver = getenv("FTPSERVER"); |
|
if (gateserver == NULL || *gateserver == '\0') |
|
gateserver = GATE_SERVER; |
|
if (gatemode) { |
|
if (*gateserver == '\0') { |
|
warnx( |
|
"Neither $FTPSERVER nor GATE_SERVER is defined; disabling gate-ftp"); |
|
gatemode = 0; |
|
} |
|
} |
|
|
cp = getenv("TERM"); |
cp = getenv("TERM"); |
dumb_terminal = (cp == NULL || !strcmp(cp, "dumb") || |
dumb_terminal = (cp == NULL || !strcmp(cp, "dumb") || |
!strcmp(cp, "emacs") || !strcmp(cp, "su")); |
!strcmp(cp, "emacs") || !strcmp(cp, "su")); |
|
|
break; |
break; |
|
|
case 'P': |
case 'P': |
port = strtol(optarg, &cp, 10); |
port = strtol(optarg, &ep, 10); |
if (port < 1 || port > 0xffff || *cp != '\0') |
if (port < 1 || port > USHRT_MAX || *ep != '\0') |
warnx("bad port number: %s (ignored)", optarg); |
warnx("bad port number: %s (ignored)", optarg); |
else |
else |
ftpport = htons((in_port_t)port); |
ftpport = htons((in_port_t)port); |