1 /* $NetBSD: cmdtab.c,v 1.44 2005/04/11 01:49:31 lukem Exp $ */
4 * Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
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.
40 * Copyright (c) 1985, 1989, 1993, 1994
41 * The Regents of the University of California. All rights reserved.
43 * Redistribution and use in source and binary forms, with or without
44 * modification, are permitted provided that the following conditions
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.
51 * 3. Neither the name of the University nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
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
68 #include <sys/cdefs.h>
74 * User FTP -- Command Tables.
77 #define HSTR static const char
80 HSTR accounthelp
[] = "send account command to remote server";
81 HSTR appendhelp
[] = "append to a file";
82 HSTR asciihelp
[] = "set ascii transfer type";
83 HSTR beephelp
[] = "beep when command completed";
84 HSTR binaryhelp
[] = "set binary transfer type";
85 HSTR casehelp
[] = "toggle mget upper/lower case id mapping";
86 HSTR cdhelp
[] = "change remote working directory";
87 HSTR cduphelp
[] = "change remote working directory to parent directory";
88 HSTR chmodhelp
[] = "change file permissions of remote file";
89 HSTR connecthelp
[] = "connect to remote ftp server";
90 HSTR crhelp
[] = "toggle carriage return stripping on ascii gets";
91 HSTR debughelp
[] = "toggle/set debugging mode";
92 HSTR deletehelp
[] = "delete remote file";
93 HSTR disconhelp
[] = "terminate ftp session";
94 HSTR domachelp
[] = "execute macro";
95 HSTR edithelp
[] = "toggle command line editing";
96 HSTR epsv4help
[] = "toggle use of EPSV/EPRT on IPv4 ftp";
97 HSTR feathelp
[] = "show FEATures supported by remote system";
98 HSTR formhelp
[] = "set file transfer format";
99 HSTR gatehelp
[] = "toggle gate-ftp; specify host[:port] to change proxy";
100 HSTR globhelp
[] = "toggle metacharacter expansion of local file names";
101 HSTR hashhelp
[] = "toggle printing `#' marks; specify number to set size";
102 HSTR helphelp
[] = "print local help information";
103 HSTR idlehelp
[] = "get (set) idle timer on remote side";
104 HSTR lcdhelp
[] = "change local working directory";
105 HSTR lpagehelp
[] = "view a local file through your pager";
106 HSTR lpwdhelp
[] = "print local working directory";
107 HSTR lshelp
[] = "list contents of remote path";
108 HSTR macdefhelp
[] = "define a macro";
109 HSTR mdeletehelp
[] = "delete multiple files";
110 HSTR mgethelp
[] = "get multiple files";
111 HSTR mregethelp
[] = "get multiple files restarting at end of local file";
112 HSTR fgethelp
[] = "get files using a localfile as a source of names";
113 HSTR mkdirhelp
[] = "make directory on the remote machine";
114 HSTR mlshelp
[] = "list contents of multiple remote directories";
115 HSTR mlsdhelp
[] = "list contents of remote directory in a machine "
117 HSTR mlsthelp
[] = "list remote path in a machine parsable form";
118 HSTR modehelp
[] = "set file transfer mode";
119 HSTR modtimehelp
[] = "show last modification time of remote file";
120 HSTR mputhelp
[] = "send multiple files";
121 HSTR newerhelp
[] = "get file if remote file is newer than local file ";
122 HSTR nmaphelp
[] = "set templates for default file name mapping";
123 HSTR ntranshelp
[] = "set translation table for default file name mapping";
124 HSTR optshelp
[] = "show or set options for remote commands";
125 HSTR pagehelp
[] = "view a remote file through your pager";
126 HSTR passivehelp
[] = "toggle use of passive transfer mode";
127 HSTR plshelp
[] = "list contents of remote path through your pager";
128 HSTR pmlsdhelp
[] = "list contents of remote directory in a machine "
129 "parsable form through your pager";
130 HSTR porthelp
[] = "toggle use of PORT/LPRT cmd for each data connection";
131 HSTR preservehelp
[] ="toggle preservation of modification time of "
133 HSTR progresshelp
[] ="toggle transfer progress meter";
134 HSTR prompthelp
[] = "force interactive prompting on multiple commands";
135 HSTR proxyhelp
[] = "issue command on alternate connection";
136 HSTR pwdhelp
[] = "print working directory on remote machine";
137 HSTR quithelp
[] = "terminate ftp session and exit";
138 HSTR quotehelp
[] = "send arbitrary ftp command";
139 HSTR ratehelp
[] = "set transfer rate limit (in bytes/second)";
140 HSTR receivehelp
[] = "receive file";
141 HSTR regethelp
[] = "get file restarting at end of local file";
142 HSTR remotehelp
[] = "get help from remote server";
143 HSTR renamehelp
[] = "rename file";
144 HSTR resethelp
[] = "clear queued command replies";
145 HSTR restarthelp
[]= "restart file transfer at bytecount";
146 HSTR rmdirhelp
[] = "remove directory on the remote machine";
147 HSTR rmtstatushelp
[]="show status of remote machine";
148 HSTR runiquehelp
[] = "toggle store unique for local files";
149 HSTR sendhelp
[] = "send one file";
150 HSTR sethelp
[] = "set or display options";
151 HSTR shellhelp
[] = "escape to the shell";
152 HSTR sitehelp
[] = "send site specific command to remote server\n"
153 "\t\tTry \"rhelp site\" or \"site help\" "
154 "for more information";
155 HSTR sizecmdhelp
[] = "show size of remote file";
156 HSTR statushelp
[] = "show current status";
157 HSTR structhelp
[] = "set file transfer structure";
158 HSTR suniquehelp
[] = "toggle store unique on remote machine";
159 HSTR systemhelp
[] = "show remote system type";
160 HSTR tenexhelp
[] = "set tenex file transfer type";
161 HSTR tracehelp
[] = "toggle packet tracing";
162 HSTR typehelp
[] = "set file transfer type";
163 HSTR umaskhelp
[] = "get (set) umask on remote side";
164 HSTR unsethelp
[] = "unset an option";
165 HSTR usagehelp
[] = "show command usage";
166 HSTR userhelp
[] = "send new user information";
167 HSTR verbosehelp
[] = "toggle verbose mode";
168 HSTR xferbufhelp
[] = "set socket send/receive buffer size";
179 #ifdef NO_EDITCOMPLETE
182 #else /* !NO_EDITCOMPLETE */
185 #endif /* !NO_EDITCOMPLETE */
187 struct cmd cmdtab
[] = {
188 { "!", H(shellhelp
), 0, 0, 0, CMPL0 shell
},
189 { "$", H(domachelp
), 1, 0, 0, CMPL0 domacro
},
190 { "account", H(accounthelp
), 0, 1, 1, CMPL0 account
},
191 { "append", H(appendhelp
), 1, 1, 1, CMPL(lr
) put
},
192 { "ascii", H(asciihelp
), 0, 1, 1, CMPL0 setascii
},
193 { "bell", H(beephelp
), 0, 0, 0, CMPL0 setbell
},
194 { "binary", H(binaryhelp
), 0, 1, 1, CMPL0 setbinary
},
195 { "bye", H(quithelp
), 0, 0, 0, CMPL0 quit
},
196 { "case", H(casehelp
), 0, 0, 1, CMPL0 setcase
},
197 { "cd", H(cdhelp
), 0, 1, 1, CMPL(r
) cd
},
198 { "cdup", H(cduphelp
), 0, 1, 1, CMPL0 cdup
},
199 { "chmod", H(chmodhelp
), 0, 1, 1, CMPL(nr
) do_chmod
},
200 { "close", H(disconhelp
), 0, 1, 1, CMPL0 disconnect
},
201 { "cr", H(crhelp
), 0, 0, 0, CMPL0 setcr
},
202 { "debug", H(debughelp
), 0, 0, 0, CMPL0 setdebug
},
203 { "delete", H(deletehelp
), 0, 1, 1, CMPL(r
) delete },
204 { "dir", H(lshelp
), 1, 1, 1, CMPL(rl
) ls
},
205 { "disconnect", H(disconhelp
), 0, 1, 1, CMPL0 disconnect
},
206 { "edit", H(edithelp
), 0, 0, 0, CMPL0 setedit
},
207 { "epsv4", H(epsv4help
), 0, 0, 0, CMPL0 setepsv4
},
208 { "exit", H(quithelp
), 0, 0, 0, CMPL0 quit
},
209 { "features", H(feathelp
), 0, 1, 1, CMPL0 feat
},
210 { "fget", H(fgethelp
), 1, 1, 1, CMPL(l
) fget
},
211 { "form", H(formhelp
), 0, 1, 1, CMPL0 setform
},
212 { "ftp", H(connecthelp
), 0, 0, 1, CMPL0 setpeer
},
213 { "gate", H(gatehelp
), 0, 0, 0, CMPL0 setgate
},
214 { "get", H(receivehelp
), 1, 1, 1, CMPL(rl
) get
},
215 { "glob", H(globhelp
), 0, 0, 0, CMPL0 setglob
},
216 { "hash", H(hashhelp
), 0, 0, 0, CMPL0 sethash
},
217 { "help", H(helphelp
), 0, 0, 1, CMPL(C
) help
},
218 { "idle", H(idlehelp
), 0, 1, 1, CMPL0 idlecmd
},
219 { "image", H(binaryhelp
), 0, 1, 1, CMPL0 setbinary
},
220 { "lcd", H(lcdhelp
), 0, 0, 0, CMPL(l
) lcd
},
221 { "less", H(pagehelp
), 1, 1, 1, CMPL(r
) page
},
222 { "lpage", H(lpagehelp
), 0, 0, 0, CMPL(l
) lpage
},
223 { "lpwd", H(lpwdhelp
), 0, 0, 0, CMPL0 lpwd
},
224 { "ls", H(lshelp
), 1, 1, 1, CMPL(rl
) ls
},
225 { "macdef", H(macdefhelp
), 0, 0, 0, CMPL0 macdef
},
226 { "mdelete", H(mdeletehelp
), 1, 1, 1, CMPL(R
) mdelete
},
227 { "mdir", H(mlshelp
), 1, 1, 1, CMPL(R
) mls
},
228 { "mget", H(mgethelp
), 1, 1, 1, CMPL(R
) mget
},
229 { "mkdir", H(mkdirhelp
), 0, 1, 1, CMPL(r
) makedir
},
230 { "mls", H(mlshelp
), 1, 1, 1, CMPL(R
) mls
},
231 { "mlsd", H(mlsdhelp
), 1, 1, 1, CMPL(r
) ls
},
232 { "mlst", H(mlsthelp
), 1, 1, 1, CMPL(r
) mlst
},
233 { "mode", H(modehelp
), 0, 1, 1, CMPL0 setftmode
},
234 { "modtime", H(modtimehelp
), 0, 1, 1, CMPL(r
) modtime
},
235 { "more", H(pagehelp
), 1, 1, 1, CMPL(r
) page
},
236 { "mput", H(mputhelp
), 1, 1, 1, CMPL(L
) mput
},
237 { "mreget", H(mregethelp
), 1, 1, 1, CMPL(R
) mget
},
238 { "msend", H(mputhelp
), 1, 1, 1, CMPL(L
) mput
},
239 { "newer", H(newerhelp
), 1, 1, 1, CMPL(r
) newer
},
240 { "nlist", H(lshelp
), 1, 1, 1, CMPL(rl
) ls
},
241 { "nmap", H(nmaphelp
), 0, 0, 1, CMPL0 setnmap
},
242 { "ntrans", H(ntranshelp
), 0, 0, 1, CMPL0 setntrans
},
243 { "open", H(connecthelp
), 0, 0, 1, CMPL0 setpeer
},
244 { "page", H(pagehelp
), 1, 1, 1, CMPL(r
) page
},
245 { "passive", H(passivehelp
), 0, 0, 0, CMPL0 setpassive
},
246 { "pdir", H(plshelp
), 1, 1, 1, CMPL(r
) ls
},
247 { "pls", H(plshelp
), 1, 1, 1, CMPL(r
) ls
},
248 { "pmlsd", H(pmlsdhelp
), 1, 1, 1, CMPL(r
) ls
},
249 { "preserve", H(preservehelp
),0, 0, 0, CMPL0 setpreserve
},
250 { "progress", H(progresshelp
),0, 0, 0, CMPL0 setprogress
},
251 { "prompt", H(prompthelp
), 0, 0, 0, CMPL0 setprompt
},
252 { "proxy", H(proxyhelp
), 0, 0, 1, CMPL(c
) doproxy
},
253 { "put", H(sendhelp
), 1, 1, 1, CMPL(lr
) put
},
254 { "pwd", H(pwdhelp
), 0, 1, 1, CMPL0 pwd
},
255 { "quit", H(quithelp
), 0, 0, 0, CMPL0 quit
},
256 { "quote", H(quotehelp
), 1, 1, 1, CMPL0 quote
},
257 { "rate", H(ratehelp
), 0, 0, 0, CMPL0 setrate
},
258 { "rcvbuf", H(xferbufhelp
), 0, 0, 0, CMPL0 setxferbuf
},
259 { "recv", H(receivehelp
), 1, 1, 1, CMPL(rl
) get
},
260 { "reget", H(regethelp
), 1, 1, 1, CMPL(rl
) reget
},
261 { "remopts", H(optshelp
), 0, 1, 1, CMPL0 opts
},
262 { "rename", H(renamehelp
), 0, 1, 1, CMPL(rr
) renamefile
},
263 { "reset", H(resethelp
), 0, 1, 1, CMPL0 reset
},
264 { "restart", H(restarthelp
), 1, 1, 1, CMPL0 restart
},
265 { "rhelp", H(remotehelp
), 0, 1, 1, CMPL0 rmthelp
},
266 { "rmdir", H(rmdirhelp
), 0, 1, 1, CMPL(r
) removedir
},
267 { "rstatus", H(rmtstatushelp
),0, 1, 1, CMPL(r
) rmtstatus
},
268 { "runique", H(runiquehelp
), 0, 0, 1, CMPL0 setrunique
},
269 { "send", H(sendhelp
), 1, 1, 1, CMPL(lr
) put
},
270 { "sendport", H(porthelp
), 0, 0, 0, CMPL0 setport
},
271 { "set", H(sethelp
), 0, 0, 0, CMPL(o
) setoption
},
272 { "site", H(sitehelp
), 0, 1, 1, CMPL0 site
},
273 { "size", H(sizecmdhelp
), 1, 1, 1, CMPL(r
) sizecmd
},
274 { "sndbuf", H(xferbufhelp
), 0, 0, 0, CMPL0 setxferbuf
},
275 { "status", H(statushelp
), 0, 0, 1, CMPL0 status
},
276 { "struct", H(structhelp
), 0, 1, 1, CMPL0 setstruct
},
277 { "sunique", H(suniquehelp
), 0, 0, 1, CMPL0 setsunique
},
278 { "system", H(systemhelp
), 0, 1, 1, CMPL0 syst
},
279 { "tenex", H(tenexhelp
), 0, 1, 1, CMPL0 settenex
},
280 { "throttle", H(ratehelp
), 0, 0, 0, CMPL0 setrate
},
281 { "trace", H(tracehelp
), 0, 0, 0, CMPL0 settrace
},
282 { "type", H(typehelp
), 0, 1, 1, CMPL0 settype
},
283 { "umask", H(umaskhelp
), 0, 1, 1, CMPL0 do_umask
},
284 { "unset", H(unsethelp
), 0, 0, 0, CMPL(o
) unsetoption
},
285 { "usage", H(usagehelp
), 0, 0, 1, CMPL(C
) help
},
286 { "user", H(userhelp
), 0, 1, 1, CMPL0 user
},
287 { "verbose", H(verbosehelp
), 0, 0, 0, CMPL0 setverbose
},
288 { "xferbuf", H(xferbufhelp
), 0, 0, 0, CMPL0 setxferbuf
},
289 { "?", H(helphelp
), 0, 0, 1, CMPL(C
) help
},
293 struct option optiontab
[] = {
294 { "anonpass", NULL
},
295 { "ftp_proxy", NULL
},
296 { "http_proxy", NULL
},
297 { "no_proxy", NULL
},