home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 4 / CDPD_IV.bin / networking / tcpip / amitcp-support / ncftp-1.5.6 / src / rcs / cmdtab.c,v < prev    next >
Encoding:
Text File  |  1994-06-29  |  10.9 KB  |  297 lines

  1. head    14020.11;
  2. access;
  3. symbols
  4.     ORIGINAL:14020.11;
  5. locks; strict;
  6. comment    @ * @;
  7.  
  8.  
  9. 14020.11
  10. date    93.07.09.11.04.56;    author alph;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @Original version
  17. @
  18.  
  19.  
  20. 14020.11
  21. log
  22. @checked in with -k by alph at 1993/10/10 19:59:56
  23. @
  24. text
  25. @/* cmdtab.c */
  26.  
  27. /*  $RCSfile: cmdtab.c,v $
  28.  *  $Revision: 14020.11 $
  29.  *  $Date: 93/07/09 11:04:56 $
  30.  */
  31.  
  32. #include "sys.h"
  33. #include <sys/types.h>
  34. #include <sys/time.h>
  35. #include "util.h"
  36. #include "cmds.h"
  37. #include "main.h"
  38. #include "ftp.h"
  39. #include "ftprc.h"
  40. #include "glob.h"
  41. #include "open.h"
  42. #include "set.h"
  43. #include "copyright.h"
  44.  
  45. #define REMOTEFILE " remote-file-name"
  46. #define REMOTEFILES " remote-file-names and/or UNIX-style-wildcards"
  47. #define LOCALFILE " local-file-name"
  48. #define LOCALFILES " local-file-names and/or UNIX-style-wildcards"
  49. #define LDIRNAME " local-directory-name"
  50. #define RMTDIRNAME " remote-directory-name"
  51. #define EMPTYSTR ""
  52. #define TOGGLE " [on | off] (no argument toggles the switch)"
  53.  
  54. #define BINARYHELP "transfer files as binary files, without CR/LF translation"
  55. #define BINARYUSAGE EMPTYSTR
  56.  
  57. #define CHDIRHELP "changes the current remote working directory"
  58. #define CHDIRUSAGE RMTDIRNAME
  59.  
  60. #define CLOSEHELP "closes FTP connection to current remote host"
  61. #define CLOSEUSAGE EMPTYSTR
  62.  
  63. #define DELETEHELP "deletes the specified file on the remote host"
  64. #define DELETEUSAGE REMOTEFILE
  65.  
  66. #define DIRUSAGE " \
  67. [flags] [remote-items] [>outfile or \"|pipecmd [cmd-args]\"]\n\
  68.     Note that there must be no whitespace between > and outfile, or | and\n\
  69.     pipecmd, and if the pipe-command needs arguments, you must enclose the\n\
  70.     whole thing with double quotes.\n\
  71. Examples:\n\
  72.     dir -s\n\
  73.     dir remoteFile\n\
  74.     dir /pub/mac \"|head -20\"\n\
  75.     dir -rtR file1 file2 dir1 >contents.txt"
  76.  
  77. #define GETUSAGE " remote-file-name [local-file-name or |pipecommand]\n\
  78. Examples:\n\
  79.     get myfile.txt\n\
  80.     get MYFILE.ZIP myfile.zip\n\
  81.     get myfile.txt |head\n\
  82.     get myfile.txt \"|head -20\"\n\
  83.     get ./help/newuser.txt    (./newuser.txt will be local-file-name)\n\
  84.     get ./help/newuser.txt ./docs/newbie.help\n\
  85.     get my*.txt  (pseudo-filename-completion if match is unique, i.e. myfile.txt)"
  86.  
  87. #define    HELPHELP "shows commands, and optionally tell you how to use a specific one"
  88. #define    HELPUSAGE " [command-name | showall (shows hidden commands) | helpall"
  89.  
  90. #define LSHELP "prints remote directory contents (short-mode)"
  91. #define LSUSAGE " \
  92. [flags] [remote-items] [>outfile or \"|pipecmd [cmd-args]\"]\n\
  93.     Note that there must be no whitespace between > and outfile, or | and\n\
  94.     pipecmd, and if the pipe-command needs arguments, you must enclose the\n\
  95.     whole thing with double quotes.\n\
  96. Examples:\n\
  97.     ls -s\n\
  98.     ls remoteFile\n\
  99.     ls /pub/mac \"|head -20\"\n\
  100.     ls -lrtR file1 file2 dir1 >contents.txt"
  101.  
  102. #define OPENHELP "connects to a new remote host, and optionally fetches a file\n\
  103.     or sets the current remote working directory"
  104. #define OPENUSAGE " \
  105. [-a | -u] [-i] [-p N] [-r [-d N] [-g N]] hostname[:pathname]\n\
  106.     -a     : Open anonymously (this is the default).\n\
  107.     -u     : Open, specify user/password.\n\
  108.     -i     : Ignore machine entry in your .netrc.\n\
  109.     -p N   : Use port #N for connection.\n\
  110.     -r     : \"Redial\" until connected.\n\
  111.     -d N   : Redial, pausing N seconds between tries.\n\
  112.     -g N   : Redial, giving up after N tries.\n\
  113.     :path  : Open site, then retrieve file \"path.\""
  114.  
  115. #define PAGEHELP "view a file on the remote host with your $PAGER"
  116. #define PAGEUSAGE REMOTEFILE
  117.  
  118. #define PDIRUSAGE " [flags] [remote-files]"
  119.  
  120. #define PUTHELP "sends a local file to the current remote host"
  121. #define PUTUSAGE " local-file-name [remote-file-name]"
  122.  
  123. #define QUITHELP "quits the program"
  124. #define QUITUSAGE EMPTYSTR
  125.  
  126. #define RHELPHELP "asks the remote-server for help"
  127. #define RHELPUSAGE " [help-topic (i.e. FTP command)]"
  128.  
  129. #define UNIMPLHELP "this command is not supported"
  130. #define UNIMPLUSAGE (NULL)
  131.  
  132. struct cmd cmdtab[] = {
  133.     /* name ; must-be-connected ; hidden ; help-string ; usage-string */
  134.     { "!",                0,  0,  shell,
  135.         "spawns a shell for you to run other commands",
  136.         " [single-command-and-arguments]" },
  137.     { "$",                0,  0,  domacro,
  138.         "runs a macro previously defined in your NETRC, or with the macdef cmd",
  139.         "macro-number" },
  140.     { "account",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  141.     { "append",        0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  142.     { "ascii",            1,  1,  setascii,
  143.         "transfer files as text files, with proper CR/LF translation",
  144.         "" },
  145.     { "bell",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  146.     { "binary",           1,  1,  setbinary, BINARYHELP, BINARYUSAGE },
  147.     { "bye",              0,  1,  quit, QUITHELP, QUITUSAGE },
  148.     { "case",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  149.     { "cd",               1,  0,  cd, CHDIRHELP, CHDIRUSAGE },
  150.     { "cdup",             1,  0,  cdup,
  151.         "changes the current remote working directory to it's parent",
  152.         "" },
  153.     { "chdir",            1,  1,  cd, CHDIRHELP, CHDIRUSAGE },
  154.     { "close",            1,  1,  disconnect, CLOSEHELP, CLOSEUSAGE },
  155.     { "connect",          0,  1,  cmdOpen, OPENHELP, OPENUSAGE },
  156.     { "cr",            0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  157.     { "create",           1,  0,  create,
  158.         "create an empty file on the remote host",
  159.         REMOTEFILE },
  160.     { "delete",           1,  0,  do_delete, DELETEHELP, DELETEUSAGE },
  161.     { "debug",            0,  1,  setdebug,
  162.         "to print debugging messages during execution of the program",
  163.         TOGGLE },
  164.     { "dir",              1,  0,  ls,
  165.         "prints remote directory contents (long-mode)",
  166.         DIRUSAGE },
  167.     { "erase",            1,  1,  do_delete, DELETEHELP, DELETEUSAGE },
  168.     { "exit",             0,  1,  quit, QUITHELP, QUITUSAGE },
  169.     { "form",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  170.     { "get",              1,  0,  get,
  171.         "fetches a file from the current remote host", GETUSAGE },
  172.     { "glob",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  173.     { "hash",             0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  174.     { "help",             0,  0,  help, HELPHELP, HELPUSAGE },
  175.     { "idle",             0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  176.     { "image",            1,  1,  setbinary, BINARYHELP, BINARYUSAGE },
  177.     { "lcd",              0,  0,  lcd,
  178.         "changes the current local directory", LDIRNAME },
  179.     { "lookup",           0,  0,  lookup,
  180.         "uses the name-server to tell you a host's IP number given it's\n\
  181.     name, or it's name given it's IP number",
  182.         " hostname | host-IP-number" },
  183.     { "ls",               1,  0,  ls, LSHELP, LSUSAGE },
  184.     { "macdef",           0,  0,  macdef,
  185.         "defines a macro which is expanded when you use the $ command",
  186.         " new-macro-name" },
  187.     { "mdelete",          1,  0,  mdelete,
  188.         "deletes multiple files on the remote host", REMOTEFILES  },
  189.     { "mdir",             1,  1,  ls, LSHELP, LSUSAGE },
  190.     { "mget",             1,  0,  mget,
  191.         "fetches multiple files from the remote host", REMOTEFILES },
  192.     { "mkdir",            1,  0,  makedir,
  193.         "creates a new sub-directory on the current remote host",
  194.         RMTDIRNAME },
  195.     { "mls",              1,  0,  ls, LSHELP, LSUSAGE },
  196.     { "mode",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  197.     { "modtime",          1,  0,  modtime,
  198.         "shows the last modification date for a remote file",
  199.         REMOTEFILE },
  200.     { "more",             1,  1,  get, PAGEHELP, PAGEUSAGE },
  201.     { "mput",             1,  0,  mput,
  202.         "sends multiple local files to the current remote host",
  203.         LOCALFILES },
  204.     { "newer",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  205.     { "nlist",            1,  1,  ls, LSHELP, LSUSAGE },
  206.     { "nmap",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  207.     { "ntrans",        0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  208.     { "open",             0,  0,  cmdOpen, OPENHELP, OPENUSAGE },
  209.     { "p",             1,  1,  get, PAGEHELP, PAGEUSAGE },
  210.     { "page",             1,  0,  get, PAGEHELP, PAGEUSAGE },
  211.     { "pdir",             1,  0,  ls,
  212.         "view a remote directory listing (long mode) with your $PAGER",
  213.         PDIRUSAGE },
  214.     { "pls",              1,  0,  ls,
  215.         "view a remote directory listing (short mode) with your $PAGER",
  216.         PDIRUSAGE },
  217.     { "predir",           1,  0,  ShowLineBuffer,
  218.         "view the last remote directory listing with your $PAGER",
  219.         EMPTYSTR },
  220.     { "prompt",           0,  1,  setprompt,
  221.         "toggle interactive prompting on multiple commands",
  222.         TOGGLE },
  223.     { "proxy",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  224.     { "put",              1,  0,  put, PUTHELP, PUTUSAGE },
  225.     { "pwd",              1,  0,  pwd,
  226.         "prints the name of the current remote directory",
  227.         EMPTYSTR },
  228.     { "quit",             0,  0,  quit, QUITHELP, QUITUSAGE },
  229.     { "quote",            1,  0,  quote,
  230.         "allows advanced users to directly enter FTP commands verbatim",
  231.         " FTP-commands" },
  232.     { "redir",            1,  0,  ShowLineBuffer,
  233.         "re-prints the last directory listing",
  234.         EMPTYSTR },
  235.     { "reget",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  236.     { "remotehelp",       1,  0,  rmthelp, RHELPHELP, RHELPUSAGE },
  237.     { "reset",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  238.     { "restart",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  239.     { "rm",               1,  1,  do_delete, DELETEHELP, DELETEUSAGE },
  240.     { "rstatus",          1,  0,  rmtstatus,
  241.         "asks the remote-server for it's status",
  242.         EMPTYSTR },
  243.     { "rhelp",            1,  1,  rmthelp, RHELPHELP, RHELPUSAGE },
  244.     { "rename",           1,  0,  renamefile,
  245.         "changes the name of a file on the current remote host",
  246.         " old-name new-name" },
  247.     { "rmdir",            1,  0,  removedir,
  248.         "deletes a directory on the current remote host",
  249.         RMTDIRNAME },
  250.     { "runique",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  251.     { "send",             1,  1,  put, PUTHELP, PUTUSAGE },
  252.     { "sendport",      0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  253.     { "show",             0,  0,  do_show,
  254.         "prints the value of some or all program variables",
  255.         " all | variable-names" },
  256.     { "set",              0,  0,  set,
  257.         "changes the value of a program variable; for numeric/boolean\n\
  258.     variables sets them to 1/true",
  259.         " variable-name [= new-value]" },
  260.     { "site",            1,  0,  quote,
  261.         "allows advanced users to send site-specific commands to the host",
  262.         " site-specific-commands\n\
  263. Example (to try on wuarchive.wustl.edu):\n\
  264.     site locate emacs" },
  265.     { "size",             1,  0,  sizecmd,
  266.         "shows the size of a remote file",
  267.         REMOTEFILE },
  268.     { "struct",        0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  269.     { "sunique",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  270.     { "system",           1,  0,  syst,
  271.         "tells you what type of machine the current remote host is",
  272.         EMPTYSTR },
  273.     { "tenex",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  274.     { "umask",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  275.     { "unset",            0,  0,  set,
  276.         "resets the value of a program variable to it's default state, or for\n\
  277.     numeric/boolean variables, sets them to 0/false",
  278.         " variable-name" },
  279.     { "user",             1,  0,  do_user,
  280.         "lets you login as a new user (with appropriate password)",
  281.         " new-user-name [new-password]" },
  282.     { "type",             1,  0,  settype,
  283.         "changes the current file transfer method",
  284.         " ascii | binary | ebcdic | tenex" },
  285.     { "verbose",          0,  0,  setverbose,
  286.         "controls how many message the program prints in response to commands",
  287.         " -1 (quiet) | 0 (errs) | 1 (terse) | 2 (verbose)" },
  288.     { "version",          0,  0,  show_version,
  289.         "prints information about the program",
  290.         EMPTYSTR },
  291.     { "?",                0,  1,  help, HELPHELP, HELPUSAGE },
  292.     { NULL,               0,  0,  NULL, NULL, NULL }
  293. };
  294.  
  295. /* eof cmdtab.c */
  296. @
  297.