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