From f1ab9eb0b97f361077c9ffe2aad9a3004249c6d9 Mon Sep 17 00:00:00 2001 From: sobrado Date: Fri, 22 Aug 2008 08:52:35 +0000 Subject: [PATCH] default file transfer type is binary, not ascii; commands which toggle settings can take an explicit on or off argument to force the setting appropiately, show these arguments in usage; synchronize synopsis and usage of commands; spacing; KNF; other minor documentation tweaks. written with help by jmc@ ok jmc@ (documentation), martynas@ (type usage and default file transfer type) --- usr.bin/ftp/cmds.c | 58 ++++++++++++----------- usr.bin/ftp/domacro.c | 6 +-- usr.bin/ftp/ftp.1 | 105 ++++++++++++++++++++++++------------------ usr.bin/ftp/main.c | 6 +-- usr.bin/ftp/util.c | 6 +-- 5 files changed, 99 insertions(+), 82 deletions(-) diff --git a/usr.bin/ftp/cmds.c b/usr.bin/ftp/cmds.c index b97454cdd19..f5269afad74 100644 --- a/usr.bin/ftp/cmds.c +++ b/usr.bin/ftp/cmds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmds.c,v 1.63 2008/07/08 21:07:57 martynas Exp $ */ +/* $OpenBSD: cmds.c,v 1.64 2008/08/22 08:52:35 sobrado Exp $ */ /* $NetBSD: cmds.c,v 1.27 1997/08/18 10:20:15 lukem Exp $ */ /* @@ -60,7 +60,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: cmds.c,v 1.63 2008/07/08 21:07:57 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: cmds.c,v 1.64 2008/08/22 08:52:35 sobrado Exp $"; #endif /* not lint and not SMALL */ /* @@ -118,12 +118,12 @@ settype(int argc, char *argv[]) char *sep; fprintf(ttyout, "usage: %s [", argv[0]); - sep = " "; + sep = ""; for (p = types; p->t_name; p++) { fprintf(ttyout, "%s%s", sep, p->t_name); sep = " | "; } - fputs(" ]\n", ttyout); + fputs("]\n", ttyout); code = -1; return; } @@ -300,7 +300,8 @@ putit(int argc, char *argv[], int restartit) goto usage; if ((argc < 3 && !another(&argc, &argv, "remote-file")) || argc > 3) { usage: - fprintf(ttyout, "usage: %s local-file [ remote-file ]\n", argv[0]); + fprintf(ttyout, "usage: %s local-file [remote-file]\n", + argv[0]); code = -1; return; } @@ -553,7 +554,8 @@ getit(int argc, char *argv[], int restartit, const char *mode) goto usage; if ((argc < 3 && !another(&argc, &argv, "local-file")) || argc > 3) { usage: - fprintf(ttyout, "usage: %s remote-file [ local-file ]\n", argv[0]); + fprintf(ttyout, "usage: %s remote-file [local-file]\n", + argv[0]); code = -1; return (0); } @@ -893,7 +895,7 @@ togglevar(int argc, char *argv[], int *var, const char *mesg) } else if (argc == 2 && strcasecmp(argv[1], "off") == 0) { *var = 0; } else { - fprintf(ttyout, "usage: %s [ on | off ]\n", argv[0]); + fprintf(ttyout, "usage: %s [on | off]\n", argv[0]); return (-1); } if (mesg) @@ -959,7 +961,7 @@ sethash(int argc, char *argv[]) if (argc == 1) hash = !hash; else if (argc != 2) { - fprintf(ttyout, "usage: %s [ on | off | bytecount ]\n", argv[0]); + fprintf(ttyout, "usage: %s [on | off | size]\n", argv[0]); code = -1; return; } else if (strcasecmp(argv[1], "on") == 0) @@ -1041,7 +1043,7 @@ setgate(int argc, char *argv[]) static char gsbuf[MAXHOSTNAMELEN]; if (argc > 3) { - fprintf(ttyout, "usage: %s [ on | off | gateserver [ port ] ]\n", + fprintf(ttyout, "usage: %s [on | off | host [port]]\n", argv[0]); code = -1; return; @@ -1106,7 +1108,7 @@ void setdebug(int argc, char *argv[]) { if (argc > 2) { - fprintf(ttyout, "usage: %s [ on | off | debuglevel ]\n", argv[0]); + fprintf(ttyout, "usage: %s [on | off | debuglevel]\n", argv[0]); code = -1; return; } else if (argc == 2) { @@ -1178,7 +1180,7 @@ lcd(int argc, char *argv[]) if (argc < 2) argc++, argv[1] = home; if (argc != 2) { - fprintf(ttyout, "usage: %s local-directory\n", argv[0]); + fprintf(ttyout, "usage: %s [local-directory]\n", argv[0]); code = -1; return; } @@ -1284,7 +1286,8 @@ ls(int argc, char *argv[]) if (argc < 3) argc++, argv[2] = "-"; if (argc > 3) { - fprintf(ttyout, "usage: %s remote-directory local-file\n", argv[0]); + fprintf(ttyout, "usage: %s [remote-directory [local-file]]\n", + argv[0]); code = -1; return; } @@ -1427,7 +1430,8 @@ user(int argc, char *argv[]) if (argc < 2) (void)another(&argc, &argv, "username"); if (argc < 2 || argc > 4) { - fprintf(ttyout, "usage: %s username [password] [account]\n", argv[0]); + fprintf(ttyout, "usage: %s username [password [account]]\n", + argv[0]); code = -1; return; } @@ -1549,7 +1553,7 @@ quote(int argc, char *argv[]) { if (argc < 2 && !another(&argc, &argv, "command line to send")) { - fprintf(ttyout, "usage: %s line-to-send\n", argv[0]); + fprintf(ttyout, "usage: %s arg ...\n", argv[0]); code = -1; return; } @@ -1566,7 +1570,7 @@ site(int argc, char *argv[]) { if (argc < 2 && !another(&argc, &argv, "arguments to SITE command")) { - fprintf(ttyout, "usage: %s line-to-send\n", argv[0]); + fprintf(ttyout, "usage: %s arg ...\n", argv[0]); code = -1; return; } @@ -1617,9 +1621,9 @@ do_chmod(int argc, char *argv[]) if (argc < 2 && !another(&argc, &argv, "mode")) goto usage; - if ((argc < 3 && !another(&argc, &argv, "file-name")) || argc > 3) { + if ((argc < 3 && !another(&argc, &argv, "file")) || argc > 3) { usage: - fprintf(ttyout, "usage: %s mode file-name\n", argv[0]); + fprintf(ttyout, "usage: %s mode file\n", argv[0]); code = -1; return; } @@ -1867,8 +1871,8 @@ setnmap(int argc, char *argv[]) code = mapflag; return; } - if ((argc < 3 && !another(&argc, &argv, "mapout")) || argc > 3) { - fprintf(ttyout, "usage: %s [mapin mapout]\n", argv[0]); + if ((argc < 3 && !another(&argc, &argv, "outpattern")) || argc > 3) { + fprintf(ttyout, "usage: %s [inpattern outpattern]\n", argv[0]); code = -1; return; } @@ -2144,8 +2148,8 @@ macdef(int argc, char *argv[]) code = -1; return; } - if ((argc < 2 && !another(&argc, &argv, "macro name")) || argc > 2) { - fprintf(ttyout, "usage: %s macro_name\n", argv[0]); + if ((argc < 2 && !another(&argc, &argv, "macro-name")) || argc > 2) { + fprintf(ttyout, "usage: %s macro-name\n", argv[0]); code = -1; return; } @@ -2199,8 +2203,8 @@ sizecmd(int argc, char *argv[]) { off_t size; - if ((argc < 2 && !another(&argc, &argv, "filename")) || argc > 2) { - fprintf(ttyout, "usage: %s filename\n", argv[0]); + if ((argc < 2 && !another(&argc, &argv, "file")) || argc > 2) { + fprintf(ttyout, "usage: %s file\n", argv[0]); code = -1; return; } @@ -2218,8 +2222,8 @@ modtime(int argc, char *argv[]) { time_t mtime; - if ((argc < 2 && !another(&argc, &argv, "filename")) || argc > 2) { - fprintf(ttyout, "usage: %s filename\n", argv[0]); + if ((argc < 2 && !another(&argc, &argv, "file")) || argc > 2) { + fprintf(ttyout, "usage: %s file\n", argv[0]); code = -1; return; } @@ -2260,8 +2264,8 @@ page(int argc, char *argv[]) int orestart_point, ohash, overbose; char *p, *pager, *oldargv1; - if ((argc < 2 && !another(&argc, &argv, "filename")) || argc > 2) { - fprintf(ttyout, "usage: %s filename\n", argv[0]); + if ((argc < 2 && !another(&argc, &argv, "file")) || argc > 2) { + fprintf(ttyout, "usage: %s file\n", argv[0]); code = -1; return; } diff --git a/usr.bin/ftp/domacro.c b/usr.bin/ftp/domacro.c index b2dbf192a58..26eafd3edd2 100644 --- a/usr.bin/ftp/domacro.c +++ b/usr.bin/ftp/domacro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: domacro.c,v 1.13 2006/05/16 23:43:16 ray Exp $ */ +/* $OpenBSD: domacro.c,v 1.14 2008/08/22 08:52:35 sobrado Exp $ */ /* $NetBSD: domacro.c,v 1.10 1997/07/20 09:45:45 lukem Exp $ */ /* @@ -31,7 +31,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: domacro.c,v 1.13 2006/05/16 23:43:16 ray Exp $"; +static const char rcsid[] = "$OpenBSD: domacro.c,v 1.14 2008/08/22 08:52:35 sobrado Exp $"; #endif /* not lint and not SMALL */ #include @@ -49,7 +49,7 @@ domacro(int argc, char *argv[]) struct cmd *c; if (argc < 2 && !another(&argc, &argv, "macro name")) { - fprintf(ttyout, "usage: %s macro_name\n", argv[0]); + fprintf(ttyout, "usage: %s macro-name\n", argv[0]); code = -1; return; } diff --git a/usr.bin/ftp/ftp.1 b/usr.bin/ftp/ftp.1 index 58fb7667792..0ef122e015f 100644 --- a/usr.bin/ftp/ftp.1 +++ b/usr.bin/ftp/ftp.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ftp.1,v 1.72 2008/07/16 14:57:27 martynas Exp $ +.\" $OpenBSD: ftp.1,v 1.73 2008/08/22 08:52:35 sobrado Exp $ .\" $NetBSD: ftp.1,v 1.22 1997/08/18 10:20:22 lukem Exp $ .\" .\" Copyright (c) 1985, 1989, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd $Mdocdate: July 16 2008 $ +.Dd $Mdocdate: August 22 2008 $ .Dt FTP 1 .Os .Sh NAME @@ -242,11 +242,13 @@ The following commands are recognized by .Nm : .Bl -tag -width Fl -.It Ic \&! Op Ar command Op Ar args +.It Ic \&! Oo Ar command +.Op Ar arg ... +.Oc Invoke an interactive shell on the local machine. If there are arguments, the first is taken to be a command to execute directly, with the rest of the arguments as its arguments. -.It Ic \&$ Ar macro-name Op Ar args +.It Ic \&$ Ar macro-name Op Ar arg ... Execute the macro .Ar macro-name that was defined with the @@ -256,7 +258,7 @@ Arguments are passed to the macro unglobbed. .It Ic \&? Op Ar command A synonym for .Ic help . -.It Ic account Op Ar passwd +.It Ic account Op Ar password Supply a supplemental password required by a remote system for access to resources once a login has been successfully completed. If no argument is included, the user will be prompted for an account @@ -282,19 +284,19 @@ Set the file transfer .Ic type to network .Tn ASCII . -This is the default type. -.It Ic bell +.It Ic bell Op Ic on | off Arrange that a bell be sounded after each file transfer command is completed. .It Ic binary Set the file transfer .Ic type to support binary image transfer. +This is the default type. .It Ic bye Terminate the FTP session with the remote server and exit .Nm . An end-of-file will also terminate the session and exit. -.It Ic case +.It Ic case Op Ic on | off Toggle remote computer file name case mapping during .Ic mget commands. @@ -310,9 +312,9 @@ to .It Ic cdup Change the remote machine working directory to the parent of the current remote machine working directory. -.It Ic chmod Ar mode file-name -Change the permission modes of the file -.Ar file-name +.It Ic chmod Ar mode file +Change the permission modes of +.Ar file on the remote system to .Ar mode . @@ -320,7 +322,7 @@ system to Terminate the FTP session with the remote server and return to the command interpreter. Any defined macros are erased. -.It Ic cr +.It Ic cr Op Ic on | off Toggle carriage return stripping during ASCII type file retrieval. Records are denoted by a carriage return/linefeed sequence @@ -337,10 +339,12 @@ when an ASCII type transfer is made, these linefeeds may be distinguished from a record delimiter only when .Ic cr is off. -.It Ic debug Op Ar debug-value +.It Ic debug Oo Ic on | off | +.Ar debuglevel +.Oc Toggle debugging mode. If an optional -.Ar debug-value +.Ar debuglevel is specified, it is used to set the debugging level. When debugging is on, .Nm @@ -357,12 +361,12 @@ A synonym for .It Ic disconnect A synonym for .Ic close . -.It Ic edit +.It Ic edit Op Ic on | off Toggle command line editing, and context sensitive command and file completion. This is automatically enabled if input is from a terminal, and disabled otherwise. -.It Ic epsv4 +.It Ic epsv4 Op Ic on | off Toggle use of EPSV/EPRT command on IPv4 connection. .It Ic exit A synonym for @@ -377,7 +381,9 @@ The default format is .It Ic ftp Ar host Op Ar port A synonym for .Ic open . -.It Ic gate Op Ar host Op Ar port +.It Ic gate Oo Ic on | off | +.Ar host Op Ar port +.Oc Toggle gate-ftp mode. This will not be permitted if the gate-ftp server hasn't been set (either explicitly by the user, or from the @@ -412,7 +418,7 @@ The current settings for and .Ic structure are used while transferring the file. -.It Ic glob +.It Ic glob Op Ic on | off Toggle filename expansion for .Ic mdelete , .Ic mget @@ -447,7 +453,9 @@ That can be done by transferring a .Xr tar 1 archive of the subtree (in binary mode). -.It Ic hash Op Ar size +.It Ic hash Oo Ic on | off | +.Ar size +.Oc Toggle hash mark .Pq Ql # printing for each data block transferred. @@ -468,11 +476,11 @@ seconds. If .Ar seconds is omitted, the current inactivity timer is printed. -.It Ic lcd Op Ar directory +.It Ic lcd Op Ar local-directory Change the working directory on the local machine. If no -.Ar directory +.Ar local-directory is specified, the user's home directory is used. .It Ic less Ar file A synonym for @@ -616,8 +624,10 @@ to The default mode is .Dq stream mode. -.It Ic modtime Ar file-name -Show the last modification time of the file on the remote machine. +.It Ic modtime Ar file +Show the last modification time of +.Ar file +on the remote machine. .It Ic more Ar file A synonym for .Ic page . @@ -644,10 +654,13 @@ flag is specified then .Ic reput is used instead of .Ic put . -.It Ic msend Ar local-files +.It Xo Ic msend +.Op Fl c +.Ar local-files +.Xc A synonym for .Ic mput . -.It Ic newer Ar file-name +.It Ic newer Ar remote-file Op Ar local-file Get the file only if the modification time of the remote file is more recent than the file on the current system. If the file does not @@ -833,7 +846,7 @@ and display with the program defined in if .Ev PAGER is null or not defined). -.It Ic passive +.It Ic passive Op Ic on | off Toggle passive mode. If passive mode is turned on (default is on), .Nm @@ -858,9 +871,9 @@ traffic. (Note that though FTP servers are required to support the .Dv PASV command by RFC 1123, some do not.) -.It Ic preserve +.It Ic preserve Op Ic on | off Toggle preservation of modification times on retrieved files. -.It Ic progress +.It Ic progress Op Ic on | off Toggle display of transfer progress bar. The progress bar will be disabled for a transfer that has .Ar local-file @@ -871,7 +884,7 @@ or a command that starts with Refer to .Sx FILE NAMING CONVENTIONS for more information. -.It Ic prompt +.It Ic prompt Op Ic on | off Toggle interactive prompting. Interactive prompting occurs during multiple file transfers to allow the @@ -912,7 +925,7 @@ to any remaining files for the current command. .It Ic y Transfer the file. .El -.It Ic proxy Ar ftp-command +.It Ic proxy Ar command Execute an FTP command on a secondary control connection. This command allows simultaneous connection to two remote FTP servers for transferring files between the two servers. @@ -969,7 +982,7 @@ machine. .It Ic quit A synonym for .Ic bye . -.It Ic quote Ar arg1 arg2 ... +.It Ic quote Ar arg ... The arguments specified are sent, verbatim, to the remote FTP server. .It Ic recv Ar remote-file Op Ar local-file A synonym for @@ -989,11 +1002,11 @@ is continued from the apparent point of failure. This command is useful when transferring very large files over networks that are prone to dropping connections. -.It Ic rename Op Ar from Op Ar to +.It Ic rename Ar from-name to-name Rename the file -.Ar from +.Ar from-name on the remote machine to the file -.Ar to . +.Ar to-name . .It Ic reput Ar local-file Op Ar remote-file Reput acts like put, except that if .Ar remote-file @@ -1036,14 +1049,14 @@ If a is specified, it is supplied to the server as well. .It Ic rmdir Ar directory-name Delete a directory on the remote machine. -.It Ic rstatus Op Ar file-name +.It Ic rstatus Op Ar file With no arguments, show status of remote machine. If -.Ar file-name +.Ar file is specified, show status of -.Ar file-name +.Ar file on remote machine. -.It Ic runique +.It Ic runique Op Ic on | off Toggle storing of files on the local system with unique filenames. If a file already exists with a name equal to the target local filename for a @@ -1069,7 +1082,7 @@ The default value is off. .It Ic send Ar local-file Op Ar remote-file A synonym for .Ic put . -.It Ic sendport +.It Ic sendport Op Ic on | off Toggle the use of .Dv PORT commands. @@ -1096,13 +1109,13 @@ commands for each data transfer. This is useful for certain FTP implementations which do ignore .Dv PORT commands but, incorrectly, indicate they've been accepted. -.It Ic site Ar arg1 arg2 ... +.It Ic site Ar arg ... The arguments specified are sent, verbatim, to the remote FTP server as a .Dv SITE command. -.It Ic size Ar file-name +.It Ic size Ar file Return size of -.Ar file-name +.Ar file on remote machine. .It Ic status Show the current status of @@ -1115,7 +1128,7 @@ Show the current status of .\" By default, .\" .Dq file .\" structure is used. -.It Ic sunique +.It Ic sunique Op Ic on | off Toggle storing of files on remote machine under unique file names. The remote FTP server must support the FTP protocol .Dv STOU @@ -1130,7 +1143,7 @@ Set the file transfer type to that needed to talk to .Tn TENEX machines. -.It Ic trace +.It Ic trace Op Ic on | off Toggle packet tracing. .It Ic type Op Ar type-name Set the file transfer @@ -1148,7 +1161,7 @@ If .Ar newmask is omitted, the current umask is printed. .It Xo -.Ic user Ar user-name +.Ic user Ar username .Op Ar password Op Ar account .Xc Identify yourself to the remote FTP server. @@ -1173,7 +1186,7 @@ is invoked with .Dq auto-login disabled, this process is done automatically on initial connection to the FTP server. -.It Ic verbose +.It Ic verbose Op Ic on | off Toggle verbose mode. In verbose mode, all responses from the FTP server are displayed to the user. diff --git a/usr.bin/ftp/main.c b/usr.bin/ftp/main.c index 90e247f7e7a..cdde0670620 100644 --- a/usr.bin/ftp/main.c +++ b/usr.bin/ftp/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.70 2008/07/08 21:07:57 martynas Exp $ */ +/* $OpenBSD: main.c,v 1.71 2008/08/22 08:52:35 sobrado Exp $ */ /* $NetBSD: main.c,v 1.24 1997/08/18 10:20:26 lukem Exp $ */ /* @@ -66,7 +66,7 @@ static const char copyright[] = #endif /* not lint */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: main.c,v 1.70 2008/07/08 21:07:57 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: main.c,v 1.71 2008/08/22 08:52:35 sobrado Exp $"; #endif /* not lint and not SMALL */ /* @@ -792,7 +792,7 @@ usage(void) #ifndef SMALL "[-C] " #endif /* !SMALL */ - "[-o output] host:[/path/]file[/]\n", + "[-o output] host:/file[/]\n", #ifndef SMALL __progname, __progname, __progname, __progname, __progname); #else /* !SMALL */ diff --git a/usr.bin/ftp/util.c b/usr.bin/ftp/util.c index 9bed9278af3..d73a7755a5b 100644 --- a/usr.bin/ftp/util.c +++ b/usr.bin/ftp/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.54 2008/07/08 21:07:57 martynas Exp $ */ +/* $OpenBSD: util.c,v 1.55 2008/08/22 08:52:35 sobrado Exp $ */ /* $NetBSD: util.c,v 1.12 1997/08/18 10:20:27 lukem Exp $ */ /*- @@ -64,7 +64,7 @@ */ #if !defined(lint) && !defined(SMALL) -static const char rcsid[] = "$OpenBSD: util.c,v 1.54 2008/07/08 21:07:57 martynas Exp $"; +static const char rcsid[] = "$OpenBSD: util.c,v 1.55 2008/08/22 08:52:35 sobrado Exp $"; #endif /* not lint and not SMALL */ /* @@ -113,7 +113,7 @@ setpeer(int argc, char *argv[]) if (argc < 2) (void)another(&argc, &argv, "to"); if (argc < 2 || argc > 3) { - fprintf(ttyout, "usage: %s host-name [port]\n", argv[0]); + fprintf(ttyout, "usage: %s host [port]\n", argv[0]); code = -1; return; } -- 2.20.1