home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume39 / ncftp / part04 / cmdtab.c next >
Encoding:
C/C++ Source or Header  |  1993-08-25  |  10.7 KB  |  272 lines

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