cmdtab.c revision 1.15 1 1.15 lukem /* $NetBSD: cmdtab.c,v 1.15 1997/04/05 03:27:33 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.1 cgd #ifndef lint
37 1.6 tls #if 0
38 1.6 tls static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
39 1.6 tls #else
40 1.15 lukem static char rcsid[] = "$NetBSD: cmdtab.c,v 1.15 1997/04/05 03:27:33 lukem Exp $";
41 1.6 tls #endif
42 1.1 cgd #endif /* not lint */
43 1.1 cgd
44 1.3 cgd #include <stdio.h>
45 1.1 cgd #include "ftp_var.h"
46 1.1 cgd
47 1.1 cgd /*
48 1.1 cgd * User FTP -- Command Tables.
49 1.1 cgd */
50 1.1 cgd
51 1.1 cgd char accounthelp[] = "send account command to remote server";
52 1.1 cgd char appendhelp[] = "append to a file";
53 1.1 cgd char asciihelp[] = "set ascii transfer type";
54 1.1 cgd char beephelp[] = "beep when command completed";
55 1.1 cgd char binaryhelp[] = "set binary transfer type";
56 1.1 cgd char casehelp[] = "toggle mget upper/lower case id mapping";
57 1.1 cgd char cdhelp[] = "change remote working directory";
58 1.12 lukem char cduphelp[] = "change remote working directory to parent directory";
59 1.1 cgd char chmodhelp[] = "change file permissions of remote file";
60 1.8 fvdl char connecthelp[] = "connect to remote ftp server";
61 1.1 cgd char crhelp[] = "toggle carriage return stripping on ascii gets";
62 1.10 lukem char debughelp[] = "toggle/set debugging mode";
63 1.1 cgd char deletehelp[] = "delete remote file";
64 1.1 cgd char dirhelp[] = "list contents of remote directory";
65 1.1 cgd char disconhelp[] = "terminate ftp session";
66 1.12 lukem char domachelp[] = "execute macro";
67 1.14 christos #ifndef SMALL
68 1.12 lukem char edithelp[] = "toggle command line editing";
69 1.14 christos #endif /* !SMALL */
70 1.1 cgd char formhelp[] = "set file transfer format";
71 1.1 cgd char globhelp[] = "toggle metacharacter expansion of local file names";
72 1.7 lukem char hashhelp[] = "toggle printing `#' marks; specify number to set size";
73 1.1 cgd char helphelp[] = "print local help information";
74 1.1 cgd char idlehelp[] = "get (set) idle timer on remote side";
75 1.1 cgd char lcdhelp[] = "change local working directory";
76 1.9 lukem char lpwdhelp[] = "print local working directory";
77 1.1 cgd char lshelp[] = "list contents of remote directory";
78 1.1 cgd char macdefhelp[] = "define a macro";
79 1.1 cgd char mdeletehelp[] = "delete multiple files";
80 1.1 cgd char mdirhelp[] = "list contents of multiple remote directories";
81 1.1 cgd char mgethelp[] = "get multiple files";
82 1.1 cgd char mkdirhelp[] = "make directory on the remote machine";
83 1.1 cgd char mlshelp[] = "list contents of multiple remote directories";
84 1.10 lukem char modehelp[] = "set file transfer mode";
85 1.1 cgd char modtimehelp[] = "show last modification time of remote file";
86 1.1 cgd char mputhelp[] = "send multiple files";
87 1.1 cgd char newerhelp[] = "get file if remote file is newer than local file ";
88 1.1 cgd char nlisthelp[] = "nlist contents of remote directory";
89 1.1 cgd char nmaphelp[] = "set templates for default file name mapping";
90 1.1 cgd char ntranshelp[] = "set translation table for default file name mapping";
91 1.13 lukem char pagehelp[] = "view a remote file through your pager";
92 1.10 lukem char passivehelp[] = "enter passive transfer mode";
93 1.1 cgd char porthelp[] = "toggle use of PORT cmd for each data connection";
94 1.10 lukem char preservehelp[] ="toggle preservation of modification time of "
95 1.9 lukem "retreived files";
96 1.10 lukem char progresshelp[] ="toggle transfer progress meter";
97 1.1 cgd char prompthelp[] = "force interactive prompting on multiple commands";
98 1.1 cgd char proxyhelp[] = "issue command on alternate connection";
99 1.1 cgd char pwdhelp[] = "print working directory on remote machine";
100 1.1 cgd char quithelp[] = "terminate ftp session and exit";
101 1.1 cgd char quotehelp[] = "send arbitrary ftp command";
102 1.1 cgd char receivehelp[] = "receive file";
103 1.1 cgd char regethelp[] = "get file restarting at end of local file";
104 1.1 cgd char remotehelp[] = "get help from remote server";
105 1.1 cgd char renamehelp[] = "rename file";
106 1.10 lukem char resethelp[] = "clear queued command replies";
107 1.1 cgd char restarthelp[]= "restart file transfer at bytecount";
108 1.1 cgd char rmdirhelp[] = "remove directory on the remote machine";
109 1.1 cgd char rmtstatushelp[]="show status of remote machine";
110 1.1 cgd char runiquehelp[] = "toggle store unique for local files";
111 1.1 cgd char sendhelp[] = "send one file";
112 1.10 lukem char shellhelp[] = "escape to the shell";
113 1.9 lukem char sitehelp[] = "send site specific command to remote server\n"
114 1.10 lukem "\t\tTry \"rhelp site\" or \"site help\" "
115 1.10 lukem "for more information";
116 1.1 cgd char sizecmdhelp[] = "show size of remote file";
117 1.1 cgd char statushelp[] = "show current status";
118 1.1 cgd char structhelp[] = "set file transfer structure";
119 1.1 cgd char suniquehelp[] = "toggle store unique on remote machine";
120 1.1 cgd char systemhelp[] = "show remote system type";
121 1.1 cgd char tenexhelp[] = "set tenex file transfer type";
122 1.1 cgd char tracehelp[] = "toggle packet tracing";
123 1.1 cgd char typehelp[] = "set file transfer type";
124 1.1 cgd char umaskhelp[] = "get (set) umask on remote side";
125 1.1 cgd char userhelp[] = "send new user information";
126 1.1 cgd char verbosehelp[] = "toggle verbose mode";
127 1.1 cgd
128 1.14 christos #ifdef SMALL
129 1.12 lukem #define CMPL(x)
130 1.12 lukem #define CMPL0
131 1.14 christos #else /* !SMALL */
132 1.12 lukem #define CMPL(x) __STRING(x),
133 1.12 lukem #define CMPL0 "",
134 1.14 christos #endif /* !SMALL */
135 1.12 lukem
136 1.1 cgd struct cmd cmdtab[] = {
137 1.12 lukem { "!", shellhelp, 0, 0, 0, CMPL0 shell },
138 1.12 lukem { "$", domachelp, 1, 0, 0, CMPL0 domacro },
139 1.12 lukem { "account", accounthelp, 0, 1, 1, CMPL0 account},
140 1.12 lukem { "append", appendhelp, 1, 1, 1, CMPL(lr) put },
141 1.12 lukem { "ascii", asciihelp, 0, 1, 1, CMPL0 setascii },
142 1.12 lukem { "bell", beephelp, 0, 0, 0, CMPL0 setbell },
143 1.12 lukem { "binary", binaryhelp, 0, 1, 1, CMPL0 setbinary },
144 1.12 lukem { "bye", quithelp, 0, 0, 0, CMPL0 quit },
145 1.12 lukem { "case", casehelp, 0, 0, 1, CMPL0 setcase },
146 1.12 lukem { "cd", cdhelp, 0, 1, 1, CMPL(r) cd },
147 1.12 lukem { "cdup", cduphelp, 0, 1, 1, CMPL0 cdup },
148 1.12 lukem { "chmod", chmodhelp, 0, 1, 1, CMPL(nr) do_chmod },
149 1.12 lukem { "close", disconhelp, 0, 1, 1, CMPL0 disconnect },
150 1.12 lukem { "cr", crhelp, 0, 0, 0, CMPL0 setcr },
151 1.12 lukem { "debug", debughelp, 0, 0, 0, CMPL0 setdebug },
152 1.12 lukem { "delete", deletehelp, 0, 1, 1, CMPL(r) delete },
153 1.12 lukem { "dir", dirhelp, 1, 1, 1, CMPL(rl) ls },
154 1.12 lukem { "disconnect", disconhelp, 0, 1, 1, CMPL0 disconnect },
155 1.14 christos #ifndef SMALL
156 1.12 lukem { "edit", edithelp, 0, 0, 0, CMPL0 setedit },
157 1.14 christos #endif /* !SMALL */
158 1.12 lukem { "exit", quithelp, 0, 0, 0, CMPL0 quit },
159 1.12 lukem { "form", formhelp, 0, 1, 1, CMPL0 setform },
160 1.12 lukem { "ftp", connecthelp, 0, 0, 1, CMPL0 setpeer },
161 1.12 lukem { "get", receivehelp, 1, 1, 1, CMPL(rl) get },
162 1.12 lukem { "glob", globhelp, 0, 0, 0, CMPL0 setglob },
163 1.12 lukem { "hash", hashhelp, 0, 0, 0, CMPL0 sethash },
164 1.12 lukem { "help", helphelp, 0, 0, 1, CMPL(C) help },
165 1.12 lukem { "idle", idlehelp, 0, 1, 1, CMPL0 idle },
166 1.12 lukem { "image", binaryhelp, 0, 1, 1, CMPL0 setbinary },
167 1.12 lukem { "lcd", lcdhelp, 0, 0, 0, CMPL(l) lcd },
168 1.15 lukem { "less", pagehelp, 1, 1, 1, CMPL(r) page },
169 1.12 lukem { "lpwd", lpwdhelp, 0, 0, 0, CMPL0 lpwd },
170 1.12 lukem { "ls", lshelp, 1, 1, 1, CMPL(rl) ls },
171 1.12 lukem { "macdef", macdefhelp, 0, 0, 0, CMPL0 macdef },
172 1.12 lukem { "mdelete", mdeletehelp, 1, 1, 1, CMPL(R) mdelete },
173 1.12 lukem { "mdir", mdirhelp, 1, 1, 1, CMPL(R) mls },
174 1.12 lukem { "mget", mgethelp, 1, 1, 1, CMPL(R) mget },
175 1.12 lukem { "mkdir", mkdirhelp, 0, 1, 1, CMPL(r) makedir },
176 1.12 lukem { "mls", mlshelp, 1, 1, 1, CMPL(R) mls },
177 1.12 lukem { "mode", modehelp, 0, 1, 1, CMPL0 setftmode },
178 1.12 lukem { "modtime", modtimehelp, 0, 1, 1, CMPL(r) modtime },
179 1.15 lukem { "more", pagehelp, 1, 1, 1, CMPL(r) page },
180 1.12 lukem { "mput", mputhelp, 1, 1, 1, CMPL(L) mput },
181 1.12 lukem { "msend", mputhelp, 1, 1, 1, CMPL(L) mput },
182 1.12 lukem { "newer", newerhelp, 1, 1, 1, CMPL(r) newer },
183 1.12 lukem { "nlist", nlisthelp, 1, 1, 1, CMPL(rl) ls },
184 1.12 lukem { "nmap", nmaphelp, 0, 0, 1, CMPL0 setnmap },
185 1.12 lukem { "ntrans", ntranshelp, 0, 0, 1, CMPL0 setntrans },
186 1.12 lukem { "open", connecthelp, 0, 0, 1, CMPL0 setpeer },
187 1.13 lukem { "page", pagehelp, 1, 1, 1, CMPL(r) page },
188 1.12 lukem { "passive", passivehelp, 0, 0, 0, CMPL0 setpassive },
189 1.12 lukem { "preserve", preservehelp, 0, 0, 0, CMPL0 setpreserve },
190 1.12 lukem { "progress", progresshelp, 0, 0, 0, CMPL0 setprogress },
191 1.12 lukem { "prompt", prompthelp, 0, 0, 0, CMPL0 setprompt },
192 1.12 lukem { "proxy", proxyhelp, 0, 0, 1, CMPL(c) doproxy },
193 1.12 lukem { "put", sendhelp, 1, 1, 1, CMPL(lr) put },
194 1.12 lukem { "pwd", pwdhelp, 0, 1, 1, CMPL0 pwd },
195 1.12 lukem { "quit", quithelp, 0, 0, 0, CMPL0 quit },
196 1.12 lukem { "quote", quotehelp, 1, 1, 1, CMPL0 quote },
197 1.12 lukem { "recv", receivehelp, 1, 1, 1, CMPL(rl) get },
198 1.12 lukem { "reget", regethelp, 1, 1, 1, CMPL(rl) reget },
199 1.12 lukem { "rename", renamehelp, 0, 1, 1, CMPL(rr) renamefile },
200 1.12 lukem { "reset", resethelp, 0, 1, 1, CMPL0 reset },
201 1.12 lukem { "restart", restarthelp, 1, 1, 1, CMPL0 restart },
202 1.12 lukem { "rhelp", remotehelp, 0, 1, 1, CMPL0 rmthelp },
203 1.12 lukem { "rmdir", rmdirhelp, 0, 1, 1, CMPL(r) removedir },
204 1.12 lukem { "rstatus", rmtstatushelp, 0, 1, 1, CMPL(r) rmtstatus },
205 1.12 lukem { "runique", runiquehelp, 0, 0, 1, CMPL0 setrunique },
206 1.12 lukem { "send", sendhelp, 1, 1, 1, CMPL(lr) put },
207 1.12 lukem { "sendport", porthelp, 0, 0, 0, CMPL0 setport },
208 1.12 lukem { "site", sitehelp, 0, 1, 1, CMPL0 site },
209 1.12 lukem { "size", sizecmdhelp, 1, 1, 1, CMPL(r) sizecmd },
210 1.12 lukem { "status", statushelp, 0, 0, 1, CMPL0 status },
211 1.12 lukem { "struct", structhelp, 0, 1, 1, CMPL0 setstruct },
212 1.12 lukem { "sunique", suniquehelp, 0, 0, 1, CMPL0 setsunique },
213 1.12 lukem { "system", systemhelp, 0, 1, 1, CMPL0 syst },
214 1.12 lukem { "tenex", tenexhelp, 0, 1, 1, CMPL0 settenex },
215 1.12 lukem { "trace", tracehelp, 0, 0, 0, CMPL0 settrace },
216 1.12 lukem { "type", typehelp, 0, 1, 1, CMPL0 settype },
217 1.12 lukem { "umask", umaskhelp, 0, 1, 1, CMPL0 do_umask },
218 1.12 lukem { "user", userhelp, 0, 1, 1, CMPL0 user },
219 1.12 lukem { "verbose", verbosehelp, 0, 0, 0, CMPL0 setverbose },
220 1.12 lukem { "?", helphelp, 0, 0, 1, CMPL(C) help },
221 1.1 cgd { 0 },
222 1.1 cgd };
223 1.1 cgd
224 1.13 lukem int NCMDS = (sizeof(cmdtab) / sizeof(cmdtab[0])) - 1;
225