ftp: remove from sources.
Now provided in the tnftp package. Change-Id: I862b1ff98586aa0e5a9418cf26e30b7136140249 Reviewed-on: https://review.haiku-os.org/c/1641 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
c5ec5c0c38
commit
c0daed76e1
@@ -8,7 +8,7 @@ SYSTEM_BIN = [ FFilterByBuildFeatures
|
||||
driveinfo dstcheck dumpcatalog
|
||||
eject error
|
||||
fdinfo ffm filepanel finddir findpaths fortune fstrim
|
||||
ftp@libedit ftpd
|
||||
ftpd
|
||||
getarch groupadd groupdel groupmod
|
||||
hd hey
|
||||
ifconfig iroster isvolume
|
||||
|
||||
@@ -5,7 +5,6 @@ StdBinCommands
|
||||
: network : $(haiku-utils_rsrc) ;
|
||||
|
||||
SubInclude HAIKU_TOP src bin network arp ;
|
||||
SubInclude HAIKU_TOP src bin network ftp ;
|
||||
SubInclude HAIKU_TOP src bin network ftpd ;
|
||||
SubInclude HAIKU_TOP src bin network ifconfig ;
|
||||
SubInclude HAIKU_TOP src bin network mount_nfs ;
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
SubDir HAIKU_TOP src bin network ftp ;
|
||||
|
||||
UseHeaders [ FDirName $(HAIKU_TOP) headers compatibility bsd ] : true ;
|
||||
SubDirCcFlags [ FDefines _BSD_SOURCE=1 ] ;
|
||||
|
||||
UseBuildFeatureHeaders libedit ;
|
||||
|
||||
local ftp_src =
|
||||
cmds.c
|
||||
cmdtab.c
|
||||
complete.c
|
||||
domacro.c
|
||||
fetch.c
|
||||
ftp.c
|
||||
main.c
|
||||
progressbar.c
|
||||
ruserpass.c
|
||||
util.c
|
||||
;
|
||||
Includes [ FGristFiles $(ftp_src) ]
|
||||
: [ BuildFeatureAttribute libedit : headers ] ;
|
||||
|
||||
|
||||
BinCommand ftp :
|
||||
$(ftp_src)
|
||||
:
|
||||
[ BuildFeatureAttribute libedit : library ]
|
||||
[ BuildFeatureAttribute ncurses : library ]
|
||||
libutil.a libbsd.so
|
||||
$(TARGET_NETWORK_LIBS)
|
||||
;
|
||||
|
||||
# Installation -- in the test directory for the time being
|
||||
HaikuInstall install-networking
|
||||
: [ FDirName $(HAIKU_TEST_DIR) kits net ]
|
||||
: ftp ;
|
||||
|
||||
HaikuInstall install-userland-networking
|
||||
: [ FDirName $(HAIKU_TEST_DIR) kits net userland ]
|
||||
: ftp
|
||||
: installed-userland-networking
|
||||
;
|
||||
@@ -1,28 +0,0 @@
|
||||
# $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>
|
||||
@@ -1,43 +0,0 @@
|
||||
#
|
||||
# $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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,302 +0,0 @@
|
||||
/* $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>
|
||||
|
||||
#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 },
|
||||
};
|
||||
@@ -1,432 +0,0 @@
|
||||
/* $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>
|
||||
|
||||
/*
|
||||
* 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 */
|
||||
@@ -1,276 +0,0 @@
|
||||
/* config.h. Generated automatically by configure. */
|
||||
/* 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. */
|
||||
#define GETPGRP_VOID 1
|
||||
|
||||
/* 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. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
/* #undef VOID_CLOSEDIR */
|
||||
|
||||
/* The number of bytes in a off_t. */
|
||||
#define SIZEOF_OFF_T 8
|
||||
|
||||
/* Define if you have the err function. */
|
||||
/* #undef HAVE_ERR */
|
||||
|
||||
/* Define if you have the fgetln function. */
|
||||
#define HAVE_FGETLN 1
|
||||
|
||||
/* Define if you have the fparseln function. */
|
||||
/* #undef HAVE_FPARSELN */
|
||||
|
||||
/* Define if you have the fseeko function. */
|
||||
#define HAVE_FSEEKO 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_GETPGRP 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
/* Define if you have the mkstemp function. */
|
||||
#define HAVE_MKSTEMP 1
|
||||
|
||||
/* Define if you have the poll function. */
|
||||
/* #undef HAVE_POLL */
|
||||
|
||||
/* Define if you have the select function. */
|
||||
#define HAVE_SELECT 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_SNPRINTF 1
|
||||
|
||||
/* Define if you have the strdup function. */
|
||||
#define HAVE_STRDUP 1
|
||||
|
||||
/* Define if you have the strerror function. */
|
||||
#define HAVE_STRERROR 1
|
||||
|
||||
/* Define if you have the strlcat function. */
|
||||
#define HAVE_STRLCAT 1
|
||||
|
||||
/* Define if you have the strlcpy function. */
|
||||
#define HAVE_STRLCPY 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_STRTOLL 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_ARPA_NAMESER_H 1
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#define HAVE_DIRENT_H 1
|
||||
|
||||
/* Define if you have the <err.h> header file. */
|
||||
#define HAVE_ERR_H 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_REGEX_H 1
|
||||
|
||||
/* 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. */
|
||||
#define HAVE_TERMCAP_H 1
|
||||
|
||||
/* 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). */
|
||||
#define HAVE_LIBSOCKET 1
|
||||
|
||||
/* 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' */
|
||||
#define HAVE_LONG_LONG 1
|
||||
|
||||
/* Define if *printf() uses %qd to print `long long' (otherwise uses %lld) */
|
||||
/* #undef HAVE_PRINTF_QD */
|
||||
|
||||
/* Define if in_port_t exists */
|
||||
#define HAVE_IN_PORT_T 1
|
||||
|
||||
/* Define if sa_family_t exists in <sys/socket.h> */
|
||||
/* #undef HAVE_SA_FAMILY_T */
|
||||
|
||||
/* Define if struct sockaddr.sa_len exists (implies sockaddr_in.sin_len, etc) */
|
||||
#define HAVE_SOCKADDR_SA_LEN 1
|
||||
|
||||
/* Define if socklen_t exists */
|
||||
/* #undef HAVE_SOCKLEN_T */
|
||||
|
||||
/* Define if AF_INET6 exists in <sys/socket.h> */
|
||||
#define HAVE_AF_INET6 1
|
||||
|
||||
/* Define if `struct sockaddr_in6' exists in <netinet/in.h> */
|
||||
/* #undef HAVE_SOCKADDR_IN6 */
|
||||
|
||||
/* Define if `struct addrinfo' exists in <netdb.h> */
|
||||
#define HAVE_ADDRINFO 1
|
||||
|
||||
/*
|
||||
* 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> */
|
||||
#define HAVE_H_ERRNO_D 1
|
||||
|
||||
/* Define if fclose() is declared in <stdio.h> */
|
||||
#define HAVE_FCLOSE_D 1
|
||||
|
||||
/* 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> */
|
||||
#define HAVE_OPTARG_D 1
|
||||
|
||||
/* Define if optind is declared in <stdlib.h> or <unistd.h> */
|
||||
#define HAVE_OPTIND_D 1
|
||||
|
||||
/* Define if pclose() is declared in <stdio.h> */
|
||||
#define HAVE_PCLOSE_D 1
|
||||
|
||||
/* Define if `long long' is supported and sizeof(off_t) >= 8 */
|
||||
#define HAVE_QUAD_SUPPORT 1
|
||||
|
||||
/* 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 */
|
||||
@@ -1,136 +0,0 @@
|
||||
/* $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>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -1,257 +0,0 @@
|
||||
/* $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 *);
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,342 +0,0 @@
|
||||
/* $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 <stdint.h>
|
||||
|
||||
#define DIRENT_MISSING_D_NAMLEN
|
||||
#define INFTIM INT_MAX
|
||||
|
||||
#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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,461 +0,0 @@
|
||||
/* $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>
|
||||
|
||||
/*
|
||||
* 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));
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/* $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
|
||||
@@ -1,286 +0,0 @@
|
||||
/* $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>
|
||||
|
||||
#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);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,44 +0,0 @@
|
||||
/* $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
|
||||
@@ -23,7 +23,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
@@ -23,7 +23,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
@@ -23,7 +23,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
@@ -23,7 +23,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
@@ -23,7 +23,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
@@ -23,7 +23,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
@@ -22,7 +22,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
@@ -23,7 +23,6 @@ provides {
|
||||
cmd:clear
|
||||
cmd:compress
|
||||
cmd:df
|
||||
cmd:ftp
|
||||
cmd:ftpd
|
||||
cmd:hd
|
||||
cmd:hey
|
||||
|
||||
Reference in New Issue
Block a user