version 1.43, 1998/11/21 02:58:37 |
version 1.44, 1999/12/08 12:57:06 |
|
|
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ |
/* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ |
|
|
/* |
/* |
|
* Copyright (C) 1997 and 1998 WIDE Project. |
|
* All rights reserved. |
|
* |
|
* Redistribution and use in source and binary forms, with or without |
|
* modification, are permitted provided that the following conditions |
|
* are met: |
|
* 1. Redistributions of source code must retain the above copyright |
|
* notice, this list of conditions and the following disclaimer. |
|
* 2. Redistributions in binary form must reproduce the above copyright |
|
* notice, this list of conditions and the following disclaimer in the |
|
* documentation and/or other materials provided with the distribution. |
|
* 3. Neither the name of the project nor the names of its contributors |
|
* may be used to endorse or promote products derived from this software |
|
* without specific prior written permission. |
|
* |
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND |
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE |
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
* SUCH DAMAGE. |
|
*/ |
|
|
|
/* |
* Copyright (c) 1985, 1989, 1993, 1994 |
* Copyright (c) 1985, 1989, 1993, 1994 |
* The Regents of the University of California. All rights reserved. |
* The Regents of the University of California. All rights reserved. |
* |
* |
|
|
int argc; |
int argc; |
char *argv[]; |
char *argv[]; |
{ |
{ |
struct servent *sp; |
|
int ch, top, rval; |
int ch, top, rval; |
long port; |
|
struct passwd *pw = NULL; |
struct passwd *pw = NULL; |
char *cp, *ep, homedir[MAXPATHLEN]; |
char *cp, homedir[MAXPATHLEN]; |
char *outfile = NULL; |
char *outfile = NULL; |
int dumb_terminal = 0; |
int dumb_terminal = 0; |
|
|
sp = getservbyname("ftp", "tcp"); |
ftpport = "ftp"; |
if (sp == 0) |
httpport = "http"; |
ftpport = htons(FTP_PORT); /* good fallback */ |
gateport = getenv("FTPSERVERPORT"); |
else |
if (gateport == NULL) |
ftpport = sp->s_port; |
gateport = "ftpgate"; |
sp = getservbyname("http", "tcp"); |
|
if (sp == 0) |
|
httpport = htons(HTTP_PORT); /* good fallback */ |
|
else |
|
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; |
|
|
break; |
break; |
|
|
case 'P': |
case 'P': |
port = strtol(optarg, &ep, 10); |
ftpport = optarg; |
if (port < 1 || port > USHRT_MAX || *ep != '\0') |
|
warnx("bad port number: %s (ignored)", optarg); |
|
else |
|
ftpport = htons((in_port_t)port); |
|
break; |
break; |
|
|
case 'r': |
case 'r': |
|
|
#endif |
#endif |
|
|
if (argc > 0) { |
if (argc > 0) { |
if (strchr(argv[0], ':') != NULL) { |
if (isurl(argv[0])) { |
anonftp = 1; /* Handle "automatic" transfers. */ |
anonftp = 1; /* Handle "automatic" transfers. */ |
rval = auto_fetch(argc, argv, outfile); |
rval = auto_fetch(argc, argv, outfile); |
if (rval >= 0) /* -1 == connected and cd-ed */ |
if (rval >= 0) /* -1 == connected and cd-ed */ |