Home | History | Annotate | Download | only in ftp
      1 /*
      2  * CDDL HEADER START
      3  *
      4  * The contents of this file are subject to the terms of the
      5  * Common Development and Distribution License, Version 1.0 only
      6  * (the "License").  You may not use this file except in compliance
      7  * with the License.
      8  *
      9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
     10  * or http://www.opensolaris.org/os/licensing.
     11  * See the License for the specific language governing permissions
     12  * and limitations under the License.
     13  *
     14  * When distributing Covered Code, include this CDDL HEADER in each
     15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     16  * If applicable, add the following below this CDDL HEADER, with the
     17  * fields enclosed by brackets "[]" replaced with your own identifying
     18  * information: Portions Copyright [yyyy] [name of copyright owner]
     19  *
     20  * CDDL HEADER END
     21  */
     22 /*
     23  *	Copyright 2002 Sun Microsystems, Inc.  All rights reserved.
     24  *	Use is subject to license terms.
     25  */
     26 
     27 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
     28 /*	All Rights Reserved  	*/
     29 
     30 /*
     31  *	University Copyright- Copyright (c) 1982, 1986, 1988
     32  *	The Regents of the University of California
     33  *	All Rights Reserved
     34  *
     35  *	University Acknowledgment- Portions of this document are derived from
     36  *	software developed by the University of California, Berkeley, and its
     37  *	contributors.
     38  */
     39 
     40 #pragma ident	"%Z%%M%	%I%	%E% SMI"
     41 
     42 #include "ftp_var.h"
     43 
     44 /*
     45  * User FTP -- Command Tables.
     46  */
     47 
     48 static char	accounthelp[] =	"send account command to remote server";
     49 static char	appendhelp[] =	"append to a file";
     50 static char	asciihelp[] =	"set ascii transfer type";
     51 static char	beephelp[] =	"beep when command completed";
     52 static char	binaryhelp[] =	"set binary transfer type";
     53 static char	casehelp[] =	"toggle mget upper/lower case id mapping";
     54 static char	ccchelp[] =	"set clear protection level for commands";
     55 static char	cdhelp[] =	"change remote working directory";
     56 static char	cduphelp[] = 	"change remote working directory to parent "
     57 				"directory";
     58 static char	clearhelp[] =	"set clear protection level for data";
     59 static char	connecthelp[] =	"connect to remote tftp";
     60 static char	crhelp[] =	"toggle carriage return stripping on ascii "
     61 				"gets";
     62 static char	deletehelp[] =	"delete remote file";
     63 static char	debughelp[] =	"toggle/set debugging mode";
     64 static char	dirhelp[] =	"list contents of remote directory";
     65 static char	disconhelp[] =	"terminate ftp session";
     66 static char	domachelp[] = 	"execute macro";
     67 static char	formhelp[] =	"set file transfer format";
     68 static char	globhelp[] =	"toggle metacharacter expansion of local file "
     69 				"names";
     70 static char	hashhelp[] =	"toggle printing `#' for each buffer "
     71 				"transferred";
     72 static char	helphelp[] =	"print local help information";
     73 static char	lcdhelp[] =	"change local working directory";
     74 static char	lshelp[] =	"display contents of remote directory";
     75 static char	macdefhelp[] =  "define a macro";
     76 static char	mdeletehelp[] =	"delete multiple files";
     77 static char	mdirhelp[] =	"list contents of multiple remote directories";
     78 static char	mechhelp[] =	"set mechanism type";
     79 static char	mgethelp[] =	"get multiple files";
     80 static char	mkdirhelp[] =	"make directory on the remote machine";
     81 static char	mlshelp[] =	"nlist contents of multiple remote directories";
     82 static char	modehelp[] =	"set file transfer mode";
     83 static char	mputhelp[] =	"send multiple files";
     84 static char	nlisthelp[] =	"nlist contents of remote directory";
     85 static char	nmaphelp[] =	"set templates for default file name mapping";
     86 static char	ntranshelp[] =	"set translation table for default file name "
     87 				"mapping";
     88 static char	passivehelp[] =	"toggle passive transfer mode";
     89 static char	porthelp[] =	"toggle use of PORT cmd for each data "
     90 				"connection";
     91 static char	privatehelp[] =	"set private protection level for data";
     92 static char	prompthelp[] =	"force interactive prompting on multiple "
     93 				"commands";
     94 static char	protecthelp[] =	"set protection level for data";
     95 static char	proxyhelp[] =	"issue command on alternate connection";
     96 static char	pwdhelp[] =	"print working directory on remote machine";
     97 static char	quithelp[] =	"terminate ftp session and exit";
     98 static char	quotehelp[] =	"send arbitrary ftp command";
     99 static char	receivehelp[] =	"receive file";
    100 static char	regethelp[] =	"get file restarting at end of local file";
    101 static char	remotehelp[] =	"get help from remote server";
    102 static char	renamehelp[] =	"rename file";
    103 static char	resethelp[] =	"clear queued command replies";
    104 static char	restarthelp[] =	"restart file transfer at bytecount";
    105 static char	rmdirhelp[] =	"remove directory on the remote machine";
    106 static char	runiquehelp[] = "toggle store unique for local files";
    107 static char	safehelp[] =	"set safe protection level for data";
    108 static char	sendhelp[] =	"send one file";
    109 static char	shellhelp[] =	"escape to the shell";
    110 static char	sitehelp[] =	"send site specific command to remote server\n"
    111 				"\t\tTry \"remotehelp site\" or \"site help\" "
    112 				"for more information";
    113 static char	statushelp[] =	"show current status";
    114 static char	structhelp[] =	"set file transfer structure";
    115 static char	suniquehelp[] = "toggle store unique on remote machine";
    116 static char	tenexhelp[] =	"set tenex file transfer type";
    117 static char	tracehelp[] =	"toggle packet tracing";
    118 static char	typehelp[] =	"set file transfer type";
    119 static char	userhelp[] =	"send new user information";
    120 static char	verbosehelp[] =	"toggle verbose mode";
    121 static char	windowhelp[] =	"set TCP window size for the data connection";
    122 
    123 /*
    124  * NOTE : The BUFSIZE defined in ftp_var.h includes MAXCMDLEN chars to
    125  * accomodate the longest command in the cmdtab[] defined below.
    126  * If anyone plans to add a new command that is longer than the MAXCMDLEN
    127  * make sure to update it in ftp_var.h.
    128  */
    129 
    130 struct cmd cmdtab[] = {
    131 	{ "!",		shellhelp,	0,	0,	0,	shell },
    132 	{ "$",		domachelp,	1,	0,	0,	domacro },
    133 	{ "account",	accounthelp,	0,	1,	1,	account},
    134 	{ "append",	appendhelp,	1,	1,	1,	put },
    135 	{ "ascii",	asciihelp,	0,	1,	1,	setascii },
    136 	{ "bell",	beephelp,	0,	0,	0,	setbell },
    137 	{ "binary",	binaryhelp,	0,	1,	1,	setbinary },
    138 	{ "bye",	quithelp,	0,	0,	0,	quit },
    139 	{ "case",	casehelp,	0,	0,	1,	setcase },
    140 
    141 	{ "ccc",	ccchelp,	0,	1,	1,	ccc },
    142 
    143 	{ "cd",		cdhelp,		0,	1,	1,	cd },
    144 	{ "cdup",	cduphelp,	0,	1,	1,	cdup },
    145 
    146 	{ "clear",	clearhelp,	0,	1,	1,	setclear },
    147 
    148 	{ "close",	disconhelp,	0,	1,	1,	disconnect },
    149 	{ "cr",		crhelp,		0,	0,	0,	setcr },
    150 	{ "delete",	deletehelp,	0,	1,	1,	delete },
    151 	{ "debug",	debughelp,	0,	0,	0,	setdebug },
    152 	{ "dir",	dirhelp,	1,	1,	1,	ls },
    153 	{ "disconnect",	disconhelp,	0,	1,	1,	disconnect },
    154 	{ "form",	formhelp,	0,	1,	1,	setform },
    155 	{ "get",	receivehelp,	1,	1,	1,	get },
    156 	{ "glob",	globhelp,	0,	0,	0,	setglob },
    157 	{ "hash",	hashhelp,	0,	0,	0,	sethash },
    158 	{ "help",	helphelp,	0,	0,	1,	help },
    159 	{ "lcd",	lcdhelp,	0,	0,	0,	lcd },
    160 	{ "ls",		lshelp,		1,	1,	1,	ls },
    161 	{ "macdef",	macdefhelp,	0,	0,	0,	macdef },
    162 	{ "mdelete",	mdeletehelp,	1,	1,	1,	mdelete },
    163 	{ "mdir",	mdirhelp,	1,	1,	1,	mls },
    164 
    165 	{ "mechanism",	mechhelp,	1,	0,	1,	setmech },
    166 
    167 	{ "mget",	mgethelp,	1,	1,	1,	mget },
    168 	{ "mkdir",	mkdirhelp,	0,	1,	1,	makedir },
    169 	{ "mls",	mlshelp,	1,	1,	1,	mls },
    170 	{ "mode",	modehelp,	0,	1,	1,	setmode },
    171 	{ "mput",	mputhelp,	1,	1,	1,	mput },
    172 	{ "nlist",	nlisthelp,	1,	1,	1,	ls },
    173 	{ "nmap",	nmaphelp,	0,	0,	1,	setnmap },
    174 	{ "ntrans",	ntranshelp,	0,	0,	1,	setntrans },
    175 	{ "open",	connecthelp,	0,	0,	1,	setpeer },
    176 	{ "passive",	passivehelp,	0,	0,	0,	setpassive },
    177 
    178 	{ "private",	privatehelp,	0,	1,	1,	setprivate },
    179 
    180 	{ "prompt",	prompthelp,	0,	0,	0,	setprompt },
    181 
    182 	{ "protect",	protecthelp,	0,	1,	1,	setdlevel },
    183 
    184 	{ "proxy",	proxyhelp,	0,	0,	1,	doproxy },
    185 	{ "put",	sendhelp,	1,	1,	1,	put },
    186 	{ "pwd",	pwdhelp,	0,	1,	1,	pwd },
    187 	{ "quit",	quithelp,	0,	0,	0,	quit },
    188 	{ "quote",	quotehelp,	1,	1,	1,	quote },
    189 	{ "recv",	receivehelp,	1,	1,	1,	get },
    190 	{ "reget",	regethelp,	1,	1,	1,	reget },
    191 	{ "remotehelp",	remotehelp,	0,	1,	1,	rmthelp },
    192 	{ "rename",	renamehelp,	0,	1,	1,	renamefile },
    193 	{ "reset",	resethelp,	0,	1,	1,	reset },
    194 	{ "restart",	restarthelp,	1,	1,	1,	restart },
    195 	{ "rmdir",	rmdirhelp,	0,	1,	1,	removedir },
    196 	{ "runique",	runiquehelp,	0,	0,	1,	setrunique },
    197 
    198 	{ "safe",	safehelp,	0,	1,	1,	setsafe },
    199 
    200 	{ "send",	sendhelp,	1,	1,	1,	put },
    201 	{ "sendport",	porthelp,	0,	0,	0,	setport },
    202 	{ "site",	sitehelp,	0,	1,	1,	site },
    203 	{ "status",	statushelp,	0,	0,	1,	status },
    204 	{ "struct",	structhelp,	0,	1,	1,	setstruct },
    205 	{ "sunique",	suniquehelp,	0,	0,	1,	setsunique },
    206 	{ "tcpwindow",	windowhelp,	0,	0,	0,	settcpwindow },
    207 	{ "tenex",	tenexhelp,	0,	1,	1,	settenex },
    208 	{ "trace",	tracehelp,	0,	0,	0,	settrace },
    209 	{ "type",	typehelp,	0,	1,	1,	settype },
    210 	{ "user",	userhelp,	0,	1,	1,	user },
    211 	{ "verbose",	verbosehelp,	0,	0,	0,	setverbose },
    212 	{ "?",		helphelp,	0,	0,	1,	help },
    213 	{ 0 },
    214 };
    215 
    216 int	NCMDS = (sizeof (cmdtab) / sizeof (cmdtab[0])) - 1;
    217