Import latest CVS lukemftp.

This commit is contained in:
Mike Heffner 2003-11-03 17:12:09 +00:00
parent fa547236e7
commit 0e54ef8be7
13 changed files with 98 additions and 108 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmds.c,v 1.100 2002/11/30 03:10:55 lukem Exp $ */
/* $NetBSD: cmds.c,v 1.102 2003/08/07 11:13:52 agc Exp $ */
/*-
* Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
@ -52,11 +52,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -107,7 +103,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
__RCSID("$NetBSD: cmds.c,v 1.100 2002/11/30 03:10:55 lukem Exp $");
__RCSID("$NetBSD: cmds.c,v 1.102 2003/08/07 11:13:52 agc Exp $");
#endif
#endif /* not lint */
@ -1185,7 +1181,8 @@ delete(int argc, char *argv[])
code = -1;
return;
}
(void)command("DELE %s", argv[1]);
if (command("DELE %s", argv[1]) == COMPLETE)
dirchange = 1;
}
/*
@ -1215,7 +1212,8 @@ mdelete(int argc, char *argv[])
continue;
}
if (mflag && confirm(argv[0], cp)) {
(void)command("DELE %s", cp);
if (command("DELE %s", cp) == COMPLETE)
dirchange = 1;
if (!mflag && fromatty) {
ointer = interactive;
interactive = 1;
@ -1245,8 +1243,9 @@ renamefile(int argc, char *argv[])
code = -1;
return;
}
if (command("RNFR %s", argv[1]) == CONTINUE)
(void)command("RNTO %s", argv[2]);
if (command("RNFR %s", argv[1]) == CONTINUE &&
command("RNTO %s", argv[2]) == COMPLETE)
dirchange = 1;
}
/*
@ -1553,6 +1552,7 @@ lpwd(int argc, char *argv[])
void
makedir(int argc, char *argv[])
{
int r;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "directory-name"))) {
@ -1560,12 +1560,15 @@ makedir(int argc, char *argv[])
code = -1;
return;
}
if (command("MKD %s", argv[1]) == ERROR && code == 500) {
r = command("MKD %s", argv[1]);
if (r == ERROR && code == 500) {
if (verbose)
fputs("MKD command not recognized, trying XMKD.\n",
ttyout);
(void)command("XMKD %s", argv[1]);
r = command("XMKD %s", argv[1]);
}
if (r == COMPLETE)
dirchange = 1;
}
/*
@ -1574,6 +1577,7 @@ makedir(int argc, char *argv[])
void
removedir(int argc, char *argv[])
{
int r;
if (argc == 0 || argc > 2 ||
(argc == 1 && !another(&argc, &argv, "directory-name"))) {
@ -1581,12 +1585,15 @@ removedir(int argc, char *argv[])
code = -1;
return;
}
if (command("RMD %s", argv[1]) == ERROR && code == 500) {
r = command("RMD %s", argv[1]);
if (r == ERROR && code == 500) {
if (verbose)
fputs("RMD command not recognized, trying XRMD.\n",
ttyout);
(void)command("XRMD %s", argv[1]);
r = command("XRMD %s", argv[1]);
}
if (r == COMPLETE)
dirchange = 1;
}
/*
@ -1643,6 +1650,7 @@ quote1(const char *initial, int argc, char *argv[])
while (getreply(0) == PRELIM)
continue;
}
dirchange = 1;
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmdtab.c,v 1.40 2002/07/29 04:24:47 lukem Exp $ */
/* $NetBSD: cmdtab.c,v 1.41 2003/08/07 11:13:53 agc Exp $ */
/*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@ -48,11 +48,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -74,7 +70,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
__RCSID("$NetBSD: cmdtab.c,v 1.40 2002/07/29 04:24:47 lukem Exp $");
__RCSID("$NetBSD: cmdtab.c,v 1.41 2003/08/07 11:13:53 agc Exp $");
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: domacro.c,v 1.19 2002/02/01 05:04:43 itojun Exp $ */
/* $NetBSD: domacro.c,v 1.20 2003/08/07 11:13:53 agc Exp $ */
/*
* Copyright (c) 1985, 1993, 1994
@ -12,11 +12,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -38,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)domacro.c 8.3 (Berkeley) 4/2/94";
#else
__RCSID("$NetBSD: domacro.c,v 1.19 2002/02/01 05:04:43 itojun Exp $");
__RCSID("$NetBSD: domacro.c,v 1.20 2003/08/07 11:13:53 agc Exp $");
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.61 2003/01/21 16:08:07 jhawk Exp $ */
/* $NetBSD: extern.h,v 1.62 2003/08/07 11:13:54 agc Exp $ */
/*-
* Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
@ -48,11 +48,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: fetch.c,v 1.141 2003/05/14 14:31:00 wiz Exp $ */
/* $NetBSD: fetch.c,v 1.144 2003/07/31 05:23:59 lukem Exp $ */
/*-
* Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fetch.c,v 1.141 2003/05/14 14:31:00 wiz Exp $");
__RCSID("$NetBSD: fetch.c,v 1.144 2003/07/31 05:23:59 lukem Exp $");
#endif /* not lint */
/*
@ -438,7 +438,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
char *cp, *ep, *buf, *savefile;
char *auth, *location, *message;
char *user, *pass, *host, *port, *path, *decodedpath;
char *puser, *ppass;
char *puser, *ppass, *useragent;
off_t hashbytes, rangestart, rangeend, entitylen;
int (*closefunc)(FILE *);
FILE *fin, *fout;
@ -666,9 +666,8 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
*/
ai_unmapped(res);
if (getnameinfo(res->ai_addr, res->ai_addrlen,
hbuf, sizeof(hbuf), NULL, 0,
NI_NUMERICHOST) != 0)
strncpy(hbuf, "invalid", sizeof(hbuf));
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST) != 0)
strlcpy(hbuf, "invalid", sizeof(hbuf));
if (verbose && res != res0)
fprintf(ttyout, "Trying %s...\n", hbuf);
@ -752,7 +751,12 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
if (flushcache)
fprintf(fin, "Cache-Control: no-cache\r\n");
}
fprintf(fin, "User-Agent: %s/%s\r\n", FTP_PRODUCT, FTP_VERSION);
if ((useragent=getenv("FTPUSERAGENT")) != NULL) {
fprintf(fin, "User-Agent: %s\r\n", useragent);
} else {
fprintf(fin, "User-Agent: %s/%s\r\n",
FTP_PRODUCT, FTP_VERSION);
}
if (wwwauth) {
if (verbose) {
fprintf(ttyout, "%swith authorization",
@ -1620,18 +1624,19 @@ go_fetch(const char *url)
*/
if (strncasecmp(url, ABOUT_URL, sizeof(ABOUT_URL) - 1) == 0) {
url += sizeof(ABOUT_URL) -1;
if (strcasecmp(url, "ftp") == 0) {
if (strcasecmp(url, "ftp") == 0 ||
strcasecmp(url, "tnftp") == 0) {
fputs(
"This version of ftp has been enhanced by Luke Mewburn <lukem@netbsd.org>\n"
"This version of ftp has been enhanced by Luke Mewburn <lukem@NetBSD.org>\n"
"for the NetBSD project. Execute `man ftp' for more details.\n", ttyout);
} else if (strcasecmp(url, "lukem") == 0) {
fputs(
"Luke Mewburn is the author of most of the enhancements in this ftp client.\n"
"Please email feedback to <lukem@netbsd.org>.\n", ttyout);
"Please email feedback to <lukem@NetBSD.org>.\n", ttyout);
} else if (strcasecmp(url, "netbsd") == 0) {
fputs(
"NetBSD is a freely available and redistributable UNIX-like operating system.\n"
"For more information, see http://www.netbsd.org/index.html\n", ttyout);
"For more information, see http://www.NetBSD.org/\n", ttyout);
} else if (strcasecmp(url, "version") == 0) {
fprintf(ttyout, "Version: %s %s%s\n",
FTP_PRODUCT, FTP_VERSION,

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ftp.1,v 1.96 2003/06/26 17:48:37 wiz Exp $
.\" $NetBSD: ftp.1,v 1.100 2003/08/07 11:13:54 agc Exp $
.\"
.\" Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -46,11 +46,7 @@
.\" 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. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" 3. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
@ -68,7 +64,7 @@
.\"
.\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
.\"
.Dd January 20, 2003
.Dd July 31, 2003
.Dt FTP 1
.Os
.Sh NAME
@ -2092,10 +2088,7 @@ The current remote working directory.
.It Xo
.Sm off
.Li \&%c
.Op Oo Li 0 Oc Ar n
.Sm on
.No ,
.Sm off
.Op Oo Li 0 Oc Ar n Ns ,
.Li \&%.
.Op Oo Li 0 Oc Ar n
.Sm on
@ -2189,6 +2182,11 @@ Default is port returned by a
.Fn getservbyname
lookup of
.Dq ftpgate/tcp .
.It Ev FTPUSERAGENT
The value to send for the
.Tn HTTP
User-Agent
header.
.It Ev HOME
For default location of a
.Pa .netrc

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftp.c,v 1.120 2002/06/05 10:20:49 lukem Exp $ */
/* $NetBSD: ftp.c,v 1.122 2003/08/07 11:13:55 agc Exp $ */
/*-
* Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
@ -48,11 +48,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -103,7 +99,7 @@
#if 0
static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94";
#else
__RCSID("$NetBSD: ftp.c,v 1.120 2002/06/05 10:20:49 lukem Exp $");
__RCSID("$NetBSD: ftp.c,v 1.122 2003/08/07 11:13:55 agc Exp $");
#endif
#endif /* not lint */
@ -745,6 +741,7 @@ sendrequest(const char *cmd, const char *local, const char *remote,
if (command("%s", cmd) != PRELIM)
goto cleanupsend;
}
dirchange = 1;
dout = dataconn(lmode);
if (dout == NULL)
goto abort;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ftp_var.h,v 1.64 2003/01/21 16:08:07 jhawk Exp $ */
/* $NetBSD: ftp_var.h,v 1.65 2003/08/07 11:13:56 agc Exp $ */
/*-
* Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
@ -48,11 +48,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.84 2003/05/14 14:31:00 wiz Exp $ */
/* $NetBSD: main.c,v 1.86 2003/08/07 11:13:56 agc Exp $ */
/*-
* Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
@ -48,11 +48,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -108,7 +104,7 @@ __COPYRIGHT("@(#) Copyright (c) 1985, 1989, 1993, 1994\n\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 10/9/94";
#else
__RCSID("$NetBSD: main.c,v 1.84 2003/05/14 14:31:00 wiz Exp $");
__RCSID("$NetBSD: main.c,v 1.86 2003/08/07 11:13:56 agc Exp $");
#endif
#endif /* not lint */
@ -467,7 +463,7 @@ main(int argc, char *argv[])
* string "username@", and will append the hostname itself. We
* do this by default since many servers are picky about not
* having a FQDN in the anonymous password.
* - thorpej@netbsd.org
* - thorpej@NetBSD.org
*/
len = strlen(anonuser) + 2;
anonpass = xmalloc(len);

View File

@ -1,4 +1,4 @@
/* $NetBSD: progressbar.c,v 1.3 2003/02/28 09:53:49 lukem Exp $ */
/* $NetBSD: progressbar.c,v 1.4 2003/07/17 12:06:18 lukem Exp $ */
/*-
* Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
@ -7,10 +7,6 @@
* This code is derived from software contributed to The NetBSD Foundation
* by Luke Mewburn.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -42,7 +38,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: progressbar.c,v 1.3 2003/02/28 09:53:49 lukem Exp $");
__RCSID("$NetBSD: progressbar.c,v 1.4 2003/07/17 12:06:18 lukem Exp $");
#endif /* not lint */
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: ruserpass.c,v 1.28 2000/11/15 00:11:04 lukem Exp $ */
/* $NetBSD: ruserpass.c,v 1.29 2003/08/07 11:13:57 agc Exp $ */
/*
* Copyright (c) 1985, 1993, 1994
@ -12,11 +12,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -38,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
#else
__RCSID("$NetBSD: ruserpass.c,v 1.28 2000/11/15 00:11:04 lukem Exp $");
__RCSID("$NetBSD: ruserpass.c,v 1.29 2003/08/07 11:13:57 agc Exp $");
#endif
#endif /* not lint */

View File

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.112 2003/06/15 13:49:46 lukem Exp $ */
/* $NetBSD: util.c,v 1.114 2003/08/07 11:13:57 agc Exp $ */
/*-
* Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
@ -52,11 +52,7 @@
* 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
@ -75,7 +71,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: util.c,v 1.112 2003/06/15 13:49:46 lukem Exp $");
__RCSID("$NetBSD: util.c,v 1.114 2003/08/07 11:13:57 agc Exp $");
#endif /* not lint */
/*
@ -177,15 +173,22 @@ static void
parse_feat(const char *line)
{
if (strcasecmp(line, " MDTM") == 0)
/*
* work-around broken ProFTPd servers that can't
* even obey RFC 2389.
*/
while (*line && isspace((int)*line))
line++;
if (strcasecmp(line, "MDTM") == 0)
features[FEAT_MDTM] = 1;
else if (strncasecmp(line, " MLST", sizeof(" MLST") - 1) == 0) {
else if (strncasecmp(line, "MLST", sizeof("MLST") - 1) == 0) {
features[FEAT_MLST] = 1;
} else if (strcasecmp(line, " REST STREAM") == 0)
} else if (strcasecmp(line, "REST STREAM") == 0)
features[FEAT_REST_STREAM] = 1;
else if (strcasecmp(line, " SIZE") == 0)
else if (strcasecmp(line, "SIZE") == 0)
features[FEAT_SIZE] = 1;
else if (strcasecmp(line, " TVFS") == 0)
else if (strcasecmp(line, "TVFS") == 0)
features[FEAT_TVFS] = 1;
}
@ -265,9 +268,16 @@ getremoteinfo(void)
features[FEAT_FEAT] = 1;
} else
features[FEAT_FEAT] = 0;
if (debug)
for (i = 0; i < FEAT_max; i++)
printf("features[%d] = %d\n", i, features[i]);
if (debug) {
#define DEBUG_FEAT(x) fprintf(ttyout, "features[" #x "] = %d\n", features[(x)])
DEBUG_FEAT(FEAT_FEAT);
DEBUG_FEAT(FEAT_MDTM);
DEBUG_FEAT(FEAT_MLST);
DEBUG_FEAT(FEAT_REST_STREAM);
DEBUG_FEAT(FEAT_SIZE);
DEBUG_FEAT(FEAT_TVFS);
#undef DEBUG_FEAT
}
reply_callback = NULL;
verbose = overbose;

View File

@ -1,4 +1,4 @@
/* $NetBSD: version.h,v 1.31 2003/06/15 13:49:46 lukem Exp $ */
/* $NetBSD: version.h,v 1.33 2003/07/31 07:13:01 lukem Exp $ */
/*-
* Copyright (c) 1999-2003 The NetBSD Foundation, Inc.
* All rights reserved.
@ -40,5 +40,5 @@
#endif
#ifndef FTP_VERSION
#define FTP_VERSION "20030615"
#define FTP_VERSION "20030731b"
#endif