Home | History | Annotate | Line # | Download | only in ftp
cmdtab.c revision 1.27
      1 /*	$NetBSD: cmdtab.c,v 1.27 1999/09/27 23:09:42 lukem Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1985, 1989, 1993, 1994
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *	This product includes software developed by the University of
     18  *	California, Berkeley and its contributors.
     19  * 4. Neither the name of the University nor the names of its contributors
     20  *    may be used to endorse or promote products derived from this software
     21  *    without specific prior written permission.
     22  *
     23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  * SUCH DAMAGE.
     34  */
     35 
     36 #include <sys/cdefs.h>
     37 #ifndef lint
     38 #if 0
     39 static char sccsid[] = "@(#)cmdtab.c	8.4 (Berkeley) 10/9/94";
     40 #else
     41 __RCSID("$NetBSD: cmdtab.c,v 1.27 1999/09/27 23:09:42 lukem Exp $");
     42 #endif
     43 #endif /* not lint */
     44 
     45 #include <stdio.h>
     46 #include "ftp_var.h"
     47 
     48 /*
     49  * User FTP -- Command Tables.
     50  */
     51 
     52 char	accounthelp[] =	"send account command to remote server";
     53 char	appendhelp[] =	"append to a file";
     54 char	asciihelp[] =	"set ascii transfer type";
     55 char	beephelp[] =	"beep when command completed";
     56 char	binaryhelp[] =	"set binary transfer type";
     57 char	casehelp[] =	"toggle mget upper/lower case id mapping";
     58 char	cdhelp[] =	"change remote working directory";
     59 char	cduphelp[] =	"change remote working directory to parent directory";
     60 char	chmodhelp[] =	"change file permissions of remote file";
     61 char	connecthelp[] =	"connect to remote ftp server";
     62 char	crhelp[] =	"toggle carriage return stripping on ascii gets";
     63 char	debughelp[] =	"toggle/set debugging mode";
     64 char	deletehelp[] =	"delete remote file";
     65 char	dirhelp[] =	"list contents of remote directory";
     66 char	disconhelp[] =	"terminate ftp session";
     67 char	domachelp[] =	"execute macro";
     68 #ifndef NO_EDITCOMPLETE
     69 char	edithelp[] =	"toggle command line editing";
     70 #endif /* !NO_EDITCOMPLETE */
     71 char	epsv4help[] =	"toggle use of EPSV/EPRT on IPv4 ftp";
     72 char	formhelp[] =	"set file transfer format";
     73 char	gatehelp[] =	"toggle gate-ftp; specify host[:port] to change proxy";
     74 char	globhelp[] =	"toggle metacharacter expansion of local file names";
     75 char	hashhelp[] =	"toggle printing `#' marks; specify number to set size";
     76 char	helphelp[] =	"print local help information";
     77 char	idlehelp[] =	"get (set) idle timer on remote side";
     78 char	lcdhelp[] =	"change local working directory";
     79 char	lpwdhelp[] =	"print local working directory";
     80 char	lshelp[] =	"list contents of remote directory";
     81 char	macdefhelp[] =  "define a macro";
     82 char	mdeletehelp[] =	"delete multiple files";
     83 char	mdirhelp[] =	"list contents of multiple remote directories";
     84 char	mgethelp[] =	"get multiple files";
     85 char	mkdirhelp[] =	"make directory on the remote machine";
     86 char	mlshelp[] =	"list contents of multiple remote directories";
     87 char	modehelp[] =	"set file transfer mode";
     88 char	modtimehelp[] = "show last modification time of remote file";
     89 char	mputhelp[] =	"send multiple files";
     90 char	newerhelp[] =	"get file if remote file is newer than local file ";
     91 char	nlisthelp[] =	"nlist contents of remote directory";
     92 char	nmaphelp[] =	"set templates for default file name mapping";
     93 char	ntranshelp[] =	"set translation table for default file name mapping";
     94 char	pagehelp[] =	"view a remote file through your pager";
     95 char	passivehelp[] =	"enter passive transfer mode";
     96 char	porthelp[] =	"toggle use of PORT/LPRT cmd for each data connection";
     97 char	preservehelp[] ="toggle preservation of modification time of "
     98 			"retrieved files";
     99 char	progresshelp[] ="toggle transfer progress meter";
    100 char	prompthelp[] =	"force interactive prompting on multiple commands";
    101 char	proxyhelp[] =	"issue command on alternate connection";
    102 char	pwdhelp[] =	"print working directory on remote machine";
    103 char	quithelp[] =	"terminate ftp session and exit";
    104 char	quotehelp[] =	"send arbitrary ftp command";
    105 char	ratehelp[] =	"set transfer rate limit";
    106 char	receivehelp[] =	"receive file";
    107 char	regethelp[] =	"get file restarting at end of local file";
    108 char	remotehelp[] =	"get help from remote server";
    109 char	renamehelp[] =	"rename file";
    110 char	resethelp[] =	"clear queued command replies";
    111 char	restarthelp[]=	"restart file transfer at bytecount";
    112 char	rmdirhelp[] =	"remove directory on the remote machine";
    113 char	rmtstatushelp[]="show status of remote machine";
    114 char	runiquehelp[] = "toggle store unique for local files";
    115 char	sendhelp[] =	"send one file";
    116 char	shellhelp[] =	"escape to the shell";
    117 char	sitehelp[] =	"send site specific command to remote server\n"
    118 			"\t\tTry \"rhelp site\" or \"site help\" "
    119 			"for more information";
    120 char	sizecmdhelp[] = "show size of remote file";
    121 char	statushelp[] =	"show current status";
    122 char	structhelp[] =	"set file transfer structure";
    123 char	suniquehelp[] = "toggle store unique on remote machine";
    124 char	systemhelp[] =  "show remote system type";
    125 char	tenexhelp[] =	"set tenex file transfer type";
    126 char	tracehelp[] =	"toggle packet tracing";
    127 char	typehelp[] =	"set file transfer type";
    128 char	umaskhelp[] =	"get (set) umask on remote side";
    129 char	userhelp[] =	"send new user information";
    130 char	verbosehelp[] =	"toggle verbose mode";
    131 char	xferbufhelp[] =	"set socket send/receive buffer size";
    132 
    133 #ifdef NO_EDITCOMPLETE
    134 #define CMPL(x)
    135 #define CMPL0
    136 #else  /* !NO_EDITCOMPLETE */
    137 #define CMPL(x)	__STRING(x),
    138 #define CMPL0	"",
    139 #endif /* !NO_EDITCOMPLETE */
    140 
    141 struct cmd cmdtab[] = {
    142 	{ "!",		shellhelp,	0, 0, 0, CMPL0		shell },
    143 	{ "$",		domachelp,	1, 0, 0, CMPL0		domacro },
    144 	{ "account",	accounthelp,	0, 1, 1, CMPL0		account},
    145 	{ "append",	appendhelp,	1, 1, 1, CMPL(lr)	put },
    146 	{ "ascii",	asciihelp,	0, 1, 1, CMPL0		setascii },
    147 	{ "bell",	beephelp,	0, 0, 0, CMPL0		setbell },
    148 	{ "binary",	binaryhelp,	0, 1, 1, CMPL0		setbinary },
    149 	{ "bye",	quithelp,	0, 0, 0, CMPL0		quit },
    150 	{ "case",	casehelp,	0, 0, 1, CMPL0		setcase },
    151 	{ "cd",		cdhelp,		0, 1, 1, CMPL(r)	cd },
    152 	{ "cdup",	cduphelp,	0, 1, 1, CMPL0		cdup },
    153 	{ "chmod",	chmodhelp,	0, 1, 1, CMPL(nr)	do_chmod },
    154 	{ "close",	disconhelp,	0, 1, 1, CMPL0		disconnect },
    155 	{ "cr",		crhelp,		0, 0, 0, CMPL0		setcr },
    156 	{ "debug",	debughelp,	0, 0, 0, CMPL0		setdebug },
    157 	{ "delete",	deletehelp,	0, 1, 1, CMPL(r)	delete },
    158 	{ "dir",	dirhelp,	1, 1, 1, CMPL(rl)	ls },
    159 	{ "disconnect",	disconhelp,	0, 1, 1, CMPL0		disconnect },
    160 #ifndef NO_EDITCOMPLETE
    161 	{ "edit",	edithelp,	0, 0, 0, CMPL0		setedit },
    162 #endif /* !NO_EDITCOMPLETE */
    163 	{ "epsv4",	epsv4help,	0, 0, 0, CMPL0		setepsv4 },
    164 	{ "exit",	quithelp,	0, 0, 0, CMPL0		quit },
    165 	{ "form",	formhelp,	0, 1, 1, CMPL0		setform },
    166 	{ "ftp",	connecthelp,	0, 0, 1, CMPL0		setpeer },
    167 	{ "get",	receivehelp,	1, 1, 1, CMPL(rl)	get },
    168 	{ "gate",	gatehelp,	0, 0, 0, CMPL0		setgate },
    169 	{ "glob",	globhelp,	0, 0, 0, CMPL0		setglob },
    170 	{ "hash",	hashhelp,	0, 0, 0, CMPL0		sethash },
    171 	{ "help",	helphelp,	0, 0, 1, CMPL(C)	help },
    172 	{ "idle",	idlehelp,	0, 1, 1, CMPL0		idlecmd },
    173 	{ "image",	binaryhelp,	0, 1, 1, CMPL0		setbinary },
    174 	{ "lcd",	lcdhelp,	0, 0, 0, CMPL(l)	lcd },
    175 	{ "less",	pagehelp,	1, 1, 1, CMPL(r)	page },
    176 	{ "lpwd",	lpwdhelp,	0, 0, 0, CMPL0		lpwd },
    177 	{ "ls",		lshelp,		1, 1, 1, CMPL(rl)	ls },
    178 	{ "macdef",	macdefhelp,	0, 0, 0, CMPL0		macdef },
    179 	{ "mdelete",	mdeletehelp,	1, 1, 1, CMPL(R)	mdelete },
    180 	{ "mdir",	mdirhelp,	1, 1, 1, CMPL(R)	mls },
    181 	{ "mget",	mgethelp,	1, 1, 1, CMPL(R)	mget },
    182 	{ "mkdir",	mkdirhelp,	0, 1, 1, CMPL(r)	makedir },
    183 	{ "mls",	mlshelp,	1, 1, 1, CMPL(R)	mls },
    184 	{ "mode",	modehelp,	0, 1, 1, CMPL0		setftmode },
    185 	{ "modtime",	modtimehelp,	0, 1, 1, CMPL(r)	modtime },
    186 	{ "more",	pagehelp,	1, 1, 1, CMPL(r)	page },
    187 	{ "mput",	mputhelp,	1, 1, 1, CMPL(L)	mput },
    188 	{ "msend",	mputhelp,	1, 1, 1, CMPL(L)	mput },
    189 	{ "newer",	newerhelp,	1, 1, 1, CMPL(r)	newer },
    190 	{ "nlist",	nlisthelp,	1, 1, 1, CMPL(rl)	ls },
    191 	{ "nmap",	nmaphelp,	0, 0, 1, CMPL0		setnmap },
    192 	{ "ntrans",	ntranshelp,	0, 0, 1, CMPL0		setntrans },
    193 	{ "open",	connecthelp,	0, 0, 1, CMPL0		setpeer },
    194 	{ "page",	pagehelp,	1, 1, 1, CMPL(r)	page },
    195 	{ "passive",	passivehelp,	0, 0, 0, CMPL0		setpassive },
    196 	{ "preserve",	preservehelp,	0, 0, 0, CMPL0		setpreserve },
    197 	{ "progress",	progresshelp,	0, 0, 0, CMPL0		setprogress },
    198 	{ "prompt",	prompthelp,	0, 0, 0, CMPL0		setprompt },
    199 	{ "proxy",	proxyhelp,	0, 0, 1, CMPL(c)	doproxy },
    200 	{ "put",	sendhelp,	1, 1, 1, CMPL(lr)	put },
    201 	{ "pwd",	pwdhelp,	0, 1, 1, CMPL0		pwd },
    202 	{ "quit",	quithelp,	0, 0, 0, CMPL0		quit },
    203 	{ "quote",	quotehelp,	1, 1, 1, CMPL0		quote },
    204 	{ "rate",	ratehelp,	0, 0, 0, CMPL0		setrate },
    205 	{ "rcvbuf",	xferbufhelp,	0, 0, 0, CMPL0		setxferbuf },
    206 	{ "recv",	receivehelp,	1, 1, 1, CMPL(rl)	get },
    207 	{ "reget",	regethelp,	1, 1, 1, CMPL(rl)	reget },
    208 	{ "rename",	renamehelp,	0, 1, 1, CMPL(rr)	renamefile },
    209 	{ "reset",	resethelp,	0, 1, 1, CMPL0		reset },
    210 	{ "restart",	restarthelp,	1, 1, 1, CMPL0		restart },
    211 	{ "rhelp",	remotehelp,	0, 1, 1, CMPL0		rmthelp },
    212 	{ "rmdir",	rmdirhelp,	0, 1, 1, CMPL(r)	removedir },
    213 	{ "rstatus",	rmtstatushelp,	0, 1, 1, CMPL(r)	rmtstatus },
    214 	{ "runique",	runiquehelp,	0, 0, 1, CMPL0		setrunique },
    215 	{ "send",	sendhelp,	1, 1, 1, CMPL(lr)	put },
    216 	{ "sendport",	porthelp,	0, 0, 0, CMPL0		setport },
    217 	{ "site",	sitehelp,	0, 1, 1, CMPL0		site },
    218 	{ "size",	sizecmdhelp,	1, 1, 1, CMPL(r)	sizecmd },
    219 	{ "sndbuf",	xferbufhelp,	0, 0, 0, CMPL0		setxferbuf },
    220 	{ "status",	statushelp,	0, 0, 1, CMPL0		status },
    221 	{ "struct",	structhelp,	0, 1, 1, CMPL0		setstruct },
    222 	{ "sunique",	suniquehelp,	0, 0, 1, CMPL0		setsunique },
    223 	{ "system",	systemhelp,	0, 1, 1, CMPL0		syst },
    224 	{ "tenex",	tenexhelp,	0, 1, 1, CMPL0		settenex },
    225 	{ "throttle",	ratehelp,	0, 0, 0, CMPL0		setrate },
    226 	{ "trace",	tracehelp,	0, 0, 0, CMPL0		settrace },
    227 	{ "type",	typehelp,	0, 1, 1, CMPL0		settype },
    228 	{ "umask",	umaskhelp,	0, 1, 1, CMPL0		do_umask },
    229 	{ "user",	userhelp,	0, 1, 1, CMPL0		user },
    230 	{ "verbose",	verbosehelp,	0, 0, 0, CMPL0		setverbose },
    231 	{ "xferbuf",	xferbufhelp,	0, 0, 0, CMPL0		setxferbuf },
    232 	{ "?",		helphelp,	0, 0, 1, CMPL(C)	help },
    233 	{ 0 },
    234 };
    235 
    236 int	NCMDS = (sizeof(cmdtab) / sizeof(cmdtab[0])) - 1;
    237