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