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