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