Copy lukemftp to its new home, tnftp. I'm doing this in stages so as to
not confuse the CVS exporter.
This commit is contained in:
parent
95eeb54f18
commit
f3c9355897
47
contrib/tnftp/COPYING
Normal file
47
contrib/tnftp/COPYING
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
Copyright 1999, 2000 Luke Mewburn <lukem@netbsd.org>. All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
1. Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer in the
|
||||||
|
documentation and/or other materials provided with the distribution.
|
||||||
|
3. All advertising materials mentioning features or use of this software
|
||||||
|
must display the following acknowledgement:
|
||||||
|
This product includes software developed by Luke Mewburn.
|
||||||
|
4. The name of the author may not be used to endorse or promote products
|
||||||
|
derived from this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||||
|
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
This product also contains software developed by other people, and you
|
||||||
|
are advised to read the various source files to read the full details
|
||||||
|
of the other licenses. Those licenses also require the following
|
||||||
|
acknowledgements:
|
||||||
|
|
||||||
|
This product includes software developed by the NetBSD Foundation,
|
||||||
|
Inc. and its contributors. Those contributors include:
|
||||||
|
- Jaromir Dolecek
|
||||||
|
- Klaus Klein
|
||||||
|
- Luke Mewburn
|
||||||
|
- Jason R. Thorpe of the Numerical Aerospace Simulation
|
||||||
|
Facility, NASA Ames Research Center.
|
||||||
|
|
||||||
|
This product includes software developed by the University of
|
||||||
|
California, Berkeley and its contributors. Those contributors include:
|
||||||
|
- Christos Zoulas of Cornell University.
|
||||||
|
- Guido van Rossum.
|
||||||
|
|
||||||
|
This product includes software developed by Christos Zoulas.
|
||||||
|
|
1084
contrib/tnftp/ChangeLog
Normal file
1084
contrib/tnftp/ChangeLog
Normal file
File diff suppressed because it is too large
Load Diff
64
contrib/tnftp/FreeBSD-patchset
Normal file
64
contrib/tnftp/FreeBSD-patchset
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
diff -ru src.orig/cmds.c src/cmds.c
|
||||||
|
--- src.orig/cmds.c Sun Jun 15 22:11:43 2003
|
||||||
|
+++ src/cmds.c Sun Jun 15 21:46:37 2003
|
||||||
|
@@ -131,6 +131,7 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
+#include <libutil.h>
|
||||||
|
|
||||||
|
#include "ftp_var.h"
|
||||||
|
#include "version.h"
|
||||||
|
diff -ru src.orig/fetch.c src/fetch.c
|
||||||
|
--- src.orig/fetch.c Sun Jun 15 22:11:43 2003
|
||||||
|
+++ src/fetch.c Sun Jun 15 21:46:53 2003
|
||||||
|
@@ -69,6 +69,7 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
+#include <libutil.h>
|
||||||
|
|
||||||
|
#include "ftp_var.h"
|
||||||
|
#include "version.h"
|
||||||
|
Only in src: ftp.cat1
|
||||||
|
diff -ru src.orig/progressbar.c src/progressbar.c
|
||||||
|
--- src.orig/progressbar.c Sun Jun 15 22:11:43 2003
|
||||||
|
+++ src/progressbar.c Sun Jun 15 21:50:48 2003
|
||||||
|
@@ -50,6 +50,7 @@
|
||||||
|
*/
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
+#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
@@ -57,10 +58,12 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <time.h>
|
||||||
|
-#include <tzfile.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "progressbar.h"
|
||||||
|
+
|
||||||
|
+#define SECSPERHOUR (60 * 60)
|
||||||
|
+#define SECSPERDAY ((long)60 * 60 * 24)
|
||||||
|
|
||||||
|
#if !defined(NO_PROGRESS)
|
||||||
|
/*
|
||||||
|
diff -ru src.orig/util.c src/util.c
|
||||||
|
--- src.orig/util.c Sun Jun 15 22:11:44 2003
|
||||||
|
+++ src/util.c Sun Jun 15 21:51:31 2003
|
||||||
|
@@ -101,10 +101,11 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <time.h>
|
||||||
|
-#include <tzfile.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "ftp_var.h"
|
||||||
|
+
|
||||||
|
+#define TM_YEAR_BASE 1900
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Connect to peer server and auto-login, if possible.
|
211
contrib/tnftp/INSTALL
Normal file
211
contrib/tnftp/INSTALL
Normal file
@ -0,0 +1,211 @@
|
|||||||
|
INSTALLATION INTRODUCTION
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
This file describes how to compile and install lukemftp on your
|
||||||
|
system.
|
||||||
|
|
||||||
|
============================================
|
||||||
|
= =
|
||||||
|
= NOTE: You will need an ANSI C compiler. =
|
||||||
|
= =
|
||||||
|
============================================
|
||||||
|
|
||||||
|
|
||||||
|
For most systems, execute the following to compile and install
|
||||||
|
lukemftp:
|
||||||
|
./configure
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
A preformatted manual page (src/ftp.cat1) is also installed. If
|
||||||
|
you wish to install the source (src/ftp.1), ensure that your system
|
||||||
|
has up-to-date mandoc macros. groff ships with this macro suite,
|
||||||
|
but it has bugs. Try:
|
||||||
|
ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/tmac/
|
||||||
|
for a more recent version.
|
||||||
|
|
||||||
|
|
||||||
|
CONFIGURATION OPTIONS
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
lukemftp is configured using an `autoconf' generated `configure'
|
||||||
|
script. `configure' supports the following options:
|
||||||
|
|
||||||
|
* The standard `autoconf configure' options, including:
|
||||||
|
--prefix=PREFIX install architecture-independent files in PREFIX
|
||||||
|
[/usr/local]
|
||||||
|
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
|
||||||
|
[same as prefix]
|
||||||
|
--srcdir=DIR find the sources in DIR [configure dir or ..]
|
||||||
|
BSD or GNU make may be required for this to work.
|
||||||
|
|
||||||
|
* Specific options:
|
||||||
|
--enable-editcomplete Turn on command line editing and completion.
|
||||||
|
--disable-editcomplete Turn off command line editing and completion
|
||||||
|
[default: enabled].
|
||||||
|
--enable-ipv6 Enable IPv6 support (if your OS supports it)
|
||||||
|
--disable-ipv6 Disable IPv6 support (even if your OS supports it.)
|
||||||
|
[default: enabled].
|
||||||
|
--with-socks Compile with SOCKS firewall traversal support.
|
||||||
|
--with-socks5[=PATH] Compile with SOCKS5 firewall traversal support.
|
||||||
|
--with-socks4[=PATH] Compile with SOCKS4 firewall traversal support.
|
||||||
|
|
||||||
|
The following environment variables can be set to override various
|
||||||
|
compiler related settings.
|
||||||
|
CC=compiler specify name of the C compiler (default: gcc or cc)
|
||||||
|
CFLAGS=flags specify flags to C compiler (default: -O -g or just -O)
|
||||||
|
LDFLAGS=flags specify flags to linker (default: none)
|
||||||
|
|
||||||
|
This can be achieved with:
|
||||||
|
env CC="compiler" CFLAGS="flags" LDFLAGS="flags" ./configure
|
||||||
|
|
||||||
|
|
||||||
|
============================================
|
||||||
|
= =
|
||||||
|
= NOTE: You will need an ANSI C compiler. =
|
||||||
|
= =
|
||||||
|
============================================
|
||||||
|
|
||||||
|
|
||||||
|
PLATFORM SPECIFIC NOTES
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
The following platforms & compilers have been tested:
|
||||||
|
|
||||||
|
- AIX 4.1.5:
|
||||||
|
- AIX 4.2.1:
|
||||||
|
- AIX 4.3.3:
|
||||||
|
- Compiler: xlc -qlanglvl=ansi
|
||||||
|
version: xlC 3.1.4.10 -- C for AIX Compiler
|
||||||
|
version: ibmcxx.cmp 3.6.6.6 -- IBM C and C++ Compilers
|
||||||
|
|
||||||
|
Configure with:
|
||||||
|
env CC="xlc" CFLAGS="-qlanglvl=ansi" ./configure
|
||||||
|
|
||||||
|
- BSD/OS 4.0.1 (x86)
|
||||||
|
- BSD/OS 4.1 (x86)
|
||||||
|
- BSD/OS 4.1 (sparc)
|
||||||
|
- BSD/OS 4.2 (x86)
|
||||||
|
- Compiler: /bin/cc
|
||||||
|
version: gcc 2.7.2.1
|
||||||
|
version: gcc version 2.95.2 19991024
|
||||||
|
|
||||||
|
- Digital UNIX 4.0b
|
||||||
|
- Digital UNIX 4.0d
|
||||||
|
- Digital UNIX 4.0f
|
||||||
|
- Compiler: cc -std
|
||||||
|
version: DEC C V5.2-036 on Digital UNIX V4.0 (Rev. 564)
|
||||||
|
version: DEC C V5.9-005 on Digital UNIX V4.0 (Rev. 1229)
|
||||||
|
|
||||||
|
Configure with
|
||||||
|
env CC="cc -std" ./configure
|
||||||
|
|
||||||
|
- Compiler: gcc
|
||||||
|
version: 2.95.1
|
||||||
|
|
||||||
|
- Digital UNIX 5.0
|
||||||
|
- Compiler: cc
|
||||||
|
version: Compaq C V6.1-011 on Digital UNIX V5.0 (Rev. 910)
|
||||||
|
|
||||||
|
- FreeBSD 3.4 (i386):
|
||||||
|
- FreeBSD 3.5 (i386):
|
||||||
|
- FreeBSD 4.1 (i386):
|
||||||
|
- Compiler: cc
|
||||||
|
version: gcc version 2.7.2.3
|
||||||
|
version: gcc version 2.95.2 19991024
|
||||||
|
|
||||||
|
- HP/UX 10.20:
|
||||||
|
- HP/UX 11.00:
|
||||||
|
- Compiler: /opt/ansic/bin/cc -Ae
|
||||||
|
version: A.10.32.03
|
||||||
|
|
||||||
|
Configure with
|
||||||
|
env CC="cc -Ae" ./configure
|
||||||
|
|
||||||
|
To generate code that will run on old architectures you
|
||||||
|
may need to add "+DAportable" to CC.
|
||||||
|
|
||||||
|
|
||||||
|
- IRIX 6.5.4
|
||||||
|
- IRIX 6.5.8
|
||||||
|
Compiler: /bin/cc
|
||||||
|
version: MIPSpro Compilers: Version 7.2.1
|
||||||
|
Compiler:
|
||||||
|
version: gcc version 2.95.2
|
||||||
|
|
||||||
|
- HP/UX 11.00:
|
||||||
|
- HP/UX 11.00 64 bit:
|
||||||
|
- Compiler: /opt/ansic/bin/cc -Ae
|
||||||
|
version: A.11.01.00
|
||||||
|
|
||||||
|
Configure with
|
||||||
|
env CC="cc -Ae" ./configure
|
||||||
|
|
||||||
|
- NetBSD 1.3.3 (i386)
|
||||||
|
Compiler: /usr/bin/cc
|
||||||
|
Compiler: /usr/bin/cc
|
||||||
|
|
||||||
|
Ignore warnings about ``passing arg 3 of `tputs' from
|
||||||
|
incompatible pointer type''.
|
||||||
|
|
||||||
|
- RedHat Linux 5.1 (?? i386)
|
||||||
|
- RedHat Linux 5.2 (?? i386)
|
||||||
|
- RedHat Linux 6.0 (Linux 2.2.10 i686)
|
||||||
|
- RedHat Linux 6.1 (Linux 2.2.5-15 i686)
|
||||||
|
- RedHat Linux 6.2 (Linux 2.2.16-3smp i686)
|
||||||
|
- Compiler: cc
|
||||||
|
version: egcs-1.1.2
|
||||||
|
|
||||||
|
- Slackware (Linux 2.0.35 i686)
|
||||||
|
- Compiler: cc
|
||||||
|
version: 2.7.2.3
|
||||||
|
|
||||||
|
- Solaris 2.6 (sparc)
|
||||||
|
- Solaris 7 (sparc)
|
||||||
|
- Compiler: /opt/SUNWspro/bin/cc
|
||||||
|
version: WorkShop Compilers 5.0
|
||||||
|
|
||||||
|
- Compiler: gcc
|
||||||
|
version: egcs-1.1.2
|
||||||
|
|
||||||
|
=============
|
||||||
|
= OLD NOTES =
|
||||||
|
=============
|
||||||
|
|
||||||
|
XXX: clean up to match reality
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
- RedHat Linux 5.0 (i386)
|
||||||
|
Compiler: cc
|
||||||
|
|
||||||
|
- Solaris 2.5 (sparc)
|
||||||
|
- Solaris 7 (x86)
|
||||||
|
Compiler: /opt/SUNWspro/bin/cc
|
||||||
|
version: SC3.0 15 Dec 1993
|
||||||
|
version: WorkShop Compilers 5.0
|
||||||
|
Compiler: gcc
|
||||||
|
version: egcs-1.1.2
|
||||||
|
version: gcc 2.8.1
|
||||||
|
version: gcc 2.95.1
|
||||||
|
|
||||||
|
- Solaris 7 (sparc) 64 bit
|
||||||
|
Compiler: /opt/SUNWspro/bin/cc -xarch=v9
|
||||||
|
version: WorkShop Compilers 5.0
|
||||||
|
|
||||||
|
- SunOS 4
|
||||||
|
Compiler: gcc -lresolv
|
||||||
|
version:
|
||||||
|
|
||||||
|
- SuSE Linux
|
||||||
|
Compiler: gcc
|
||||||
|
version:
|
||||||
|
|
||||||
|
/usr/bin/ftp on SuSE Linux 6.4 is this ftp client.
|
||||||
|
|
||||||
|
May need `gcc -L/usr/lib/termcap' if tgetent() et al aren't found.
|
||||||
|
|
||||||
|
- Ultrix 4.5
|
||||||
|
Compiler: cc
|
||||||
|
version: MIPS C Compiler 3.0
|
||||||
|
Compiler: gcc
|
||||||
|
version: 2.7.2.2
|
33
contrib/tnftp/Makefile.in
Normal file
33
contrib/tnftp/Makefile.in
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# $Id: Makefile.in,v 1.6 1999/11/13 01:18:22 lukem Exp $
|
||||||
|
#
|
||||||
|
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
@SET_MAKE@
|
||||||
|
|
||||||
|
|
||||||
|
SUBDIRS = libedit libukem src
|
||||||
|
|
||||||
|
all: ftp
|
||||||
|
|
||||||
|
ftp: @LIBEDIT@ @LIBUKEM@
|
||||||
|
( cd src; ${MAKE} )
|
||||||
|
|
||||||
|
libedit.a:
|
||||||
|
( cd libedit; ${MAKE} )
|
||||||
|
|
||||||
|
libukem.a:
|
||||||
|
( cd libukem; ${MAKE} )
|
||||||
|
|
||||||
|
install clean:
|
||||||
|
@for i in ${SUBDIRS}; do \
|
||||||
|
( echo "$@ ===> $$i" ; cd $$i ; ${MAKE} $@ ); \
|
||||||
|
done
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
@for i in ${SUBDIRS}; do \
|
||||||
|
( echo "$@ ===> $$i" ; cd $$i ; ${MAKE} $@ ); \
|
||||||
|
done
|
||||||
|
rm -f Makefile config.cache config.log config.status config.h
|
84
contrib/tnftp/NEWS
Normal file
84
contrib/tnftp/NEWS
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
This is a brief description of the new features and fixes added to
|
||||||
|
lukemftp-1.5 since the release of lukemftp-1.4. As always, the manual
|
||||||
|
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||||
|
|
||||||
|
* Add new commands:
|
||||||
|
features list remote features supported by servers
|
||||||
|
mlsd machine parseable directory listing
|
||||||
|
mlst machine parseable file listing
|
||||||
|
remopts set options on remote features
|
||||||
|
|
||||||
|
These require support in the remote server for the ftp extensions
|
||||||
|
described in RFC 2389 and draft-ietf-ftpext-mlst-11.
|
||||||
|
|
||||||
|
* Fix support for the --program-prefix and --program-suffix configure
|
||||||
|
options.
|
||||||
|
|
||||||
|
---
|
||||||
|
This is a brief description of the new features and fixes added to
|
||||||
|
lukemftp-1.4 since the release of lukemftp-1.3. As always, the manual
|
||||||
|
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||||
|
|
||||||
|
* Fix compilation problems on various non 4.4BSD derived platforms which
|
||||||
|
support IPv6, and on Linux systems which have strdup() as a macro.
|
||||||
|
|
||||||
|
* During auto-fetch, don't attempt to autologin a second time if the first
|
||||||
|
time failed.
|
||||||
|
|
||||||
|
---
|
||||||
|
This is a brief description of the new features and fixes added to
|
||||||
|
lukemftp-1.3 since the release of lukemftp-1.2. As always, the manual
|
||||||
|
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||||
|
|
||||||
|
* The `ls' command now uses the `LIST' directive instead of `NLST',
|
||||||
|
in order to be compatible with RFC959.
|
||||||
|
|
||||||
|
* Add fget command, which reads a list of filenames to retrieve from
|
||||||
|
the given file.
|
||||||
|
|
||||||
|
* Add support for uploading files on the command-line with `ftp -u'.
|
||||||
|
|
||||||
|
* Various fixes to the IPv6 support.
|
||||||
|
|
||||||
|
---
|
||||||
|
This is a brief description of the new features and fixes added to
|
||||||
|
lukemftp-1.2 since the release of lukemftp-1.1. As always, the manual
|
||||||
|
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||||
|
|
||||||
|
* During remote completion, only send ``NLST'' instead of ``NLST .''
|
||||||
|
when reading the list of files from the remote server; some servers
|
||||||
|
don't like the trailing `.'.
|
||||||
|
|
||||||
|
* Support a leading ``[user@]'' for ``[user@]host[:][path]'' auto-fetches
|
||||||
|
and ``[user@]host'' connections.
|
||||||
|
|
||||||
|
* Always compile in support for setting the type of service on transfers.
|
||||||
|
Should speed up transfers on Linux systems.
|
||||||
|
|
||||||
|
* Improve performance of non-rate-limited transfers.
|
||||||
|
|
||||||
|
* Work around ftp servers that aren't Y2K compliant in returning the
|
||||||
|
modification time of a file.
|
||||||
|
|
||||||
|
* Update the libedit library to support automatic and magic margins,
|
||||||
|
allowing ftp's rprompt to move an extra character to the right.
|
||||||
|
|
||||||
|
---
|
||||||
|
This is a brief description of the new features and fixes added to
|
||||||
|
lukemftp-1.1 since the release of lukemftp-1.0. As always, the manual
|
||||||
|
page (src/ftp.cat1) is the place to look for complete descriptions.
|
||||||
|
|
||||||
|
* Implemented `set prompt' and `set rprompt', which allow you to
|
||||||
|
configure the prompt and right side prompt (respectively).
|
||||||
|
Some tcsh(1) style `%' escapes are supported, including
|
||||||
|
%. %c %/ %m %M %n
|
||||||
|
|
||||||
|
* Implemented restarting of file:/// and non-proxied http:// URLs
|
||||||
|
(using -R)
|
||||||
|
|
||||||
|
* Correctly parse remote ports given as numbers that don't appear in
|
||||||
|
the services(5) database.
|
||||||
|
|
||||||
|
* Prevent a couple of minor memory leaks
|
||||||
|
|
||||||
|
* Add missing compilation setting for SOCKS
|
61
contrib/tnftp/README
Normal file
61
contrib/tnftp/README
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
WHAT IS LUKEMFTP?
|
||||||
|
-----------------
|
||||||
|
|
||||||
|
`lukemftp' is what many users affectionately call the enhanced ftp
|
||||||
|
client in NetBSD (http://www.netbsd.org). The `lukem' comes from
|
||||||
|
the account name of the NetBSD developer who wrote most of the
|
||||||
|
enhancements: Luke Mewburn <lukem@netbsd.org>.
|
||||||
|
|
||||||
|
This package is a `port' of the NetBSD ftp client to other systems.
|
||||||
|
|
||||||
|
The enhancements over the standard ftp client in 4.4BSD (and
|
||||||
|
derivatives) include:
|
||||||
|
* command-line editing within ftp
|
||||||
|
* command-line fetching of URLS, including support for:
|
||||||
|
- http proxies (c.f: $http_proxy, $ftp_proxy)
|
||||||
|
- authentication
|
||||||
|
* configurable prompt
|
||||||
|
* context sensitive command and filename completion
|
||||||
|
* dynamic progress bar
|
||||||
|
* feature negotiation extensions from RFC 2389
|
||||||
|
(c.f: `feat' and `remopts')
|
||||||
|
* extensions to ftp from the IETF ftpext working group
|
||||||
|
(c.f: `mlsd' and `mlst')
|
||||||
|
* IPv6 support (from the WIDE project)
|
||||||
|
* modification time preservation
|
||||||
|
* paging of local and remote files, and of directory listings
|
||||||
|
(c.f: `lpage', `page', `pdir')
|
||||||
|
* passive mode support, with fallback to active mode
|
||||||
|
* retrieval of filenames listed in a given file (c.f: `fget')
|
||||||
|
* `set option' override of ftp environment variables
|
||||||
|
* socks4/socks5 support
|
||||||
|
* TIS Firewall Toolkit gate ftp proxy support (c.f: `gate')
|
||||||
|
* transfer-rate throttling (c.f: `-T', `rate')
|
||||||
|
* uploading of files on the command line (c.f: `-u')
|
||||||
|
|
||||||
|
|
||||||
|
INSTALLATION
|
||||||
|
------------
|
||||||
|
|
||||||
|
Refer to `INSTALL' for more information on how to compile and install
|
||||||
|
lukemftp.
|
||||||
|
|
||||||
|
|
||||||
|
FEEDBACK / BUG REPORTS
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Please email feedback back to the maintainer: <lukem@netbsd.org>.
|
||||||
|
|
||||||
|
|
||||||
|
COPYRIGHT
|
||||||
|
---------
|
||||||
|
|
||||||
|
lukemftp is covered by a BSD-style copyright notice. Please refer to
|
||||||
|
the file `COPYING' for more information.
|
||||||
|
|
||||||
|
|
||||||
|
AVAILABILITY
|
||||||
|
------------
|
||||||
|
|
||||||
|
The primary ftp site for lukemftp is:
|
||||||
|
ftp://ftp.netbsd.org/pub/NetBSD/misc/lukemftp/
|
30
contrib/tnftp/THANKS
Normal file
30
contrib/tnftp/THANKS
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
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
|
||||||
|
without the enhancements, fixes, or input from the following people:
|
||||||
|
|
||||||
|
Brian Stark <bstark1990@netscape.net>
|
||||||
|
Chris G. Demetriou <cgd@netbsd.org>
|
||||||
|
Christos Zoulas <christos@netbsd.org>
|
||||||
|
Dan Winship <danw@mit.edu>
|
||||||
|
Darren Reed <darrenr@pobox.com>
|
||||||
|
David Carrel <carrel@netbsd.org>
|
||||||
|
Giles Lean <giles@nemeton.com.au>
|
||||||
|
Havard Eidnes <Havard.Eidnes@runit.sintef.no>
|
||||||
|
ITOH Yasufumi <itohy@netbsd.org>
|
||||||
|
Jason R. Thorpe <thorpej@netbsd.org>
|
||||||
|
John Hawkinson <jhawk@mit.edu>
|
||||||
|
Joseph S. Myers <jsm28@cam.ac.uk>
|
||||||
|
Jun-ichiro itojun Hagino <itojun@netbsd.org>
|
||||||
|
Kimmo Suominen <kim@tac.nyc.ny.us>
|
||||||
|
Klaus Klein <kleink@netbsd.org>
|
||||||
|
Luke Mewburn <lukem@netbsd.org>
|
||||||
|
Marc Horowitz <marc@mit.edu>
|
||||||
|
Matthew R. Green <mrg@eterna.com.au>
|
||||||
|
Matthias Pfaller <leo@dachau.marco.de>
|
||||||
|
Matthias Scheler <tron@zhadum.de>
|
||||||
|
Michael L. Hitch <osymh@terra.oscs.montana.edu>
|
||||||
|
Scott Aaron Bamford <sab@ansic.net>
|
||||||
|
Simon Burge <simonb@thistledown.com.au>
|
||||||
|
Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
|
||||||
|
Apologies to anyone I've missed.
|
92
contrib/tnftp/acconfig.h
Normal file
92
contrib/tnftp/acconfig.h
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/* $Id: acconfig.h,v 1.9 2002/06/10 01:27:13 lukem Exp $ */
|
||||||
|
|
||||||
|
@TOP@
|
||||||
|
@BOTTOM@
|
||||||
|
|
||||||
|
/* Define if your compiler supports `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 */
|
||||||
|
#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) */
|
||||||
|
#undef HAVE_SOCKADDR_SA_LEN
|
||||||
|
|
||||||
|
/* Define if socklen_t exists */
|
||||||
|
#undef HAVE_SOCKLEN_T
|
||||||
|
|
||||||
|
/* Define if AF_INET6 exists in <sys/socket.h> */
|
||||||
|
#undef HAVE_AF_INET6
|
||||||
|
|
||||||
|
/* Define if `struct sockaddr_in6' exists in <netinet/in.h> */
|
||||||
|
#undef HAVE_SOCKADDR_IN6
|
||||||
|
|
||||||
|
/* Define if `struct addrinfo' exists in <netdb.h> */
|
||||||
|
#undef HAVE_ADDRINFO
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define if <netdb.h> contains AI_NUMERICHOST et al.
|
||||||
|
* Systems which only implement RFC2133 will need this.
|
||||||
|
*/
|
||||||
|
#undef HAVE_RFC2553_NETDB
|
||||||
|
|
||||||
|
/* Define if `struct direct' has a d_namlen element */
|
||||||
|
#undef HAVE_D_NAMLEN
|
||||||
|
|
||||||
|
/* Define if h_errno exists in <netdb.h> */
|
||||||
|
#undef HAVE_H_ERRNO_D
|
||||||
|
|
||||||
|
/* Define if fclose() is declared in <stdio.h> */
|
||||||
|
#undef HAVE_FCLOSE_D
|
||||||
|
|
||||||
|
/* Define if getpass() is declared in <stdlib.h> or <unistd.h> */
|
||||||
|
#undef HAVE_GETPASS_D
|
||||||
|
|
||||||
|
/* Define if optarg is declared in <stdlib.h> or <unistd.h> */
|
||||||
|
#undef HAVE_OPTARG_D
|
||||||
|
|
||||||
|
/* Define if optind is declared in <stdlib.h> or <unistd.h> */
|
||||||
|
#undef HAVE_OPTIND_D
|
||||||
|
|
||||||
|
/* Define if pclose() is declared in <stdio.h> */
|
||||||
|
#undef HAVE_PCLOSE_D
|
||||||
|
|
||||||
|
/* Define if `long long' is supported and sizeof(off_t) >= 8 */
|
||||||
|
#undef HAVE_QUAD_SUPPORT
|
||||||
|
|
||||||
|
/* Define if strptime() is declared in <time.h> */
|
||||||
|
#undef HAVE_STRPTIME_D
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define this if compiling with SOCKS (the firewall traversal library).
|
||||||
|
* Also, you must define connect, getsockname, bind, accept, listen, and
|
||||||
|
* select to their R-versions.
|
||||||
|
*/
|
||||||
|
#undef SOCKS
|
||||||
|
#undef SOCKS4
|
||||||
|
#undef SOCKS5
|
||||||
|
#undef connect
|
||||||
|
#undef getsockname
|
||||||
|
#undef bind
|
||||||
|
#undef accept
|
||||||
|
#undef listen
|
||||||
|
#undef select
|
||||||
|
#undef dup
|
||||||
|
#undef dup2
|
||||||
|
#undef fclose
|
||||||
|
#undef gethostbyname
|
||||||
|
#undef getpeername
|
||||||
|
#undef read
|
||||||
|
#undef recv
|
||||||
|
#undef recvfrom
|
||||||
|
#undef rresvport
|
||||||
|
#undef send
|
||||||
|
#undef sendto
|
||||||
|
#undef shutdown
|
||||||
|
#undef write
|
257
contrib/tnftp/aclocal.m4
vendored
Normal file
257
contrib/tnftp/aclocal.m4
vendored
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
dnl $Id: aclocal.m4,v 1.5 1999/11/13 10:50:39 lukem Exp $
|
||||||
|
dnl
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl AC_MSG_TRY_COMPILE
|
||||||
|
dnl
|
||||||
|
dnl Written by Luke Mewburn <lukem@netbsd.org>
|
||||||
|
dnl
|
||||||
|
dnl Usage:
|
||||||
|
dnl AC_MSG_TRY_COMPILE(Message, CacheVar, Includes, Code,
|
||||||
|
dnl ActionPass [,ActionFail] )
|
||||||
|
dnl
|
||||||
|
dnl effectively does:
|
||||||
|
dnl AC_CACHE_CHECK(Message, CacheVar,
|
||||||
|
dnl AC_TRY_COMPILE(Includes, Code, CacheVar = yes, CacheVar = no)
|
||||||
|
dnl if CacheVar == yes
|
||||||
|
dnl AC_MESSAGE_RESULT(yes)
|
||||||
|
dnl ActionPass
|
||||||
|
dnl else
|
||||||
|
dnl AC_MESSAGE_RESULT(no)
|
||||||
|
dnl ActionFail
|
||||||
|
dnl )
|
||||||
|
dnl
|
||||||
|
AC_DEFUN(AC_MSG_TRY_COMPILE, [
|
||||||
|
AC_CACHE_CHECK($1, $2, [
|
||||||
|
AC_TRY_COMPILE([ $3 ], [ $4; ], [ $2=yes ], [ $2=no ])
|
||||||
|
])
|
||||||
|
if test "x[$]$2" = "xyes"; then
|
||||||
|
$5
|
||||||
|
else
|
||||||
|
$6
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl AC_MSG_TRY_LINK
|
||||||
|
dnl
|
||||||
|
dnl Usage:
|
||||||
|
dnl AC_MSG_TRY_LINK(Message, CacheVar, Includes, Code,
|
||||||
|
dnl ActionPass [,ActionFail] )
|
||||||
|
dnl
|
||||||
|
dnl as AC_MSG_TRY_COMPILE, but uses AC_TRY_LINK instead of AC_TRY_COMPILE
|
||||||
|
dnl
|
||||||
|
AC_DEFUN(AC_MSG_TRY_LINK, [
|
||||||
|
AC_CACHE_CHECK($1, $2, [
|
||||||
|
AC_TRY_LINK([ $3 ], [ $4; ], [ $2=yes ], [ $2=no ])
|
||||||
|
])
|
||||||
|
if test "x[$]$2" = "xyes"; then
|
||||||
|
$5
|
||||||
|
else
|
||||||
|
$6
|
||||||
|
:
|
||||||
|
fi
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl
|
||||||
|
dnl AC_LIBRARY_NET: #Id: net.m4,v 1.5 1997/11/09 21:36:54 jhawk Exp #
|
||||||
|
dnl
|
||||||
|
dnl Written by John Hawkinson <jhawk@mit.edu>. This code is in the Public
|
||||||
|
dnl Domain.
|
||||||
|
dnl
|
||||||
|
dnl This test is for network applications that need socket() and
|
||||||
|
dnl gethostbyname() -ish functions. Under Solaris, those applications need to
|
||||||
|
dnl link with "-lsocket -lnsl". Under IRIX, they should *not* link with
|
||||||
|
dnl "-lsocket" because libsocket.a breaks a number of things (for instance:
|
||||||
|
dnl gethostbyname() under IRIX 5.2, and snoop sockets under most versions of
|
||||||
|
dnl IRIX).
|
||||||
|
dnl
|
||||||
|
dnl Unfortunately, many application developers are not aware of this, and
|
||||||
|
dnl mistakenly write tests that cause -lsocket to be used under IRIX. It is
|
||||||
|
dnl also easy to write tests that cause -lnsl to be used under operating
|
||||||
|
dnl systems where neither are necessary (or useful), such as SunOS 4.1.4, which
|
||||||
|
dnl uses -lnsl for TLI.
|
||||||
|
dnl
|
||||||
|
dnl This test exists so that every application developer does not test this in
|
||||||
|
dnl a different, and subtly broken fashion.
|
||||||
|
dnl
|
||||||
|
dnl It has been argued that this test should be broken up into two seperate
|
||||||
|
dnl tests, one for the resolver libraries, and one for the libraries necessary
|
||||||
|
dnl for using Sockets API. Unfortunately, the two are carefully intertwined and
|
||||||
|
dnl allowing the autoconf user to use them independantly potentially results in
|
||||||
|
dnl unfortunate ordering dependancies -- as such, such component macros would
|
||||||
|
dnl have to carefully use indirection and be aware if the other components were
|
||||||
|
dnl executed. Since other autoconf macros do not go to this trouble, and almost
|
||||||
|
dnl no applications use sockets without the resolver, this complexity has not
|
||||||
|
dnl been implemented.
|
||||||
|
dnl
|
||||||
|
dnl The check for libresolv is in case you are attempting to link statically
|
||||||
|
dnl and happen to have a libresolv.a lying around (and no libnsl.a).
|
||||||
|
dnl
|
||||||
|
AC_DEFUN(AC_LIBRARY_NET, [
|
||||||
|
# Most operating systems have gethostbyname() in the default searched
|
||||||
|
# libraries (i.e. libc):
|
||||||
|
AC_CHECK_FUNC(gethostbyname, ,
|
||||||
|
# Some OSes (eg. Solaris) place it in libnsl:
|
||||||
|
AC_CHECK_LIB(nsl, gethostbyname, ,
|
||||||
|
# Some strange OSes (SINIX) have it in libsocket:
|
||||||
|
AC_CHECK_LIB(socket, gethostbyname, ,
|
||||||
|
# Unfortunately libsocket sometimes depends on libnsl.
|
||||||
|
# AC_CHECK_LIB's API is essentially broken so the following
|
||||||
|
# ugliness is necessary:
|
||||||
|
AC_CHECK_LIB(socket, gethostbyname,
|
||||||
|
LIBS="-lsocket -lnsl $LIBS",
|
||||||
|
AC_CHECK_LIB(resolv, gethostbyname),
|
||||||
|
-lnsl)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
|
||||||
|
AC_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", , -lnsl)))
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Checks for SOCKS firewall support.
|
||||||
|
dnl
|
||||||
|
dnl Written by Matthew R. Green <mrg@eterna.com.au>
|
||||||
|
dnl
|
||||||
|
AC_DEFUN(AC_LIBRARY_SOCKS, [
|
||||||
|
AC_MSG_CHECKING(whether to support SOCKS)
|
||||||
|
AC_ARG_WITH(socks,
|
||||||
|
[ --with-socks Compile with SOCKS firewall traversal support.],
|
||||||
|
[
|
||||||
|
case "$withval" in
|
||||||
|
no)
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
;;
|
||||||
|
yes)
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
AC_CHECK_LIB(socks5, SOCKSconnect, [
|
||||||
|
socks=5
|
||||||
|
LIBS="-lsocks5 $LIBS"], [
|
||||||
|
AC_CHECK_LIB(socks, Rconnect, [
|
||||||
|
socks=4
|
||||||
|
LIBS="-lsocks $LIBS"], [
|
||||||
|
AC_MSG_ERROR(Could not find socks library. You must first install socks.) ] ) ] )
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
],
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
)
|
||||||
|
|
||||||
|
if test "x$socks" = "x"; then
|
||||||
|
AC_MSG_CHECKING(whether to support SOCKS5)
|
||||||
|
AC_ARG_WITH(socks5,
|
||||||
|
[ --with-socks5[=PATH] Compile with SOCKS5 firewall traversal support.],
|
||||||
|
[
|
||||||
|
case "$withval" in
|
||||||
|
no)
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
socks=5
|
||||||
|
if test "x$withval" = "xyes"; then
|
||||||
|
withval="-lsocks5"
|
||||||
|
else
|
||||||
|
if test -d "$withval"; then
|
||||||
|
if test -d "$withval/include"; then
|
||||||
|
CFLAGS="$CFLAGS -I$withval/include"
|
||||||
|
else
|
||||||
|
CFLAGS="$CFLAGS -I$withval"
|
||||||
|
fi
|
||||||
|
if test -d "$withval/lib"; then
|
||||||
|
withval="-L$withval/lib -lsocks5"
|
||||||
|
else
|
||||||
|
withval="-L$withval -lsocks5"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
LIBS="$withval $LIBS"
|
||||||
|
# If Socks was compiled with Kerberos support, we will need
|
||||||
|
# to link against kerberos libraries. Temporarily append
|
||||||
|
# to LIBS. This is harmless if there is no kerberos support.
|
||||||
|
TMPLIBS="$LIBS"
|
||||||
|
LIBS="$LIBS $KERBEROS_LIBS"
|
||||||
|
AC_TRY_LINK([],
|
||||||
|
[ SOCKSconnect(); ],
|
||||||
|
[],
|
||||||
|
[ AC_MSG_ERROR(Could not find the $withval library. You must first install socks5.) ])
|
||||||
|
LIBS="$TMPLIBS"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
],
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x$socks" = "x"; then
|
||||||
|
AC_MSG_CHECKING(whether to support SOCKS4)
|
||||||
|
AC_ARG_WITH(socks4,
|
||||||
|
[ --with-socks4[=PATH] Compile with SOCKS4 firewall traversal support.],
|
||||||
|
[
|
||||||
|
case "$withval" in
|
||||||
|
no)
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
socks=4
|
||||||
|
if test "x$withval" = "xyes"; then
|
||||||
|
withval="-lsocks"
|
||||||
|
else
|
||||||
|
if test -d "$withval"; then
|
||||||
|
withval="-L$withval -lsocks"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
LIBS="$withval $LIBS"
|
||||||
|
AC_TRY_LINK([],
|
||||||
|
[ Rconnect(); ],
|
||||||
|
[],
|
||||||
|
[ AC_MSG_ERROR(Could not find the $withval library. You must first install socks.) ])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
],
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x$socks" = "x4"; then
|
||||||
|
AC_DEFINE(SOCKS)
|
||||||
|
AC_DEFINE(SOCKS4)
|
||||||
|
AC_DEFINE(connect, Rconnect)
|
||||||
|
AC_DEFINE(getsockname, Rgetsockname)
|
||||||
|
AC_DEFINE(bind, Rbind)
|
||||||
|
AC_DEFINE(accept, Raccept)
|
||||||
|
AC_DEFINE(listen, Rlisten)
|
||||||
|
AC_DEFINE(select, Rselect)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test "x$socks" = "x5"; then
|
||||||
|
AC_DEFINE(SOCKS)
|
||||||
|
AC_DEFINE(SOCKS5)
|
||||||
|
AC_DEFINE(connect,SOCKSconnect)
|
||||||
|
AC_DEFINE(getsockname,SOCKSgetsockname)
|
||||||
|
AC_DEFINE(getpeername,SOCKSgetpeername)
|
||||||
|
AC_DEFINE(bind,SOCKSbind)
|
||||||
|
AC_DEFINE(accept,SOCKSaccept)
|
||||||
|
AC_DEFINE(listen,SOCKSlisten)
|
||||||
|
AC_DEFINE(select,SOCKSselect)
|
||||||
|
AC_DEFINE(recvfrom,SOCKSrecvfrom)
|
||||||
|
AC_DEFINE(sendto,SOCKSsendto)
|
||||||
|
AC_DEFINE(recv,SOCKSrecv)
|
||||||
|
AC_DEFINE(send,SOCKSsend)
|
||||||
|
AC_DEFINE(read,SOCKSread)
|
||||||
|
AC_DEFINE(write,SOCKSwrite)
|
||||||
|
AC_DEFINE(rresvport,SOCKSrresvport)
|
||||||
|
AC_DEFINE(shutdown,SOCKSshutdown)
|
||||||
|
AC_DEFINE(listen,SOCKSlisten)
|
||||||
|
AC_DEFINE(close,SOCKSclose)
|
||||||
|
AC_DEFINE(dup,SOCKSdup)
|
||||||
|
AC_DEFINE(dup2,SOCKSdup2)
|
||||||
|
AC_DEFINE(fclose,SOCKSfclose)
|
||||||
|
AC_DEFINE(gethostbyname,SOCKSgethostbyname)
|
||||||
|
fi
|
||||||
|
])
|
275
contrib/tnftp/config.h.in
Normal file
275
contrib/tnftp/config.h.in
Normal file
@ -0,0 +1,275 @@
|
|||||||
|
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||||
|
/* $Id: config.h.in,v 1.28 2002/06/10 08:10:33 lukem Exp $ */
|
||||||
|
|
||||||
|
|
||||||
|
/* Define if on AIX 3.
|
||||||
|
System headers sometimes define this.
|
||||||
|
We just want to avoid a redefinition error message. */
|
||||||
|
#ifndef _ALL_SOURCE
|
||||||
|
#undef _ALL_SOURCE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define if the closedir function returns void instead of int. */
|
||||||
|
#undef CLOSEDIR_VOID
|
||||||
|
|
||||||
|
/* Define if the `getpgrp' function takes no argument. */
|
||||||
|
#undef GETPGRP_VOID
|
||||||
|
|
||||||
|
/* Define if your C compiler doesn't accept -c and -o together. */
|
||||||
|
#undef NO_MINUS_C_MINUS_O
|
||||||
|
|
||||||
|
/* Define if your Fortran 77 compiler doesn't accept -c and -o together. */
|
||||||
|
#undef F77_NO_MINUS_C_MINUS_O
|
||||||
|
|
||||||
|
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||||
|
#undef off_t
|
||||||
|
|
||||||
|
/* Define to the type of arg1 for select(). */
|
||||||
|
#undef SELECT_TYPE_ARG1
|
||||||
|
|
||||||
|
/* Define to the type of args 2, 3 and 4 for select(). */
|
||||||
|
#undef SELECT_TYPE_ARG234
|
||||||
|
|
||||||
|
/* Define to the type of arg5 for select(). */
|
||||||
|
#undef SELECT_TYPE_ARG5
|
||||||
|
|
||||||
|
/* Define if you have the ANSI C header files. */
|
||||||
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||||
|
#undef TIME_WITH_SYS_TIME
|
||||||
|
|
||||||
|
/* Define if the closedir function returns void instead of int. */
|
||||||
|
#undef VOID_CLOSEDIR
|
||||||
|
|
||||||
|
/* The number of bytes in a off_t. */
|
||||||
|
#undef SIZEOF_OFF_T
|
||||||
|
|
||||||
|
/* Define if you have the err function. */
|
||||||
|
#undef HAVE_ERR
|
||||||
|
|
||||||
|
/* Define if you have the fgetln function. */
|
||||||
|
#undef HAVE_FGETLN
|
||||||
|
|
||||||
|
/* Define if you have the fparseln function. */
|
||||||
|
#undef HAVE_FPARSELN
|
||||||
|
|
||||||
|
/* Define if you have the fseeko function. */
|
||||||
|
#undef HAVE_FSEEKO
|
||||||
|
|
||||||
|
/* Define if you have the getaddrinfo function. */
|
||||||
|
#undef HAVE_GETADDRINFO
|
||||||
|
|
||||||
|
/* Define if you have the gethostbyname2 function. */
|
||||||
|
#undef HAVE_GETHOSTBYNAME2
|
||||||
|
|
||||||
|
/* Define if you have the getnameinfo function. */
|
||||||
|
#undef HAVE_GETNAMEINFO
|
||||||
|
|
||||||
|
/* Define if you have the getpassphrase function. */
|
||||||
|
#undef HAVE_GETPASSPHRASE
|
||||||
|
|
||||||
|
/* Define if you have the getpgrp function. */
|
||||||
|
#undef HAVE_GETPGRP
|
||||||
|
|
||||||
|
/* Define if you have the inet_ntop function. */
|
||||||
|
#undef HAVE_INET_NTOP
|
||||||
|
|
||||||
|
/* Define if you have the inet_pton function. */
|
||||||
|
#undef HAVE_INET_PTON
|
||||||
|
|
||||||
|
/* Define if you have the memmove function. */
|
||||||
|
#undef HAVE_MEMMOVE
|
||||||
|
|
||||||
|
/* Define if you have the mkstemp function. */
|
||||||
|
#undef HAVE_MKSTEMP
|
||||||
|
|
||||||
|
/* Define if you have the poll function. */
|
||||||
|
#undef HAVE_POLL
|
||||||
|
|
||||||
|
/* Define if you have the select function. */
|
||||||
|
#undef HAVE_SELECT
|
||||||
|
|
||||||
|
/* Define if you have the setprogname function. */
|
||||||
|
#undef HAVE_SETPROGNAME
|
||||||
|
|
||||||
|
/* Define if you have the sl_init function. */
|
||||||
|
#undef HAVE_SL_INIT
|
||||||
|
|
||||||
|
/* Define if you have the snprintf function. */
|
||||||
|
#undef HAVE_SNPRINTF
|
||||||
|
|
||||||
|
/* Define if you have the strdup function. */
|
||||||
|
#undef HAVE_STRDUP
|
||||||
|
|
||||||
|
/* Define if you have the strerror function. */
|
||||||
|
#undef HAVE_STRERROR
|
||||||
|
|
||||||
|
/* Define if you have the strlcat function. */
|
||||||
|
#undef HAVE_STRLCAT
|
||||||
|
|
||||||
|
/* Define if you have the strlcpy function. */
|
||||||
|
#undef HAVE_STRLCPY
|
||||||
|
|
||||||
|
/* Define if you have the strptime function. */
|
||||||
|
#undef HAVE_STRPTIME
|
||||||
|
|
||||||
|
/* Define if you have the strsep function. */
|
||||||
|
#undef HAVE_STRSEP
|
||||||
|
|
||||||
|
/* Define if you have the strtoll function. */
|
||||||
|
#undef HAVE_STRTOLL
|
||||||
|
|
||||||
|
/* Define if you have the strunvis function. */
|
||||||
|
#undef HAVE_STRUNVIS
|
||||||
|
|
||||||
|
/* Define if you have the strvis function. */
|
||||||
|
#undef HAVE_STRVIS
|
||||||
|
|
||||||
|
/* Define if you have the timegm function. */
|
||||||
|
#undef HAVE_TIMEGM
|
||||||
|
|
||||||
|
/* Define if you have the usleep function. */
|
||||||
|
#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. */
|
||||||
|
#undef HAVE_DIRENT_H
|
||||||
|
|
||||||
|
/* Define if you have the <err.h> header file. */
|
||||||
|
#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. */
|
||||||
|
#undef HAVE_NDIR_H
|
||||||
|
|
||||||
|
/* Define if you have the <paths.h> header file. */
|
||||||
|
#undef HAVE_PATHS_H
|
||||||
|
|
||||||
|
/* Define if you have the <poll.h> header file. */
|
||||||
|
#undef HAVE_POLL_H
|
||||||
|
|
||||||
|
/* Define if you have the <regex.h> header file. */
|
||||||
|
#undef HAVE_REGEX_H
|
||||||
|
|
||||||
|
/* Define if you have the <sys/dir.h> header file. */
|
||||||
|
#undef HAVE_SYS_DIR_H
|
||||||
|
|
||||||
|
/* Define if you have the <sys/ndir.h> header file. */
|
||||||
|
#undef HAVE_SYS_NDIR_H
|
||||||
|
|
||||||
|
/* Define if you have the <sys/poll.h> header file. */
|
||||||
|
#undef HAVE_SYS_POLL_H
|
||||||
|
|
||||||
|
/* Define if you have the <termcap.h> header file. */
|
||||||
|
#undef HAVE_TERMCAP_H
|
||||||
|
|
||||||
|
/* Define if you have the <util.h> header file. */
|
||||||
|
#undef HAVE_UTIL_H
|
||||||
|
|
||||||
|
/* Define if you have the <vis.h> header file. */
|
||||||
|
#undef HAVE_VIS_H
|
||||||
|
|
||||||
|
/* Define if you have the nsl library (-lnsl). */
|
||||||
|
#undef HAVE_LIBNSL
|
||||||
|
|
||||||
|
/* Define if you have the socket library (-lsocket). */
|
||||||
|
#undef HAVE_LIBSOCKET
|
||||||
|
|
||||||
|
/* Define if you have the tinfo library (-ltinfo). */
|
||||||
|
#undef HAVE_LIBTINFO
|
||||||
|
|
||||||
|
/* Define if you have the util library (-lutil). */
|
||||||
|
#undef HAVE_LIBUTIL
|
||||||
|
|
||||||
|
/* Define if your compiler supports `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 */
|
||||||
|
#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) */
|
||||||
|
#undef HAVE_SOCKADDR_SA_LEN
|
||||||
|
|
||||||
|
/* Define if socklen_t exists */
|
||||||
|
#undef HAVE_SOCKLEN_T
|
||||||
|
|
||||||
|
/* Define if AF_INET6 exists in <sys/socket.h> */
|
||||||
|
#undef HAVE_AF_INET6
|
||||||
|
|
||||||
|
/* Define if `struct sockaddr_in6' exists in <netinet/in.h> */
|
||||||
|
#undef HAVE_SOCKADDR_IN6
|
||||||
|
|
||||||
|
/* Define if `struct addrinfo' exists in <netdb.h> */
|
||||||
|
#undef HAVE_ADDRINFO
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define if <netdb.h> contains AI_NUMERICHOST et al.
|
||||||
|
* Systems which only implement RFC2133 will need this.
|
||||||
|
*/
|
||||||
|
#undef HAVE_RFC2553_NETDB
|
||||||
|
|
||||||
|
/* Define if `struct direct' has a d_namlen element */
|
||||||
|
#undef HAVE_D_NAMLEN
|
||||||
|
|
||||||
|
/* Define if h_errno exists in <netdb.h> */
|
||||||
|
#undef HAVE_H_ERRNO_D
|
||||||
|
|
||||||
|
/* Define if fclose() is declared in <stdio.h> */
|
||||||
|
#undef HAVE_FCLOSE_D
|
||||||
|
|
||||||
|
/* Define if getpass() is declared in <stdlib.h> or <unistd.h> */
|
||||||
|
#undef HAVE_GETPASS_D
|
||||||
|
|
||||||
|
/* Define if optarg is declared in <stdlib.h> or <unistd.h> */
|
||||||
|
#undef HAVE_OPTARG_D
|
||||||
|
|
||||||
|
/* Define if optind is declared in <stdlib.h> or <unistd.h> */
|
||||||
|
#undef HAVE_OPTIND_D
|
||||||
|
|
||||||
|
/* Define if pclose() is declared in <stdio.h> */
|
||||||
|
#undef HAVE_PCLOSE_D
|
||||||
|
|
||||||
|
/* Define if `long long' is supported and sizeof(off_t) >= 8 */
|
||||||
|
#undef HAVE_QUAD_SUPPORT
|
||||||
|
|
||||||
|
/* Define if strptime() is declared in <time.h> */
|
||||||
|
#undef HAVE_STRPTIME_D
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define this if compiling with SOCKS (the firewall traversal library).
|
||||||
|
* Also, you must define connect, getsockname, bind, accept, listen, and
|
||||||
|
* select to their R-versions.
|
||||||
|
*/
|
||||||
|
#undef SOCKS
|
||||||
|
#undef SOCKS4
|
||||||
|
#undef SOCKS5
|
||||||
|
#undef connect
|
||||||
|
#undef getsockname
|
||||||
|
#undef bind
|
||||||
|
#undef accept
|
||||||
|
#undef listen
|
||||||
|
#undef select
|
||||||
|
#undef dup
|
||||||
|
#undef dup2
|
||||||
|
#undef fclose
|
||||||
|
#undef gethostbyname
|
||||||
|
#undef getpeername
|
||||||
|
#undef read
|
||||||
|
#undef recv
|
||||||
|
#undef recvfrom
|
||||||
|
#undef rresvport
|
||||||
|
#undef send
|
||||||
|
#undef sendto
|
||||||
|
#undef shutdown
|
||||||
|
#undef write
|
4229
contrib/tnftp/configure
vendored
Executable file
4229
contrib/tnftp/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
307
contrib/tnftp/configure.in
Normal file
307
contrib/tnftp/configure.in
Normal file
@ -0,0 +1,307 @@
|
|||||||
|
dnl $Id: configure.in,v 1.37 2002/06/10 08:08:53 lukem Exp $
|
||||||
|
dnl
|
||||||
|
dnl configure.in --
|
||||||
|
dnl process this file with autoconf to produce a configure script.
|
||||||
|
dnl
|
||||||
|
|
||||||
|
AC_REVISION($Revision: 1.37 $)dnl
|
||||||
|
|
||||||
|
AC_INIT(lukemftp.h)
|
||||||
|
|
||||||
|
dnl Arguments for which features are included
|
||||||
|
dnl
|
||||||
|
AC_ARG_PROGRAM
|
||||||
|
AC_ARG_ENABLE(editcomplete, [\
|
||||||
|
--enable-editcomplete Turn on command line editing and completion.
|
||||||
|
--disable-editcomplete Turn off command line editing and completion
|
||||||
|
[default: enabled].],
|
||||||
|
opt_editcomplete=$enableval,
|
||||||
|
opt_editcomplete=yes)
|
||||||
|
AC_ARG_ENABLE(ipv6, [\
|
||||||
|
--enable-ipv6 Enable IPv6 support (if your OS supports it).
|
||||||
|
--disable-ipv6 Disable IPv6 support (even if your OS supports it)
|
||||||
|
[default: enabled].],
|
||||||
|
opt_ipv6=$enableval,
|
||||||
|
opt_ipv6=yes)
|
||||||
|
|
||||||
|
dnl Checks for programs.
|
||||||
|
dnl
|
||||||
|
AC_PROG_MAKE_SET
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_AWK
|
||||||
|
AC_PROG_INSTALL
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
AC_CHECK_PROGS(AR, ar)
|
||||||
|
AC_AIX
|
||||||
|
|
||||||
|
|
||||||
|
dnl Checks for libraries.
|
||||||
|
dnl
|
||||||
|
AC_CHECK_LIB(util, fparseln)
|
||||||
|
if test $opt_editcomplete = yes; then
|
||||||
|
AC_CHECK_LIB(tinfo, tgetent, ,
|
||||||
|
AC_CHECK_LIB(termcap, tgetent, ,
|
||||||
|
AC_CHECK_LIB(curses, tgetent, ,
|
||||||
|
AC_CHECK_LIB(ncurses, tgetent))))
|
||||||
|
AC_SEARCH_LIBS(el_init, edit, have_libedit=yes, have_libedit=no)
|
||||||
|
fi
|
||||||
|
AC_LIBRARY_NET
|
||||||
|
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
|
||||||
|
AC_CONFIG_HEADER(config.h)
|
||||||
|
AC_HEADER_DIRENT
|
||||||
|
AC_HEADER_STDC
|
||||||
|
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
|
||||||
|
AC_HEADER_TIME
|
||||||
|
AC_TYPE_OFF_T
|
||||||
|
AC_CHECK_SIZEOF(off_t, 0)
|
||||||
|
AC_MSG_TRY_LINK(for long long, ftp_cv_HAVE_LONG_LONG, [
|
||||||
|
#include <sys/types.h>] , [
|
||||||
|
long long X = 2, Y = 1, Z;
|
||||||
|
Z = X / Y; ], [
|
||||||
|
AC_DEFINE(HAVE_LONG_LONG, 1)
|
||||||
|
have_long_long=yes], [have_long_long=no])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for in_port_t, ftp_cv_HAVE_IN_PORT_T, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#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, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h> ], [
|
||||||
|
struct sockaddr_in sin;
|
||||||
|
int X = sin.sin_len ], [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for socklen_t, ftp_cv_HAVE_SOCKLEN_T, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h> ], [ socklen_t X ], [AC_DEFINE(HAVE_SOCKLEN_T, 1)])
|
||||||
|
|
||||||
|
if test $opt_ipv6 = yes; then
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for AF_INET6, ftp_cv_HAVE_AF_INET6, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h> ],
|
||||||
|
[ int X = AF_INET6 ], [AC_DEFINE(HAVE_AF_INET6, 1)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for struct sockaddr_in6, ftp_cv_HAVE_SOCKADDR_IN6, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <netinet/in.h> ],
|
||||||
|
[ struct sockaddr_in6 X ], [AC_DEFINE(HAVE_SOCKADDR_IN6, 1)])
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for struct addrinfo, ftp_cv_HAVE_ADDRINFO, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netdb.h> ],
|
||||||
|
[ struct addrinfo X ], [AC_DEFINE(HAVE_ADDRINFO, 1)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for d_namlen in struct dirent, ftp_cv_HAVE_D_NAMLEN, [
|
||||||
|
#if HAVE_DIRENT_H
|
||||||
|
# include <dirent.h>
|
||||||
|
#else
|
||||||
|
# define dirent direct
|
||||||
|
# if HAVE_SYS_NDIR_H
|
||||||
|
# include <sys/ndir.h>
|
||||||
|
# endif
|
||||||
|
# if HAVE_SYS_DIR_H
|
||||||
|
# include <sys/dir.h>
|
||||||
|
# endif
|
||||||
|
# if HAVE_NDIR_H
|
||||||
|
# include <ndir.h>
|
||||||
|
# endif
|
||||||
|
#endif ], [
|
||||||
|
struct dirent dp;
|
||||||
|
int X = dp.d_namlen; ], [AC_DEFINE(HAVE_D_NAMLEN, 1)])
|
||||||
|
|
||||||
|
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)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for fclose() declaration, ftp_cv_HAVE_FCLOSE_D, [
|
||||||
|
#include <stdio.h> ], [ int (*X)() = fclose ], [AC_DEFINE(HAVE_FCLOSE_D, 1)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for getpass() declaration, ftp_cv_HAVE_GETPASS_D, [
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h> ], [ char *(*X)() = getpass ], [
|
||||||
|
AC_DEFINE(HAVE_GETPASS_D, 1)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for optarg declaration, ftp_cv_HAVE_OPTARG_D, [
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h> ], [ char *X = optarg ], [AC_DEFINE(HAVE_OPTARG_D, 1)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for optind declaration, ftp_cv_HAVE_OPTIND_D, [
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <unistd.h> ], [ int X = optind ], [AC_DEFINE(HAVE_OPTIND_D, 1)])
|
||||||
|
|
||||||
|
AC_MSG_TRY_COMPILE(for pclose() declaration, ftp_cv_HAVE_PCLOSE_D, [
|
||||||
|
#include <stdio.h> ], [ int (*X)() = pclose ], [AC_DEFINE(HAVE_PCLOSE_D, 1)])
|
||||||
|
|
||||||
|
|
||||||
|
dnl Checks for library functions.
|
||||||
|
dnl
|
||||||
|
AC_REPLACE_FUNCS(err fgetln fseeko getaddrinfo getnameinfo inet_ntop inet_pton \
|
||||||
|
mkstemp setprogname sl_init snprintf strdup strerror strlcat \
|
||||||
|
strlcpy strptime strsep strunvis strvis timegm usleep)
|
||||||
|
AC_CHECK_FUNCS(gethostbyname2 getpassphrase getpgrp memmove poll select)
|
||||||
|
if test $ac_cv_func_getpgrp = yes; then
|
||||||
|
AC_FUNC_GETPGRP
|
||||||
|
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
|
||||||
|
AC_MSG_TRY_COMPILE(for strptime() declaration, ftp_cv_HAVE_STRPTIME_D, [
|
||||||
|
#include <time.h> ], [ char *X = strptime("", "", NULL) ],
|
||||||
|
[AC_DEFINE(HAVE_STRPTIME_D, 1)])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $have_long_long = yes -a $ac_cv_sizeof_off_t -ge 8; then
|
||||||
|
|
||||||
|
dnl We assume that if sprintf() supports %lld or %qd,
|
||||||
|
dnl then all of *printf() does. If not, disable long long
|
||||||
|
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([
|
||||||
|
#include <stdio.h>
|
||||||
|
int main() {
|
||||||
|
char buf[100];
|
||||||
|
sprintf(buf, "%qd", 4294967300LL);
|
||||||
|
return (strcmp(buf, "4294967300"));
|
||||||
|
}
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
can_printf_longlong=yes
|
||||||
|
AC_DEFINE(HAVE_PRINTF_QD, 1)
|
||||||
|
], [
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
], [ : ])
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $can_printf_longlong = yes; then
|
||||||
|
AC_DEFINE(HAVE_QUAD_SUPPORT, 1)
|
||||||
|
AC_REPLACE_FUNCS(strtoll)
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test $opt_editcomplete = yes; then
|
||||||
|
if test $have_libedit = yes; then
|
||||||
|
AC_MSG_TRY_COMPILE(for EL_RPROMPT in libedit,
|
||||||
|
ftp_cv_have_libedit, [
|
||||||
|
#include <histedit.h> ], [ int X = EL_RPROMPT ], [:],
|
||||||
|
have_libedit=no )
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for working libedit)
|
||||||
|
if test $have_libedit = no; then
|
||||||
|
AC_MSG_RESULT(no - using my own)
|
||||||
|
INCLUDES="-I\${srcdir}/../libedit $INCLUDES"
|
||||||
|
LDFLAGS="-L../libedit $LDFLAGS"
|
||||||
|
LIBS="-ledit $LIBS"
|
||||||
|
LIBEDIT=libedit.a
|
||||||
|
LIBDEPENDS="$LIBDEPENDS ../libedit/libedit.a"
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
CFLAGS="-DNO_EDITCOMPLETE $CFLAGS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test $ac_cv_func_sl_init = yes; then
|
||||||
|
AC_MSG_TRY_COMPILE(if sl_add() returns int, ftp_cv_INT_SL_ADD, [
|
||||||
|
#include <stringlist.h> ], [ int f = sl_add((StringList *)0, "foo") ],
|
||||||
|
[:] , [LIBOBJS="$LIBOBJS sl_init.o"])
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
have_rfc2553_netdb=no
|
||||||
|
if test $ac_cv_func_getaddrinfo = yes -a ! -n "$socks"; then
|
||||||
|
AC_MSG_TRY_COMPILE(for AI_NUMERICHOST,
|
||||||
|
ftp_cv_have_ai_numerichost, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netdb.h> ],
|
||||||
|
[ int X = AI_NUMERICHOST ], [ have_rfc2553_netdb=yes ])
|
||||||
|
fi
|
||||||
|
AC_MSG_CHECKING(for working getaddrinfo())
|
||||||
|
if test $have_rfc2553_netdb = yes; then
|
||||||
|
AC_DEFINE(HAVE_RFC2553_NETDB, 1)
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
else
|
||||||
|
if test $ac_cv_func_getaddrinfo = yes; then
|
||||||
|
LIBOBJS="$LIBOBJS getaddrinfo.o"
|
||||||
|
AC_MSG_RESULT(no - using local version)
|
||||||
|
else
|
||||||
|
AC_MSG_RESULT(using local version)
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test $ac_cv_header_vis_h = yes; then
|
||||||
|
AC_MSG_TRY_COMPILE(for VIS_WHITE in vis.h,
|
||||||
|
ftp_cv_have_vis_white, [
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <vis.h> ], [ int X = VIS_WHITE ], [:],
|
||||||
|
ac_cv_header_vis_h=no )
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if test -n "$LIBOBJS"; then
|
||||||
|
INCLUDES="$INCLUDES -I\${srcdir}/../libukem"
|
||||||
|
LDFLAGS="$LDFLAGS -L../libukem"
|
||||||
|
LIBS="$LIBS -lukem"
|
||||||
|
LIBUKEM=libukem.a
|
||||||
|
LIBDEPENDS="$LIBDEPENDS ../libukem/libukem.a"
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Create the Makefiles
|
||||||
|
dnl
|
||||||
|
|
||||||
|
AC_SUBST(INCLUDES)
|
||||||
|
AC_SUBST(LIBEDIT)
|
||||||
|
AC_SUBST(LIBUKEM)
|
||||||
|
AC_SUBST(LIBDEPENDS)
|
||||||
|
|
||||||
|
AC_OUTPUT(Makefile libedit/Makefile libedit/makelist libukem/Makefile \
|
||||||
|
src/Makefile)
|
3500
contrib/tnftp/diffout
Normal file
3500
contrib/tnftp/diffout
Normal file
File diff suppressed because it is too large
Load Diff
251
contrib/tnftp/install-sh
Executable file
251
contrib/tnftp/install-sh
Executable file
@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# install - install a program, script, or datafile
|
||||||
|
# This comes from X11R5 (mit/util/scripts/install.sh).
|
||||||
|
#
|
||||||
|
# Copyright 1991 by the Massachusetts Institute of Technology
|
||||||
|
#
|
||||||
|
# Permission to use, copy, modify, distribute, and sell this software and its
|
||||||
|
# documentation for any purpose is hereby granted without fee, provided that
|
||||||
|
# the above copyright notice appear in all copies and that both that
|
||||||
|
# copyright notice and this permission notice appear in supporting
|
||||||
|
# documentation, and that the name of M.I.T. not be used in advertising or
|
||||||
|
# publicity pertaining to distribution of the software without specific,
|
||||||
|
# written prior permission. M.I.T. makes no representations about the
|
||||||
|
# suitability of this software for any purpose. It is provided "as is"
|
||||||
|
# without express or implied warranty.
|
||||||
|
#
|
||||||
|
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||||
|
# `make' implicit rules from creating a file called install from it
|
||||||
|
# when there is no Makefile.
|
||||||
|
#
|
||||||
|
# This script is compatible with the BSD install script, but was written
|
||||||
|
# from scratch. It can only install one file at a time, a restriction
|
||||||
|
# shared with many OS's install programs.
|
||||||
|
|
||||||
|
|
||||||
|
# set DOITPROG to echo to test this script
|
||||||
|
|
||||||
|
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||||
|
doit="${DOITPROG-}"
|
||||||
|
|
||||||
|
|
||||||
|
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||||
|
|
||||||
|
mvprog="${MVPROG-mv}"
|
||||||
|
cpprog="${CPPROG-cp}"
|
||||||
|
chmodprog="${CHMODPROG-chmod}"
|
||||||
|
chownprog="${CHOWNPROG-chown}"
|
||||||
|
chgrpprog="${CHGRPPROG-chgrp}"
|
||||||
|
stripprog="${STRIPPROG-strip}"
|
||||||
|
rmprog="${RMPROG-rm}"
|
||||||
|
mkdirprog="${MKDIRPROG-mkdir}"
|
||||||
|
|
||||||
|
transformbasename=""
|
||||||
|
transform_arg=""
|
||||||
|
instcmd="$mvprog"
|
||||||
|
chmodcmd="$chmodprog 0755"
|
||||||
|
chowncmd=""
|
||||||
|
chgrpcmd=""
|
||||||
|
stripcmd=""
|
||||||
|
rmcmd="$rmprog -f"
|
||||||
|
mvcmd="$mvprog"
|
||||||
|
src=""
|
||||||
|
dst=""
|
||||||
|
dir_arg=""
|
||||||
|
|
||||||
|
while [ x"$1" != x ]; do
|
||||||
|
case $1 in
|
||||||
|
-c) instcmd="$cpprog"
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-d) dir_arg=true
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-m) chmodcmd="$chmodprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-o) chowncmd="$chownprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-g) chgrpcmd="$chgrpprog $2"
|
||||||
|
shift
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-s) stripcmd="$stripprog"
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
|
||||||
|
*) if [ x"$src" = x ]
|
||||||
|
then
|
||||||
|
src=$1
|
||||||
|
else
|
||||||
|
# this colon is to work around a 386BSD /bin/sh bug
|
||||||
|
:
|
||||||
|
dst=$1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
continue;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ x"$src" = x ]
|
||||||
|
then
|
||||||
|
echo "install: no input file specified"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$dir_arg" != x ]; then
|
||||||
|
dst=$src
|
||||||
|
src=""
|
||||||
|
|
||||||
|
if [ -d $dst ]; then
|
||||||
|
instcmd=:
|
||||||
|
chmodcmd=""
|
||||||
|
else
|
||||||
|
instcmd=mkdir
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
|
||||||
|
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
|
||||||
|
# might cause directories to be created, which would be especially bad
|
||||||
|
# if $src (and thus $dsttmp) contains '*'.
|
||||||
|
|
||||||
|
if [ -f $src -o -d $src ]
|
||||||
|
then
|
||||||
|
true
|
||||||
|
else
|
||||||
|
echo "install: $src does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$dst" = x ]
|
||||||
|
then
|
||||||
|
echo "install: no destination specified"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If destination is a directory, append the input filename; if your system
|
||||||
|
# does not like double slashes in filenames, you may need to add some logic
|
||||||
|
|
||||||
|
if [ -d $dst ]
|
||||||
|
then
|
||||||
|
dst="$dst"/`basename $src`
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
## this sed command emulates the dirname command
|
||||||
|
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||||
|
|
||||||
|
# Make sure that the destination directory exists.
|
||||||
|
# this part is taken from Noah Friedman's mkinstalldirs script
|
||||||
|
|
||||||
|
# Skip lots of stat calls in the usual case.
|
||||||
|
if [ ! -d "$dstdir" ]; then
|
||||||
|
defaultIFS='
|
||||||
|
'
|
||||||
|
IFS="${IFS-${defaultIFS}}"
|
||||||
|
|
||||||
|
oIFS="${IFS}"
|
||||||
|
# Some sh's can't handle IFS=/ for some reason.
|
||||||
|
IFS='%'
|
||||||
|
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||||
|
IFS="${oIFS}"
|
||||||
|
|
||||||
|
pathcomp=''
|
||||||
|
|
||||||
|
while [ $# -ne 0 ] ; do
|
||||||
|
pathcomp="${pathcomp}${1}"
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [ ! -d "${pathcomp}" ] ;
|
||||||
|
then
|
||||||
|
$mkdirprog "${pathcomp}"
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
pathcomp="${pathcomp}/"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ x"$dir_arg" != x ]
|
||||||
|
then
|
||||||
|
$doit $instcmd $dst &&
|
||||||
|
|
||||||
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
|
||||||
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
|
||||||
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
|
||||||
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
|
||||||
|
else
|
||||||
|
|
||||||
|
# If we're going to rename the final executable, determine the name now.
|
||||||
|
|
||||||
|
if [ x"$transformarg" = x ]
|
||||||
|
then
|
||||||
|
dstfile=`basename $dst`
|
||||||
|
else
|
||||||
|
dstfile=`basename $dst $transformbasename |
|
||||||
|
sed $transformarg`$transformbasename
|
||||||
|
fi
|
||||||
|
|
||||||
|
# don't allow the sed command to completely eliminate the filename
|
||||||
|
|
||||||
|
if [ x"$dstfile" = x ]
|
||||||
|
then
|
||||||
|
dstfile=`basename $dst`
|
||||||
|
else
|
||||||
|
true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Make a temp file name in the proper directory.
|
||||||
|
|
||||||
|
dsttmp=$dstdir/#inst.$$#
|
||||||
|
|
||||||
|
# Move or copy the file name to the temp name
|
||||||
|
|
||||||
|
$doit $instcmd $src $dsttmp &&
|
||||||
|
|
||||||
|
trap "rm -f ${dsttmp}" 0 &&
|
||||||
|
|
||||||
|
# and set any options; do chmod last to preserve setuid bits
|
||||||
|
|
||||||
|
# If any of these fail, we abort the whole thing. If we want to
|
||||||
|
# ignore errors from any of these, just make sure not to ignore
|
||||||
|
# errors from the above "$doit $instcmd $src $dsttmp" command.
|
||||||
|
|
||||||
|
if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
|
||||||
|
if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
|
||||||
|
if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
|
||||||
|
if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
|
||||||
|
|
||||||
|
# Now rename the file to the real destination.
|
||||||
|
|
||||||
|
$doit $rmcmd -f $dstdir/$dstfile &&
|
||||||
|
$doit $mvcmd $dsttmp $dstdir/$dstfile
|
||||||
|
|
||||||
|
fi &&
|
||||||
|
|
||||||
|
|
||||||
|
exit 0
|
403
contrib/tnftp/lukemftp.h
Normal file
403
contrib/tnftp/lukemftp.h
Normal file
@ -0,0 +1,403 @@
|
|||||||
|
/* $Id: lukemftp.h,v 1.43 2002/06/10 08:13:01 lukem Exp $ */
|
||||||
|
|
||||||
|
#define FTP_PRODUCT "lukemftp"
|
||||||
|
#define FTP_VERSION "1.6-beta2"
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/in_systm.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
|
||||||
|
#include <arpa/ftp.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#if HAVE_POLL
|
||||||
|
# if HAVE_POLL_H
|
||||||
|
# include <poll.h>
|
||||||
|
# elif HAVE_SYS_POLL_H
|
||||||
|
# include <sys/poll.h>
|
||||||
|
# endif
|
||||||
|
#elif HAVE_SELECT
|
||||||
|
# define USE_SELECT
|
||||||
|
#else
|
||||||
|
# error "no poll() or select() found"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_DIRENT_H
|
||||||
|
# include <dirent.h>
|
||||||
|
#else
|
||||||
|
# define dirent direct
|
||||||
|
# if HAVE_SYS_NDIR_H
|
||||||
|
# include <sys/ndir.h>
|
||||||
|
# endif
|
||||||
|
# if HAVE_SYS_DIR_H
|
||||||
|
# include <sys/dir.h>
|
||||||
|
# endif
|
||||||
|
# if HAVE_NDIR_H
|
||||||
|
# include <ndir.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if TIME_WITH_SYS_TIME
|
||||||
|
# include <sys/time.h>
|
||||||
|
# include <time.h>
|
||||||
|
#else
|
||||||
|
# if HAVE_SYS_TIME_H
|
||||||
|
# include <sys/time.h>
|
||||||
|
# else
|
||||||
|
# include <time.h>
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_ERR_H
|
||||||
|
# include <err.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if USE_GLOB_H /* not set by configure; used by other build systems */
|
||||||
|
# include <glob.h>
|
||||||
|
#else
|
||||||
|
# include "ftpglob.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_PATHS_H
|
||||||
|
# include <paths.h>
|
||||||
|
#endif
|
||||||
|
#ifndef _PATH_BSHELL
|
||||||
|
#define _PATH_BSHELL "/bin/sh"
|
||||||
|
#endif
|
||||||
|
#ifndef _PATH_TMP
|
||||||
|
#define _PATH_TMP "/tmp/"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct _stringlist {
|
||||||
|
char **sl_str;
|
||||||
|
size_t sl_max;
|
||||||
|
size_t sl_cur;
|
||||||
|
} StringList;
|
||||||
|
|
||||||
|
StringList *sl_init(void);
|
||||||
|
int sl_add(StringList *, char *);
|
||||||
|
void sl_free(StringList *, int);
|
||||||
|
char *sl_find(StringList *, char *);
|
||||||
|
|
||||||
|
#if HAVE_TERMCAP_H
|
||||||
|
# include <termcap.h>
|
||||||
|
#else
|
||||||
|
int tgetent(char *, const char *);
|
||||||
|
char *tgetstr(const char *, char **);
|
||||||
|
int tgetflag(const char *);
|
||||||
|
int tgetnum(const char *);
|
||||||
|
char *tgoto(const char *, int, int);
|
||||||
|
void tputs(const char *, int, int (*)(int));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_UTIL_H
|
||||||
|
# include <util.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_LIBUTIL_H
|
||||||
|
# include <libutil.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_VIS_H
|
||||||
|
# include <vis.h>
|
||||||
|
#else
|
||||||
|
# include "ftpvis.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_IN_PORT_T
|
||||||
|
typedef unsigned short in_port_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_SA_FAMILY_T
|
||||||
|
typedef unsigned short sa_family_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_SOCKLEN_T
|
||||||
|
typedef unsigned int socklen_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_AF_INET6 && HAVE_SOCKADDR_IN6
|
||||||
|
# define INET6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if ! HAVE_RFC2553_NETDB
|
||||||
|
|
||||||
|
/* RFC 2553 */
|
||||||
|
#undef EAI_ADDRFAMILY
|
||||||
|
#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
|
||||||
|
#undef EAI_AGAIN
|
||||||
|
#define EAI_AGAIN 2 /* temporary failure in name resolution */
|
||||||
|
#undef EAI_BADFLAGS
|
||||||
|
#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
|
||||||
|
#undef EAI_FAIL
|
||||||
|
#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
|
||||||
|
#undef EAI_FAMILY
|
||||||
|
#define EAI_FAMILY 5 /* ai_family not supported */
|
||||||
|
#undef EAI_MEMORY
|
||||||
|
#define EAI_MEMORY 6 /* memory allocation failure */
|
||||||
|
#undef EAI_NODATA
|
||||||
|
#define EAI_NODATA 7 /* no address associated with hostname */
|
||||||
|
#undef EAI_NONAME
|
||||||
|
#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
|
||||||
|
#undef EAI_SERVICE
|
||||||
|
#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
|
||||||
|
#undef EAI_SOCKTYPE
|
||||||
|
#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
|
||||||
|
#undef EAI_SYSTEM
|
||||||
|
#define EAI_SYSTEM 11 /* system error returned in errno */
|
||||||
|
|
||||||
|
/* KAME extensions? */
|
||||||
|
#undef EAI_BADHINTS
|
||||||
|
#define EAI_BADHINTS 12
|
||||||
|
#undef EAI_PROTOCOL
|
||||||
|
#define EAI_PROTOCOL 13
|
||||||
|
#undef EAI_MAX
|
||||||
|
#define EAI_MAX 14
|
||||||
|
|
||||||
|
/* RFC 2553 */
|
||||||
|
#undef NI_MAXHOST
|
||||||
|
#define NI_MAXHOST 1025
|
||||||
|
#undef NI_MAXSERV
|
||||||
|
#define NI_MAXSERV 32
|
||||||
|
|
||||||
|
#undef NI_NOFQDN
|
||||||
|
#define NI_NOFQDN 0x00000001
|
||||||
|
#undef NI_NUMERICHOST
|
||||||
|
#define NI_NUMERICHOST 0x00000002
|
||||||
|
#undef NI_NAMEREQD
|
||||||
|
#define NI_NAMEREQD 0x00000004
|
||||||
|
#undef NI_NUMERICSERV
|
||||||
|
#define NI_NUMERICSERV 0x00000008
|
||||||
|
#undef NI_DGRAM
|
||||||
|
#define NI_DGRAM 0x00000010
|
||||||
|
|
||||||
|
/* RFC 2553 */
|
||||||
|
#undef AI_PASSIVE
|
||||||
|
#define AI_PASSIVE 0x00000001 /* get address to use bind() */
|
||||||
|
#undef AI_CANONNAME
|
||||||
|
#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
|
||||||
|
|
||||||
|
/* KAME extensions ? */
|
||||||
|
#undef AI_NUMERICHOST
|
||||||
|
#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
|
||||||
|
#undef AI_MASK
|
||||||
|
#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
|
||||||
|
|
||||||
|
/* RFC 2553 */
|
||||||
|
#undef AI_ALL
|
||||||
|
#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
|
||||||
|
#undef AI_V4MAPPED_CFG
|
||||||
|
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
|
||||||
|
#undef AI_ADDRCONFIG
|
||||||
|
#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
|
||||||
|
#undef AI_V4MAPPED
|
||||||
|
#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
|
||||||
|
|
||||||
|
#endif /* ! HAVE_RFC2553_NETDB */
|
||||||
|
|
||||||
|
|
||||||
|
#if ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO
|
||||||
|
|
||||||
|
struct addrinfo {
|
||||||
|
int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
|
||||||
|
int ai_family; /* PF_xxx */
|
||||||
|
int ai_socktype; /* SOCK_xxx */
|
||||||
|
int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
|
||||||
|
size_t ai_addrlen; /* length of ai_addr */
|
||||||
|
char *ai_canonname; /* canonical name for hostname */
|
||||||
|
struct sockaddr *ai_addr; /* binary address */
|
||||||
|
struct addrinfo *ai_next; /* next structure in linked list */
|
||||||
|
};
|
||||||
|
|
||||||
|
int getaddrinfo(const char *, const char *,
|
||||||
|
const struct addrinfo *, struct addrinfo **);
|
||||||
|
int getnameinfo(const struct sockaddr *, socklen_t, char *,
|
||||||
|
size_t, char *, size_t, int);
|
||||||
|
void freeaddrinfo(struct addrinfo *);
|
||||||
|
char *gai_strerror(int);
|
||||||
|
|
||||||
|
#endif /* ! HAVE_RFC2553_NETDB && ! HAVE_ADDRINFO */
|
||||||
|
|
||||||
|
|
||||||
|
#if ! HAVE_D_NAMLEN
|
||||||
|
# define DIRENT_MISSING_D_NAMLEN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_H_ERRNO_D
|
||||||
|
extern int h_errno;
|
||||||
|
#endif
|
||||||
|
#define HAVE_H_ERRNO 1 /* XXX: an assumption for now... */
|
||||||
|
|
||||||
|
#if ! HAVE_FCLOSE_D
|
||||||
|
int fclose(FILE *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_GETPASS_D
|
||||||
|
char *getpass(const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_OPTARG_D
|
||||||
|
extern char *optarg;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_OPTIND_D
|
||||||
|
extern int optind;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_PCLOSE_D
|
||||||
|
int pclose(FILE *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_ERR
|
||||||
|
void err(int, const char *, ...);
|
||||||
|
void errx(int, const char *, ...);
|
||||||
|
void warn(const char *, ...);
|
||||||
|
void warnx(const char *, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_FGETLN
|
||||||
|
char *fgetln(FILE *, size_t *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_FSEEKO
|
||||||
|
int fseeko(FILE *, off_t, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_FPARSELN
|
||||||
|
# define FPARSELN_UNESCESC 0x01
|
||||||
|
# define FPARSELN_UNESCCONT 0x02
|
||||||
|
# define FPARSELN_UNESCCOMM 0x04
|
||||||
|
# define FPARSELN_UNESCREST 0x08
|
||||||
|
# define FPARSELN_UNESCALL 0x0f
|
||||||
|
char *fparseln(FILE *, size_t *, size_t *, const char[3], int);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_INET_NTOP
|
||||||
|
const char *inet_ntop(int, const void *, char *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_INET_PTON
|
||||||
|
int inet_pton(int, const char *, void *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_MKSTEMP
|
||||||
|
int mkstemp(char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_SETPROGNAME
|
||||||
|
const char *getprogname(void);
|
||||||
|
void setprogname(const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_SNPRINTF
|
||||||
|
int snprintf(char *, size_t, const char *, ...);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_STRDUP
|
||||||
|
char *strdup(const char *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_STRERROR
|
||||||
|
char *strerror(int);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_STRPTIME || ! HAVE_STRPTIME_D
|
||||||
|
char *strptime(const char *, const char *, struct tm *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_QUAD_SUPPORT
|
||||||
|
# if ! HAVE_STRTOLL && HAVE_LONG_LONG
|
||||||
|
long long strtoll(const char *, char **, int);
|
||||||
|
# if ! defined(QUAD_MIN)
|
||||||
|
# define QUAD_MIN (-0x7fffffffffffffffL-1)
|
||||||
|
# endif
|
||||||
|
# if ! defined(QUAD_MAX)
|
||||||
|
# define QUAD_MAX (0x7fffffffffffffffL)
|
||||||
|
# endif
|
||||||
|
# endif
|
||||||
|
#else /* ! HAVE_QUAD_SUPPORT */
|
||||||
|
# define NO_LONG_LONG 1
|
||||||
|
#endif /* ! HAVE_QUAD_SUPPORT */
|
||||||
|
|
||||||
|
#if ! HAVE_TIMEGM
|
||||||
|
time_t timegm(struct tm *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_HSTRERROR
|
||||||
|
char *strerror(int);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_STRLCAT
|
||||||
|
size_t strlcat(char *, const char *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_STRLCPY
|
||||||
|
size_t strlcpy(char *, const char *, size_t);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_STRSEP
|
||||||
|
char *strsep(char **stringp, const char *delim);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! HAVE_MEMMOVE
|
||||||
|
# define memmove(a,b,c) bcopy((b),(a),(c))
|
||||||
|
/* XXX: add others #defines for borken systems? */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if HAVE_GETPASSPHRASE
|
||||||
|
# define getpass getpassphrase
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! defined(MIN)
|
||||||
|
# define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
#endif
|
||||||
|
#if ! defined(MAX)
|
||||||
|
# define MAX(a, b) ((a) < (b) ? (b) : (a))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! defined(timersub)
|
||||||
|
# define timersub(tvp, uvp, vvp) \
|
||||||
|
do { \
|
||||||
|
(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \
|
||||||
|
(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \
|
||||||
|
if ((vvp)->tv_usec < 0) { \
|
||||||
|
(vvp)->tv_sec--; \
|
||||||
|
(vvp)->tv_usec += 1000000; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if ! defined(S_ISLNK)
|
||||||
|
# define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define EPOCH_YEAR 1970
|
||||||
|
#define SECSPERHOUR 3600
|
||||||
|
#define SECSPERDAY 86400
|
||||||
|
#define TM_YEAR_BASE 1900
|
28
contrib/tnftp/src/Makefile
Normal file
28
contrib/tnftp/src/Makefile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# $NetBSD: Makefile,v 1.30 2005/02/11 15:13:28 jmc Exp $
|
||||||
|
# from: @(#)Makefile 8.2 (Berkeley) 4/3/94
|
||||||
|
|
||||||
|
.include <bsd.own.mk>
|
||||||
|
|
||||||
|
PROG= ftp
|
||||||
|
SRCS= cmds.c cmdtab.c complete.c domacro.c fetch.c ftp.c main.c \
|
||||||
|
progressbar.c ruserpass.c util.c
|
||||||
|
|
||||||
|
# Uncomment the following to provide defaults for gate-ftp operation
|
||||||
|
#
|
||||||
|
#CPPFLAGS+=-DGATE_SERVER=\"ftp-gw.host\" # -DGATE_PORT=21
|
||||||
|
|
||||||
|
.if defined(SMALLPROG)
|
||||||
|
CPPFLAGS+=-DNO_EDITCOMPLETE -DNO_ABOUT -DNO_AUTH -DNO_HELP -DNO_STATUS
|
||||||
|
.else
|
||||||
|
LDADD+= -ledit -ltermcap
|
||||||
|
DPADD+= ${LIBEDIT} ${LIBTERMCAP}
|
||||||
|
.endif
|
||||||
|
|
||||||
|
.if (!defined(SMALLPROG) || defined(SMALLPROG_INET6)) && (${USE_INET6} != "no")
|
||||||
|
CPPFLAGS+= -DINET6
|
||||||
|
.endif
|
||||||
|
|
||||||
|
cmds.o fetch.o: version.h
|
||||||
|
main.o: ftp_var.h
|
||||||
|
|
||||||
|
.include <bsd.prog.mk>
|
43
contrib/tnftp/src/Makefile.in
Normal file
43
contrib/tnftp/src/Makefile.in
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
#
|
||||||
|
# $Id: Makefile.in,v 1.8 2000/08/08 07:04:27 lukem Exp $
|
||||||
|
#
|
||||||
|
|
||||||
|
srcdir = @srcdir@
|
||||||
|
VPATH = @srcdir@
|
||||||
|
SHELL = /bin/sh
|
||||||
|
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix = @exec_prefix@
|
||||||
|
bindir = @bindir@
|
||||||
|
mandir = @mandir@
|
||||||
|
transform = @program_transform_name@
|
||||||
|
|
||||||
|
mandircat1 = ${mandir}/cat1
|
||||||
|
|
||||||
|
CC = @CC@
|
||||||
|
CFLAGS = -I${srcdir} -I${srcdir}/.. -I. -I.. @INCLUDES@ @CFLAGS@
|
||||||
|
LIBS = @LIBS@
|
||||||
|
LDFLAGS = @LDFLAGS@
|
||||||
|
|
||||||
|
INSTALL = @INSTALL@
|
||||||
|
|
||||||
|
PROG = ftp
|
||||||
|
OBJS = cmds.o cmdtab.o complete.o domacro.o fetch.o ftp.o main.o \
|
||||||
|
ruserpass.o util.o
|
||||||
|
|
||||||
|
all: ${PROG}
|
||||||
|
|
||||||
|
install: all
|
||||||
|
-mkdir -p ${bindir}
|
||||||
|
${INSTALL} -m 555 ${PROG} ${bindir}/`echo ${PROG}|sed '$(transform)'`
|
||||||
|
-mkdir -p ${mandircat1}
|
||||||
|
${INSTALL} -m 444 ${srcdir}/${PROG}.cat1 ${mandircat1}/`echo ${PROG}|sed '$(transform)'`.1
|
||||||
|
|
||||||
|
${PROG}: ${OBJS} @LIBDEPENDS@
|
||||||
|
${CC} ${CFLAGS} ${LDFLAGS} -o ${PROG} ${OBJS} ${LIBS}
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f core ${PROG} ${OBJS}
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
rm -f Makefile
|
2753
contrib/tnftp/src/cmds.c
Normal file
2753
contrib/tnftp/src/cmds.c
Normal file
File diff suppressed because it is too large
Load Diff
309
contrib/tnftp/src/cmdtab.c
Normal file
309
contrib/tnftp/src/cmdtab.c
Normal file
@ -0,0 +1,309 @@
|
|||||||
|
/* $NetBSD: cmdtab.c,v 1.44 2005/04/11 01:49:31 lukem Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Luke Mewburn.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1985, 1989, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: cmdtab.c,v 1.44 2005/04/11 01:49:31 lukem Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "ftp_var.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* User FTP -- Command Tables.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define HSTR static const char
|
||||||
|
|
||||||
|
#ifndef NO_HELP
|
||||||
|
HSTR accounthelp[] = "send account command to remote server";
|
||||||
|
HSTR appendhelp[] = "append to a file";
|
||||||
|
HSTR asciihelp[] = "set ascii transfer type";
|
||||||
|
HSTR beephelp[] = "beep when command completed";
|
||||||
|
HSTR binaryhelp[] = "set binary transfer type";
|
||||||
|
HSTR casehelp[] = "toggle mget upper/lower case id mapping";
|
||||||
|
HSTR cdhelp[] = "change remote working directory";
|
||||||
|
HSTR cduphelp[] = "change remote working directory to parent directory";
|
||||||
|
HSTR chmodhelp[] = "change file permissions of remote file";
|
||||||
|
HSTR connecthelp[] = "connect to remote ftp server";
|
||||||
|
HSTR crhelp[] = "toggle carriage return stripping on ascii gets";
|
||||||
|
HSTR debughelp[] = "toggle/set debugging mode";
|
||||||
|
HSTR deletehelp[] = "delete remote file";
|
||||||
|
HSTR disconhelp[] = "terminate ftp session";
|
||||||
|
HSTR domachelp[] = "execute macro";
|
||||||
|
HSTR edithelp[] = "toggle command line editing";
|
||||||
|
HSTR epsv4help[] = "toggle use of EPSV/EPRT on IPv4 ftp";
|
||||||
|
HSTR feathelp[] = "show FEATures supported by remote system";
|
||||||
|
HSTR formhelp[] = "set file transfer format";
|
||||||
|
HSTR gatehelp[] = "toggle gate-ftp; specify host[:port] to change proxy";
|
||||||
|
HSTR globhelp[] = "toggle metacharacter expansion of local file names";
|
||||||
|
HSTR hashhelp[] = "toggle printing `#' marks; specify number to set size";
|
||||||
|
HSTR helphelp[] = "print local help information";
|
||||||
|
HSTR idlehelp[] = "get (set) idle timer on remote side";
|
||||||
|
HSTR lcdhelp[] = "change local working directory";
|
||||||
|
HSTR lpagehelp[] = "view a local file through your pager";
|
||||||
|
HSTR lpwdhelp[] = "print local working directory";
|
||||||
|
HSTR lshelp[] = "list contents of remote path";
|
||||||
|
HSTR macdefhelp[] = "define a macro";
|
||||||
|
HSTR mdeletehelp[] = "delete multiple files";
|
||||||
|
HSTR mgethelp[] = "get multiple files";
|
||||||
|
HSTR mregethelp[] = "get multiple files restarting at end of local file";
|
||||||
|
HSTR fgethelp[] = "get files using a localfile as a source of names";
|
||||||
|
HSTR mkdirhelp[] = "make directory on the remote machine";
|
||||||
|
HSTR mlshelp[] = "list contents of multiple remote directories";
|
||||||
|
HSTR mlsdhelp[] = "list contents of remote directory in a machine "
|
||||||
|
"parsable form";
|
||||||
|
HSTR mlsthelp[] = "list remote path in a machine parsable form";
|
||||||
|
HSTR modehelp[] = "set file transfer mode";
|
||||||
|
HSTR modtimehelp[] = "show last modification time of remote file";
|
||||||
|
HSTR mputhelp[] = "send multiple files";
|
||||||
|
HSTR newerhelp[] = "get file if remote file is newer than local file ";
|
||||||
|
HSTR nmaphelp[] = "set templates for default file name mapping";
|
||||||
|
HSTR ntranshelp[] = "set translation table for default file name mapping";
|
||||||
|
HSTR optshelp[] = "show or set options for remote commands";
|
||||||
|
HSTR pagehelp[] = "view a remote file through your pager";
|
||||||
|
HSTR passivehelp[] = "toggle use of passive transfer mode";
|
||||||
|
HSTR plshelp[] = "list contents of remote path through your pager";
|
||||||
|
HSTR pmlsdhelp[] = "list contents of remote directory in a machine "
|
||||||
|
"parsable form through your pager";
|
||||||
|
HSTR porthelp[] = "toggle use of PORT/LPRT cmd for each data connection";
|
||||||
|
HSTR preservehelp[] ="toggle preservation of modification time of "
|
||||||
|
"retrieved files";
|
||||||
|
HSTR progresshelp[] ="toggle transfer progress meter";
|
||||||
|
HSTR prompthelp[] = "force interactive prompting on multiple commands";
|
||||||
|
HSTR proxyhelp[] = "issue command on alternate connection";
|
||||||
|
HSTR pwdhelp[] = "print working directory on remote machine";
|
||||||
|
HSTR quithelp[] = "terminate ftp session and exit";
|
||||||
|
HSTR quotehelp[] = "send arbitrary ftp command";
|
||||||
|
HSTR ratehelp[] = "set transfer rate limit (in bytes/second)";
|
||||||
|
HSTR receivehelp[] = "receive file";
|
||||||
|
HSTR regethelp[] = "get file restarting at end of local file";
|
||||||
|
HSTR remotehelp[] = "get help from remote server";
|
||||||
|
HSTR renamehelp[] = "rename file";
|
||||||
|
HSTR resethelp[] = "clear queued command replies";
|
||||||
|
HSTR restarthelp[]= "restart file transfer at bytecount";
|
||||||
|
HSTR rmdirhelp[] = "remove directory on the remote machine";
|
||||||
|
HSTR rmtstatushelp[]="show status of remote machine";
|
||||||
|
HSTR runiquehelp[] = "toggle store unique for local files";
|
||||||
|
HSTR sendhelp[] = "send one file";
|
||||||
|
HSTR sethelp[] = "set or display options";
|
||||||
|
HSTR shellhelp[] = "escape to the shell";
|
||||||
|
HSTR sitehelp[] = "send site specific command to remote server\n"
|
||||||
|
"\t\tTry \"rhelp site\" or \"site help\" "
|
||||||
|
"for more information";
|
||||||
|
HSTR sizecmdhelp[] = "show size of remote file";
|
||||||
|
HSTR statushelp[] = "show current status";
|
||||||
|
HSTR structhelp[] = "set file transfer structure";
|
||||||
|
HSTR suniquehelp[] = "toggle store unique on remote machine";
|
||||||
|
HSTR systemhelp[] = "show remote system type";
|
||||||
|
HSTR tenexhelp[] = "set tenex file transfer type";
|
||||||
|
HSTR tracehelp[] = "toggle packet tracing";
|
||||||
|
HSTR typehelp[] = "set file transfer type";
|
||||||
|
HSTR umaskhelp[] = "get (set) umask on remote side";
|
||||||
|
HSTR unsethelp[] = "unset an option";
|
||||||
|
HSTR usagehelp[] = "show command usage";
|
||||||
|
HSTR userhelp[] = "send new user information";
|
||||||
|
HSTR verbosehelp[] = "toggle verbose mode";
|
||||||
|
HSTR xferbufhelp[] = "set socket send/receive buffer size";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
HSTR empty[] = "";
|
||||||
|
|
||||||
|
#ifdef NO_HELP
|
||||||
|
#define H(x) empty
|
||||||
|
#else
|
||||||
|
#define H(x) x
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_EDITCOMPLETE
|
||||||
|
#define CMPL(x)
|
||||||
|
#define CMPL0
|
||||||
|
#else /* !NO_EDITCOMPLETE */
|
||||||
|
#define CMPL(x) #x,
|
||||||
|
#define CMPL0 empty,
|
||||||
|
#endif /* !NO_EDITCOMPLETE */
|
||||||
|
|
||||||
|
struct cmd cmdtab[] = {
|
||||||
|
{ "!", H(shellhelp), 0, 0, 0, CMPL0 shell },
|
||||||
|
{ "$", H(domachelp), 1, 0, 0, CMPL0 domacro },
|
||||||
|
{ "account", H(accounthelp), 0, 1, 1, CMPL0 account},
|
||||||
|
{ "append", H(appendhelp), 1, 1, 1, CMPL(lr) put },
|
||||||
|
{ "ascii", H(asciihelp), 0, 1, 1, CMPL0 setascii },
|
||||||
|
{ "bell", H(beephelp), 0, 0, 0, CMPL0 setbell },
|
||||||
|
{ "binary", H(binaryhelp), 0, 1, 1, CMPL0 setbinary },
|
||||||
|
{ "bye", H(quithelp), 0, 0, 0, CMPL0 quit },
|
||||||
|
{ "case", H(casehelp), 0, 0, 1, CMPL0 setcase },
|
||||||
|
{ "cd", H(cdhelp), 0, 1, 1, CMPL(r) cd },
|
||||||
|
{ "cdup", H(cduphelp), 0, 1, 1, CMPL0 cdup },
|
||||||
|
{ "chmod", H(chmodhelp), 0, 1, 1, CMPL(nr) do_chmod },
|
||||||
|
{ "close", H(disconhelp), 0, 1, 1, CMPL0 disconnect },
|
||||||
|
{ "cr", H(crhelp), 0, 0, 0, CMPL0 setcr },
|
||||||
|
{ "debug", H(debughelp), 0, 0, 0, CMPL0 setdebug },
|
||||||
|
{ "delete", H(deletehelp), 0, 1, 1, CMPL(r) delete },
|
||||||
|
{ "dir", H(lshelp), 1, 1, 1, CMPL(rl) ls },
|
||||||
|
{ "disconnect", H(disconhelp), 0, 1, 1, CMPL0 disconnect },
|
||||||
|
{ "edit", H(edithelp), 0, 0, 0, CMPL0 setedit },
|
||||||
|
{ "epsv4", H(epsv4help), 0, 0, 0, CMPL0 setepsv4 },
|
||||||
|
{ "exit", H(quithelp), 0, 0, 0, CMPL0 quit },
|
||||||
|
{ "features", H(feathelp), 0, 1, 1, CMPL0 feat },
|
||||||
|
{ "fget", H(fgethelp), 1, 1, 1, CMPL(l) fget },
|
||||||
|
{ "form", H(formhelp), 0, 1, 1, CMPL0 setform },
|
||||||
|
{ "ftp", H(connecthelp), 0, 0, 1, CMPL0 setpeer },
|
||||||
|
{ "gate", H(gatehelp), 0, 0, 0, CMPL0 setgate },
|
||||||
|
{ "get", H(receivehelp), 1, 1, 1, CMPL(rl) get },
|
||||||
|
{ "glob", H(globhelp), 0, 0, 0, CMPL0 setglob },
|
||||||
|
{ "hash", H(hashhelp), 0, 0, 0, CMPL0 sethash },
|
||||||
|
{ "help", H(helphelp), 0, 0, 1, CMPL(C) help },
|
||||||
|
{ "idle", H(idlehelp), 0, 1, 1, CMPL0 idlecmd },
|
||||||
|
{ "image", H(binaryhelp), 0, 1, 1, CMPL0 setbinary },
|
||||||
|
{ "lcd", H(lcdhelp), 0, 0, 0, CMPL(l) lcd },
|
||||||
|
{ "less", H(pagehelp), 1, 1, 1, CMPL(r) page },
|
||||||
|
{ "lpage", H(lpagehelp), 0, 0, 0, CMPL(l) lpage },
|
||||||
|
{ "lpwd", H(lpwdhelp), 0, 0, 0, CMPL0 lpwd },
|
||||||
|
{ "ls", H(lshelp), 1, 1, 1, CMPL(rl) ls },
|
||||||
|
{ "macdef", H(macdefhelp), 0, 0, 0, CMPL0 macdef },
|
||||||
|
{ "mdelete", H(mdeletehelp), 1, 1, 1, CMPL(R) mdelete },
|
||||||
|
{ "mdir", H(mlshelp), 1, 1, 1, CMPL(R) mls },
|
||||||
|
{ "mget", H(mgethelp), 1, 1, 1, CMPL(R) mget },
|
||||||
|
{ "mkdir", H(mkdirhelp), 0, 1, 1, CMPL(r) makedir },
|
||||||
|
{ "mls", H(mlshelp), 1, 1, 1, CMPL(R) mls },
|
||||||
|
{ "mlsd", H(mlsdhelp), 1, 1, 1, CMPL(r) ls },
|
||||||
|
{ "mlst", H(mlsthelp), 1, 1, 1, CMPL(r) mlst },
|
||||||
|
{ "mode", H(modehelp), 0, 1, 1, CMPL0 setftmode },
|
||||||
|
{ "modtime", H(modtimehelp), 0, 1, 1, CMPL(r) modtime },
|
||||||
|
{ "more", H(pagehelp), 1, 1, 1, CMPL(r) page },
|
||||||
|
{ "mput", H(mputhelp), 1, 1, 1, CMPL(L) mput },
|
||||||
|
{ "mreget", H(mregethelp), 1, 1, 1, CMPL(R) mget },
|
||||||
|
{ "msend", H(mputhelp), 1, 1, 1, CMPL(L) mput },
|
||||||
|
{ "newer", H(newerhelp), 1, 1, 1, CMPL(r) newer },
|
||||||
|
{ "nlist", H(lshelp), 1, 1, 1, CMPL(rl) ls },
|
||||||
|
{ "nmap", H(nmaphelp), 0, 0, 1, CMPL0 setnmap },
|
||||||
|
{ "ntrans", H(ntranshelp), 0, 0, 1, CMPL0 setntrans },
|
||||||
|
{ "open", H(connecthelp), 0, 0, 1, CMPL0 setpeer },
|
||||||
|
{ "page", H(pagehelp), 1, 1, 1, CMPL(r) page },
|
||||||
|
{ "passive", H(passivehelp), 0, 0, 0, CMPL0 setpassive },
|
||||||
|
{ "pdir", H(plshelp), 1, 1, 1, CMPL(r) ls },
|
||||||
|
{ "pls", H(plshelp), 1, 1, 1, CMPL(r) ls },
|
||||||
|
{ "pmlsd", H(pmlsdhelp), 1, 1, 1, CMPL(r) ls },
|
||||||
|
{ "preserve", H(preservehelp),0, 0, 0, CMPL0 setpreserve },
|
||||||
|
{ "progress", H(progresshelp),0, 0, 0, CMPL0 setprogress },
|
||||||
|
{ "prompt", H(prompthelp), 0, 0, 0, CMPL0 setprompt },
|
||||||
|
{ "proxy", H(proxyhelp), 0, 0, 1, CMPL(c) doproxy },
|
||||||
|
{ "put", H(sendhelp), 1, 1, 1, CMPL(lr) put },
|
||||||
|
{ "pwd", H(pwdhelp), 0, 1, 1, CMPL0 pwd },
|
||||||
|
{ "quit", H(quithelp), 0, 0, 0, CMPL0 quit },
|
||||||
|
{ "quote", H(quotehelp), 1, 1, 1, CMPL0 quote },
|
||||||
|
{ "rate", H(ratehelp), 0, 0, 0, CMPL0 setrate },
|
||||||
|
{ "rcvbuf", H(xferbufhelp), 0, 0, 0, CMPL0 setxferbuf },
|
||||||
|
{ "recv", H(receivehelp), 1, 1, 1, CMPL(rl) get },
|
||||||
|
{ "reget", H(regethelp), 1, 1, 1, CMPL(rl) reget },
|
||||||
|
{ "remopts", H(optshelp), 0, 1, 1, CMPL0 opts },
|
||||||
|
{ "rename", H(renamehelp), 0, 1, 1, CMPL(rr) renamefile },
|
||||||
|
{ "reset", H(resethelp), 0, 1, 1, CMPL0 reset },
|
||||||
|
{ "restart", H(restarthelp), 1, 1, 1, CMPL0 restart },
|
||||||
|
{ "rhelp", H(remotehelp), 0, 1, 1, CMPL0 rmthelp },
|
||||||
|
{ "rmdir", H(rmdirhelp), 0, 1, 1, CMPL(r) removedir },
|
||||||
|
{ "rstatus", H(rmtstatushelp),0, 1, 1, CMPL(r) rmtstatus },
|
||||||
|
{ "runique", H(runiquehelp), 0, 0, 1, CMPL0 setrunique },
|
||||||
|
{ "send", H(sendhelp), 1, 1, 1, CMPL(lr) put },
|
||||||
|
{ "sendport", H(porthelp), 0, 0, 0, CMPL0 setport },
|
||||||
|
{ "set", H(sethelp), 0, 0, 0, CMPL(o) setoption },
|
||||||
|
{ "site", H(sitehelp), 0, 1, 1, CMPL0 site },
|
||||||
|
{ "size", H(sizecmdhelp), 1, 1, 1, CMPL(r) sizecmd },
|
||||||
|
{ "sndbuf", H(xferbufhelp), 0, 0, 0, CMPL0 setxferbuf },
|
||||||
|
{ "status", H(statushelp), 0, 0, 1, CMPL0 status },
|
||||||
|
{ "struct", H(structhelp), 0, 1, 1, CMPL0 setstruct },
|
||||||
|
{ "sunique", H(suniquehelp), 0, 0, 1, CMPL0 setsunique },
|
||||||
|
{ "system", H(systemhelp), 0, 1, 1, CMPL0 syst },
|
||||||
|
{ "tenex", H(tenexhelp), 0, 1, 1, CMPL0 settenex },
|
||||||
|
{ "throttle", H(ratehelp), 0, 0, 0, CMPL0 setrate },
|
||||||
|
{ "trace", H(tracehelp), 0, 0, 0, CMPL0 settrace },
|
||||||
|
{ "type", H(typehelp), 0, 1, 1, CMPL0 settype },
|
||||||
|
{ "umask", H(umaskhelp), 0, 1, 1, CMPL0 do_umask },
|
||||||
|
{ "unset", H(unsethelp), 0, 0, 0, CMPL(o) unsetoption },
|
||||||
|
{ "usage", H(usagehelp), 0, 0, 1, CMPL(C) help },
|
||||||
|
{ "user", H(userhelp), 0, 1, 1, CMPL0 user },
|
||||||
|
{ "verbose", H(verbosehelp), 0, 0, 0, CMPL0 setverbose },
|
||||||
|
{ "xferbuf", H(xferbufhelp), 0, 0, 0, CMPL0 setxferbuf },
|
||||||
|
{ "?", H(helphelp), 0, 0, 1, CMPL(C) help },
|
||||||
|
{ 0 },
|
||||||
|
};
|
||||||
|
|
||||||
|
struct option optiontab[] = {
|
||||||
|
{ "anonpass", NULL },
|
||||||
|
{ "ftp_proxy", NULL },
|
||||||
|
{ "http_proxy", NULL },
|
||||||
|
{ "no_proxy", NULL },
|
||||||
|
{ "pager", NULL },
|
||||||
|
{ "prompt", NULL },
|
||||||
|
{ "rprompt", NULL },
|
||||||
|
{ 0 },
|
||||||
|
};
|
435
contrib/tnftp/src/complete.c
Normal file
435
contrib/tnftp/src/complete.c
Normal file
@ -0,0 +1,435 @@
|
|||||||
|
/* $NetBSD: complete.c,v 1.38 2000/05/01 10:35:17 lukem Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1997-2000 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Luke Mewburn.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
__RCSID("$NetBSD: complete.c,v 1.38 2000/05/01 10:35:17 lukem Exp $");
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FTP user program - command and file completion routines
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "ftp_var.h"
|
||||||
|
|
||||||
|
#ifndef NO_EDITCOMPLETE
|
||||||
|
|
||||||
|
static int comparstr (const void *, const void *);
|
||||||
|
static unsigned char complete_ambiguous (char *, int, StringList *);
|
||||||
|
static unsigned char complete_command (char *, int);
|
||||||
|
static unsigned char complete_local (char *, int);
|
||||||
|
static unsigned char complete_option (char *, int);
|
||||||
|
static unsigned char complete_remote (char *, int);
|
||||||
|
|
||||||
|
static int
|
||||||
|
comparstr(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return (strcmp(*(const char **)a, *(const char **)b));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Determine if complete is ambiguous. If unique, insert.
|
||||||
|
* If no choices, error. If unambiguous prefix, insert that.
|
||||||
|
* Otherwise, list choices. words is assumed to be filtered
|
||||||
|
* to only contain possible choices.
|
||||||
|
* Args:
|
||||||
|
* word word which started the match
|
||||||
|
* list list by default
|
||||||
|
* words stringlist containing possible matches
|
||||||
|
* Returns a result as per el_set(EL_ADDFN, ...)
|
||||||
|
*/
|
||||||
|
static unsigned char
|
||||||
|
complete_ambiguous(char *word, int list, StringList *words)
|
||||||
|
{
|
||||||
|
char insertstr[MAXPATHLEN];
|
||||||
|
char *lastmatch, *p;
|
||||||
|
int i, j;
|
||||||
|
size_t matchlen, wordlen;
|
||||||
|
|
||||||
|
wordlen = strlen(word);
|
||||||
|
if (words->sl_cur == 0)
|
||||||
|
return (CC_ERROR); /* no choices available */
|
||||||
|
|
||||||
|
if (words->sl_cur == 1) { /* only once choice available */
|
||||||
|
p = words->sl_str[0] + wordlen;
|
||||||
|
if (*p == '\0') /* at end of word? */
|
||||||
|
return (CC_REFRESH);
|
||||||
|
ftpvis(insertstr, sizeof(insertstr), p, strlen(p));
|
||||||
|
if (el_insertstr(el, insertstr) == -1)
|
||||||
|
return (CC_ERROR);
|
||||||
|
else
|
||||||
|
return (CC_REFRESH);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!list) {
|
||||||
|
matchlen = 0;
|
||||||
|
lastmatch = words->sl_str[0];
|
||||||
|
matchlen = strlen(lastmatch);
|
||||||
|
for (i = 1 ; i < words->sl_cur ; i++) {
|
||||||
|
for (j = wordlen ; j < strlen(words->sl_str[i]); j++)
|
||||||
|
if (lastmatch[j] != words->sl_str[i][j])
|
||||||
|
break;
|
||||||
|
if (j < matchlen)
|
||||||
|
matchlen = j;
|
||||||
|
}
|
||||||
|
if (matchlen > wordlen) {
|
||||||
|
ftpvis(insertstr, sizeof(insertstr),
|
||||||
|
lastmatch + wordlen, matchlen - wordlen);
|
||||||
|
if (el_insertstr(el, insertstr) == -1)
|
||||||
|
return (CC_ERROR);
|
||||||
|
else
|
||||||
|
return (CC_REFRESH_BEEP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
putc('\n', ttyout);
|
||||||
|
qsort(words->sl_str, words->sl_cur, sizeof(char *), comparstr);
|
||||||
|
list_vertical(words);
|
||||||
|
return (CC_REDISPLAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Complete a command
|
||||||
|
*/
|
||||||
|
static unsigned char
|
||||||
|
complete_command(char *word, int list)
|
||||||
|
{
|
||||||
|
struct cmd *c;
|
||||||
|
StringList *words;
|
||||||
|
size_t wordlen;
|
||||||
|
unsigned char rv;
|
||||||
|
|
||||||
|
words = xsl_init();
|
||||||
|
wordlen = strlen(word);
|
||||||
|
|
||||||
|
for (c = cmdtab; c->c_name != NULL; c++) {
|
||||||
|
if (wordlen > strlen(c->c_name))
|
||||||
|
continue;
|
||||||
|
if (strncmp(word, c->c_name, wordlen) == 0)
|
||||||
|
xsl_add(words, c->c_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = complete_ambiguous(word, list, words);
|
||||||
|
if (rv == CC_REFRESH) {
|
||||||
|
if (el_insertstr(el, " ") == -1)
|
||||||
|
rv = CC_ERROR;
|
||||||
|
}
|
||||||
|
sl_free(words, 0);
|
||||||
|
return (rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Complete a local file
|
||||||
|
*/
|
||||||
|
static unsigned char
|
||||||
|
complete_local(char *word, int list)
|
||||||
|
{
|
||||||
|
StringList *words;
|
||||||
|
char dir[MAXPATHLEN];
|
||||||
|
char *file;
|
||||||
|
DIR *dd;
|
||||||
|
struct dirent *dp;
|
||||||
|
unsigned char rv;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
if ((file = strrchr(word, '/')) == NULL) {
|
||||||
|
dir[0] = '.';
|
||||||
|
dir[1] = '\0';
|
||||||
|
file = word;
|
||||||
|
} else {
|
||||||
|
if (file == word) {
|
||||||
|
dir[0] = '/';
|
||||||
|
dir[1] = '\0';
|
||||||
|
} else
|
||||||
|
(void)strlcpy(dir, word, file - word + 1);
|
||||||
|
file++;
|
||||||
|
}
|
||||||
|
if (dir[0] == '~') {
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if ((p = globulize(dir)) == NULL)
|
||||||
|
return (CC_ERROR);
|
||||||
|
(void)strlcpy(dir, p, sizeof(dir));
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((dd = opendir(dir)) == NULL)
|
||||||
|
return (CC_ERROR);
|
||||||
|
|
||||||
|
words = xsl_init();
|
||||||
|
len = strlen(file);
|
||||||
|
|
||||||
|
for (dp = readdir(dd); dp != NULL; dp = readdir(dd)) {
|
||||||
|
if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, ".."))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
#if defined(DIRENT_MISSING_D_NAMLEN)
|
||||||
|
if (len > strlen(dp->d_name))
|
||||||
|
continue;
|
||||||
|
#else
|
||||||
|
if (len > dp->d_namlen)
|
||||||
|
continue;
|
||||||
|
#endif
|
||||||
|
if (strncmp(file, dp->d_name, len) == 0) {
|
||||||
|
char *tcp;
|
||||||
|
|
||||||
|
tcp = xstrdup(dp->d_name);
|
||||||
|
xsl_add(words, tcp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(dd);
|
||||||
|
|
||||||
|
rv = complete_ambiguous(file, list, words);
|
||||||
|
if (rv == CC_REFRESH) {
|
||||||
|
struct stat sb;
|
||||||
|
char path[MAXPATHLEN];
|
||||||
|
|
||||||
|
(void)strlcpy(path, dir, sizeof(path));
|
||||||
|
(void)strlcat(path, "/", sizeof(path));
|
||||||
|
(void)strlcat(path, words->sl_str[0], sizeof(path));
|
||||||
|
|
||||||
|
if (stat(path, &sb) >= 0) {
|
||||||
|
char suffix[2] = " ";
|
||||||
|
|
||||||
|
if (S_ISDIR(sb.st_mode))
|
||||||
|
suffix[0] = '/';
|
||||||
|
if (el_insertstr(el, suffix) == -1)
|
||||||
|
rv = CC_ERROR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sl_free(words, 1);
|
||||||
|
return (rv);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Complete an option
|
||||||
|
*/
|
||||||
|
static unsigned char
|
||||||
|
complete_option(char *word, int list)
|
||||||
|
{
|
||||||
|
struct option *o;
|
||||||
|
StringList *words;
|
||||||
|
size_t wordlen;
|
||||||
|
unsigned char rv;
|
||||||
|
|
||||||
|
words = xsl_init();
|
||||||
|
wordlen = strlen(word);
|
||||||
|
|
||||||
|
for (o = optiontab; o->name != NULL; o++) {
|
||||||
|
if (wordlen > strlen(o->name))
|
||||||
|
continue;
|
||||||
|
if (strncmp(word, o->name, wordlen) == 0)
|
||||||
|
xsl_add(words, o->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = complete_ambiguous(word, list, words);
|
||||||
|
if (rv == CC_REFRESH) {
|
||||||
|
if (el_insertstr(el, " ") == -1)
|
||||||
|
rv = CC_ERROR;
|
||||||
|
}
|
||||||
|
sl_free(words, 0);
|
||||||
|
return (rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Complete a remote file
|
||||||
|
*/
|
||||||
|
static unsigned char
|
||||||
|
complete_remote(char *word, int list)
|
||||||
|
{
|
||||||
|
static StringList *dirlist;
|
||||||
|
static char lastdir[MAXPATHLEN];
|
||||||
|
StringList *words;
|
||||||
|
char dir[MAXPATHLEN];
|
||||||
|
char *file, *cp;
|
||||||
|
int i;
|
||||||
|
unsigned char rv;
|
||||||
|
|
||||||
|
char *dummyargv[] = { "complete", NULL, NULL };
|
||||||
|
dummyargv[1] = dir;
|
||||||
|
|
||||||
|
if ((file = strrchr(word, '/')) == NULL) {
|
||||||
|
dir[0] = '\0';
|
||||||
|
file = word;
|
||||||
|
} else {
|
||||||
|
cp = file;
|
||||||
|
while (*cp == '/' && cp > word)
|
||||||
|
cp--;
|
||||||
|
(void)strlcpy(dir, word, cp - word + 2);
|
||||||
|
file++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dirchange || dirlist == NULL ||
|
||||||
|
strcmp(dir, lastdir) != 0) { /* dir not cached */
|
||||||
|
char *emesg;
|
||||||
|
|
||||||
|
if (dirlist != NULL)
|
||||||
|
sl_free(dirlist, 1);
|
||||||
|
dirlist = xsl_init();
|
||||||
|
|
||||||
|
mflag = 1;
|
||||||
|
emesg = NULL;
|
||||||
|
while ((cp = remglob(dummyargv, 0, &emesg)) != NULL) {
|
||||||
|
char *tcp;
|
||||||
|
|
||||||
|
if (!mflag)
|
||||||
|
continue;
|
||||||
|
if (*cp == '\0') {
|
||||||
|
mflag = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tcp = strrchr(cp, '/');
|
||||||
|
if (tcp)
|
||||||
|
tcp++;
|
||||||
|
else
|
||||||
|
tcp = cp;
|
||||||
|
tcp = xstrdup(tcp);
|
||||||
|
xsl_add(dirlist, tcp);
|
||||||
|
}
|
||||||
|
if (emesg != NULL) {
|
||||||
|
fprintf(ttyout, "\n%s\n", emesg);
|
||||||
|
return (CC_REDISPLAY);
|
||||||
|
}
|
||||||
|
(void)strlcpy(lastdir, dir, sizeof(lastdir));
|
||||||
|
dirchange = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
words = xsl_init();
|
||||||
|
for (i = 0; i < dirlist->sl_cur; i++) {
|
||||||
|
cp = dirlist->sl_str[i];
|
||||||
|
if (strlen(file) > strlen(cp))
|
||||||
|
continue;
|
||||||
|
if (strncmp(file, cp, strlen(file)) == 0)
|
||||||
|
xsl_add(words, cp);
|
||||||
|
}
|
||||||
|
rv = complete_ambiguous(file, list, words);
|
||||||
|
sl_free(words, 0);
|
||||||
|
return (rv);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Generic complete routine
|
||||||
|
*/
|
||||||
|
unsigned char
|
||||||
|
complete(EditLine *el, int ch)
|
||||||
|
{
|
||||||
|
static char word[FTPBUFLEN];
|
||||||
|
static int lastc_argc, lastc_argo;
|
||||||
|
|
||||||
|
struct cmd *c;
|
||||||
|
const LineInfo *lf;
|
||||||
|
int celems, dolist, cmpltype;
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
lf = el_line(el);
|
||||||
|
len = lf->lastchar - lf->buffer;
|
||||||
|
if (len >= sizeof(line))
|
||||||
|
return (CC_ERROR);
|
||||||
|
(void)strlcpy(line, lf->buffer, len + 1);
|
||||||
|
cursor_pos = line + (lf->cursor - lf->buffer);
|
||||||
|
lastc_argc = cursor_argc; /* remember last cursor pos */
|
||||||
|
lastc_argo = cursor_argo;
|
||||||
|
makeargv(); /* build argc/argv of current line */
|
||||||
|
|
||||||
|
if (cursor_argo >= sizeof(word))
|
||||||
|
return (CC_ERROR);
|
||||||
|
|
||||||
|
dolist = 0;
|
||||||
|
/* if cursor and word is same, list alternatives */
|
||||||
|
if (lastc_argc == cursor_argc && lastc_argo == cursor_argo
|
||||||
|
&& strncmp(word, margv[cursor_argc] ? margv[cursor_argc] : "",
|
||||||
|
cursor_argo) == 0)
|
||||||
|
dolist = 1;
|
||||||
|
else if (cursor_argc < margc)
|
||||||
|
(void)strlcpy(word, margv[cursor_argc], cursor_argo + 1);
|
||||||
|
word[cursor_argo] = '\0';
|
||||||
|
|
||||||
|
if (cursor_argc == 0)
|
||||||
|
return (complete_command(word, dolist));
|
||||||
|
|
||||||
|
c = getcmd(margv[0]);
|
||||||
|
if (c == (struct cmd *)-1 || c == 0)
|
||||||
|
return (CC_ERROR);
|
||||||
|
celems = strlen(c->c_complete);
|
||||||
|
|
||||||
|
/* check for 'continuation' completes (which are uppercase) */
|
||||||
|
if ((cursor_argc > celems) && (celems > 0)
|
||||||
|
&& isupper((unsigned char) c->c_complete[celems-1]))
|
||||||
|
cursor_argc = celems;
|
||||||
|
|
||||||
|
if (cursor_argc > celems)
|
||||||
|
return (CC_ERROR);
|
||||||
|
|
||||||
|
cmpltype = c->c_complete[cursor_argc - 1];
|
||||||
|
switch (cmpltype) {
|
||||||
|
case 'c': /* command complete */
|
||||||
|
case 'C':
|
||||||
|
return (complete_command(word, dolist));
|
||||||
|
case 'l': /* local complete */
|
||||||
|
case 'L':
|
||||||
|
return (complete_local(word, dolist));
|
||||||
|
case 'n': /* no complete */
|
||||||
|
case 'N': /* no complete */
|
||||||
|
return (CC_ERROR);
|
||||||
|
case 'o': /* local complete */
|
||||||
|
case 'O':
|
||||||
|
return (complete_option(word, dolist));
|
||||||
|
case 'r': /* remote complete */
|
||||||
|
case 'R':
|
||||||
|
if (connected != -1) {
|
||||||
|
fputs("\nMust be logged in to complete.\n",
|
||||||
|
ttyout);
|
||||||
|
return (CC_REDISPLAY);
|
||||||
|
}
|
||||||
|
return (complete_remote(word, dolist));
|
||||||
|
default:
|
||||||
|
errx(1, "unknown complete type `%c'", cmpltype);
|
||||||
|
return (CC_ERROR);
|
||||||
|
}
|
||||||
|
/* NOTREACHED */
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* !NO_EDITCOMPLETE */
|
143
contrib/tnftp/src/domacro.c
Normal file
143
contrib/tnftp/src/domacro.c
Normal file
@ -0,0 +1,143 @@
|
|||||||
|
/* $NetBSD: domacro.c,v 1.20 2003/08/07 11:13:53 agc Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1985, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)domacro.c 8.3 (Berkeley) 4/2/94";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: domacro.c,v 1.20 2003/08/07 11:13:53 agc Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "ftp_var.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
domacro(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i, j, count = 2, loopflg = 0;
|
||||||
|
char *cp1, *cp2, line2[FTPBUFLEN];
|
||||||
|
struct cmd *c;
|
||||||
|
|
||||||
|
if ((argc == 0 && argv != NULL) ||
|
||||||
|
(argc < 2 && !another(&argc, &argv, "macro name"))) {
|
||||||
|
fprintf(ttyout, "usage: %s macro_name [args]\n", argv[0]);
|
||||||
|
code = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (i = 0; i < macnum; ++i) {
|
||||||
|
if (!strncmp(argv[1], macros[i].mac_name, 9))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (i == macnum) {
|
||||||
|
fprintf(ttyout, "'%s' macro not found.\n", argv[1]);
|
||||||
|
code = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
(void)strlcpy(line2, line, sizeof(line2));
|
||||||
|
TOP:
|
||||||
|
cp1 = macros[i].mac_start;
|
||||||
|
while (cp1 != macros[i].mac_end) {
|
||||||
|
while (isspace((unsigned char)*cp1))
|
||||||
|
cp1++;
|
||||||
|
cp2 = line;
|
||||||
|
while (*cp1 != '\0') {
|
||||||
|
switch(*cp1) {
|
||||||
|
case '\\':
|
||||||
|
*cp2++ = *++cp1;
|
||||||
|
break;
|
||||||
|
case '$':
|
||||||
|
if (isdigit((unsigned char)*(cp1+1))) {
|
||||||
|
j = 0;
|
||||||
|
while (isdigit((unsigned char)*++cp1))
|
||||||
|
j = 10*j + *cp1 - '0';
|
||||||
|
cp1--;
|
||||||
|
if (argc - 2 >= j) {
|
||||||
|
(void)strlcpy(cp2, argv[j+1],
|
||||||
|
sizeof(line) - (cp2 - line));
|
||||||
|
cp2 += strlen(argv[j+1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*(cp1+1) == 'i') {
|
||||||
|
loopflg = 1;
|
||||||
|
cp1++;
|
||||||
|
if (count < argc) {
|
||||||
|
(void)strlcpy(cp2, argv[count],
|
||||||
|
sizeof(line) - (cp2 - line));
|
||||||
|
cp2 += strlen(argv[count]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* intentional drop through */
|
||||||
|
default:
|
||||||
|
*cp2++ = *cp1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*cp1 != '\0')
|
||||||
|
cp1++;
|
||||||
|
}
|
||||||
|
*cp2 = '\0';
|
||||||
|
makeargv();
|
||||||
|
c = getcmd(margv[0]);
|
||||||
|
if (c == (struct cmd *)-1) {
|
||||||
|
fputs("?Ambiguous command.\n", ttyout);
|
||||||
|
code = -1;
|
||||||
|
} else if (c == 0) {
|
||||||
|
fputs("?Invalid command.\n", ttyout);
|
||||||
|
code = -1;
|
||||||
|
} else if (c->c_conn && !connected) {
|
||||||
|
fputs("Not connected.\n", ttyout);
|
||||||
|
code = -1;
|
||||||
|
} else {
|
||||||
|
if (verbose) {
|
||||||
|
fputs(line, ttyout);
|
||||||
|
putc('\n', ttyout);
|
||||||
|
}
|
||||||
|
margv[0] = c->c_name;
|
||||||
|
(*c->c_handler)(margc, margv);
|
||||||
|
if (bell && c->c_bell)
|
||||||
|
(void)putc('\007', ttyout);
|
||||||
|
(void)strlcpy(line, line2, sizeof(line));
|
||||||
|
makeargv();
|
||||||
|
argc = margc;
|
||||||
|
argv = margv;
|
||||||
|
}
|
||||||
|
if (cp1 != macros[i].mac_end)
|
||||||
|
cp1++;
|
||||||
|
}
|
||||||
|
if (loopflg && ++count < argc)
|
||||||
|
goto TOP;
|
||||||
|
}
|
257
contrib/tnftp/src/extern.h
Normal file
257
contrib/tnftp/src/extern.h
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
/* $NetBSD: extern.h,v 1.67 2005/05/14 15:26:43 lukem Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Luke Mewburn.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1994 The Regents of the University of California.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* @(#)extern.h 8.3 (Berkeley) 10/9/94
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1997 and 1998 WIDE Project.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct sockaddr;
|
||||||
|
struct tm;
|
||||||
|
struct addrinfo;
|
||||||
|
|
||||||
|
void abort_remote(FILE *);
|
||||||
|
void abort_squared(int);
|
||||||
|
void abortpt(int);
|
||||||
|
void abortxfer(int);
|
||||||
|
void account(int, char **);
|
||||||
|
void ai_unmapped(struct addrinfo *);
|
||||||
|
int another(int *, char ***, const char *);
|
||||||
|
int auto_fetch(int, char **);
|
||||||
|
int auto_put(int, char **, const char *);
|
||||||
|
void blkfree(char **);
|
||||||
|
void cd(int, char **);
|
||||||
|
void cdup(int, char **);
|
||||||
|
void changetype(int, int);
|
||||||
|
void cleanuppeer(void);
|
||||||
|
void cmdabort(int);
|
||||||
|
void cmdtimeout(int);
|
||||||
|
void cmdscanner(void);
|
||||||
|
int command(const char *, ...)
|
||||||
|
__attribute__((__format__(__printf__, 1, 2)));
|
||||||
|
#ifndef NO_EDITCOMPLETE
|
||||||
|
unsigned char complete(EditLine *, int);
|
||||||
|
void controlediting(void);
|
||||||
|
#endif /* !NO_EDITCOMPLETE */
|
||||||
|
void crankrate(int);
|
||||||
|
FILE *dataconn(const char *);
|
||||||
|
void delete(int, char **);
|
||||||
|
void disconnect(int, char **);
|
||||||
|
void do_chmod(int, char **);
|
||||||
|
void do_umask(int, char **);
|
||||||
|
void domacro(int, char **);
|
||||||
|
void doproxy(int, char **);
|
||||||
|
void feat(int, char **);
|
||||||
|
void fget(int, char **);
|
||||||
|
int fileindir(const char *, const char *);
|
||||||
|
int foregroundproc(void);
|
||||||
|
void formatbuf(char *, size_t, const char *);
|
||||||
|
void ftpvis(char *, size_t, const char *, size_t);
|
||||||
|
int ftp_login(const char *, const char *, const char *);
|
||||||
|
void get(int, char **);
|
||||||
|
struct cmd *getcmd(const char *);
|
||||||
|
int getit(int, char **, int, const char *);
|
||||||
|
struct option *getoption(const char *);
|
||||||
|
char *getoptionvalue(const char *);
|
||||||
|
void getremoteinfo(void);
|
||||||
|
int getreply(int);
|
||||||
|
char *globulize(const char *);
|
||||||
|
char *gunique(const char *);
|
||||||
|
void help(int, char **);
|
||||||
|
char *hookup(char *, char *);
|
||||||
|
void idlecmd(int, char **);
|
||||||
|
int initconn(void);
|
||||||
|
void intr(int);
|
||||||
|
int isipv6addr(const char *);
|
||||||
|
void list_vertical(StringList *);
|
||||||
|
void lcd(int, char **);
|
||||||
|
void lostpeer(int);
|
||||||
|
void lpage(int, char **);
|
||||||
|
void lpwd(int, char **);
|
||||||
|
void ls(int, char **);
|
||||||
|
void mabort(void);
|
||||||
|
void macdef(int, char **);
|
||||||
|
void makeargv(void);
|
||||||
|
void makedir(int, char **);
|
||||||
|
void mdelete(int, char **);
|
||||||
|
void mget(int, char **);
|
||||||
|
void mintr(int);
|
||||||
|
void mls(int, char **);
|
||||||
|
void mlst(int, char **);
|
||||||
|
void modtime(int, char **);
|
||||||
|
void mput(int, char **);
|
||||||
|
char *onoff(int);
|
||||||
|
void opts(int, char **);
|
||||||
|
void newer(int, char **);
|
||||||
|
void page(int, char **);
|
||||||
|
int parseport(const char *, int);
|
||||||
|
int parserate(int, char **, int);
|
||||||
|
char *prompt(void);
|
||||||
|
void proxabort(int);
|
||||||
|
void proxtrans(const char *, const char *, const char *);
|
||||||
|
void psabort(int);
|
||||||
|
void pswitch(int);
|
||||||
|
void put(int, char **);
|
||||||
|
void pwd(int, char **);
|
||||||
|
void quit(int, char **);
|
||||||
|
void quote(int, char **);
|
||||||
|
void quote1(const char *, int, char **);
|
||||||
|
void recvrequest(const char *, const char *, const char *,
|
||||||
|
const char *, int, int);
|
||||||
|
void reget(int, char **);
|
||||||
|
char *remglob(char **, int, char **);
|
||||||
|
time_t remotemodtime(const char *, int);
|
||||||
|
off_t remotesize(const char *, int);
|
||||||
|
void removedir(int, char **);
|
||||||
|
void renamefile(int, char **);
|
||||||
|
void reset(int, char **);
|
||||||
|
void restart(int, char **);
|
||||||
|
void rmthelp(int, char **);
|
||||||
|
void rmtstatus(int, char **);
|
||||||
|
char *rprompt(void);
|
||||||
|
int ruserpass(const char *, const char **, const char **,
|
||||||
|
const char **);
|
||||||
|
void sendrequest(const char *, const char *, const char *, int);
|
||||||
|
void setascii(int, char **);
|
||||||
|
void setbell(int, char **);
|
||||||
|
void setbinary(int, char **);
|
||||||
|
void setcase(int, char **);
|
||||||
|
void setcr(int, char **);
|
||||||
|
void setdebug(int, char **);
|
||||||
|
void setedit(int, char **);
|
||||||
|
void setepsv4(int, char **);
|
||||||
|
void setform(int, char **);
|
||||||
|
void setftmode(int, char **);
|
||||||
|
void setgate(int, char **);
|
||||||
|
void setglob(int, char **);
|
||||||
|
void sethash(int, char **);
|
||||||
|
void setnmap(int, char **);
|
||||||
|
void setntrans(int, char **);
|
||||||
|
void setoption(int, char **);
|
||||||
|
void setpassive(int, char **);
|
||||||
|
void setpeer(int, char **);
|
||||||
|
void setport(int, char **);
|
||||||
|
void setpreserve(int, char **);
|
||||||
|
void setprogress(int, char **);
|
||||||
|
void setprompt(int, char **);
|
||||||
|
void setrate(int, char **);
|
||||||
|
void setrunique(int, char **);
|
||||||
|
void setstruct(int, char **);
|
||||||
|
void setsunique(int, char **);
|
||||||
|
void settenex(int, char **);
|
||||||
|
void settrace(int, char **);
|
||||||
|
void setttywidth(int);
|
||||||
|
void settype(int, char **);
|
||||||
|
void setupsockbufsize(int);
|
||||||
|
void setverbose(int, char **);
|
||||||
|
void setxferbuf(int, char **);
|
||||||
|
void shell(int, char **);
|
||||||
|
void site(int, char **);
|
||||||
|
void sizecmd(int, char **);
|
||||||
|
char *slurpstring(void);
|
||||||
|
void status(int, char **);
|
||||||
|
int strsuftoi(const char *);
|
||||||
|
void syst(int, char **);
|
||||||
|
int togglevar(int, char **, int *, const char *);
|
||||||
|
void unsetoption(int, char **);
|
||||||
|
void updatelocalcwd(void);
|
||||||
|
void updateremotecwd(void);
|
||||||
|
void usage(void);
|
||||||
|
void user(int, char **);
|
||||||
|
int xconnect(int, const struct sockaddr *, socklen_t);
|
||||||
|
int xlisten(int, int);
|
||||||
|
int xpoll(struct pollfd *, int, int);
|
||||||
|
void *xmalloc(size_t);
|
||||||
|
StringList *xsl_init(void);
|
||||||
|
void xsl_add(StringList *, char *);
|
||||||
|
char *xstrdup(const char *);
|
1834
contrib/tnftp/src/fetch.c
Normal file
1834
contrib/tnftp/src/fetch.c
Normal file
File diff suppressed because it is too large
Load Diff
2357
contrib/tnftp/src/ftp.1
Normal file
2357
contrib/tnftp/src/ftp.1
Normal file
File diff suppressed because it is too large
Load Diff
2171
contrib/tnftp/src/ftp.c
Normal file
2171
contrib/tnftp/src/ftp.c
Normal file
File diff suppressed because it is too large
Load Diff
337
contrib/tnftp/src/ftp_var.h
Normal file
337
contrib/tnftp/src/ftp_var.h
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
/* $NetBSD: ftp_var.h,v 1.71 2005/04/11 01:49:31 lukem Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1996-2005 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Luke Mewburn.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1985, 1989, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* @(#)ftp_var.h 8.4 (Berkeley) 10/9/94
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 1997 and 1998 WIDE Project.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the project nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FTP global variables.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef SMALL
|
||||||
|
#undef NO_EDITCOMPLETE
|
||||||
|
#define NO_EDITCOMPLETE
|
||||||
|
#undef NO_PROGRESS
|
||||||
|
#define NO_PROGRESS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <sys/param.h>
|
||||||
|
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
|
#include <poll.h>
|
||||||
|
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <stringlist.h>
|
||||||
|
|
||||||
|
#ifndef NO_EDITCOMPLETE
|
||||||
|
#include <histedit.h>
|
||||||
|
#endif /* !NO_EDITCOMPLETE */
|
||||||
|
|
||||||
|
#include "extern.h"
|
||||||
|
#include "progressbar.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format of command table.
|
||||||
|
*/
|
||||||
|
struct cmd {
|
||||||
|
char *c_name; /* name of command */
|
||||||
|
const char *c_help; /* help string */
|
||||||
|
char c_bell; /* give bell when command completes */
|
||||||
|
char c_conn; /* must be connected to use command */
|
||||||
|
char c_proxy; /* proxy server may execute */
|
||||||
|
#ifndef NO_EDITCOMPLETE
|
||||||
|
const char *c_complete; /* context sensitive completion list */
|
||||||
|
#endif /* !NO_EDITCOMPLETE */
|
||||||
|
void (*c_handler)(int, char **); /* function to call */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format of macro table
|
||||||
|
*/
|
||||||
|
struct macel {
|
||||||
|
char mac_name[9]; /* macro name */
|
||||||
|
char *mac_start; /* start of macro in macbuf */
|
||||||
|
char *mac_end; /* end of macro in macbuf */
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Format of option table
|
||||||
|
*/
|
||||||
|
struct option {
|
||||||
|
char *name;
|
||||||
|
char *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Indices to features[]; an array containing status of remote server
|
||||||
|
* features; -1 not known (FEAT failed), 0 absent, 1 present.
|
||||||
|
*/
|
||||||
|
enum {
|
||||||
|
FEAT_FEAT = 0, /* FEAT, OPTS */
|
||||||
|
FEAT_MDTM, /* MDTM */
|
||||||
|
FEAT_MLST, /* MLSD, MLST */
|
||||||
|
FEAT_REST_STREAM, /* RESTart STREAM */
|
||||||
|
FEAT_SIZE, /* SIZE */
|
||||||
|
FEAT_TVFS, /* TVFS (not used) */
|
||||||
|
FEAT_max
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Global defines
|
||||||
|
*/
|
||||||
|
#define FTPBUFLEN MAXPATHLEN + 200
|
||||||
|
#define MAX_IN_PORT_T 0xffffU
|
||||||
|
|
||||||
|
#define HASHBYTES 1024 /* default mark for `hash' command */
|
||||||
|
#define DEFAULTINCR 1024 /* default increment for `rate' command */
|
||||||
|
|
||||||
|
#define FTP_PORT 21 /* default if ! getservbyname("ftp/tcp") */
|
||||||
|
#define HTTP_PORT 80 /* default if ! getservbyname("http/tcp") */
|
||||||
|
#ifndef GATE_PORT
|
||||||
|
#define GATE_PORT 21 /* default if ! getservbyname("ftpgate/tcp") */
|
||||||
|
#endif
|
||||||
|
#ifndef GATE_SERVER
|
||||||
|
#define GATE_SERVER "" /* default server */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DEFAULTPAGER "more" /* default pager if $PAGER isn't set */
|
||||||
|
#define DEFAULTPROMPT "ftp> " /* default prompt if `set prompt' is empty */
|
||||||
|
#define DEFAULTRPROMPT "" /* default rprompt if `set rprompt' is empty */
|
||||||
|
|
||||||
|
#define TMPFILE "ftpXXXXXXXXXX"
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef GLOBAL
|
||||||
|
#define GLOBAL extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Options and other state info.
|
||||||
|
*/
|
||||||
|
GLOBAL int trace; /* trace packets exchanged */
|
||||||
|
GLOBAL int hash; /* print # for each buffer transferred */
|
||||||
|
GLOBAL int mark; /* number of bytes between hashes */
|
||||||
|
GLOBAL int sendport; /* use PORT/LPRT cmd for each data connection */
|
||||||
|
GLOBAL int connected; /* 1 = connected to server, -1 = logged in */
|
||||||
|
GLOBAL int interactive; /* interactively prompt on m* cmds */
|
||||||
|
GLOBAL int confirmrest; /* confirm rest of current m* cmd */
|
||||||
|
GLOBAL int debug; /* debugging level */
|
||||||
|
GLOBAL int bell; /* ring bell on cmd completion */
|
||||||
|
GLOBAL int doglob; /* glob local file names */
|
||||||
|
GLOBAL int autologin; /* establish user account on connection */
|
||||||
|
GLOBAL int proxy; /* proxy server connection active */
|
||||||
|
GLOBAL int proxflag; /* proxy connection exists */
|
||||||
|
GLOBAL int gatemode; /* use gate-ftp */
|
||||||
|
GLOBAL char *gateserver; /* server to use for gate-ftp */
|
||||||
|
GLOBAL int sunique; /* store files on server with unique name */
|
||||||
|
GLOBAL int runique; /* store local files with unique name */
|
||||||
|
GLOBAL int mcase; /* map upper to lower case for mget names */
|
||||||
|
GLOBAL int ntflag; /* use ntin ntout tables for name translation */
|
||||||
|
GLOBAL int mapflag; /* use mapin mapout templates on file names */
|
||||||
|
GLOBAL int preserve; /* preserve modification time on files */
|
||||||
|
GLOBAL int code; /* return/reply code for ftp command */
|
||||||
|
GLOBAL int crflag; /* if 1, strip car. rets. on ascii gets */
|
||||||
|
GLOBAL int passivemode; /* passive mode enabled */
|
||||||
|
GLOBAL int activefallback; /* fall back to active mode if passive fails */
|
||||||
|
GLOBAL char *altarg; /* argv[1] with no shell-like preprocessing */
|
||||||
|
GLOBAL char ntin[17]; /* input translation table */
|
||||||
|
GLOBAL char ntout[17]; /* output translation table */
|
||||||
|
GLOBAL char mapin[MAXPATHLEN]; /* input map template */
|
||||||
|
GLOBAL char mapout[MAXPATHLEN]; /* output map template */
|
||||||
|
GLOBAL char typename[32]; /* name of file transfer type */
|
||||||
|
GLOBAL int type; /* requested file transfer type */
|
||||||
|
GLOBAL int curtype; /* current file transfer type */
|
||||||
|
GLOBAL char structname[32]; /* name of file transfer structure */
|
||||||
|
GLOBAL int stru; /* file transfer structure */
|
||||||
|
GLOBAL char formname[32]; /* name of file transfer format */
|
||||||
|
GLOBAL int form; /* file transfer format */
|
||||||
|
GLOBAL char modename[32]; /* name of file transfer mode */
|
||||||
|
GLOBAL int mode; /* file transfer mode */
|
||||||
|
GLOBAL char bytename[32]; /* local byte size in ascii */
|
||||||
|
GLOBAL int bytesize; /* local byte size in binary */
|
||||||
|
GLOBAL int anonftp; /* automatic anonymous login */
|
||||||
|
GLOBAL int dirchange; /* remote directory changed by cd command */
|
||||||
|
GLOBAL int flushcache; /* set HTTP cache flush headers with request */
|
||||||
|
GLOBAL int rate_get; /* maximum get xfer rate */
|
||||||
|
GLOBAL int rate_get_incr; /* increment for get xfer rate */
|
||||||
|
GLOBAL int rate_put; /* maximum put xfer rate */
|
||||||
|
GLOBAL int rate_put_incr; /* increment for put xfer rate */
|
||||||
|
GLOBAL int retry_connect; /* seconds between retrying connection */
|
||||||
|
GLOBAL char *tmpdir; /* temporary directory */
|
||||||
|
GLOBAL int epsv4; /* use EPSV/EPRT on IPv4 connections */
|
||||||
|
GLOBAL int epsv4bad; /* EPSV doesn't work on the current server */
|
||||||
|
GLOBAL int editing; /* command line editing enabled */
|
||||||
|
GLOBAL int features[FEAT_max]; /* remote FEATures supported */
|
||||||
|
|
||||||
|
#ifndef NO_EDITCOMPLETE
|
||||||
|
GLOBAL EditLine *el; /* editline(3) status structure */
|
||||||
|
GLOBAL History *hist; /* editline(3) history structure */
|
||||||
|
GLOBAL char *cursor_pos; /* cursor position we're looking for */
|
||||||
|
GLOBAL size_t cursor_argc; /* location of cursor in margv */
|
||||||
|
GLOBAL size_t cursor_argo; /* offset of cursor in margv[cursor_argc] */
|
||||||
|
#endif /* !NO_EDITCOMPLETE */
|
||||||
|
|
||||||
|
GLOBAL char *direction; /* direction transfer is occurring */
|
||||||
|
|
||||||
|
GLOBAL char *hostname; /* name of host connected to */
|
||||||
|
GLOBAL int unix_server; /* server is unix, can use binary for ascii */
|
||||||
|
GLOBAL int unix_proxy; /* proxy is unix, can use binary for ascii */
|
||||||
|
GLOBAL char localcwd[MAXPATHLEN]; /* local dir */
|
||||||
|
GLOBAL char remotecwd[MAXPATHLEN]; /* remote dir */
|
||||||
|
GLOBAL char *username; /* name of user logged in as. (dynamic) */
|
||||||
|
|
||||||
|
GLOBAL sa_family_t family; /* address family to use for connections */
|
||||||
|
GLOBAL char *ftpport; /* port number to use for FTP connections */
|
||||||
|
GLOBAL char *httpport; /* port number to use for HTTP connections */
|
||||||
|
GLOBAL char *gateport; /* port number to use for gateftp connections */
|
||||||
|
|
||||||
|
GLOBAL char *outfile; /* filename to output URLs to */
|
||||||
|
GLOBAL int restartautofetch; /* restart auto-fetch */
|
||||||
|
|
||||||
|
GLOBAL char line[FTPBUFLEN]; /* input line buffer */
|
||||||
|
GLOBAL char *stringbase; /* current scan point in line buffer */
|
||||||
|
GLOBAL char argbuf[FTPBUFLEN]; /* argument storage buffer */
|
||||||
|
GLOBAL char *argbase; /* current storage point in arg buffer */
|
||||||
|
GLOBAL StringList *marg_sl; /* stringlist containing margv */
|
||||||
|
GLOBAL int margc; /* count of arguments on input line */
|
||||||
|
#define margv (marg_sl->sl_str) /* args parsed from input line */
|
||||||
|
GLOBAL int cpend; /* flag: if != 0, then pending server reply */
|
||||||
|
GLOBAL int mflag; /* flag: if != 0, then active multi command */
|
||||||
|
|
||||||
|
GLOBAL int options; /* used during socket creation */
|
||||||
|
|
||||||
|
GLOBAL int sndbuf_size; /* socket send buffer size */
|
||||||
|
GLOBAL int rcvbuf_size; /* socket receive buffer size */
|
||||||
|
|
||||||
|
GLOBAL int macnum; /* number of defined macros */
|
||||||
|
GLOBAL struct macel macros[16];
|
||||||
|
GLOBAL char macbuf[4096];
|
||||||
|
|
||||||
|
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 void (*reply_callback)(const char *);
|
||||||
|
/*
|
||||||
|
* function to call for each line in
|
||||||
|
* the server's reply except for the
|
||||||
|
* first (`xxx-') and last (`xxx ')
|
||||||
|
*/
|
||||||
|
|
||||||
|
GLOBAL volatile sig_atomic_t sigint_raised;
|
||||||
|
|
||||||
|
GLOBAL FILE *cin;
|
||||||
|
GLOBAL FILE *cout;
|
||||||
|
GLOBAL int data;
|
||||||
|
|
||||||
|
extern struct cmd cmdtab[];
|
||||||
|
extern struct option optiontab[];
|
||||||
|
|
||||||
|
|
||||||
|
#define EMPTYSTRING(x) ((x) == NULL || (*(x) == '\0'))
|
||||||
|
#define FREEPTR(x) if ((x) != NULL) { free(x); (x) = NULL; }
|
||||||
|
|
||||||
|
#ifdef BSD4_4
|
||||||
|
# define HAVE_SOCKADDR_SA_LEN 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_LONG_LONG
|
||||||
|
# define STRTOLL(x,y,z) strtol(x,y,z)
|
||||||
|
#else
|
||||||
|
# define STRTOLL(x,y,z) strtoll(x,y,z)
|
||||||
|
#endif
|
1052
contrib/tnftp/src/main.c
Normal file
1052
contrib/tnftp/src/main.c
Normal file
File diff suppressed because it is too large
Load Diff
464
contrib/tnftp/src/progressbar.c
Normal file
464
contrib/tnftp/src/progressbar.c
Normal file
@ -0,0 +1,464 @@
|
|||||||
|
/* $NetBSD: progressbar.c,v 1.7 2005/04/11 01:49:31 lukem Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1997-2003 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Luke Mewburn.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
__RCSID("$NetBSD: progressbar.c,v 1.7 2005/04/11 01:49:31 lukem Exp $");
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FTP User Program -- Misc support routines
|
||||||
|
*/
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "progressbar.h"
|
||||||
|
|
||||||
|
#define SECSPERHOUR (60 * 60)
|
||||||
|
#define SECSPERDAY ((long)60 * 60 * 24)
|
||||||
|
|
||||||
|
#if !defined(NO_PROGRESS)
|
||||||
|
/*
|
||||||
|
* return non-zero if we're the current foreground process
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
foregroundproc(void)
|
||||||
|
{
|
||||||
|
static pid_t pgrp = -1;
|
||||||
|
|
||||||
|
if (pgrp == -1)
|
||||||
|
pgrp = getpgrp();
|
||||||
|
|
||||||
|
return (tcgetpgrp(fileno(ttyout)) == pgrp);
|
||||||
|
}
|
||||||
|
#endif /* !defined(NO_PROGRESS) */
|
||||||
|
|
||||||
|
|
||||||
|
static void updateprogressmeter(int);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SIGALRM handler to update the progress meter
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
updateprogressmeter(int dummy)
|
||||||
|
{
|
||||||
|
int oerrno = errno;
|
||||||
|
|
||||||
|
progressmeter(0);
|
||||||
|
errno = oerrno;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* List of order of magnitude prefixes.
|
||||||
|
* The last is `P', as 2^64 = 16384 Petabytes
|
||||||
|
*/
|
||||||
|
static const char prefixes[] = " KMGTP";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Display a transfer progress bar if progress is non-zero.
|
||||||
|
* SIGALRM is hijacked for use by this function.
|
||||||
|
* - Before the transfer, set filesize to size of file (or -1 if unknown),
|
||||||
|
* and call with flag = -1. This starts the once per second timer,
|
||||||
|
* and a call to updateprogressmeter() upon SIGALRM.
|
||||||
|
* - During the transfer, updateprogressmeter will call progressmeter
|
||||||
|
* with flag = 0
|
||||||
|
* - After the transfer, call with flag = 1
|
||||||
|
*/
|
||||||
|
static struct timeval start;
|
||||||
|
static struct timeval lastupdate;
|
||||||
|
|
||||||
|
#define BUFLEFT (sizeof(buf) - len)
|
||||||
|
|
||||||
|
void
|
||||||
|
progressmeter(int flag)
|
||||||
|
{
|
||||||
|
static off_t lastsize;
|
||||||
|
off_t cursize;
|
||||||
|
struct timeval now, wait;
|
||||||
|
#ifndef NO_PROGRESS
|
||||||
|
struct timeval td;
|
||||||
|
off_t abbrevsize, bytespersec;
|
||||||
|
double elapsed;
|
||||||
|
int ratio, barlength, i, remaining;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Work variables for progress bar.
|
||||||
|
*
|
||||||
|
* XXX: if the format of the progress bar changes
|
||||||
|
* (especially the number of characters in the
|
||||||
|
* `static' portion of it), be sure to update
|
||||||
|
* these appropriately.
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
int len;
|
||||||
|
char buf[256]; /* workspace for progress bar */
|
||||||
|
#ifndef NO_PROGRESS
|
||||||
|
#define BAROVERHEAD 43 /* non `*' portion of progress bar */
|
||||||
|
/*
|
||||||
|
* stars should contain at least
|
||||||
|
* sizeof(buf) - BAROVERHEAD entries
|
||||||
|
*/
|
||||||
|
static const char stars[] =
|
||||||
|
"*****************************************************************************"
|
||||||
|
"*****************************************************************************"
|
||||||
|
"*****************************************************************************";
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (flag == -1) {
|
||||||
|
(void)gettimeofday(&start, NULL);
|
||||||
|
lastupdate = start;
|
||||||
|
lastsize = restart_point;
|
||||||
|
}
|
||||||
|
|
||||||
|
(void)gettimeofday(&now, NULL);
|
||||||
|
cursize = bytes + restart_point;
|
||||||
|
timersub(&now, &lastupdate, &wait);
|
||||||
|
if (cursize > lastsize) {
|
||||||
|
lastupdate = now;
|
||||||
|
lastsize = cursize;
|
||||||
|
wait.tv_sec = 0;
|
||||||
|
} else {
|
||||||
|
#ifndef STANDALONE_PROGRESS
|
||||||
|
if (quit_time > 0 && wait.tv_sec > quit_time) {
|
||||||
|
len = snprintf(buf, sizeof(buf), "\r\n%s: "
|
||||||
|
"transfer aborted because stalled for %lu sec.\r\n",
|
||||||
|
getprogname(), (unsigned long)wait.tv_sec);
|
||||||
|
(void)write(fileno(ttyout), buf, len);
|
||||||
|
(void)xsignal(SIGALRM, SIG_DFL);
|
||||||
|
alarmtimer(0);
|
||||||
|
siglongjmp(toplevel, 1);
|
||||||
|
}
|
||||||
|
#endif /* !STANDALONE_PROGRESS */
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* Always set the handler even if we are not the foreground process.
|
||||||
|
*/
|
||||||
|
#ifdef STANDALONE_PROGRESS
|
||||||
|
if (progress) {
|
||||||
|
#else
|
||||||
|
if (quit_time > 0 || progress) {
|
||||||
|
#endif /* !STANDALONE_PROGRESS */
|
||||||
|
if (flag == -1) {
|
||||||
|
(void)xsignal_restart(SIGALRM, updateprogressmeter, 1);
|
||||||
|
alarmtimer(1); /* set alarm timer for 1 Hz */
|
||||||
|
} else if (flag == 1) {
|
||||||
|
(void)xsignal(SIGALRM, SIG_DFL);
|
||||||
|
alarmtimer(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#ifndef NO_PROGRESS
|
||||||
|
if (!progress)
|
||||||
|
return;
|
||||||
|
len = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* print progress bar only if we are foreground process.
|
||||||
|
*/
|
||||||
|
if (! foregroundproc())
|
||||||
|
return;
|
||||||
|
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "\r");
|
||||||
|
if (prefix)
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "%s", prefix);
|
||||||
|
if (filesize > 0) {
|
||||||
|
ratio = (int)((double)cursize * 100.0 / (double)filesize);
|
||||||
|
ratio = MAX(ratio, 0);
|
||||||
|
ratio = MIN(ratio, 100);
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "%3d%% ", ratio);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* calculate the length of the `*' bar, ensuring that
|
||||||
|
* the number of stars won't exceed the buffer size
|
||||||
|
*/
|
||||||
|
barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD;
|
||||||
|
if (prefix)
|
||||||
|
barlength -= strlen(prefix);
|
||||||
|
if (barlength > 0) {
|
||||||
|
i = barlength * ratio / 100;
|
||||||
|
len += snprintf(buf + len, BUFLEFT,
|
||||||
|
"|%.*s%*s|", i, stars, barlength - i, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abbrevsize = cursize;
|
||||||
|
for (i = 0; abbrevsize >= 100000 && i < sizeof(prefixes); i++)
|
||||||
|
abbrevsize >>= 10;
|
||||||
|
len += snprintf(buf + len, BUFLEFT, " " LLFP("5") " %c%c ",
|
||||||
|
(LLT)abbrevsize,
|
||||||
|
prefixes[i],
|
||||||
|
i == 0 ? ' ' : 'B');
|
||||||
|
|
||||||
|
timersub(&now, &start, &td);
|
||||||
|
elapsed = td.tv_sec + (td.tv_usec / 1000000.0);
|
||||||
|
|
||||||
|
bytespersec = 0;
|
||||||
|
if (bytes > 0) {
|
||||||
|
bytespersec = bytes;
|
||||||
|
if (elapsed > 0.0)
|
||||||
|
bytespersec /= elapsed;
|
||||||
|
}
|
||||||
|
for (i = 1; bytespersec >= 1024000 && i < sizeof(prefixes); i++)
|
||||||
|
bytespersec >>= 10;
|
||||||
|
len += snprintf(buf + len, BUFLEFT,
|
||||||
|
" " LLFP("3") ".%02d %cB/s ",
|
||||||
|
(LLT)(bytespersec / 1024),
|
||||||
|
(int)((bytespersec % 1024) * 100 / 1024),
|
||||||
|
prefixes[i]);
|
||||||
|
|
||||||
|
if (filesize > 0) {
|
||||||
|
if (bytes <= 0 || elapsed <= 0.0 || cursize > filesize) {
|
||||||
|
len += snprintf(buf + len, BUFLEFT, " --:-- ETA");
|
||||||
|
} 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)
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "\n");
|
||||||
|
(void)write(fileno(ttyout), buf, len);
|
||||||
|
|
||||||
|
#endif /* !NO_PROGRESS */
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef STANDALONE_PROGRESS
|
||||||
|
/*
|
||||||
|
* Display transfer statistics.
|
||||||
|
* Requires start to be initialised by progressmeter(-1),
|
||||||
|
* direction to be defined by xfer routines, and filesize and bytes
|
||||||
|
* to be updated by xfer routines
|
||||||
|
* If siginfo is nonzero, an ETA is displayed, and the output goes to stderr
|
||||||
|
* instead of ttyout.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
ptransfer(int siginfo)
|
||||||
|
{
|
||||||
|
struct timeval now, td, wait;
|
||||||
|
double elapsed;
|
||||||
|
off_t bytespersec;
|
||||||
|
int remaining, hh, i, len;
|
||||||
|
|
||||||
|
char buf[256]; /* Work variable for transfer status. */
|
||||||
|
|
||||||
|
if (!verbose && !progress && !siginfo)
|
||||||
|
return;
|
||||||
|
|
||||||
|
(void)gettimeofday(&now, NULL);
|
||||||
|
timersub(&now, &start, &td);
|
||||||
|
elapsed = td.tv_sec + (td.tv_usec / 1000000.0);
|
||||||
|
bytespersec = 0;
|
||||||
|
if (bytes > 0) {
|
||||||
|
bytespersec = bytes;
|
||||||
|
if (elapsed > 0.0)
|
||||||
|
bytespersec /= elapsed;
|
||||||
|
}
|
||||||
|
len = 0;
|
||||||
|
len += snprintf(buf + len, BUFLEFT, LLF " byte%s %s in ",
|
||||||
|
(LLT)bytes, bytes == 1 ? "" : "s", direction);
|
||||||
|
remaining = (int)elapsed;
|
||||||
|
if (remaining > SECSPERDAY) {
|
||||||
|
int days;
|
||||||
|
|
||||||
|
days = remaining / SECSPERDAY;
|
||||||
|
remaining %= SECSPERDAY;
|
||||||
|
len += snprintf(buf + len, BUFLEFT,
|
||||||
|
"%d day%s ", days, days == 1 ? "" : "s");
|
||||||
|
}
|
||||||
|
hh = remaining / SECSPERHOUR;
|
||||||
|
remaining %= SECSPERHOUR;
|
||||||
|
if (hh)
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "%2d:", hh);
|
||||||
|
len += snprintf(buf + len, BUFLEFT,
|
||||||
|
"%02d:%02d ", remaining / 60, remaining % 60);
|
||||||
|
|
||||||
|
for (i = 1; bytespersec >= 1024000 && i < sizeof(prefixes); i++)
|
||||||
|
bytespersec >>= 10;
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "(" LLF ".%02d %cB/s)",
|
||||||
|
(LLT)(bytespersec / 1024),
|
||||||
|
(int)((bytespersec % 1024) * 100 / 1024),
|
||||||
|
prefixes[i]);
|
||||||
|
|
||||||
|
if (siginfo && bytes > 0 && elapsed > 0.0 && filesize >= 0
|
||||||
|
&& bytes + restart_point <= filesize) {
|
||||||
|
remaining = (int)((filesize - restart_point) /
|
||||||
|
(bytes / elapsed) - elapsed);
|
||||||
|
hh = remaining / SECSPERHOUR;
|
||||||
|
remaining %= SECSPERHOUR;
|
||||||
|
len += snprintf(buf + len, BUFLEFT, " ETA: ");
|
||||||
|
if (hh)
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "%2d:", hh);
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "%02d:%02d",
|
||||||
|
remaining / 60, remaining % 60);
|
||||||
|
timersub(&now, &lastupdate, &wait);
|
||||||
|
if (wait.tv_sec >= STALLTIME)
|
||||||
|
len += snprintf(buf + len, BUFLEFT, " (stalled)");
|
||||||
|
}
|
||||||
|
len += snprintf(buf + len, BUFLEFT, "\n");
|
||||||
|
(void)write(siginfo ? STDERR_FILENO : fileno(ttyout), buf, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SIG{INFO,QUIT} handler to print transfer stats if a transfer is in progress
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
psummary(int notused)
|
||||||
|
{
|
||||||
|
int oerrno = errno;
|
||||||
|
|
||||||
|
if (bytes > 0) {
|
||||||
|
if (fromatty)
|
||||||
|
write(fileno(ttyout), "\n", 1);
|
||||||
|
ptransfer(1);
|
||||||
|
}
|
||||||
|
errno = oerrno;
|
||||||
|
}
|
||||||
|
#endif /* !STANDALONE_PROGRESS */
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set the SIGALRM interval timer for wait seconds, 0 to disable.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
alarmtimer(int wait)
|
||||||
|
{
|
||||||
|
struct itimerval itv;
|
||||||
|
|
||||||
|
itv.it_value.tv_sec = wait;
|
||||||
|
itv.it_value.tv_usec = 0;
|
||||||
|
itv.it_interval = itv.it_value;
|
||||||
|
setitimer(ITIMER_REAL, &itv, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Install a POSIX signal handler, allowing the invoker to set whether
|
||||||
|
* the signal should be restartable or not
|
||||||
|
*/
|
||||||
|
sigfunc
|
||||||
|
xsignal_restart(int sig, sigfunc func, int restartable)
|
||||||
|
{
|
||||||
|
struct sigaction act, oact;
|
||||||
|
act.sa_handler = func;
|
||||||
|
|
||||||
|
sigemptyset(&act.sa_mask);
|
||||||
|
#if defined(SA_RESTART) /* 4.4BSD, Posix(?), SVR4 */
|
||||||
|
act.sa_flags = restartable ? SA_RESTART : 0;
|
||||||
|
#elif defined(SA_INTERRUPT) /* SunOS 4.x */
|
||||||
|
act.sa_flags = restartable ? 0 : SA_INTERRUPT;
|
||||||
|
#else
|
||||||
|
#error "system must have SA_RESTART or SA_INTERRUPT"
|
||||||
|
#endif
|
||||||
|
if (sigaction(sig, &act, &oact) < 0)
|
||||||
|
return (SIG_ERR);
|
||||||
|
return (oact.sa_handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Install a signal handler with the `restartable' flag set dependent upon
|
||||||
|
* which signal is being set. (This is a wrapper to xsignal_restart())
|
||||||
|
*/
|
||||||
|
sigfunc
|
||||||
|
xsignal(int sig, sigfunc func)
|
||||||
|
{
|
||||||
|
int restartable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some signals print output or change the state of the process.
|
||||||
|
* There should be restartable, so that reads and writes are
|
||||||
|
* not affected. Some signals should cause program flow to change;
|
||||||
|
* these signals should not be restartable, so that the system call
|
||||||
|
* will return with EINTR, and the program will go do something
|
||||||
|
* different. If the signal handler calls longjmp() or siglongjmp(),
|
||||||
|
* it doesn't matter if it's restartable.
|
||||||
|
*/
|
||||||
|
|
||||||
|
switch(sig) {
|
||||||
|
#ifdef SIGINFO
|
||||||
|
case SIGINFO:
|
||||||
|
#endif
|
||||||
|
case SIGQUIT:
|
||||||
|
case SIGUSR1:
|
||||||
|
case SIGUSR2:
|
||||||
|
case SIGWINCH:
|
||||||
|
restartable = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case SIGALRM:
|
||||||
|
case SIGINT:
|
||||||
|
case SIGPIPE:
|
||||||
|
restartable = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/*
|
||||||
|
* This is unpleasant, but I don't know what would be better.
|
||||||
|
* Right now, this "can't happen"
|
||||||
|
*/
|
||||||
|
errx(1, "xsignal_restart called with signal %d", sig);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(xsignal_restart(sig, func, restartable));
|
||||||
|
}
|
99
contrib/tnftp/src/progressbar.h
Normal file
99
contrib/tnftp/src/progressbar.h
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
/* $NetBSD: progressbar.h,v 1.5 2005/02/10 16:00:38 jmc Exp $ */
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1996-2003 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Luke Mewburn.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STANDALONE_PROGRESS
|
||||||
|
#include <setjmp.h>
|
||||||
|
#endif /* !STANDALONE_PROGRESS */
|
||||||
|
|
||||||
|
#ifndef GLOBAL
|
||||||
|
#define GLOBAL extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define STALLTIME 5 /* # of seconds of no xfer before "stalling" */
|
||||||
|
|
||||||
|
typedef void (*sigfunc)(int);
|
||||||
|
|
||||||
|
|
||||||
|
GLOBAL FILE *ttyout; /* stdout, or stderr if retrieving to stdout */
|
||||||
|
|
||||||
|
GLOBAL int progress; /* display transfer progress bar */
|
||||||
|
GLOBAL int ttywidth; /* width of tty */
|
||||||
|
|
||||||
|
GLOBAL off_t bytes; /* current # of bytes read */
|
||||||
|
GLOBAL off_t filesize; /* size of file being transferred */
|
||||||
|
GLOBAL off_t restart_point; /* offset to restart transfer */
|
||||||
|
GLOBAL char *prefix; /* Text written left of progress bar */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef STANDALONE_PROGRESS
|
||||||
|
GLOBAL int fromatty; /* input is from a terminal */
|
||||||
|
GLOBAL int verbose; /* print messages coming back from server */
|
||||||
|
GLOBAL int quit_time; /* maximum time to wait if stalled */
|
||||||
|
|
||||||
|
GLOBAL char *direction; /* direction transfer is occurring */
|
||||||
|
|
||||||
|
GLOBAL sigjmp_buf toplevel; /* non-local goto stuff for cmd scanner */
|
||||||
|
#endif /* !STANDALONE_PROGRESS */
|
||||||
|
|
||||||
|
int foregroundproc(void);
|
||||||
|
void alarmtimer(int);
|
||||||
|
void progressmeter(int);
|
||||||
|
sigfunc xsignal(int, sigfunc);
|
||||||
|
sigfunc xsignal_restart(int, sigfunc, int);
|
||||||
|
|
||||||
|
#ifndef STANDALONE_PROGRESS
|
||||||
|
void psummary(int);
|
||||||
|
void ptransfer(int);
|
||||||
|
#endif /* !STANDALONE_PROGRESS */
|
||||||
|
|
||||||
|
#ifdef NO_LONG_LONG
|
||||||
|
# define LLF "%ld"
|
||||||
|
# define LLFP(x) "%" x "ld"
|
||||||
|
# define LLT long
|
||||||
|
# define ULLF "%lu"
|
||||||
|
# define ULLFP(x) "%" x "lu"
|
||||||
|
# define ULLT unsigned long
|
||||||
|
#else
|
||||||
|
# define LLF "%lld"
|
||||||
|
# define LLFP(x) "%" x "lld"
|
||||||
|
# define LLT long long
|
||||||
|
# define ULLF "%llu"
|
||||||
|
# define ULLFP(x) "%" x "llu"
|
||||||
|
# define ULLT unsigned long long
|
||||||
|
#endif
|
293
contrib/tnftp/src/ruserpass.c
Normal file
293
contrib/tnftp/src/ruserpass.c
Normal file
@ -0,0 +1,293 @@
|
|||||||
|
/* $NetBSD: ruserpass.c,v 1.29 2003/08/07 11:13:57 agc Exp $ */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (c) 1985, 1993, 1994
|
||||||
|
* The Regents of the University of California. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the University nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
#ifndef lint
|
||||||
|
#if 0
|
||||||
|
static char sccsid[] = "@(#)ruserpass.c 8.4 (Berkeley) 4/27/95";
|
||||||
|
#else
|
||||||
|
__RCSID("$NetBSD: ruserpass.c,v 1.29 2003/08/07 11:13:57 agc Exp $");
|
||||||
|
#endif
|
||||||
|
#endif /* not lint */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "ftp_var.h"
|
||||||
|
|
||||||
|
static int token(void);
|
||||||
|
static FILE *cfile;
|
||||||
|
|
||||||
|
#define DEFAULT 1
|
||||||
|
#define LOGIN 2
|
||||||
|
#define PASSWD 3
|
||||||
|
#define ACCOUNT 4
|
||||||
|
#define MACDEF 5
|
||||||
|
#define ID 10
|
||||||
|
#define MACH 11
|
||||||
|
|
||||||
|
static char tokval[100];
|
||||||
|
|
||||||
|
static struct toktab {
|
||||||
|
char *tokstr;
|
||||||
|
int tval;
|
||||||
|
} toktab[] = {
|
||||||
|
{ "default", DEFAULT },
|
||||||
|
{ "login", LOGIN },
|
||||||
|
{ "password", PASSWD },
|
||||||
|
{ "passwd", PASSWD },
|
||||||
|
{ "account", ACCOUNT },
|
||||||
|
{ "machine", MACH },
|
||||||
|
{ "macdef", MACDEF },
|
||||||
|
{ NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
ruserpass(const char *host, const char **aname, const char **apass,
|
||||||
|
const char **aacct)
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
char myname[MAXHOSTNAMELEN + 1], *mydomain;
|
||||||
|
int t, i, c, usedefault = 0;
|
||||||
|
struct stat stb;
|
||||||
|
|
||||||
|
if (netrc[0] == '\0')
|
||||||
|
return (0);
|
||||||
|
cfile = fopen(netrc, "r");
|
||||||
|
if (cfile == NULL) {
|
||||||
|
if (errno != ENOENT)
|
||||||
|
warn("%s", netrc);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
if (gethostname(myname, sizeof(myname)) < 0)
|
||||||
|
myname[0] = '\0';
|
||||||
|
myname[sizeof(myname) - 1] = '\0';
|
||||||
|
if ((mydomain = strchr(myname, '.')) == NULL)
|
||||||
|
mydomain = "";
|
||||||
|
next:
|
||||||
|
while ((t = token())) switch(t) {
|
||||||
|
|
||||||
|
case DEFAULT:
|
||||||
|
usedefault = 1;
|
||||||
|
/* FALL THROUGH */
|
||||||
|
|
||||||
|
case MACH:
|
||||||
|
if (!usedefault) {
|
||||||
|
if (token() != ID)
|
||||||
|
continue;
|
||||||
|
/*
|
||||||
|
* Allow match either for user's input host name
|
||||||
|
* or official hostname. Also allow match of
|
||||||
|
* incompletely-specified host in local domain.
|
||||||
|
*/
|
||||||
|
if (strcasecmp(host, tokval) == 0)
|
||||||
|
goto match;
|
||||||
|
if (strcasecmp(hostname, tokval) == 0)
|
||||||
|
goto match;
|
||||||
|
if ((tmp = strchr(hostname, '.')) != NULL &&
|
||||||
|
strcasecmp(tmp, mydomain) == 0 &&
|
||||||
|
strncasecmp(hostname, tokval, tmp-hostname) == 0 &&
|
||||||
|
tokval[tmp - hostname] == '\0')
|
||||||
|
goto match;
|
||||||
|
if ((tmp = strchr(host, '.')) != NULL &&
|
||||||
|
strcasecmp(tmp, mydomain) == 0 &&
|
||||||
|
strncasecmp(host, tokval, tmp - host) == 0 &&
|
||||||
|
tokval[tmp - host] == '\0')
|
||||||
|
goto match;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match:
|
||||||
|
while ((t = token()) && t != MACH && t != DEFAULT) switch(t) {
|
||||||
|
|
||||||
|
case LOGIN:
|
||||||
|
if (token()) {
|
||||||
|
if (*aname == NULL)
|
||||||
|
*aname = xstrdup(tokval);
|
||||||
|
else {
|
||||||
|
if (strcmp(*aname, tokval))
|
||||||
|
goto next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PASSWD:
|
||||||
|
if ((*aname == NULL || strcmp(*aname, "anonymous")) &&
|
||||||
|
fstat(fileno(cfile), &stb) >= 0 &&
|
||||||
|
(stb.st_mode & 077) != 0) {
|
||||||
|
warnx("Error: .netrc file is readable by others.");
|
||||||
|
warnx("Remove password or make file unreadable by others.");
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
if (token() && *apass == NULL)
|
||||||
|
*apass = xstrdup(tokval);
|
||||||
|
break;
|
||||||
|
case ACCOUNT:
|
||||||
|
if (fstat(fileno(cfile), &stb) >= 0
|
||||||
|
&& (stb.st_mode & 077) != 0) {
|
||||||
|
warnx("Error: .netrc file is readable by others.");
|
||||||
|
warnx("Remove account or make file unreadable by others.");
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
if (token() && *aacct == NULL)
|
||||||
|
*aacct = xstrdup(tokval);
|
||||||
|
break;
|
||||||
|
case MACDEF:
|
||||||
|
if (proxy) {
|
||||||
|
(void)fclose(cfile);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
while ((c = getc(cfile)) != EOF)
|
||||||
|
if (c != ' ' && c != '\t')
|
||||||
|
break;
|
||||||
|
if (c == EOF || c == '\n') {
|
||||||
|
fputs("Missing macdef name argument.\n",
|
||||||
|
ttyout);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
if (macnum == 16) {
|
||||||
|
fputs(
|
||||||
|
"Limit of 16 macros have already been defined.\n",
|
||||||
|
ttyout);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
tmp = macros[macnum].mac_name;
|
||||||
|
*tmp++ = c;
|
||||||
|
for (i = 0; i < 8 && (c = getc(cfile)) != EOF &&
|
||||||
|
!isspace(c); ++i) {
|
||||||
|
*tmp++ = c;
|
||||||
|
}
|
||||||
|
if (c == EOF) {
|
||||||
|
fputs(
|
||||||
|
"Macro definition missing null line terminator.\n",
|
||||||
|
ttyout);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
*tmp = '\0';
|
||||||
|
if (c != '\n') {
|
||||||
|
while ((c = getc(cfile)) != EOF && c != '\n');
|
||||||
|
}
|
||||||
|
if (c == EOF) {
|
||||||
|
fputs(
|
||||||
|
"Macro definition missing null line terminator.\n",
|
||||||
|
ttyout);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
if (macnum == 0) {
|
||||||
|
macros[macnum].mac_start = macbuf;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
macros[macnum].mac_start =
|
||||||
|
macros[macnum-1].mac_end + 1;
|
||||||
|
}
|
||||||
|
tmp = macros[macnum].mac_start;
|
||||||
|
while (tmp != macbuf + 4096) {
|
||||||
|
if ((c = getc(cfile)) == EOF) {
|
||||||
|
fputs(
|
||||||
|
"Macro definition missing null line terminator.\n",
|
||||||
|
ttyout);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
*tmp = c;
|
||||||
|
if (*tmp == '\n') {
|
||||||
|
if (*(tmp-1) == '\0') {
|
||||||
|
macros[macnum++].mac_end = tmp - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*tmp = '\0';
|
||||||
|
}
|
||||||
|
tmp++;
|
||||||
|
}
|
||||||
|
if (tmp == macbuf + 4096) {
|
||||||
|
fputs("4K macro buffer exceeded.\n",
|
||||||
|
ttyout);
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
warnx("Unknown .netrc keyword %s", tokval);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
done:
|
||||||
|
(void)fclose(cfile);
|
||||||
|
return (0);
|
||||||
|
bad:
|
||||||
|
(void)fclose(cfile);
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
token(void)
|
||||||
|
{
|
||||||
|
char *cp;
|
||||||
|
int c;
|
||||||
|
struct toktab *t;
|
||||||
|
|
||||||
|
if (feof(cfile) || ferror(cfile))
|
||||||
|
return (0);
|
||||||
|
while ((c = getc(cfile)) != EOF &&
|
||||||
|
(c == '\n' || c == '\t' || c == ' ' || c == ','))
|
||||||
|
continue;
|
||||||
|
if (c == EOF)
|
||||||
|
return (0);
|
||||||
|
cp = tokval;
|
||||||
|
if (c == '"') {
|
||||||
|
while ((c = getc(cfile)) != EOF && c != '"') {
|
||||||
|
if (c == '\\')
|
||||||
|
c = getc(cfile);
|
||||||
|
*cp++ = c;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*cp++ = c;
|
||||||
|
while ((c = getc(cfile)) != EOF
|
||||||
|
&& c != '\n' && c != '\t' && c != ' ' && c != ',') {
|
||||||
|
if (c == '\\')
|
||||||
|
c = getc(cfile);
|
||||||
|
*cp++ = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*cp = 0;
|
||||||
|
if (tokval[0] == 0)
|
||||||
|
return (0);
|
||||||
|
for (t = toktab; t->tokstr; t++)
|
||||||
|
if (!strcmp(t->tokstr, tokval))
|
||||||
|
return (t->tval);
|
||||||
|
return (ID);
|
||||||
|
}
|
1400
contrib/tnftp/src/util.c
Normal file
1400
contrib/tnftp/src/util.c
Normal file
File diff suppressed because it is too large
Load Diff
44
contrib/tnftp/src/version.h
Normal file
44
contrib/tnftp/src/version.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* $NetBSD: version.h,v 1.50 2005/05/14 15:26:43 lukem Exp $ */
|
||||||
|
/*-
|
||||||
|
* Copyright (c) 1999-2005 The NetBSD Foundation, Inc.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
|
* by Luke Mewburn.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. All advertising materials mentioning features or use of this software
|
||||||
|
* must display the following acknowledgement:
|
||||||
|
* This product includes software developed by the NetBSD
|
||||||
|
* Foundation, Inc. and its contributors.
|
||||||
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||||
|
* contributors may be used to endorse or promote products derived
|
||||||
|
* from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||||
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||||
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||||
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||||
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef FTP_PRODUCT
|
||||||
|
#define FTP_PRODUCT "NetBSD-ftp"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef FTP_VERSION
|
||||||
|
#define FTP_VERSION "20050514"
|
||||||
|
#endif
|
25
contrib/tnftp/todo
Normal file
25
contrib/tnftp/todo
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
$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
|
||||||
|
|
||||||
|
check if we need #defines for memcpy() et al
|
||||||
|
|
||||||
|
check for utimes() decls [which system?]
|
||||||
|
|
||||||
|
possibly install editline.3 and editrc.5
|
||||||
|
|
||||||
|
system specific tests (to remove need for manual intervention):
|
||||||
|
- sunos4
|
||||||
|
LIBS+= -lresolv
|
Loading…
Reference in New Issue
Block a user