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