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