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