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