home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / AP / TERMNET / NCFTP183 / CMDTAB.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-20  |  11.0 KB  |  283 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. #ifdef PASSIVEMODE
  94. #define PASSIVEHELP "enter passive transfer mode"
  95. #endif
  96.  
  97.  
  98. #define PDIRUSAGE " [flags] [remote-files]"
  99.  
  100. #define PUTHELP "sends a local file to the current remote host"
  101. #define PUTUSAGE " local-file-name [remote-file-name]"
  102.  
  103. #define QUITHELP "quits the program"
  104. #define QUITUSAGE EMPTYSTR
  105.  
  106. #define RHELPHELP "asks the remote-server for help"
  107. #define RHELPUSAGE " [help-topic (i.e. FTP command)]"
  108.  
  109. #define UNIMPLHELP "this command is not supported"
  110. #define UNIMPLUSAGE (NULL)
  111.  
  112. struct cmd cmdtab[] = {
  113.     /* name ; must-be-connected ; hidden ; help-string ; usage-string */
  114.     { "!",                0,  0,  shell,
  115.         "spawns a shell for you to run other commands",
  116.         " [single-command-and-arguments]" },
  117.     { "$",                0,  0,  domacro,
  118.         "runs a macro previously defined in your NETRC, or with the macdef cmd",
  119.         "macro-number" },
  120.     { "account",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  121.     { "append",        0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  122.     { "ascii",            1,  1,  setascii,
  123.         "transfer files as text files, with proper CR/LF translation",
  124.         "" },
  125.     { "bell",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  126.     { "binary",           1,  1,  setbinary, BINARYHELP, BINARYUSAGE },
  127.     { "bye",              0,  1,  quit, QUITHELP, QUITUSAGE },
  128.     { "case",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  129.     { "cd",               1,  0,  cd, CHDIRHELP, CHDIRUSAGE },
  130.     { "cdup",             1,  0,  cdup,
  131.         "changes the current remote working directory to it's parent",
  132.         "" },
  133.     { "chdir",            1,  1,  cd, CHDIRHELP, CHDIRUSAGE },
  134.     { "close",            1,  1,  disconnect, CLOSEHELP, CLOSEUSAGE },
  135.     { "connect",          0,  1,  cmdOpen, OPENHELP, OPENUSAGE },
  136.     { "cr",            0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  137.     { "create",           1,  0,  create,
  138.         "create an empty file on the remote host",
  139.         REMOTEFILE },
  140.     { "delete",           1,  0,  do_delete, DELETEHELP, DELETEUSAGE },
  141.     { "debug",            0,  1,  setdebug,
  142.         "to print debugging messages during execution of the program",
  143.         TOGGLE },
  144.     { "dir",              1,  0,  ls,
  145.         "prints remote directory contents (long-mode)",
  146.         DIRUSAGE },
  147.     { "erase",            1,  1,  do_delete, DELETEHELP, DELETEUSAGE },
  148.     { "exit",             0,  1,  quit, QUITHELP, QUITUSAGE },
  149.     { "form",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  150.     { "get",              1,  0,  get,
  151.         "fetches a file from the current remote host", GETUSAGE },
  152.     { "glob",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  153.     { "hash",             0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  154.     { "help",             0,  0,  help, HELPHELP, HELPUSAGE },
  155.     { "idle",             0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  156.     { "image",            1,  1,  setbinary, BINARYHELP, BINARYUSAGE },
  157.     { "lcd",              0,  0,  lcd,
  158.         "changes the current local directory", LDIRNAME },
  159.     { "lookup",           0,  0,  lookup,
  160.         "uses the name-server to tell you a host's IP number given it's\n\
  161.     name, or it's name given it's IP number",
  162.         " hostname | host-IP-number" },
  163.     { "ls",               1,  0,  ls, LSHELP, LSUSAGE },
  164.     { "macdef",           0,  0,  macdef,
  165.         "defines a macro which is expanded when you use the $ command",
  166.         " new-macro-name" },
  167.     { "mdelete",          1,  0,  mdelete,
  168.         "deletes multiple files on the remote host", REMOTEFILES  },
  169.     { "mdir",             1,  1,  ls, LSHELP, LSUSAGE },
  170. #if LIBMALLOC != LIBC_MALLOC
  171.     { "memchk",        0,  0,  MallocStatusCmd,
  172.         "show debugging information about memory usage.", EMPTYSTR },
  173. #endif
  174.     { "mget",             1,  0,  mget,
  175.         "fetches multiple files from the remote host", REMOTEFILES },
  176.     { "mkdir",            1,  0,  makedir,
  177.         "creates a new sub-directory on the current remote host",
  178.         RMTDIRNAME },
  179.     { "mls",              1,  0,  ls, LSHELP, LSUSAGE },
  180.     { "mode",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  181.     { "modtime",          1,  0,  modtime,
  182.         "shows the last modification date for a remote file",
  183.         REMOTEFILE },
  184.     { "more",             1,  1,  get, PAGEHELP, PAGEUSAGE },
  185.     { "mput",             1,  0,  mput,
  186.         "sends multiple local files to the current remote host",
  187.         LOCALFILES },
  188.     { "newer",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  189.     { "nlist",            1,  1,  ls, LSHELP, LSUSAGE },
  190.     { "nmap",          0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  191.     { "ntrans",        0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  192.     { "open",             0,  0,  cmdOpen, OPENHELP, OPENUSAGE },
  193.     { "p",             1,  1,  get, PAGEHELP, PAGEUSAGE },
  194. #ifdef PASSIVEMODE
  195.     { "passive",       0,  0,  setpassive, PASSIVEHELP, EMPTYSTR },
  196. #endif
  197.     { "page",             1,  0,  get, PAGEHELP, PAGEUSAGE },
  198.     { "pdir",             1,  0,  ls,
  199.         "view a remote directory listing (long mode) with your $PAGER",
  200.         PDIRUSAGE },
  201.     { "pls",              1,  0,  ls,
  202.         "view a remote directory listing (short mode) with your $PAGER",
  203.         PDIRUSAGE },
  204.     { "predir",           1,  0,  ShowLineBuffer,
  205.         "view the last remote directory listing with your $PAGER",
  206.         EMPTYSTR },
  207.     { "prompt",           0,  1,  setprompt,
  208.         "toggle interactive prompting on multiple commands",
  209.         TOGGLE },
  210.     { "proxy",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  211.     { "put",              1,  0,  put, PUTHELP, PUTUSAGE },
  212.     { "pwd",              1,  0,  pwd,
  213.         "prints the name of the current remote directory",
  214.         EMPTYSTR },
  215.     { "quit",             0,  0,  quit, QUITHELP, QUITUSAGE },
  216.     { "quote",            1,  0,  quote,
  217.         "allows advanced users to directly enter FTP commands verbatim",
  218.         " FTP-commands" },
  219.     { "redir",            1,  0,  ShowLineBuffer,
  220.         "re-prints the last directory listing",
  221.         EMPTYSTR },
  222.     { "reget",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  223.     { "remotehelp",       1,  0,  rmthelp, RHELPHELP, RHELPUSAGE },
  224.     { "reset",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  225.     { "restart",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  226.     { "rm",               1,  1,  do_delete, DELETEHELP, DELETEUSAGE },
  227.     { "rstatus",          1,  0,  rmtstatus,
  228.         "asks the remote-server for it's status",
  229.         EMPTYSTR },
  230.     { "rhelp",            1,  1,  rmthelp, RHELPHELP, RHELPUSAGE },
  231.     { "rename",           1,  0,  renamefile,
  232.         "changes the name of a file on the current remote host",
  233.         " old-name new-name" },
  234.     { "rmdir",            1,  0,  removedir,
  235.         "deletes a directory on the current remote host",
  236.         RMTDIRNAME },
  237.     { "runique",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  238.     { "send",             1,  1,  put, PUTHELP, PUTUSAGE },
  239.     { "sendport",      0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  240.     { "show",             0,  0,  do_show,
  241.         "prints the value of some or all program variables",
  242.         " all | variable-names" },
  243.     { "set",              0,  0,  set,
  244.         "changes the value of a program variable; for numeric/boolean\n\
  245.     variables sets them to 1/true",
  246.         " variable-name [= new-value]" },
  247.     { "site",            1,  0,  quote,
  248.         "allows advanced users to send site-specific commands to the host",
  249.         " site-specific-commands\n\
  250. Example (to try on wuarchive.wustl.edu):\n\
  251.     site locate emacs" },
  252.     { "size",             1,  0,  sizecmd,
  253.         "shows the size of a remote file",
  254.         REMOTEFILE },
  255.     { "struct",        0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  256.     { "sunique",       0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  257.     { "system",           1,  0,  syst,
  258.         "tells you what type of machine the current remote host is",
  259.         EMPTYSTR },
  260.     { "tenex",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  261.     { "umask",         0,  1,  unimpl, UNIMPLHELP, UNIMPLUSAGE },
  262.     { "unset",            0,  0,  set,
  263.         "resets the value of a program variable to it's default state, or for\n\
  264.     numeric/boolean variables, sets them to 0/false",
  265.         " variable-name" },
  266.     { "user",             1,  0,  do_user,
  267.         "lets you login as a new user (with appropriate password)",
  268.         " new-user-name [new-password]" },
  269.     { "type",             1,  0,  settype,
  270.         "changes the current file transfer method",
  271.         " ascii | binary | ebcdic | tenex" },
  272.     { "verbose",          0,  0,  setverbose,
  273.         "controls how many message the program prints in response to commands",
  274.         " -1 (quiet) | 0 (errs) | 1 (terse) | 2 (verbose)" },
  275.     { "version",          0,  0,  show_version,
  276.         "prints information about the program",
  277.         EMPTYSTR },
  278.     { "?",                0,  1,  help, HELPHELP, HELPUSAGE },
  279.     { NULL,               0,  0,  NULL, NULL, NULL }
  280. };
  281.  
  282. /* eof cmdtab.c */
  283.