This commit was generated by cvs2svn to compensate for changes in r98247,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Mike Heffner 2002-06-15 09:40:37 +00:00
commit 50d3977d34
22 changed files with 2106 additions and 508 deletions

View File

@ -1,3 +1,209 @@
Mon Jun 10 08:12:35 UTC 2002 lukem
* crank FTP_VERSION from 1.6-beta1 to 1.6-beta2
* replace missing fseeko(), with a wrapper to fseek() which
checks that the offset isn't > LONG_MAX
* #include <regex.h> #if HAVE_REGEX_H
Mon Jun 10 01:27:46 UTC 2002 lukem
* check for and replace sa_family_t definition
* don't bother checking for issetugid(); it was only used in the
internal libedit to prevent $HOME/.editrc from being used if
running set-id, and the newer libedit code wouldn't even read
$HOME/.editrc if issetugid() wasn't available. as many target
operating systems don't have issetugid(), and lukemftp isn't
likely to be run set-id (and $HOME/.netrc is used in any case),
the issetugid() check has been disabled in libedit.
* add back cpp code which #defines REGEX #if HAVE_REGEX_H
Wed Jun 5 14:39:11 UTC 2002 lukem
* crank FTP_VERSION from 1.6alpha1 to 1.6-beta1
* implement replacement setprogname()
* use getprogname() instead of __progname
* convert to christos' replacement fgetln(), as it's better than mine
* merge ftp from NetBSD 20020605 to 20020606:
- use setprogname()
- only support -6 if INET6 is defined
Wed Jun 5 13:08:25 UTC 2002 lukem
* don't bother checking if <glob.h> is usable (see below).
* always compile in local glob; it's the best way to ensure that
various security issues are fixed
* update libukem/glob.c from NetBSD's __glob13.c rev 1.22 and rev 1.23
* merge libedit from NetBSD 20010413 to 20020606:
- constify; passes all gcc and lint strict checks.
- add config.h [Jason Evans], to create a portable version of
libedit that can be easily compiled on other OS's.
- PR/12963:Jason Waterman: Fix signed cast problems.
- Fixed an __P remnant
- Close quoting.
- Generate <>& symbolically.
- Punctuation and whitespace nits, fix a typo.
- PR/14188: Anthony Mallet: Provide an opaque data
pointer to client programs.
- a couple of minor fixes. originally by Ruslan Ermilov
<ru@FreeBSD.org>, highlighted to me by way of Mike Barcroft
<mike@FreeBSD.org> (thanks!)
- PR/14067: Anthony Mallet: Provide a programmatic way
to set the read_char function via a new el_set() operation.
Thanks, nicely done :-)
- `existent', not `existant'
- Don't use HAVE_ yet.
- Fix a warning.
- Remove an unused variable.
- If term_init() fails, cleanup and return NULL. This
avoids other lossage. Pointed by charles.
- va_{start,end} audit: Make sure that each va_start has one
and only one matching va_end, especially in error cases.
If the va_list is used multiple times, do multiple
va_starts/va_ends. If a function gets va_list as argument,
don't let it use va_end (since it's the callers
responsibility). Improved by comments from enami and
christos -- thanks!
- history_def_enter: fix off-by-one mistake in delete
condition (the behaviour to keep at least one entry on the
history list is retained). This fixes lib/9704 by Phil Nelson.
* merge ftp from NetBSD 20020524 to 20020605:
- when showing the final progress bar, replace "00:00 ETA"
with the elapsed time. (suggested by simonb)
- actually display transfer stats after a URL fetch.
(bug introduced a *long* time ago)
- update copyright & version
* merge ftp from NetBSD 20001127 to 20020524:
- Use "r+" instead of "r+w", since the latter is not standard.
Noted by <Steve.McClellan@radisys.com> in private email.
- Only send port number in HTTP/1.1 Host: request if port !=
80. Fixes [bin/15415] from Takahiro Kambe
<taca@sky.yamashina.kyoto.jp>
- Fix bad mode passed by mls() to recvrequest(). Fixes
[bin/16642] from <steve.mcclellan@radisys.com>
- update copyrights
- minor knf
- invoke cmdtab.c_handler()s with argv[0] == c_name instead
of the supplied name. that way the full (unambiguous) name
is displayed in error messages and usage strings.
- line2 may overrun if line is too long (> 200). be more
careful on strcpy.
- Handle URLs without files correctly (e.g, when using '-o -').
Fix from Anders Dinsen <anders@dinsen.net> in [bin/13768]
- portnum is unsigned, use %u instead of %d
- Add -4 to force IPv4 and -6 to force IPv6 address usage.
From Hajimu UMEMOTO, via Mike Heffner of FreeBSD.
- use u_char instead of char in base64_encode().
problem noticed by Jorgen Lundman in private mail.
- don't make broken file with -R option.
- handle "*" in Content-Range properly.
- If no_proxy condition is true && urltype == FTP_URL_T,
use fetch_ftp to retrieve
- convert to use getprogname()
- Fix description for "form", "mode", and "struct" commands.
Inspired by [bin/16736] from Steve McClellan
<steve.mcclellan@radisys.com>
- Generate <>& symbolically. I'm avoiding .../dist/...
directories for now.
- Punctuation nits.
- Whitespace cleanup.
- put "site" in alphabetical order. noted by Mike Barcroft
in private email
- avoid buffer overrun on PASV from malicious server.
- Large file ASCII mode support by using fseeko()
instead of fseek(). From Andrey A. Chernov of FreeBSD,
via Mike Heffner.
- Deal with const'ification if el_parse().
- call setlocale() on startup
- display a limited progress bar (containing bytes xferred
and xfer rate) when the file size is unknown
- disable progress bar during remglob()
Thu Mar 14 05:41:49 UTC 2002 lukem
* ensure all AF_INET6 use is protected with #ifdef INET6
* remove unnecessary __attribute__ goop
* libukem/snprintf.c: fix compile errors with gcc 3.x
Tue Apr 17 08:07:29 UTC 2001 lukem
* autoconf check for %q long long support in *printf()
(instead of %ll), define and use HAVE_PRINTF_QD if so
* ipv6 isn't compatible with socks, so disable the former
* look for <libutil.h> (instead of <util.h>) and <arpa/nameser.h>
* don't check for fparseln() twice
* fix getaddrinfo() checks
* crank FTP_VERSION from 1.5 to 1.6alpha1
* always ensure _PATH_BSHELL and _PATH_TMP are defined
* prototype inet_pton() if its missing
* don't bother trying to use if_indextoname() in ip6_sa2str()
(fixes problems on MacOS X)
* in inet_pton(), pull in <arpa/nameser.h> for IN6ADDRSZ and INT16SZ,
and define if missing
Fri Apr 13 15:24:44 UTC 2001 lukem
* only include <arpa/nameser.h> if we have it
* update glob(3) to netbsd-current (20010329), adding support
for GLOB_LIMIT and fixing various buffer overflows.
* update editline from NetBSD 20000915 -> NetBSD 20010413
- Enlarge editline buffers as needed to support arbitrary
length lines. This also addresses lib/9712 by Phil Nelson.
- consistently check for allocation failures and return -1,
if we could not get more memory.
- add support for home and end keys.
- improve debugging support
- el_line_t: make 'limit' const
Mon Nov 27 23:23:40 EST 2000 lukem
* merge ftp from NetBSD-current (20001127):
- implement "mreget"; as per "mget" but uses "reget" instead
of "get"
- add -N netrc and $NETRC, as methods to select an alternative
.netrc file
- cache local user name and home directory for further use
- in mget(), use docase() instead of a local version to do
the case conversion.
- format string cleanups
- be more explicit that $ftp_proxy and $http_proxy are not
supported for interactive sessions
- cope with 2553bis getnameinfo (always attach scope id)
getnameinfo error check.
- use NI_MAXHOST with getnameinfo. we can assume presence of
getnameinfo.
Tue Nov 7 00:16:23 EST 2000 lukem
* libukem/snprintf.c had a non-functional `%s' due to a
function declaration mismatch. problem found and fixed
by Hubert Feyrer <hubert@feyrer.de>
Wed Oct 11 14:06:19 EST 2000 lukem Wed Oct 11 14:06:19 EST 2000 lukem
* released version 1.5 * released version 1.5

View File

@ -74,11 +74,13 @@ The following platforms & compilers have been tested:
- AIX 4.1.5: - AIX 4.1.5:
- AIX 4.2.1: - AIX 4.2.1:
- Compiler: cc -qlanglvl=ansi - AIX 4.3.3:
- Compiler: xlc -qlanglvl=ansi
version: xlC 3.1.4.10 -- C for AIX Compiler version: xlC 3.1.4.10 -- C for AIX Compiler
version: ibmcxx.cmp 3.6.6.6 -- IBM C and C++ Compilers
Configure with: Configure with:
env CC="cc -qlanglvl=ansi" ./configure env CC="xlc" CFLAGS="-qlanglvl=ansi" ./configure
- BSD/OS 4.0.1 (x86) - BSD/OS 4.0.1 (x86)
- BSD/OS 4.1 (x86) - BSD/OS 4.1 (x86)
@ -173,10 +175,6 @@ The following platforms & compilers have been tested:
XXX: clean up to match reality XXX: clean up to match reality
------------------------------ ------------------------------
- AIX 4.3.2:
Compiler: cc
version: ibmcxx 3.6.6.1 -- IBM C and C++ Compilers
- RedHat Linux 5.0 (i386) - RedHat Linux 5.0 (i386)
Compiler: cc Compiler: cc

View File

@ -2,7 +2,7 @@ Whilst a lot of the work in lukemftp (both the original sources in NetBSD
and this port) was done by me (Luke Mewburn), it would not be as useable and this port) was done by me (Luke Mewburn), it would not be as useable
without the enhancements, fixes, or input from the following people: without the enhancements, fixes, or input from the following people:
Brian Stark <bstark@siemens-psc.com> Brian Stark <bstark1990@netscape.net>
Chris G. Demetriou <cgd@netbsd.org> Chris G. Demetriou <cgd@netbsd.org>
Christos Zoulas <christos@netbsd.org> Christos Zoulas <christos@netbsd.org>
Dan Winship <danw@mit.edu> Dan Winship <danw@mit.edu>

View File

@ -1,4 +1,4 @@
/* $Id: acconfig.h,v 1.6 2000/09/17 23:29:12 lukem Exp $ */ /* $Id: acconfig.h,v 1.9 2002/06/10 01:27:13 lukem Exp $ */
@TOP@ @TOP@
@BOTTOM@ @BOTTOM@
@ -6,9 +6,15 @@
/* Define if your compiler supports `long long' */ /* Define if your compiler supports `long long' */
#undef HAVE_LONG_LONG #undef HAVE_LONG_LONG
/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */
#undef HAVE_PRINTF_QD
/* Define if in_port_t exists */ /* Define if in_port_t exists */
#undef HAVE_IN_PORT_T #undef HAVE_IN_PORT_T
/* Define if sa_family_t exists in <sys/socket.h> */
#undef HAVE_SA_FAMILY_T
/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */ /* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */
#undef HAVE_SOCKADDR_SA_LEN #undef HAVE_SOCKADDR_SA_LEN
@ -33,9 +39,6 @@
/* Define if `struct direct' has a d_namlen element */ /* Define if `struct direct' has a d_namlen element */
#undef HAVE_D_NAMLEN #undef HAVE_D_NAMLEN
/* Define if GLOB_BRACE exists in <glob.h> */
#undef HAVE_GLOB_BRACE
/* Define if h_errno exists in <netdb.h> */ /* Define if h_errno exists in <netdb.h> */
#undef HAVE_H_ERRNO_D #undef HAVE_H_ERRNO_D

View File

@ -1,5 +1,5 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */ /* config.h.in. Generated automatically from configure.in by autoheader. */
/* $Id: config.h.in,v 1.24 2000/09/18 00:40:12 lukem Exp $ */ /* $Id: config.h.in,v 1.28 2002/06/10 08:10:33 lukem Exp $ */
/* Define if on AIX 3. /* Define if on AIX 3.
@ -54,6 +54,9 @@
/* Define if you have the fparseln function. */ /* Define if you have the fparseln function. */
#undef HAVE_FPARSELN #undef HAVE_FPARSELN
/* Define if you have the fseeko function. */
#undef HAVE_FSEEKO
/* Define if you have the getaddrinfo function. */ /* Define if you have the getaddrinfo function. */
#undef HAVE_GETADDRINFO #undef HAVE_GETADDRINFO
@ -69,18 +72,12 @@
/* Define if you have the getpgrp function. */ /* Define if you have the getpgrp function. */
#undef HAVE_GETPGRP #undef HAVE_GETPGRP
/* Define if you have the glob function. */
#undef HAVE_GLOB
/* Define if you have the inet_ntop function. */ /* Define if you have the inet_ntop function. */
#undef HAVE_INET_NTOP #undef HAVE_INET_NTOP
/* Define if you have the inet_pton function. */ /* Define if you have the inet_pton function. */
#undef HAVE_INET_PTON #undef HAVE_INET_PTON
/* Define if you have the issetugid function. */
#undef HAVE_ISSETUGID
/* Define if you have the memmove function. */ /* Define if you have the memmove function. */
#undef HAVE_MEMMOVE #undef HAVE_MEMMOVE
@ -93,6 +90,9 @@
/* Define if you have the select function. */ /* Define if you have the select function. */
#undef HAVE_SELECT #undef HAVE_SELECT
/* Define if you have the setprogname function. */
#undef HAVE_SETPROGNAME
/* Define if you have the sl_init function. */ /* Define if you have the sl_init function. */
#undef HAVE_SL_INIT #undef HAVE_SL_INIT
@ -132,12 +132,18 @@
/* Define if you have the usleep function. */ /* Define if you have the usleep function. */
#undef HAVE_USLEEP #undef HAVE_USLEEP
/* Define if you have the <arpa/nameser.h> header file. */
#undef HAVE_ARPA_NAMESER_H
/* Define if you have the <dirent.h> header file. */ /* Define if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H #undef HAVE_DIRENT_H
/* Define if you have the <err.h> header file. */ /* Define if you have the <err.h> header file. */
#undef HAVE_ERR_H #undef HAVE_ERR_H
/* Define if you have the <libutil.h> header file. */
#undef HAVE_LIBUTIL_H
/* Define if you have the <ndir.h> header file. */ /* Define if you have the <ndir.h> header file. */
#undef HAVE_NDIR_H #undef HAVE_NDIR_H
@ -183,9 +189,15 @@
/* Define if your compiler supports `long long' */ /* Define if your compiler supports `long long' */
#undef HAVE_LONG_LONG #undef HAVE_LONG_LONG
/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */
#undef HAVE_PRINTF_QD
/* Define if in_port_t exists */ /* Define if in_port_t exists */
#undef HAVE_IN_PORT_T #undef HAVE_IN_PORT_T
/* Define if sa_family_t exists in <sys/socket.h> */
#undef HAVE_SA_FAMILY_T
/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */ /* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */
#undef HAVE_SOCKADDR_SA_LEN #undef HAVE_SOCKADDR_SA_LEN
@ -210,9 +222,6 @@
/* Define if `struct direct' has a d_namlen element */ /* Define if `struct direct' has a d_namlen element */
#undef HAVE_D_NAMLEN #undef HAVE_D_NAMLEN
/* Define if GLOB_BRACE exists in <glob.h> */
#undef HAVE_GLOB_BRACE
/* Define if h_errno exists in <netdb.h> */ /* Define if h_errno exists in <netdb.h> */
#undef HAVE_H_ERRNO_D #undef HAVE_H_ERRNO_D

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,10 @@
dnl $Id: configure.in,v 1.32 2000/09/18 00:10:43 lukem Exp $ dnl $Id: configure.in,v 1.37 2002/06/10 08:08:53 lukem Exp $
dnl dnl
dnl configure.in -- dnl configure.in --
dnl process this file with autoconf to produce a configure script. dnl process this file with autoconf to produce a configure script.
dnl dnl
AC_REVISION($Revision: 1.32 $)dnl AC_REVISION($Revision: 1.37 $)dnl
AC_INIT(lukemftp.h) AC_INIT(lukemftp.h)
@ -37,7 +37,6 @@ AC_AIX
dnl Checks for libraries. dnl Checks for libraries.
dnl dnl
dnl XXX: we check fparseln twice; probably best to fix that
AC_CHECK_LIB(util, fparseln) AC_CHECK_LIB(util, fparseln)
if test $opt_editcomplete = yes; then if test $opt_editcomplete = yes; then
AC_CHECK_LIB(tinfo, tgetent, , AC_CHECK_LIB(tinfo, tgetent, ,
@ -48,6 +47,12 @@ if test $opt_editcomplete = yes; then
fi fi
AC_LIBRARY_NET AC_LIBRARY_NET
AC_LIBRARY_SOCKS AC_LIBRARY_SOCKS
if test -n "$socks"; then
if test $opt_ipv6 = yes; then
echo "IPv6 is incompatible with socks, disabling IPv6 support"
opt_ipv6=no
fi
fi
dnl Checks for header files. dnl Checks for header files.
@ -55,7 +60,8 @@ dnl
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
AC_HEADER_DIRENT AC_HEADER_DIRENT
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS(err.h regex.h paths.h poll.h sys/poll.h termcap.h util.h vis.h) AC_CHECK_HEADERS(arpa/nameser.h err.h regex.h paths.h poll.h sys/poll.h \
termcap.h util.h libutil.h vis.h)
dnl Checks for typedefs, structures, and compiler characteristics. dnl Checks for typedefs, structures, and compiler characteristics.
@ -74,6 +80,10 @@ AC_MSG_TRY_COMPILE(for in_port_t, ftp_cv_HAVE_IN_PORT_T, [
#include <sys/types.h> #include <sys/types.h>
#include <netinet/in.h> ], [ in_port_t X ], [AC_DEFINE(HAVE_IN_PORT_T, 1)]) #include <netinet/in.h> ], [ in_port_t X ], [AC_DEFINE(HAVE_IN_PORT_T, 1)])
AC_MSG_TRY_COMPILE(for sa_family_t, ftp_cv_HAVE_SA_FAMILY_T, [
#include <sys/types.h>
#include <sys/socket.h> ], [ sa_family_t X ], [AC_DEFINE(HAVE_SA_FAMILY_T, 1)])
AC_MSG_TRY_COMPILE(for sockaddr_in.sin_len, ftp_cv_HAVE_SOCKADDR_SA_LEN, [ AC_MSG_TRY_COMPILE(for sockaddr_in.sin_len, ftp_cv_HAVE_SOCKADDR_SA_LEN, [
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
@ -123,9 +133,6 @@ AC_MSG_TRY_COMPILE(for d_namlen in struct dirent, ftp_cv_HAVE_D_NAMLEN, [
struct dirent dp; struct dirent dp;
int X = dp.d_namlen; ], [AC_DEFINE(HAVE_D_NAMLEN, 1)]) int X = dp.d_namlen; ], [AC_DEFINE(HAVE_D_NAMLEN, 1)])
AC_MSG_TRY_COMPILE(for GLOB_BRACE, ftp_cv_have_glob_brace, [
#include <glob.h> ], [ int X = GLOB_BRACE ], [:])
AC_MSG_TRY_COMPILE(for h_errno declaration, ftp_cv_HAVE_H_ERRNO_D, [ AC_MSG_TRY_COMPILE(for h_errno declaration, ftp_cv_HAVE_H_ERRNO_D, [
#include <netdb.h> ], [ int X = h_errno ], [AC_DEFINE(HAVE_H_ERRNO_D, 1)]) #include <netdb.h> ], [ int X = h_errno ], [AC_DEFINE(HAVE_H_ERRNO_D, 1)])
@ -151,14 +158,18 @@ AC_MSG_TRY_COMPILE(for pclose() declaration, ftp_cv_HAVE_PCLOSE_D, [
dnl Checks for library functions. dnl Checks for library functions.
dnl dnl
AC_REPLACE_FUNCS(err fgetln fparseln getaddrinfo getnameinfo glob inet_ntop \ AC_REPLACE_FUNCS(err fgetln fseeko getaddrinfo getnameinfo inet_ntop inet_pton \
inet_pton mkstemp sl_init snprintf strdup strerror strlcat \ mkstemp setprogname sl_init snprintf strdup strerror strlcat \
strlcpy strptime strsep strunvis strvis timegm usleep) strlcpy strptime strsep strunvis strvis timegm usleep)
AC_CHECK_FUNCS(gethostbyname2 getpassphrase getpgrp issetugid memmove poll \ AC_CHECK_FUNCS(gethostbyname2 getpassphrase getpgrp memmove poll select)
select)
if test $ac_cv_func_getpgrp = yes; then if test $ac_cv_func_getpgrp = yes; then
AC_FUNC_GETPGRP AC_FUNC_GETPGRP
fi fi
if test $ac_cv_lib_util_fparseln != yes; then
AC_REPLACE_FUNCS(fparseln)
fi
LIBOBJS="$LIBOBJS glob.o"
if test $ac_cv_func_strptime = yes; then if test $ac_cv_func_strptime = yes; then
AC_MSG_TRY_COMPILE(for strptime() declaration, ftp_cv_HAVE_STRPTIME_D, [ AC_MSG_TRY_COMPILE(for strptime() declaration, ftp_cv_HAVE_STRPTIME_D, [
@ -166,44 +177,51 @@ if test $ac_cv_func_strptime = yes; then
[AC_DEFINE(HAVE_STRPTIME_D, 1)]) [AC_DEFINE(HAVE_STRPTIME_D, 1)])
fi fi
AC_MSG_CHECKING(for GLOB_BRACE support in glob)
if test $ftp_cv_have_glob_brace = yes; then
AC_DEFINE(HAVE_GLOB_BRACE, 1)
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT([no, using my own])
LIBOBJS="$LIBOBJS glob.o"
fi
if test $have_long_long = yes -a $ac_cv_sizeof_off_t -ge 8; then if test $have_long_long = yes -a $ac_cv_sizeof_off_t -ge 8; then
AC_DEFINE(HAVE_QUAD_SUPPORT, 1)
AC_REPLACE_FUNCS(strtoll) dnl We assume that if sprintf() supports %lld or %qd,
AC_MSG_CHECKING(snprintf support for %lld) dnl then all of *printf() does. If not, disable long long
if test $ac_cv_func_snprintf = yes; then dnl support because we don't know how to display it.
AC_MSG_CHECKING(*printf() support for %lld)
can_printf_longlong=no
AC_TRY_RUN([
#include <stdio.h>
int main() {
char buf[100];
sprintf(buf, "%lld", 4294967300LL);
return (strcmp(buf, "4294967300"));
}
], [
AC_MSG_RESULT(yes)
can_printf_longlong=yes
], [
AC_MSG_RESULT(no)
], [ : ])
if test $can_printf_longlong != yes; then
AC_MSG_CHECKING(*printf() support for %qd)
AC_TRY_RUN([ AC_TRY_RUN([
#include <stdio.h> #include <stdio.h>
int main() { int main() {
char buf[100]; char buf[100];
snprintf(buf, sizeof(buf), "%lld", sprintf(buf, "%qd", 4294967300LL);
4294967300LL);
return (strcmp(buf, "4294967300")); return (strcmp(buf, "4294967300"));
} }
], [ ], [
AC_MSG_RESULT(yes) AC_MSG_RESULT(yes)
have_snprintf_lld=yes can_printf_longlong=yes
AC_DEFINE(HAVE_PRINTF_QD, 1)
], [ ], [
AC_MSG_RESULT(no, using local version) AC_MSG_RESULT(no)
have_snprintf_lld=no ], [ : ])
], [
AC_MSG_RESULT(cross-compiling, using local version)
have_snprintf_lld=no
])
if test $have_snprintf_lld = no; then
LIBOBJS="$LIBOBJS snprintf.o"
fi
else
AC_MSG_RESULT(using local version)
fi fi
if test $can_printf_longlong = yes; then
AC_DEFINE(HAVE_QUAD_SUPPORT, 1)
AC_REPLACE_FUNCS(strtoll)
fi
fi fi
@ -217,7 +235,7 @@ if test $opt_editcomplete = yes; then
AC_MSG_CHECKING(for working libedit) AC_MSG_CHECKING(for working libedit)
if test $have_libedit = no; then if test $have_libedit = no; then
AC_MSG_RESULT([no, using my own]) AC_MSG_RESULT(no - using my own)
INCLUDES="-I\${srcdir}/../libedit $INCLUDES" INCLUDES="-I\${srcdir}/../libedit $INCLUDES"
LDFLAGS="-L../libedit $LDFLAGS" LDFLAGS="-L../libedit $LDFLAGS"
LIBS="-ledit $LIBS" LIBS="-ledit $LIBS"
@ -238,18 +256,24 @@ fi
have_rfc2553_netdb=no have_rfc2553_netdb=no
if test $ac_cv_func_getaddrinfo = yes; then if test $ac_cv_func_getaddrinfo = yes -a ! -n "$socks"; then
AC_MSG_TRY_COMPILE(for AI_NUMERICHOST, ftp_cv_have_ai_numerichost, [ AC_MSG_TRY_COMPILE(for AI_NUMERICHOST,
ftp_cv_have_ai_numerichost, [
#include <sys/types.h> #include <sys/types.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <netdb.h> ], #include <netdb.h> ],
[ int X = AI_NUMERICHOST ], [ have_rfc2553_netdb=yes ]) [ int X = AI_NUMERICHOST ], [ have_rfc2553_netdb=yes ])
fi fi
AC_MSG_CHECKING(for working getaddrinfo())
if test $have_rfc2553_netdb = yes; then if test $have_rfc2553_netdb = yes; then
AC_DEFINE(HAVE_RFC2553_NETDB, 1) AC_DEFINE(HAVE_RFC2553_NETDB, 1)
AC_MSG_RESULT(yes)
else else
if test $ac_cv_func_getaddrinfo = yes; then if test $ac_cv_func_getaddrinfo = yes; then
LIBOBJS="$LIBOBJS getaddrinfo.o" LIBOBJS="$LIBOBJS getaddrinfo.o"
AC_MSG_RESULT(no - using local version)
else
AC_MSG_RESULT(using local version)
fi fi
fi fi

View File

@ -1,7 +1,7 @@
/* $Id: lukemftp.h,v 1.36 2000/10/11 03:07:36 lukem Exp $ */ /* $Id: lukemftp.h,v 1.43 2002/06/10 08:13:01 lukem Exp $ */
#define FTP_PRODUCT "lukemftp" #define FTP_PRODUCT "lukemftp"
#define FTP_VERSION "1.5" #define FTP_VERSION "1.6-beta2"
#include "config.h" #include "config.h"
@ -77,7 +77,7 @@
# include <err.h> # include <err.h>
#endif #endif
#if HAVE_GLOB_BRACE #if USE_GLOB_H /* not set by configure; used by other build systems */
# include <glob.h> # include <glob.h>
#else #else
# include "ftpglob.h" # include "ftpglob.h"
@ -85,9 +85,12 @@
#if HAVE_PATHS_H #if HAVE_PATHS_H
# include <paths.h> # include <paths.h>
#else #endif
# define _PATH_BSHELL "/bin/sh" #ifndef _PATH_BSHELL
# define _PATH_TMP "/tmp/" #define _PATH_BSHELL "/bin/sh"
#endif
#ifndef _PATH_TMP
#define _PATH_TMP "/tmp/"
#endif #endif
typedef struct _stringlist { typedef struct _stringlist {
@ -116,6 +119,10 @@ void tputs(const char *, int, int (*)(int));
# include <util.h> # include <util.h>
#endif #endif
#if HAVE_LIBUTIL_H
# include <libutil.h>
#endif
#if HAVE_VIS_H #if HAVE_VIS_H
# include <vis.h> # include <vis.h>
#else #else
@ -126,6 +133,10 @@ void tputs(const char *, int, int (*)(int));
typedef unsigned short in_port_t; typedef unsigned short in_port_t;
#endif #endif
#if ! HAVE_SA_FAMILY_T
typedef unsigned short sa_family_t;
#endif
#if ! HAVE_SOCKLEN_T #if ! HAVE_SOCKLEN_T
typedef unsigned int socklen_t; typedef unsigned int socklen_t;
#endif #endif
@ -274,6 +285,10 @@ void warnx(const char *, ...);
char *fgetln(FILE *, size_t *); char *fgetln(FILE *, size_t *);
#endif #endif
#if ! HAVE_FSEEKO
int fseeko(FILE *, off_t, int);
#endif
#if ! HAVE_FPARSELN #if ! HAVE_FPARSELN
# define FPARSELN_UNESCESC 0x01 # define FPARSELN_UNESCESC 0x01
# define FPARSELN_UNESCCONT 0x02 # define FPARSELN_UNESCCONT 0x02
@ -287,10 +302,19 @@ char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
const char *inet_ntop(int, const void *, char *, size_t); const char *inet_ntop(int, const void *, char *, size_t);
#endif #endif
#if ! HAVE_INET_PTON
int inet_pton(int, const char *, void *);
#endif
#if ! HAVE_MKSTEMP #if ! HAVE_MKSTEMP
int mkstemp(char *); int mkstemp(char *);
#endif #endif
#if ! HAVE_SETPROGNAME
const char *getprogname(void);
void setprogname(const char *);
#endif
#if ! HAVE_SNPRINTF #if ! HAVE_SNPRINTF
int snprintf(char *, size_t, const char *, ...); int snprintf(char *, size_t, const char *, ...);
#endif #endif

View File

@ -1,7 +1,7 @@
/* $NetBSD: cmds.c,v 1.90 2000/08/01 22:47:25 lukem Exp $ */ /* $NetBSD: cmds.c,v 1.98 2002/06/05 10:20:46 lukem Exp $ */
/*- /*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc. * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -515,26 +515,28 @@ void
reget(int argc, char *argv[]) reget(int argc, char *argv[])
{ {
(void)getit(argc, argv, 1, "r+w"); (void)getit(argc, argv, 1, "r+");
} }
void void
get(int argc, char *argv[]) get(int argc, char *argv[])
{ {
(void)getit(argc, argv, 0, restart_point ? "r+w" : "w" ); (void)getit(argc, argv, 0, restart_point ? "r+" : "w" );
} }
/* /*
* Receive one file. * Receive one file.
* If restartit is 1, restart the xfer always.
* If restartit is -1, restart the xfer only if the remote file is newer.
*/ */
int int
getit(int argc, char *argv[], int restartit, const char *mode) getit(int argc, char *argv[], int restartit, const char *mode)
{ {
int loc = 0; int loc, rval;
int rval = 0; char *remfile, *locfile, *olocfile;
char *remfile, *locfile, *olocfile;
loc = rval = 0;
if (argc == 2) { if (argc == 2) {
argc++; argc++;
argv[2] = argv[1]; argv[2] = argv[1];
@ -639,8 +641,9 @@ void
mget(int argc, char *argv[]) mget(int argc, char *argv[])
{ {
sigfunc oldintr; sigfunc oldintr;
int ch, ointer; int ointer;
char *cp, *tp, *tp2, tmpbuf[MAXPATHLEN]; char *cp, *tp;
int restartit;
if (argc == 0 || if (argc == 0 ||
(argc == 1 && !another(&argc, &argv, "remote-files"))) { (argc == 1 && !another(&argc, &argv, "remote-files"))) {
@ -650,6 +653,16 @@ mget(int argc, char *argv[])
} }
mname = argv[0]; mname = argv[0];
mflag = 1; mflag = 1;
restart_point = 0;
restartit = 0;
if (strcmp(argv[0], "mreget") == 0) {
if (! features[FEAT_REST_STREAM]) {
fprintf(ttyout,
"Restart is not supported by the remote server.\n");
return;
}
restartit = 1;
}
oldintr = xsignal(SIGINT, mintr); oldintr = xsignal(SIGINT, mintr);
if (sigsetjmp(jabort, 1)) if (sigsetjmp(jabort, 1))
mabort(); mabort();
@ -658,30 +671,32 @@ mget(int argc, char *argv[])
mflag = 0; mflag = 0;
continue; continue;
} }
if (mflag && confirm(argv[0], cp)) { if (! mflag || !confirm(argv[0], cp))
tp = cp; continue;
if (mcase) { tp = cp;
for (tp2 = tmpbuf; (ch = *tp++) != 0; ) if (mcase)
*tp2++ = isupper(ch) ? tolower(ch) : ch; tp = docase(tp);
*tp2 = '\0'; if (ntflag)
tp = tmpbuf; tp = dotrans(tp);
} if (mapflag)
if (ntflag) { tp = domap(tp);
tp = dotrans(tp); if (restartit) {
} struct stat stbuf;
if (mapflag) {
tp = domap(tp); if (stat(tp, &stbuf) == 0)
} restart_point = stbuf.st_size;
recvrequest("RETR", tp, cp, "w", else
tp != cp || !interactive, 1); warn("stat %s", tp);
if (!mflag && fromatty) { }
ointer = interactive; recvrequest("RETR", tp, cp, restart_point ? "r+" : "w",
interactive = 1; tp != cp || !interactive, 1);
if (confirm("Continue with", "mget")) { restart_point = 0;
mflag++; if (!mflag && fromatty) {
} ointer = interactive;
interactive = ointer; interactive = 1;
} if (confirm("Continue with", "mget"))
mflag++;
interactive = ointer;
} }
} }
(void)xsignal(SIGINT, oldintr); (void)xsignal(SIGINT, oldintr);
@ -711,7 +726,7 @@ fget(int argc, char *argv[])
} }
argv[0] = "get"; argv[0] = "get";
mode = restart_point ? "r+w" : "w"; mode = restart_point ? "r+" : "w";
for (; for (;
(buf = fparseln(fp, NULL, NULL, "\0\0\0", 0)) != NULL; (buf = fparseln(fp, NULL, NULL, "\0\0\0", 0)) != NULL;
@ -1111,7 +1126,7 @@ lcd(int argc, char *argv[])
code = -1; code = -1;
if (argc == 1) { if (argc == 1) {
argc++; argc++;
argv[1] = home; argv[1] = localhome;
} }
if (argc != 2) { if (argc != 2) {
fprintf(ttyout, "usage: %s [local-directory]\n", argv[0]); fprintf(ttyout, "usage: %s [local-directory]\n", argv[0]);
@ -1306,7 +1321,7 @@ mls(int argc, char *argv[])
sigfunc oldintr; sigfunc oldintr;
int ointer, i; int ointer, i;
int dolist; int dolist;
char mode[1], *dest, *odest; char *mode, *dest, *odest;
if (argc == 0) if (argc == 0)
goto usage; goto usage;
@ -1333,7 +1348,7 @@ mls(int argc, char *argv[])
if (sigsetjmp(jabort, 1)) if (sigsetjmp(jabort, 1))
mabort(); mabort();
for (i = 1; mflag && i < argc-1 && connected; i++) { for (i = 1; mflag && i < argc-1 && connected; i++) {
*mode = (i == 1) ? 'w' : 'a'; mode = (i == 1) ? "w" : "a";
recvrequest(dolist ? "LIST" : "NLST", dest, argv[i], mode, recvrequest(dolist ? "LIST" : "NLST", dest, argv[i], mode,
0, 0); 0, 0);
if (!mflag && fromatty) { if (!mflag && fromatty) {
@ -1620,6 +1635,12 @@ do_chmod(int argc, char *argv[])
(void)command("SITE CHMOD %s %s", argv[1], argv[2]); (void)command("SITE CHMOD %s %s", argv[1], argv[2]);
} }
#define COMMAND_1ARG(argc, argv, cmd) \
if (argc == 1) \
command(cmd); \
else \
command(cmd " %s", argv[1])
void void
do_umask(int argc, char *argv[]) do_umask(int argc, char *argv[])
{ {
@ -1631,7 +1652,7 @@ do_umask(int argc, char *argv[])
return; return;
} }
verbose = 1; verbose = 1;
(void)command(argc == 1 ? "SITE UMASK" : "SITE UMASK %s", argv[1]); COMMAND_1ARG(argc, argv, "SITE UMASK");
verbose = oldverbose; verbose = oldverbose;
} }
@ -1646,7 +1667,7 @@ idlecmd(int argc, char *argv[])
return; return;
} }
verbose = 1; verbose = 1;
(void)command(argc == 1 ? "SITE IDLE" : "SITE IDLE %s", argv[1]); COMMAND_1ARG(argc, argv, "SITE IDLE");
verbose = oldverbose; verbose = oldverbose;
} }
@ -1664,7 +1685,7 @@ rmthelp(int argc, char *argv[])
return; return;
} }
verbose = 1; verbose = 1;
(void)command(argc == 1 ? "HELP" : "HELP %s", argv[1]); COMMAND_1ARG(argc, argv, "HELP");
verbose = oldverbose; verbose = oldverbose;
} }
@ -1792,6 +1813,7 @@ doproxy(int argc, char *argv[])
cmdpos = strcspn(line, " \t"); cmdpos = strcspn(line, " \t");
if (cmdpos > 0) /* remove leading "proxy " from input buffer */ if (cmdpos > 0) /* remove leading "proxy " from input buffer */
memmove(line, line + cmdpos + 1, strlen(line) - cmdpos + 1); memmove(line, line + cmdpos + 1, strlen(line) - cmdpos + 1);
argv[1] = c->c_name;
(*c->c_handler)(argc-1, argv+1); (*c->c_handler)(argc-1, argv+1);
if (connected) { if (connected) {
proxflag = 1; proxflag = 1;
@ -2427,7 +2449,7 @@ rmtstatus(int argc, char *argv[])
code = -1; code = -1;
return; return;
} }
(void)command(argc > 1 ? "STAT %s" : "STAT" , argv[1]); COMMAND_1ARG(argc, argv, "STAT");
} }
/* /*
@ -2503,7 +2525,7 @@ page(int argc, char *argv[])
orestart_point = restart_point; orestart_point = restart_point;
overbose = verbose; overbose = verbose;
hash = restart_point = verbose = 0; hash = restart_point = verbose = 0;
recvrequest("RETR", pager, argv[1], "r+w", 1, 0); recvrequest("RETR", pager, argv[1], "r+", 1, 0);
hash = ohash; hash = ohash;
restart_point = orestart_point; restart_point = orestart_point;
verbose = overbose; verbose = overbose;
@ -2648,7 +2670,7 @@ mlst(int argc, char *argv[])
return; return;
} }
verbose = 1; /* If we aren't verbose, this doesn't do anything! */ verbose = 1; /* If we aren't verbose, this doesn't do anything! */
(void)command(argc == 1 ? "MLST" : "MLST %s", argv[1]); COMMAND_1ARG(argc, argv, "MLST");
verbose = oldverbose; verbose = oldverbose;
} }
@ -2668,6 +2690,9 @@ opts(int argc, char *argv[])
return; return;
} }
verbose = 1; /* If we aren't verbose, this doesn't do anything! */ verbose = 1; /* If we aren't verbose, this doesn't do anything! */
(void)command(argc == 2 ? "OPTS %s" : "OPTS %s %s", argv[1], argv[2]); if (argc == 2)
command("OPTS %s", argv[1]);
else
command("OPTS %s %s", argv[1], argv[2]);
verbose = oldverbose; verbose = oldverbose;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: cmdtab.c,v 1.38 2000/09/14 13:48:33 lukem Exp $ */ /* $NetBSD: cmdtab.c,v 1.39 2000/11/15 00:10:59 lukem Exp $ */
/*- /*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc. * Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@ -108,6 +108,7 @@ char lshelp[] = "list contents of remote path";
char macdefhelp[] = "define a macro"; char macdefhelp[] = "define a macro";
char mdeletehelp[] = "delete multiple files"; char mdeletehelp[] = "delete multiple files";
char mgethelp[] = "get multiple files"; char mgethelp[] = "get multiple files";
char mregethelp[] = "get multiple files restarting at end of local file";
char fgethelp[] = "get files using a localfile as a source of names"; char fgethelp[] = "get files using a localfile as a source of names";
char mkdirhelp[] = "make directory on the remote machine"; char mkdirhelp[] = "make directory on the remote machine";
char mlshelp[] = "list contents of multiple remote directories"; char mlshelp[] = "list contents of multiple remote directories";
@ -224,6 +225,7 @@ struct cmd cmdtab[] = {
{ "modtime", modtimehelp, 0, 1, 1, CMPL(r) modtime }, { "modtime", modtimehelp, 0, 1, 1, CMPL(r) modtime },
{ "more", pagehelp, 1, 1, 1, CMPL(r) page }, { "more", pagehelp, 1, 1, 1, CMPL(r) page },
{ "mput", mputhelp, 1, 1, 1, CMPL(L) mput }, { "mput", mputhelp, 1, 1, 1, CMPL(L) mput },
{ "mreget", mregethelp, 1, 1, 1, CMPL(R) mget },
{ "msend", mputhelp, 1, 1, 1, CMPL(L) mput }, { "msend", mputhelp, 1, 1, 1, CMPL(L) mput },
{ "newer", newerhelp, 1, 1, 1, CMPL(r) newer }, { "newer", newerhelp, 1, 1, 1, CMPL(r) newer },
{ "nlist", lshelp, 1, 1, 1, CMPL(rl) ls }, { "nlist", lshelp, 1, 1, 1, CMPL(rl) ls },

View File

@ -1,4 +1,4 @@
/* $NetBSD: domacro.c,v 1.17 2000/07/18 06:45:03 lukem Exp $ */ /* $NetBSD: domacro.c,v 1.19 2002/02/01 05:04:43 itojun Exp $ */
/* /*
* Copyright (c) 1985, 1993, 1994 * Copyright (c) 1985, 1993, 1994
@ -41,7 +41,7 @@ void
domacro(int argc, char *argv[]) domacro(int argc, char *argv[])
{ {
int i, j, count = 2, loopflg = 0; int i, j, count = 2, loopflg = 0;
char *cp1, *cp2, line2[200]; char *cp1, *cp2, line2[FTPBUFLEN];
struct cmd *c; struct cmd *c;
if ((argc == 0 && argv != NULL) || if ((argc == 0 && argv != NULL) ||
@ -59,7 +59,7 @@ domacro(int argc, char *argv[])
code = -1; code = -1;
return; return;
} }
(void)strcpy(line2, line); (void)strlcpy(line2, line, sizeof(line2));
TOP: TOP:
cp1 = macros[i].mac_start; cp1 = macros[i].mac_start;
while (cp1 != macros[i].mac_end) { while (cp1 != macros[i].mac_end) {
@ -78,7 +78,8 @@ domacro(int argc, char *argv[])
j = 10*j + *cp1 - '0'; j = 10*j + *cp1 - '0';
cp1--; cp1--;
if (argc - 2 >= j) { if (argc - 2 >= j) {
(void)strcpy(cp2, argv[j+1]); (void)strlcpy(cp2, argv[j+1],
sizeof(line) - (cp2 - line));
cp2 += strlen(argv[j+1]); cp2 += strlen(argv[j+1]);
} }
break; break;
@ -87,7 +88,8 @@ domacro(int argc, char *argv[])
loopflg = 1; loopflg = 1;
cp1++; cp1++;
if (count < argc) { if (count < argc) {
(void)strcpy(cp2, argv[count]); (void)strlcpy(cp2, argv[count],
sizeof(line) - (cp2 - line));
cp2 += strlen(argv[count]); cp2 += strlen(argv[count]);
} }
break; break;
@ -117,10 +119,11 @@ domacro(int argc, char *argv[])
fputs(line, ttyout); fputs(line, ttyout);
putc('\n', ttyout); putc('\n', ttyout);
} }
margv[0] = c->c_name;
(*c->c_handler)(margc, margv); (*c->c_handler)(margc, margv);
if (bell && c->c_bell) if (bell && c->c_bell)
(void)putc('\007', ttyout); (void)putc('\007', ttyout);
(void)strcpy(line, line2); (void)strlcpy(line, line2, sizeof(line));
makeargv(); makeargv();
argc = margc; argc = margc;
argv = margv; argv = margv;

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.59 2000/08/06 08:51:22 lukem Exp $ */ /* $NetBSD: extern.h,v 1.60 2000/10/11 14:46:03 is Exp $ */
/*- /*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc. * Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@ -122,7 +122,8 @@ void cleanuppeer(void);
void cmdabort(int); void cmdabort(int);
void cmdtimeout(int); void cmdtimeout(int);
void cmdscanner(void); void cmdscanner(void);
int command(const char *, ...); int command(const char *, ...)
;
#ifndef NO_EDITCOMPLETE #ifndef NO_EDITCOMPLETE
unsigned char complete(EditLine *, int); unsigned char complete(EditLine *, int);
void controlediting(void); void controlediting(void);

View File

@ -1,7 +1,7 @@
/* $NetBSD: fetch.c,v 1.125 2000/09/28 12:29:23 lukem Exp $ */ /* $NetBSD: fetch.c,v 1.136 2002/06/05 10:20:48 lukem Exp $ */
/*- /*-
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc. * Copyright (c) 1997-2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -58,7 +58,7 @@ typedef enum {
void aborthttp(int); void aborthttp(int);
static int auth_url(const char *, char **, const char *, const char *); static int auth_url(const char *, char **, const char *, const char *);
static void base64_encode(const char *, size_t, char *); static void base64_encode(const u_char *, size_t, u_char *);
static int go_fetch(const char *); static int go_fetch(const char *);
static int fetch_ftp(const char *); static int fetch_ftp(const char *);
static int fetch_url(const char *, const char *, char *, char *); static int fetch_url(const char *, const char *, char *, char *);
@ -171,11 +171,11 @@ auth_url(const char *challenge, char **response, const char *guser,
* which should be at least ((len + 2) * 4 / 3 + 1) in size. * which should be at least ((len + 2) * 4 / 3 + 1) in size.
*/ */
static void static void
base64_encode(const char *clear, size_t len, char *encoded) base64_encode(const u_char *clear, size_t len, u_char *encoded)
{ {
static const char enc[] = static const u_char enc[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
char *cp; u_char *cp;
int i; int i;
cp = encoded; cp = encoded;
@ -373,7 +373,7 @@ parse_url(const char *url, const char *desc, url_t *type,
if (tport != NULL) if (tport != NULL)
*port = xstrdup(tport); *port = xstrdup(tport);
if (*path == NULL) if (*path == NULL)
*path = xstrdup(""); *path = xstrdup("/");
if (debug) if (debug)
fprintf(ttyout, fprintf(ttyout,
@ -393,7 +393,7 @@ sigjmp_buf httpabort;
* If proxyenv is set, use that for the proxy, otherwise try ftp_proxy or * If proxyenv is set, use that for the proxy, otherwise try ftp_proxy or
* http_proxy as appropriate. * http_proxy as appropriate.
* Supports HTTP redirects. * Supports HTTP redirects.
* Returns -1 on failure, 0 on completed xfer, 1 if ftp connection * Returns 1 on failure, 0 on completed xfer, -1 if ftp connection
* is still open (e.g, ftp xfer with trailing /) * is still open (e.g, ftp xfer with trailing /)
*/ */
static int static int
@ -574,6 +574,10 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
} }
} }
FREEPTR(np_copy); FREEPTR(np_copy);
if (isproxy == 0 && urltype == FTP_URL_T) {
rval = fetch_ftp(url);
goto cleanup_fetch_url;
}
} }
if (isproxy) { if (isproxy) {
@ -700,10 +704,13 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
(p = strchr(h, '%')) != NULL) { (p = strchr(h, '%')) != NULL) {
*p = '\0'; *p = '\0';
} }
fprintf(fin, "Host: [%s]:%d\r\n", h, portnum); fprintf(fin, "Host: [%s]", h);
free(h); free(h);
} else } else
fprintf(fin, "Host: %s:%d\r\n", host, portnum); fprintf(fin, "Host: %s", host);
if (portnum != HTTP_PORT)
fprintf(fin, ":%u", portnum);
fprintf(fin, "\r\n");
fprintf(fin, "Accept: */*\r\n"); fprintf(fin, "Accept: */*\r\n");
fprintf(fin, "Connection: close\r\n"); fprintf(fin, "Connection: close\r\n");
if (restart_point) { if (restart_point) {
@ -801,26 +808,42 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
} else if (strncasecmp(cp, CONTENTRANGE, } else if (strncasecmp(cp, CONTENTRANGE,
sizeof(CONTENTRANGE) - 1) == 0) { sizeof(CONTENTRANGE) - 1) == 0) {
cp += sizeof(CONTENTRANGE) - 1; cp += sizeof(CONTENTRANGE) - 1;
rangestart = STRTOLL(cp, &ep, 10); if (*cp == '*') {
if (rangestart < 0 || *ep != '-') ep = cp + 1;
}
else {
rangestart = STRTOLL(cp, &ep, 10);
if (rangestart < 0 || *ep != '-')
goto improper;
cp = ep + 1;
rangeend = STRTOLL(cp, &ep, 10);
if (rangeend < 0 || rangeend < rangestart)
goto improper;
}
if (*ep != '/')
goto improper; goto improper;
cp = ep + 1; cp = ep + 1;
rangeend = STRTOLL(cp, &ep, 10); if (*cp == '*') {
if (rangeend < 0 || *ep != '/' || ep = cp + 1;
rangeend < rangestart) }
goto improper; else {
cp = ep + 1; entitylen = STRTOLL(cp, &ep, 10);
entitylen = STRTOLL(cp, &ep, 10); if (entitylen < 0)
if (entitylen < 0 || *ep != '\0') goto improper;
}
if (*ep != '\0')
goto improper; goto improper;
if (debug) if (debug) {
fprintf(ttyout, fprintf(ttyout, "parsed range as: ");
"parsed range as: " if (rangestart == -1)
LLF "-" LLF "/" LLF "\n", fprintf(ttyout, "*");
(LLT)rangestart, else
(LLT)rangeend, fprintf(ttyout, LLF "-" LLF,
(LLT)entitylen); (LLT)rangestart,
(LLT)rangeend);
fprintf(ttyout, "/" LLF "\n", (LLT)entitylen);
}
if (! restart_point) { if (! restart_point) {
warnx( warnx(
"Received unexpected Content-Range header"); "Received unexpected Content-Range header");
@ -1014,10 +1037,18 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
} }
closefunc = pclose; closefunc = pclose;
} else { } else {
if (restart_point){ if ((rangeend != -1 && rangeend <= restart_point) ||
(rangestart == -1 && filesize != -1 && filesize <= restart_point)) {
/* already done */
if (verbose)
fprintf(ttyout, "already done\n");
rval = 0;
goto cleanup_fetch_url;
}
if (restart_point && rangestart != -1) {
if (entitylen != -1) if (entitylen != -1)
filesize = entitylen; filesize = entitylen;
if (rangestart != -1 && rangestart != restart_point) { if (rangestart != restart_point) {
warnx( warnx(
"Size of `%s' differs from save file `%s'", "Size of `%s' differs from save file `%s'",
url, savefile); url, savefile);
@ -1149,7 +1180,6 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
goto cleanup_fetch_url; goto cleanup_fetch_url;
} }
progressmeter(1); progressmeter(1);
bytes = 0;
(void)fflush(fout); (void)fflush(fout);
if (closefunc == fclose && mtime != -1) { if (closefunc == fclose && mtime != -1) {
struct timeval tval[2]; struct timeval tval[2];
@ -1168,6 +1198,7 @@ fetch_url(const char *url, const char *proxyenv, char *proxyauth, char *wwwauth)
} }
if (bytes > 0) if (bytes > 0)
ptransfer(0); ptransfer(0);
bytes = 0;
rval = 0; rval = 0;
goto cleanup_fetch_url; goto cleanup_fetch_url;
@ -1351,7 +1382,7 @@ fetch_ftp(const char *url)
/* Set up the connection */ /* Set up the connection */
if (connected) if (connected)
disconnect(0, NULL); disconnect(0, NULL);
xargv[0] = __progname; xargv[0] = (char *)getprogname(); /* XXX discards const */
xargv[1] = host; xargv[1] = host;
xargv[2] = NULL; xargv[2] = NULL;
xargc = 2; xargc = 2;

View File

@ -1,6 +1,6 @@
.\" $NetBSD: ftp.1,v 1.73 2000/09/28 12:26:19 lukem Exp $ .\" $NetBSD: ftp.1,v 1.83 2002/06/05 10:20:48 lukem Exp $
.\" .\"
.\" Copyright (c) 1996-2000 The NetBSD Foundation, Inc. .\" Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
.\" All rights reserved. .\" All rights reserved.
.\" .\"
.\" This code is derived from software contributed to The NetBSD Foundation .\" This code is derived from software contributed to The NetBSD Foundation
@ -68,7 +68,7 @@
.\" .\"
.\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
.\" .\"
.Dd September 28, 2000 .Dd May 18, 2002
.Dt FTP 1 .Dt FTP 1
.Os .Os
.Sh NAME .Sh NAME
@ -79,6 +79,9 @@ Internet file transfer program
.Nm "" .Nm ""
.Op Fl 46AadefginpRtvV .Op Fl 46AadefginpRtvV
.Bk -words .Bk -words
.Op Fl N Ar netrc
.Ek
.Bk -words
.Op Fl o Ar output .Op Fl o Ar output
.Ek .Ek
.Bk -words .Bk -words
@ -202,6 +205,14 @@ If no entry exists,
will prompt for the remote machine login name (default is the user will prompt for the remote machine login name (default is the user
identity on the local machine), and, if necessary, prompt for a password identity on the local machine), and, if necessary, prompt for a password
and an account with which to login. and an account with which to login.
.It Fl N Ar netrc
Use
.Ar netrc
instead of
.Pa ~/.netrc .
Refer to
.Sx THE .netrc FILE
for more information.
.It Fl o Ar output .It Fl o Ar output
When auto-fetching files, save the contents in When auto-fetching files, save the contents in
.Ar output . .Ar output .
@ -299,7 +310,7 @@ from the user.
When When
.Nm .Nm
is awaiting commands from the user the prompt is awaiting commands from the user the prompt
.Ql ftp> .Ql ftp\*[Gt]
is provided to the user. is provided to the user.
The following commands are recognized The following commands are recognized
by by
@ -359,7 +370,10 @@ and exit
An end of file will also terminate the session and exit. An end of file will also terminate the session and exit.
.It Ic case .It Ic case
Toggle remote computer file name case mapping during Toggle remote computer file name case mapping during
.Ic get ,
.Ic mget .Ic mget
and
.Ic mput
commands. commands.
When When
.Ic case .Ic case
@ -413,7 +427,7 @@ When debugging is on,
.Nm .Nm
prints each command sent to the remote machine, preceded prints each command sent to the remote machine, preceded
by the string by the string
.Ql \-\-> .Ql \-\-\*[Gt]
.It Ic delete Ar remote-file .It Ic delete Ar remote-file
Delete the file Delete the file
.Ar remote-file .Ar remote-file
@ -481,8 +495,9 @@ Set the file transfer
.Ic form .Ic form
to to
.Ar format . .Ar format .
The default format is The default (and only supported)
.Dq file . format is
.Dq non-print .
.It Ic ftp Ar host Op Ar port .It Ic ftp Ar host Op Ar port
A synonym for A synonym for
.Ic open . .Ic open .
@ -525,9 +540,10 @@ are used while transferring the file.
.It Ic glob .It Ic glob
Toggle filename expansion for Toggle filename expansion for
.Ic mdelete , .Ic mdelete ,
.Ic mget .Ic mget ,
.Ic mput ,
and and
.Ic mput . .Ic mreget .
If globbing is turned off with If globbing is turned off with
.Ic glob , .Ic glob ,
the file name arguments the file name arguments
@ -537,9 +553,10 @@ Globbing for
is done as in is done as in
.Xr csh 1 . .Xr csh 1 .
For For
.Ic mdelete .Ic mdelete ,
.Ic mget ,
and and
.Ic mget , .Ic mreget ,
each remote file name is expanded each remote file name is expanded
separately on the remote machine and the lists are not merged. separately on the remote machine and the lists are not merged.
Expansion of a directory name is likely to be Expansion of a directory name is likely to be
@ -548,9 +565,10 @@ the exact result depends on the foreign operating system and ftp server,
and can be previewed by doing and can be previewed by doing
.Ql mls remote-files \- .Ql mls remote-files \-
Note: Note:
.Ic mget .Ic mget ,
and
.Ic mput .Ic mput
and
.Ic mreget
are not meant to transfer are not meant to transfer
entire directory subtrees of files. entire directory subtrees of files.
That can be done by That can be done by
@ -697,9 +715,9 @@ Set the file transfer
.Ic mode .Ic mode
to to
.Ar mode-name . .Ar mode-name .
The default mode is The default (and only supported)
.Dq stream mode is
mode. .Dq stream .
.It Ic modtime Ar remote-file .It Ic modtime Ar remote-file
Show the last modification time of the file on the remote machine. Show the last modification time of the file on the remote machine.
.It Ic more Ar file .It Ic more Ar file
@ -718,6 +736,13 @@ Resulting file names will then be processed according to
and and
.Ic nmap .Ic nmap
settings. settings.
.It Ic mreget Ar remote-files
As per
.Ic mget ,
but performs a
.Ic reget
instead of
.Ic get .
.It Ic msend Ar local-files .It Ic msend Ar local-files
A synonym for A synonym for
.Ic mput . .Ic mput .
@ -800,7 +825,7 @@ the output filename "myfile.data" for input filenames "myfile.data" and
"myfile.myfile" for the input filename ".myfile". "myfile.myfile" for the input filename ".myfile".
Spaces may be included in Spaces may be included in
.Ar outpattern , .Ar outpattern ,
as in the example: `nmap $1 sed "s/ *$//" > $1' . as in the example: `nmap $1 sed "s/ *$//" \*[Gt] $1' .
Use the `\e' character to prevent special treatment Use the `\e' character to prevent special treatment
of the `$','[',']', and `,' characters. of the `$','[',']', and `,' characters.
.It Ic ntrans Op Ar inchars Op Ar outchars .It Ic ntrans Op Ar inchars Op Ar outchars
@ -1121,7 +1146,7 @@ commands known to support options include:
.Sq MLST .Sq MLST
(used for (used for
.Dv MLSD .Dv MLSD
and and
.Dv MLST ) . .Dv MLST ) .
.It Ic rename Op Ar from Op Ar to .It Ic rename Op Ar from Op Ar to
Rename the file Rename the file
@ -1249,6 +1274,12 @@ Defaults to
Defaults to Defaults to
.Ev $FTPRPROMPT . .Ev $FTPRPROMPT .
.El .El
.It Ic site Ar arg1 arg2 ...
The arguments specified are sent, verbatim, to the remote
.Tn FTP
server as a
.Dv SITE
command.
.It Ic size Ar remote-file .It Ic size Ar remote-file
Return size of Return size of
.Ar remote-file .Ar remote-file
@ -1256,12 +1287,6 @@ on remote machine.
.It Ic sndbuf Ar size .It Ic sndbuf Ar size
Set the size of the socket send buffer to Set the size of the socket send buffer to
.Ar size . .Ar size .
.It Ic site Ar arg1 arg2 ...
The arguments specified are sent, verbatim, to the remote
.Tn FTP
server as a
.Dv SITE
command.
.It Ic status .It Ic status
Show the current status of Show the current status of
.Nm ftp . .Nm ftp .
@ -1270,9 +1295,9 @@ Set the file transfer
.Ar structure .Ar structure
to to
.Ar struct-name . .Ar struct-name .
By default The default (and only supported)
.Dq stream structure is
structure is used. .Dq file .
.It Ic sunique .It Ic sunique
Toggle storing of files on remote machine under unique file names. Toggle storing of files on remote machine under unique file names.
The remote The remote
@ -1720,7 +1745,12 @@ The
.Pa .netrc .Pa .netrc
file contains login and initialization information file contains login and initialization information
used by the auto-login process. used by the auto-login process.
It resides in the user's home directory. It resides in the user's home directory,
unless overridden with the
.Fl N Ar netrc
option, or specified in the
.Ev NETRC
environment variable.
The following tokens are recognized; they may be separated by spaces, The following tokens are recognized; they may be separated by spaces,
tabs, or new-lines: tabs, or new-lines:
.Bl -tag -width password .Bl -tag -width password
@ -1844,7 +1874,7 @@ By default, this is bound to the TAB key.
By default, By default,
.Nm .Nm
displays a command line prompt of displays a command line prompt of
.Dq "ftp> " .Dq "ftp\*[Gt] "
to the user. to the user.
This can be changed with the This can be changed with the
.Ic "set prompt" .Ic "set prompt"
@ -1872,7 +1902,7 @@ begins with
.Sq 0 , .Sq 0 ,
the number of skipped components precede the trailing component(s) in the number of skipped components precede the trailing component(s) in
the format the format
.Dq /\fI<skipped>\fRtrailing .Dq /\fI\*[Lt]skipped\*[Gt]\fRtrailing
(for (for
.Sq %c ) .Sq %c )
or or
@ -1920,7 +1950,7 @@ only
.It Ev FTPPROMPT .It Ev FTPPROMPT
Command-line prompt to use. Command-line prompt to use.
Defaults to Defaults to
.Dq "ftp> " . .Dq "ftp\*[Gt] " .
Refer to Refer to
.Sx COMMAND LINE PROMPT .Sx COMMAND LINE PROMPT
for more information. for more information.
@ -1947,6 +1977,10 @@ lookup of
For default location of a For default location of a
.Pa .netrc .Pa .netrc
file, if one exists. file, if one exists.
.It Ev NETRC
An alternate location of the
.Pa .netrc
file.
.It Ev PAGER .It Ev PAGER
Used by various commands to display files. Used by various commands to display files.
Defaults to Defaults to
@ -1963,6 +1997,10 @@ URL requests
(if not defined, use the standard (if not defined, use the standard
.Tn FTP .Tn FTP
protocol). protocol).
.Pp
.Em NOTE :
this is not used for interactive sessions, only for command-line
fetches.
.It Ev http_proxy .It Ev http_proxy
URL of URL of
.Tn HTTP .Tn HTTP
@ -1979,7 +2017,11 @@ and
.Ev http_proxy .Ev http_proxy
may be incompatible with other programs that use it may be incompatible with other programs that use it
(such as (such as
.Xr lynx 1 ). .Xr lynx 1 ) .
.Pp
.Em NOTE :
this is not used for interactive sessions, only for command-line
fetches.
.It Ev no_proxy .It Ev no_proxy
A space or comma separated list of hosts (or domains) for which A space or comma separated list of hosts (or domains) for which
proxying is not to be used. proxying is not to be used.
@ -2019,7 +2061,7 @@ and other enhancements over the standard
were implemented in were implemented in
.Nx 1.3 .Nx 1.3
and later releases and later releases
by Luke Mewburn <lukem@netbsd.org>. by Luke Mewburn \*[Lt]lukem@netbsd.org\*[Gt].
.Pp .Pp
IPv6 support was added by the WIDE/KAME project IPv6 support was added by the WIDE/KAME project
(but may not be present in all non-NetBSD versions of this program, depending (but may not be present in all non-NetBSD versions of this program, depending

View File

@ -1,7 +1,7 @@
/* $NetBSD: ftp.c,v 1.109 2000/09/28 12:29:24 lukem Exp $ */ /* $NetBSD: ftp.c,v 1.120 2002/06/05 10:20:49 lukem Exp $ */
/*- /*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc. * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -192,8 +192,9 @@ hookup(char *host, char *port)
if (res0->ai_next) /* if we have multiple possibilities */ if (res0->ai_next) /* if we have multiple possibilities */
#endif #endif
{ {
getnameinfo(res->ai_addr, res->ai_addrlen, if (getnameinfo(res->ai_addr, res->ai_addrlen,
hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST); hbuf, sizeof(hbuf), NULL, 0, NI_NUMERICHOST))
strlcpy(hbuf, "?", sizeof(hbuf));
fprintf(ttyout, "Trying %s...\n", hbuf); fprintf(ttyout, "Trying %s...\n", hbuf);
} }
((struct sockaddr_in *)res->ai_addr)->sin_port = htons(portnum); ((struct sockaddr_in *)res->ai_addr)->sin_port = htons(portnum);
@ -209,9 +210,10 @@ hookup(char *host, char *port)
if (error) { if (error) {
/* this "if" clause is to prevent print warning twice */ /* this "if" clause is to prevent print warning twice */
if (res->ai_next) { if (res->ai_next) {
getnameinfo(res->ai_addr, res->ai_addrlen, if (getnameinfo(res->ai_addr, res->ai_addrlen,
hbuf, sizeof(hbuf), NULL, 0, hbuf, sizeof(hbuf), NULL, 0,
NI_NUMERICHOST); NI_NUMERICHOST))
strlcpy(hbuf, "?", sizeof(hbuf));
warn("connect to address %s", hbuf); warn("connect to address %s", hbuf);
} }
cause = "connect"; cause = "connect";
@ -703,7 +705,7 @@ sendrequest(const char *cmd, const char *local, const char *remote,
} }
if (command("REST " LLF, (LLT)restart_point) != CONTINUE) if (command("REST " LLF, (LLT)restart_point) != CONTINUE)
goto cleanupsend; goto cleanupsend;
lmode = "r+w"; lmode = "r+";
} }
if (remote) { if (remote) {
if (command("%s %s", cmd, remote) != PRELIM) if (command("%s %s", cmd, remote) != PRELIM)
@ -1178,7 +1180,7 @@ recvrequest(const char *cmd, const char *local, const char *remote,
bytes++; bytes++;
contin2: ; contin2: ;
} }
break2: break2:
if (hash && (!progress || filesize < 0)) { if (hash && (!progress || filesize < 0)) {
if (bytes < hashbytes) if (bytes < hashbytes)
(void)putc('#', ttyout); (void)putc('#', ttyout);
@ -1300,7 +1302,8 @@ initconn(void)
switch (data_addr.su_family) { switch (data_addr.su_family) {
case AF_INET: case AF_INET:
if (epsv4 && !epsv4bad) { if (epsv4 && !epsv4bad) {
result = command(pasvcmd = "EPSV"); pasvcmd = "EPSV";
result = command("EPSV");
if (!connected) if (!connected)
return (1); return (1);
/* /*
@ -1322,14 +1325,16 @@ initconn(void)
} }
} }
if (result != COMPLETE) { if (result != COMPLETE) {
result = command(pasvcmd = "PASV"); pasvcmd = "PASV";
result = command("PASV");
if (!connected) if (!connected)
return (1); return (1);
} }
break; break;
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
result = command(pasvcmd = "EPSV"); pasvcmd = "EPSV";
result = command("EPSV");
if (!connected) if (!connected)
return (1); return (1);
/* this code is to be friendly with broken BSDI ftpd */ /* this code is to be friendly with broken BSDI ftpd */
@ -1339,8 +1344,10 @@ initconn(void)
ttyout); ttyout);
result = COMPLETE + 1; result = COMPLETE + 1;
} }
if (result != COMPLETE) if (result != COMPLETE) {
result = command(pasvcmd = "LPSV"); pasvcmd = "LPSV";
result = command("LPSV");
}
if (!connected) if (!connected)
return (1); return (1);
break; break;
@ -1573,10 +1580,9 @@ initconn(void)
warn("listen"); warn("listen");
if (sendport) { if (sendport) {
#ifdef INET6 char hname[NI_MAXHOST], sname[NI_MAXSERV];
char hname[INET6_ADDRSTRLEN];
int af; int af;
#endif struct sockinet tmp;
switch (data_addr.su_family) { switch (data_addr.su_family) {
case AF_INET: case AF_INET:
@ -1587,14 +1593,20 @@ initconn(void)
/* FALLTHROUGH */ /* FALLTHROUGH */
#ifdef INET6 #ifdef INET6
case AF_INET6: case AF_INET6:
#endif
af = (data_addr.su_family == AF_INET) ? 1 : 2; af = (data_addr.su_family == AF_INET) ? 1 : 2;
if (getnameinfo((struct sockaddr *)&data_addr.si_su, tmp = data_addr;
data_addr.su_len, hname, sizeof(hname), NULL, 0, #ifdef INET6
NI_NUMERICHOST)) { if (tmp.su_family == AF_INET6)
tmp.si_su.su_sin6.sin6_scope_id = 0;
#endif
if (getnameinfo((struct sockaddr *)&tmp.si_su,
tmp.su_len, hname, sizeof(hname), sname,
sizeof(sname), NI_NUMERICHOST | NI_NUMERICSERV)) {
result = ERROR; result = ERROR;
} else { } else {
result = command("EPRT |%d|%s|%d|", af, hname, result = command("EPRT |%d|%s|%s|", af, hname,
ntohs(data_addr.su_port)); sname);
if (!connected) if (!connected)
return (1); return (1);
if (result != COMPLETE) { if (result != COMPLETE) {
@ -1606,7 +1618,6 @@ initconn(void)
} }
} }
break; break;
#endif
default: default:
result = COMPLETE + 1; result = COMPLETE + 1;
break; break;

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
/* $NetBSD: ftp_var.h,v 1.58 2000/08/01 22:47:28 lukem Exp $ */ /* $NetBSD: ftp_var.h,v 1.62 2001/12/26 09:40:16 lukem Exp $ */
/*- /*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc. * Copyright (c) 1996-2001 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -308,7 +308,9 @@ GLOBAL int macnum; /* number of defined macros */
GLOBAL struct macel macros[16]; GLOBAL struct macel macros[16];
GLOBAL char macbuf[4096]; GLOBAL char macbuf[4096];
GLOBAL char home[MAXPATHLEN]; /* home directory (for lcd) */ GLOBAL char *localhome; /* local home directory */
GLOBAL char *localname; /* local user name */
GLOBAL char netrc[MAXPATHLEN]; /* path to .netrc file */
GLOBAL char reply_string[BUFSIZ]; /* first line of previous reply */ GLOBAL char reply_string[BUFSIZ]; /* first line of previous reply */
GLOBAL void (*reply_callback)(const char *); GLOBAL void (*reply_callback)(const char *);
/* /*
@ -325,8 +327,6 @@ GLOBAL int data;
extern struct cmd cmdtab[]; extern struct cmd cmdtab[];
extern struct option optiontab[]; extern struct option optiontab[];
extern char *__progname; /* from crt0.o */
#define EMPTYSTRING(x) ((x) == NULL || (*(x) == '\0')) #define EMPTYSTRING(x) ((x) == NULL || (*(x) == '\0'))
#define FREEPTR(x) if ((x) != NULL) { free(x); (x) = NULL; } #define FREEPTR(x) if ((x) != NULL) { free(x); (x) = NULL; }
@ -344,6 +344,15 @@ extern char *__progname; /* from crt0.o */
# define ULLT unsigned long # define ULLT unsigned long
# define STRTOLL(x,y,z) strtol(x,y,z) # define STRTOLL(x,y,z) strtol(x,y,z)
#else #else
#if HAVE_PRINTF_QD
# define LLF "%qd"
# define LLFP(x) "%" x "qd"
# define LLT long long
# define ULLF "%qu"
# define ULLFP(x) "%" x "qu"
# define ULLT unsigned long long
# define STRTOLL(x,y,z) strtoll(x,y,z)
#else
# define LLF "%lld" # define LLF "%lld"
# define LLFP(x) "%" x "lld" # define LLFP(x) "%" x "lld"
# define LLT long long # define LLT long long
@ -352,3 +361,4 @@ extern char *__progname; /* from crt0.o */
# define ULLT unsigned long long # define ULLT unsigned long long
# define STRTOLL(x,y,z) strtoll(x,y,z) # define STRTOLL(x,y,z) strtoll(x,y,z)
#endif #endif
#endif

View File

@ -1,7 +1,7 @@
/* $NetBSD: main.c,v 1.73 2000/07/18 07:16:56 lukem Exp $ */ /* $NetBSD: main.c,v 1.82 2002/06/05 13:51:54 lukem Exp $ */
/*- /*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc. * Copyright (c) 1996-2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -112,8 +112,6 @@
#define NO_PROXY "no_proxy" /* env var with list of non-proxied #define NO_PROXY "no_proxy" /* env var with list of non-proxied
* hosts, comma or space separated */ * hosts, comma or space separated */
char * __progname;
static void setupoption(char *, char *, char *); static void setupoption(char *, char *, char *);
int main(int, char *[]); int main(int, char *[]);
@ -121,15 +119,14 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int ch, rval; int ch, rval;
struct passwd *pw = NULL; struct passwd *pw;
char *cp, *ep, *anonuser, *anonpass, *upload_path; char *cp, *ep, *anonuser, *anonpass, *upload_path;
int dumbterm, s, len, isupload; int dumbterm, s, len, isupload;
__progname = strrchr(argv[0], '/'); #if 0 /* XXX */
if (__progname == NULL) setlocale(LC_ALL, "");
__progname = argv[0]; #endif
else setprogname(argv[0]);
__progname++;
ftpport = "ftp"; ftpport = "ftp";
httpport = "http"; httpport = "http";
@ -173,6 +170,11 @@ main(int argc, char *argv[])
reply_callback = NULL; reply_callback = NULL;
family = AF_UNSPEC; family = AF_UNSPEC;
netrc[0] = '\0';
cp = getenv("NETRC");
if (cp != NULL && strlcpy(netrc, cp, sizeof(netrc)) >= sizeof(netrc))
errx(1, "$NETRC `%s': %s", cp, strerror(ENAMETOOLONG));
/* /*
* Get the default socket buffer sizes if we don't already have them. * Get the default socket buffer sizes if we don't already have them.
* It doesn't matter which socket we do this to, because on the first * It doesn't matter which socket we do this to, because on the first
@ -218,10 +220,10 @@ main(int argc, char *argv[])
warnx("unknown $FTPMODE '%s'; using defaults", cp); warnx("unknown $FTPMODE '%s'; using defaults", cp);
} }
if (strcmp(__progname, "pftp") == 0) { if (strcmp(getprogname(), "pftp") == 0) {
passivemode = 1; passivemode = 1;
activefallback = 0; activefallback = 0;
} else if (strcmp(__progname, "gate-ftp") == 0) } else if (strcmp(getprogname(), "gate-ftp") == 0)
gatemode = 1; gatemode = 1;
gateserver = getenv("FTPSERVER"); gateserver = getenv("FTPSERVER");
@ -256,14 +258,18 @@ main(int argc, char *argv[])
} }
} }
while ((ch = getopt(argc, argv, "46Aadefgino:pP:r:RtT:u:vV")) != -1) { while ((ch = getopt(argc, argv, "46AadefginN:o:pP:r:RtT:u:vV")) != -1) {
switch (ch) { switch (ch) {
case '4': case '4':
family = AF_INET; family = AF_INET;
break; break;
case '6': case '6':
#ifdef INET6
family = AF_INET6; family = AF_INET6;
#else
warnx("INET6 support is not available; ignoring -6");
#endif
break; break;
case 'A': case 'A':
@ -302,6 +308,13 @@ main(int argc, char *argv[])
autologin = 0; autologin = 0;
break; break;
case 'N':
if (strlcpy(netrc, optarg, sizeof(netrc))
>= sizeof(netrc))
errx(1, "%s: %s", optarg,
strerror(ENAMETOOLONG));
break;
case 'o': case 'o':
outfile = optarg; outfile = optarg;
if (strcmp(outfile, "-") == 0) if (strcmp(outfile, "-") == 0)
@ -387,21 +400,38 @@ main(int argc, char *argv[])
proxy = 0; /* proxy not active */ proxy = 0; /* proxy not active */
crflag = 1; /* strip c.r. on ascii gets */ crflag = 1; /* strip c.r. on ascii gets */
sendport = -1; /* not using ports */ sendport = -1; /* not using ports */
/* /*
* Set up the home directory in case we're globbing. * Cache the user name and home directory.
*/ */
localhome = NULL;
localname = NULL;
anonuser = "anonymous";
cp = getenv("HOME");
if (! EMPTYSTRING(cp))
localhome = xstrdup(cp);
pw = NULL;
cp = getlogin(); cp = getlogin();
if (cp != NULL) if (cp != NULL)
pw = getpwnam(cp); pw = getpwnam(cp);
if (pw == NULL) if (pw == NULL)
pw = getpwuid(getuid()); pw = getpwuid(getuid());
if (pw != NULL) { if (pw != NULL) {
(void)strlcpy(home, pw->pw_dir, sizeof(home)); if (localhome == NULL && !EMPTYSTRING(pw->pw_dir))
anonuser = pw->pw_name; localhome = xstrdup(pw->pw_dir);
} else { localname = xstrdup(pw->pw_name);
(void)strlcpy(home, "/", sizeof(home)); anonuser = localname;
anonuser = "anonymous";
} }
if (netrc[0] == '\0' && localhome != NULL) {
if (strlcpy(netrc, localhome, sizeof(netrc)) >= sizeof(netrc) ||
strlcat(netrc, "/.netrc", sizeof(netrc)) >= sizeof(netrc)) {
warnx("%s/.netrc: %s", localhome,
strerror(ENAMETOOLONG));
netrc[0] = '\0';
}
}
if (localhome == NULL)
localhome = xstrdup("/");
/* /*
* Every anonymous FTP server I've encountered will accept the * Every anonymous FTP server I've encountered will accept the
@ -467,7 +497,8 @@ main(int argc, char *argv[])
user = host; user = host;
host = cp + 1; host = cp + 1;
} }
xargv[0] = __progname; /* XXX discards const */
xargv[0] = (char *)getprogname();
xargv[1] = host; xargv[1] = host;
xargv[2] = argv[1]; xargv[2] = argv[1];
xargv[3] = NULL; xargv[3] = NULL;
@ -633,7 +664,7 @@ cmdscanner(void)
* such commands as invalid. * such commands as invalid.
*/ */
if (strchr(margv[0], ':') != NULL || if (strchr(margv[0], ':') != NULL ||
el_parse(el, margc, margv) != 0) el_parse(el, margc, (const char **)margv) != 0)
#endif /* !NO_EDITCOMPLETE */ #endif /* !NO_EDITCOMPLETE */
fputs("?Invalid command.\n", ttyout); fputs("?Invalid command.\n", ttyout);
continue; continue;
@ -643,6 +674,7 @@ cmdscanner(void)
continue; continue;
} }
confirmrest = 0; confirmrest = 0;
margv[0] = c->c_name;
(*c->c_handler)(margc, margv); (*c->c_handler)(margc, margv);
if (bell && c->c_bell) if (bell && c->c_bell)
(void)putc('\007', ttyout); (void)putc('\007', ttyout);
@ -908,7 +940,7 @@ help(int argc, char *argv[])
cmd, arg); cmd, arg);
else { else {
if (isusage) { if (isusage) {
nargv[0] = arg; nargv[0] = c->c_name;
(*c->c_handler)(0, nargv); (*c->c_handler)(0, nargv);
} else } else
fprintf(ttyout, "%-*s\t%s\n", HELPINDENT, fprintf(ttyout, "%-*s\t%s\n", HELPINDENT,
@ -964,11 +996,13 @@ setupoption(char *name, char *value, char *defaultvalue)
void void
usage(void) usage(void)
{ {
const char *progname = getprogname();
(void)fprintf(stderr, (void)fprintf(stderr,
"usage: %s [-46AadefginpRtvV] [-o outfile] [-P port] [-r retry]\n" "usage: %s [-46AadefginpRtvV] [-N netrc] [-o outfile] [-P port] [-r retry]\n"
" [-T dir,max[,inc][[user@]host [port]]] [host:path[/]]\n" " [-T dir,max[,inc][[user@]host [port]]] [host:path[/]]\n"
" [file:///file] [ftp://[user[:pass]@]host[:port]/path[/]]\n" " [file:///file] [ftp://[user[:pass]@]host[:port]/path[/]]\n"
" [http://[user[:pass]@]host[:port]/path] [...]\n" " [http://[user[:pass]@]host[:port]/path] [...]\n"
" %s -u url file [...]\n", __progname, __progname); " %s -u url file [...]\n", progname, progname);
exit(1); exit(1);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: ruserpass.c,v 1.27 2000/07/18 06:47:02 lukem Exp $ */ /* $NetBSD: ruserpass.c,v 1.28 2000/11/15 00:11:04 lukem Exp $ */
/* /*
* Copyright (c) 1985, 1993, 1994 * Copyright (c) 1985, 1993, 1994
@ -66,25 +66,19 @@ static struct toktab {
int int
ruserpass(const char *host, const char **aname, const char **apass, ruserpass(const char *host, const char **aname, const char **apass,
const char **aacct) const char **aacct)
{ {
char *hdir, buf[BUFSIZ], *tmp; char *tmp;
char myname[MAXHOSTNAMELEN + 1], *mydomain; char myname[MAXHOSTNAMELEN + 1], *mydomain;
int t, i, c, usedefault = 0; int t, i, c, usedefault = 0;
struct stat stb; struct stat stb;
hdir = getenv("HOME"); if (netrc[0] == '\0')
if (hdir == NULL)
hdir = ".";
if (strlcpy(buf, hdir, sizeof(buf)) >= sizeof(buf) ||
strlcat(buf, "/.netrc", sizeof(buf)) >= sizeof(buf)) {
warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG));
return (0); return (0);
} cfile = fopen(netrc, "r");
cfile = fopen(buf, "r");
if (cfile == NULL) { if (cfile == NULL) {
if (errno != ENOENT) if (errno != ENOENT)
warn("%s", buf); warn("%s", netrc);
return (0); return (0);
} }
if (gethostname(myname, sizeof(myname)) < 0) if (gethostname(myname, sizeof(myname)) < 0)

View File

@ -1,7 +1,7 @@
/* $NetBSD: util.c,v 1.102 2000/09/08 11:54:53 lukem Exp $ */ /* $NetBSD: util.c,v 1.107 2002/06/05 10:20:50 lukem Exp $ */
/*- /*-
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc. * Copyright (c) 1997-2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -340,7 +340,6 @@ ftp_login(const char *host, const char *user, const char *pass)
{ {
char tmp[80]; char tmp[80];
const char *acct; const char *acct;
struct passwd *pw;
int n, aflag, rval, freeuser, freepass, freeacct; int n, aflag, rval, freeuser, freepass, freeacct;
acct = NULL; acct = NULL;
@ -371,12 +370,8 @@ ftp_login(const char *host, const char *user, const char *pass)
} }
while (user == NULL) { while (user == NULL) {
const char *myname = getlogin(); if (localname)
fprintf(ttyout, "Name (%s:%s): ", host, localname);
if (myname == NULL && (pw = getpwuid(getuid())) != NULL)
myname = pw->pw_name;
if (myname)
fprintf(ttyout, "Name (%s:%s): ", host, myname);
else else
fprintf(ttyout, "Name (%s): ", host); fprintf(ttyout, "Name (%s): ", host);
*tmp = '\0'; *tmp = '\0';
@ -389,7 +384,7 @@ ftp_login(const char *host, const char *user, const char *pass)
tmp[strlen(tmp) - 1] = '\0'; tmp[strlen(tmp) - 1] = '\0';
freeuser = 0; freeuser = 0;
if (*tmp == '\0') if (*tmp == '\0')
user = myname; user = localname;
else else
user = tmp; user = tmp;
} }
@ -502,7 +497,7 @@ remglob(char *argv[], int doswitch, char **errbuf)
static char buf[MAXPATHLEN]; static char buf[MAXPATHLEN];
static FILE *ftemp = NULL; static FILE *ftemp = NULL;
static char **args; static char **args;
int oldverbose, oldhash, fd, len; int oldverbose, oldhash, oldprogress, fd, len;
char *cp, *mode; char *cp, *mode;
if (!mflag || !connected) { if (!mflag || !connected) {
@ -536,7 +531,9 @@ remglob(char *argv[], int doswitch, char **errbuf)
oldverbose = verbose; oldverbose = verbose;
verbose = (errbuf != NULL) ? -1 : 0; verbose = (errbuf != NULL) ? -1 : 0;
oldhash = hash; oldhash = hash;
oldprogress = progress;
hash = 0; hash = 0;
progress = 0;
if (doswitch) if (doswitch)
pswitch(!proxy); pswitch(!proxy);
for (mode = "w"; *++argv != NULL; mode = "a") for (mode = "w"; *++argv != NULL; mode = "a")
@ -549,6 +546,7 @@ remglob(char *argv[], int doswitch, char **errbuf)
pswitch(!proxy); pswitch(!proxy);
verbose = oldverbose; verbose = oldverbose;
hash = oldhash; hash = oldhash;
progress = oldprogress;
ftemp = fopen(temp, "r"); ftemp = fopen(temp, "r");
(void)unlink(temp); (void)unlink(temp);
if (ftemp == NULL) { if (ftemp == NULL) {
@ -872,9 +870,9 @@ progressmeter(int flag)
lastsize = restart_point; lastsize = restart_point;
} }
#ifndef NO_PROGRESS #ifndef NO_PROGRESS
len = 0; if (!progress)
if (!progress || filesize <= 0)
return; return;
len = 0;
/* /*
* print progress bar only if we are foreground process. * print progress bar only if we are foreground process.
@ -891,20 +889,23 @@ progressmeter(int flag)
wait.tv_sec = 0; wait.tv_sec = 0;
} }
ratio = (int)((double)cursize * 100.0 / (double)filesize); len += snprintf(buf + len, BUFLEFT, "\r");
ratio = MAX(ratio, 0); if (filesize > 0) {
ratio = MIN(ratio, 100); ratio = (int)((double)cursize * 100.0 / (double)filesize);
len += snprintf(buf + len, BUFLEFT, "\r%3d%% ", ratio); ratio = MAX(ratio, 0);
ratio = MIN(ratio, 100);
len += snprintf(buf + len, BUFLEFT, "%3d%% ", ratio);
/* /*
* calculate the length of the `*' bar, ensuring that * calculate the length of the `*' bar, ensuring that
* the number of stars won't exceed the buffer size * the number of stars won't exceed the buffer size
*/ */
barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD; barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD;
if (barlength > 0) { if (barlength > 0) {
i = barlength * ratio / 100; i = barlength * ratio / 100;
len += snprintf(buf + len, BUFLEFT, len += snprintf(buf + len, BUFLEFT,
"|%.*s%*s|", i, stars, barlength - i, ""); "|%.*s%*s|", i, stars, barlength - i, "");
}
} }
abbrevsize = cursize; abbrevsize = cursize;
@ -932,24 +933,39 @@ progressmeter(int flag)
(int)((bytespersec % 1024) * 100 / 1024), (int)((bytespersec % 1024) * 100 / 1024),
prefixes[i]); prefixes[i]);
if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) { if (filesize > 0) {
len += snprintf(buf + len, BUFLEFT, " --:-- ETA"); if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) {
} else if (wait.tv_sec >= STALLTIME) {
len += snprintf(buf + len, BUFLEFT, " - stalled -");
} else {
remaining = (int)
((filesize - restart_point) / (bytes / elapsed) - elapsed);
if (remaining >= 100 * SECSPERHOUR)
len += snprintf(buf + len, BUFLEFT, " --:-- ETA"); len += snprintf(buf + len, BUFLEFT, " --:-- ETA");
else { } else if (flag == 1) {
i = remaining / SECSPERHOUR; i = elapsed / SECSPERHOUR;
if (i) if (i)
len += snprintf(buf + len, BUFLEFT, "%2d:", i); len += snprintf(buf + len, BUFLEFT, "%2d:", i);
else else
len += snprintf(buf + len, BUFLEFT, " "); len += snprintf(buf + len, BUFLEFT, " ");
i = remaining % SECSPERHOUR; i = (int)elapsed % SECSPERHOUR;
len += snprintf(buf + len, BUFLEFT, len += snprintf(buf + len, BUFLEFT,
"%02d:%02d ETA", i / 60, i % 60); "%02d:%02d ", i / 60, i % 60);
} else if (wait.tv_sec >= STALLTIME) {
len += snprintf(buf + len, BUFLEFT, " - stalled -");
} else {
remaining = (int)
((filesize - restart_point) / (bytes / elapsed) -
elapsed);
if (remaining >= 100 * SECSPERHOUR)
len += snprintf(buf + len, BUFLEFT,
" --:-- ETA");
else {
i = remaining / SECSPERHOUR;
if (i)
len += snprintf(buf + len, BUFLEFT,
"%2d:", i);
else
len += snprintf(buf + len, BUFLEFT,
" ");
i = remaining % SECSPERHOUR;
len += snprintf(buf + len, BUFLEFT,
"%02d:%02d ETA", i / 60, i % 60);
}
} }
} }
if (flag == 1) if (flag == 1)
@ -1166,7 +1182,7 @@ controlediting(void)
HistEvent ev; HistEvent ev;
int editmode; int editmode;
el = el_init(__progname, stdin, ttyout, stderr); el = el_init(getprogname(), stdin, ttyout, stderr);
/* init editline */ /* init editline */
hist = history_init(); /* init the builtin history */ hist = history_init(); /* init the builtin history */
history(hist, &ev, H_SETSIZE, 100);/* remember 100 events */ history(hist, &ev, H_SETSIZE, 100);/* remember 100 events */

View File

@ -1,6 +1,6 @@
/* $NetBSD: version.h,v 1.21 2000/09/28 12:29:24 lukem Exp $ */ /* $NetBSD: version.h,v 1.29 2002/06/05 10:20:51 lukem Exp $ */
/*- /*-
* Copyright (c) 1999, 2000 The NetBSD Foundation, Inc. * Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
* All rights reserved. * All rights reserved.
* *
* This code is derived from software contributed to The NetBSD Foundation * This code is derived from software contributed to The NetBSD Foundation
@ -40,5 +40,5 @@
#endif #endif
#ifndef FTP_VERSION #ifndef FTP_VERSION
#define FTP_VERSION "20000928" #define FTP_VERSION "20020605"
#endif #endif

View File

@ -1,11 +1,21 @@
$Id: todo,v 1.25 2000/09/19 22:25:50 lukem Exp $ $Id: todo,v 1.30 2002/06/10 08:08:53 lukem Exp $
update NEWS, README, ...
at end of configure, show summary of options used and features found
if socks is defined, disable ipv6 and use own getaddrinfo()/getnameinfo()
(for tron)
add locale autoconf checks
AC_CHECK_SIZEOF(off_t, 0) doesn't work on FreeBSD 4.0 because the
test doesn't include <sys/types.h>. fix autoconf?
in configure, check for ansi c compiler and barf if it fails in configure, check for ansi c compiler and barf if it fails
check if we need #defines for memcpy() et al check if we need #defines for memcpy() et al
we check for fparseln twice; once in libutil and once in general
check for utimes() decls [which system?] check for utimes() decls [which system?]
possibly install editline.3 and editrc.5 possibly install editline.3 and editrc.5