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