Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/ftp - implement "mreget"; as per "mget" but uses "re...
details: https://anonhg.NetBSD.org/src/rev/58f5f207d856
branches: trunk
changeset: 499250:58f5f207d856
user: lukem <lukem%NetBSD.org@localhost>
date: Wed Nov 15 00:10:59 2000 +0000
description:
- implement "mreget"; as per "mget" but uses "reget" instead of "get"
- add -N netrc and $NETRC, as methods to select an alternative .netrc file
- cache local user name and home directory for further use
- in mget(), use docase() instead of a local version to do the case
conversion.
diffstat:
usr.bin/ftp/cmds.c | 73 +++++++++++++++++++++++++++++-------------------
usr.bin/ftp/cmdtab.c | 6 ++-
usr.bin/ftp/ftp.1 | 51 ++++++++++++++++++++++++++++------
usr.bin/ftp/ftp_var.h | 6 ++-
usr.bin/ftp/main.c | 51 ++++++++++++++++++++++++++-------
usr.bin/ftp/ruserpass.c | 20 ++++--------
usr.bin/ftp/util.c | 16 +++-------
usr.bin/ftp/version.h | 4 +-
8 files changed, 148 insertions(+), 79 deletions(-)
diffs (truncated from 547 to 300 lines):
diff -r 62edc2bed73e -r 58f5f207d856 usr.bin/ftp/cmds.c
--- a/usr.bin/ftp/cmds.c Wed Nov 15 00:00:26 2000 +0000
+++ b/usr.bin/ftp/cmds.c Wed Nov 15 00:10:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmds.c,v 1.91 2000/10/11 14:46:03 is Exp $ */
+/* $NetBSD: cmds.c,v 1.92 2000/11/15 00:10:59 lukem Exp $ */
/*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@@ -107,7 +107,7 @@
#if 0
static char sccsid[] = "@(#)cmds.c 8.6 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: cmds.c,v 1.91 2000/10/11 14:46:03 is Exp $");
+__RCSID("$NetBSD: cmds.c,v 1.92 2000/11/15 00:10:59 lukem Exp $");
#endif
#endif /* not lint */
@@ -552,6 +552,8 @@
/*
* Receive one file.
+ * If restartit is 1, restart the xfer always.
+ * If restartit is -1, restart the xfer only if the remote file is newer.
*/
int
getit(int argc, char *argv[], int restartit, const char *mode)
@@ -664,8 +666,9 @@
mget(int argc, char *argv[])
{
sigfunc oldintr;
- int ch, ointer;
- char *cp, *tp, *tp2, tmpbuf[MAXPATHLEN];
+ int ointer;
+ char *cp, *tp;
+ int restartit;
if (argc == 0 ||
(argc == 1 && !another(&argc, &argv, "remote-files"))) {
@@ -675,6 +678,16 @@
}
mname = argv[0];
mflag = 1;
+ restart_point = 0;
+ restartit = 0;
+ if (strcmp(argv[0], "mreget") == 0) {
+ if (! features[FEAT_REST_STREAM]) {
+ fprintf(ttyout,
+ "Restart is not supported by the remote server.\n");
+ return;
+ }
+ restartit = 1;
+ }
oldintr = xsignal(SIGINT, mintr);
if (sigsetjmp(jabort, 1))
mabort();
@@ -683,30 +696,32 @@
mflag = 0;
continue;
}
- if (mflag && confirm(argv[0], cp)) {
- tp = cp;
- if (mcase) {
- for (tp2 = tmpbuf; (ch = *tp++) != 0; )
- *tp2++ = isupper(ch) ? tolower(ch) : ch;
- *tp2 = '\0';
- tp = tmpbuf;
- }
- if (ntflag) {
- tp = dotrans(tp);
- }
- if (mapflag) {
- tp = domap(tp);
- }
- recvrequest("RETR", tp, cp, "w",
- tp != cp || !interactive, 1);
- if (!mflag && fromatty) {
- ointer = interactive;
- interactive = 1;
- if (confirm("Continue with", "mget")) {
- mflag++;
- }
- interactive = ointer;
- }
+ if (! mflag || !confirm(argv[0], cp))
+ continue;
+ tp = cp;
+ if (mcase)
+ tp = docase(tp);
+ if (ntflag)
+ tp = dotrans(tp);
+ if (mapflag)
+ tp = domap(tp);
+ if (restartit) {
+ struct stat stbuf;
+
+ if (stat(tp, &stbuf) == 0)
+ restart_point = stbuf.st_size;
+ else
+ warn("stat %s", tp);
+ }
+ recvrequest("RETR", tp, cp, restart_point ? "r+w" : "w",
+ tp != cp || !interactive, 1);
+ restart_point = 0;
+ if (!mflag && fromatty) {
+ ointer = interactive;
+ interactive = 1;
+ if (confirm("Continue with", "mget"))
+ mflag++;
+ interactive = ointer;
}
}
(void)xsignal(SIGINT, oldintr);
@@ -1136,7 +1151,7 @@
code = -1;
if (argc == 1) {
argc++;
- argv[1] = home;
+ argv[1] = localhome;
}
if (argc != 2) {
fprintf(ttyout, "usage: %s [local-directory]\n", argv[0]);
diff -r 62edc2bed73e -r 58f5f207d856 usr.bin/ftp/cmdtab.c
--- a/usr.bin/ftp/cmdtab.c Wed Nov 15 00:00:26 2000 +0000
+++ b/usr.bin/ftp/cmdtab.c Wed Nov 15 00:10:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cmdtab.c,v 1.38 2000/09/14 13:48:33 lukem Exp $ */
+/* $NetBSD: cmdtab.c,v 1.39 2000/11/15 00:10:59 lukem Exp $ */
/*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
#if 0
static char sccsid[] = "@(#)cmdtab.c 8.4 (Berkeley) 10/9/94";
#else
-__RCSID("$NetBSD: cmdtab.c,v 1.38 2000/09/14 13:48:33 lukem Exp $");
+__RCSID("$NetBSD: cmdtab.c,v 1.39 2000/11/15 00:10:59 lukem Exp $");
#endif
#endif /* not lint */
@@ -116,6 +116,7 @@
char macdefhelp[] = "define a macro";
char mdeletehelp[] = "delete multiple files";
char mgethelp[] = "get multiple files";
+char mregethelp[] = "get multiple files restarting at end of local file";
char fgethelp[] = "get files using a localfile as a source of names";
char mkdirhelp[] = "make directory on the remote machine";
char mlshelp[] = "list contents of multiple remote directories";
@@ -232,6 +233,7 @@
{ "modtime", modtimehelp, 0, 1, 1, CMPL(r) modtime },
{ "more", pagehelp, 1, 1, 1, CMPL(r) page },
{ "mput", mputhelp, 1, 1, 1, CMPL(L) mput },
+ { "mreget", mregethelp, 1, 1, 1, CMPL(R) mget },
{ "msend", mputhelp, 1, 1, 1, CMPL(L) mput },
{ "newer", newerhelp, 1, 1, 1, CMPL(r) newer },
{ "nlist", lshelp, 1, 1, 1, CMPL(rl) ls },
diff -r 62edc2bed73e -r 58f5f207d856 usr.bin/ftp/ftp.1
--- a/usr.bin/ftp/ftp.1 Wed Nov 15 00:00:26 2000 +0000
+++ b/usr.bin/ftp/ftp.1 Wed Nov 15 00:10:59 2000 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ftp.1,v 1.73 2000/09/28 12:26:19 lukem Exp $
+.\" $NetBSD: ftp.1,v 1.74 2000/11/15 00:10:59 lukem Exp $
.\"
.\" Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -68,7 +68,7 @@
.\"
.\" @(#)ftp.1 8.3 (Berkeley) 10/9/94
.\"
-.Dd September 28, 2000
+.Dd November 15, 2000
.Dt FTP 1
.Os
.Sh NAME
@@ -79,6 +79,9 @@
.Nm ""
.Op Fl AadefginpRtvV
.Bk -words
+.Op Fl N Ar netrc
+.Ek
+.Bk -words
.Op Fl o Ar output
.Ek
.Bk -words
@@ -194,6 +197,14 @@
will prompt for the remote machine login name (default is the user
identity on the local machine), and, if necessary, prompt for a password
and an account with which to login.
+.It Fl N Ar netrc
+Use
+.Ar netrc
+instead of
+.Pa ~/.netrc .
+Refer to
+.Sx THE .netrc FILE
+for more information.
.It Fl o Ar output
When auto-fetching files, save the contents in
.Ar output .
@@ -351,7 +362,10 @@
An end of file will also terminate the session and exit.
.It Ic case
Toggle remote computer file name case mapping during
+.Ic get ,
.Ic mget
+and
+.Ic mput
commands.
When
.Ic case
@@ -517,9 +531,10 @@
.It Ic glob
Toggle filename expansion for
.Ic mdelete ,
-.Ic mget
+.Ic mget ,
+.Ic mput ,
and
-.Ic mput .
+.Ic mreget .
If globbing is turned off with
.Ic glob ,
the file name arguments
@@ -529,9 +544,10 @@
is done as in
.Xr csh 1 .
For
-.Ic mdelete
+.Ic mdelete ,
+.Ic mget ,
and
-.Ic mget ,
+.Ic mreget ,
each remote file name is expanded
separately on the remote machine and the lists are not merged.
Expansion of a directory name is likely to be
@@ -540,9 +556,10 @@
and can be previewed by doing
.Ql mls remote-files \-
Note:
-.Ic mget
+.Ic mget ,
+.Ic mput
and
-.Ic mput
+.Ic mreget
are not meant to transfer
entire directory subtrees of files.
That can be done by
@@ -710,6 +727,13 @@
and
.Ic nmap
settings.
+.It Ic mreget Ar remote-files
+As per
+.Ic mget ,
+but performs a
+.Ic reget
+instead of
+.Ic get .
.It Ic msend Ar local-files
A synonym for
.Ic mput .
@@ -1712,7 +1736,12 @@
.Pa .netrc
file contains login and initialization information
used by the auto-login process.
-It resides in the user's home directory.
+It resides in the user's home directory,
+unless overridden with the
+.Fl N Ar netrc
+option, or specified in the
+.Ev NETRC
+environment variable.
The following tokens are recognized; they may be separated by spaces,
tabs, or new-lines:
.Bl -tag -width password
@@ -1939,6 +1968,10 @@
For default location of a
.Pa .netrc
file, if one exists.
+.It Ev NETRC
+An alternate location of the
+.Pa .netrc
+file.
.It Ev PAGER
Used by various commands to display files.
Defaults to
diff -r 62edc2bed73e -r 58f5f207d856 usr.bin/ftp/ftp_var.h
--- a/usr.bin/ftp/ftp_var.h Wed Nov 15 00:00:26 2000 +0000
+++ b/usr.bin/ftp/ftp_var.h Wed Nov 15 00:10:59 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ftp_var.h,v 1.58 2000/08/01 22:47:28 lukem Exp $ */
+/* $NetBSD: ftp_var.h,v 1.59 2000/11/15 00:11:03 lukem Exp $ */
/*-
* Copyright (c) 1996-2000 The NetBSD Foundation, Inc.
@@ -315,7 +315,9 @@
GLOBAL struct macel macros[16];
GLOBAL char macbuf[4096];
Home |
Main Index |
Thread Index |
Old Index