[BACK]Return to cmdtab.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ftp

Annotation of src/usr.bin/ftp/cmdtab.c, Revision 1.25

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