diff options
author | mikeh <mikeh@FreeBSD.org> | 2004-04-27 00:31:36 +0000 |
---|---|---|
committer | mikeh <mikeh@FreeBSD.org> | 2004-04-27 00:31:36 +0000 |
commit | 7992092999578b760f431e4bd93d8ae21a7dd7df (patch) | |
tree | 80713a30b46e815ba6ac317d444160c8eea2f79e /contrib | |
parent | 8c05e4b20201795877e3367759bf5d2ff6fc2ace (diff) | |
download | FreeBSD-src-7992092999578b760f431e4bd93d8ae21a7dd7df.zip FreeBSD-src-7992092999578b760f431e4bd93d8ae21a7dd7df.tar.gz |
Import the latest (4/26/04) CVS lukemftp. This adds the ability to
have a prefix string on the progressbar and brings in a patch by mux@
to fix the condition when connect() returns EINTR.
Requested by: mux
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/lukemftp/src/fetch.c | 7 | ||||
-rw-r--r-- | contrib/lukemftp/src/ftp.1 | 8 | ||||
-rw-r--r-- | contrib/lukemftp/src/ftp.c | 37 | ||||
-rw-r--r-- | contrib/lukemftp/src/progressbar.c | 9 | ||||
-rw-r--r-- | contrib/lukemftp/src/progressbar.h | 3 | ||||
-rw-r--r-- | contrib/lukemftp/src/util.c | 23 | ||||
-rw-r--r-- | contrib/lukemftp/src/version.h | 4 |
7 files changed, 57 insertions, 34 deletions
diff --git a/contrib/lukemftp/src/fetch.c b/contrib/lukemftp/src/fetch.c index c17a051..abb89ce 100644 --- a/contrib/lukemftp/src/fetch.c +++ b/contrib/lukemftp/src/fetch.c @@ -1,4 +1,4 @@ -/* $NetBSD: fetch.c,v 1.144 2003/07/31 05:23:59 lukem Exp $ */ +/* $NetBSD: fetch.c,v 1.146 2003/12/10 12:34:28 lukem Exp $ */ /*- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fetch.c,v 1.144 2003/07/31 05:23:59 lukem Exp $"); +__RCSID("$NetBSD: fetch.c,v 1.146 2003/12/10 12:34:28 lukem Exp $"); #endif /* not lint */ /* @@ -246,7 +246,7 @@ url_decode(char *url) /* * Parse URL of form: - * <type>://[<user>[:<password>@]]<host>[:<port>][/<path>] + * <type>://[<user>[:<password>]@]<host>[:<port>][/<path>] * Returns -1 if a parse error occurred, otherwise 0. * It's the caller's responsibility to url_decode() the returned * user, pass and path. @@ -1303,7 +1303,6 @@ fetch_ftp(const char *url) if ((parse_url(url, "URL", &urltype, &user, &pass, &host, &port, &portnum, &path) == -1) || (user != NULL && *user == '\0') || - (pass != NULL && *pass == '\0') || EMPTYSTRING(host)) { warnx("Invalid URL `%s'", url); goto cleanup_fetch_ftp; diff --git a/contrib/lukemftp/src/ftp.1 b/contrib/lukemftp/src/ftp.1 index a17ef56..f197d3d 100644 --- a/contrib/lukemftp/src/ftp.1 +++ b/contrib/lukemftp/src/ftp.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: ftp.1,v 1.100 2003/08/07 11:13:54 agc Exp $ +.\" $NetBSD: ftp.1,v 1.101 2003/12/19 03:46:02 lukem Exp $ .\" .\" Copyright (c) 1996-2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -64,7 +64,7 @@ .\" .\" @(#)ftp.1 8.3 (Berkeley) 10/9/94 .\" -.Dd July 31, 2003 +.Dd December 19, 2003 .Dt FTP 1 .Os .Sh NAME @@ -224,7 +224,7 @@ Restrains .Nm from attempting .Dq auto-login -upon initial connection. +upon initial connection for non auto-fetch transfers. If auto-login is enabled, .Nm will check the @@ -236,6 +236,8 @@ If no entry exists, 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. +To override the auto-login for auto-fetch transfers, specify the +username (and optionally, password) as appropriate. .It Fl N Ar netrc Use .Ar netrc diff --git a/contrib/lukemftp/src/ftp.c b/contrib/lukemftp/src/ftp.c index ad3aa47..0c3b3d4 100644 --- a/contrib/lukemftp/src/ftp.c +++ b/contrib/lukemftp/src/ftp.c @@ -1,4 +1,4 @@ -/* $NetBSD: ftp.c,v 1.122 2003/08/07 11:13:55 agc Exp $ */ +/* $NetBSD: ftp.c,v 1.125 2004/04/10 12:21:39 lukem Exp $ */ /*- * Copyright (c) 1996-2002 The NetBSD Foundation, Inc. @@ -99,7 +99,7 @@ #if 0 static char sccsid[] = "@(#)ftp.c 8.6 (Berkeley) 10/27/94"; #else -__RCSID("$NetBSD: ftp.c,v 1.122 2003/08/07 11:13:55 agc Exp $"); +__RCSID("$NetBSD: ftp.c,v 1.125 2004/04/10 12:21:39 lukem Exp $"); #endif #endif /* not lint */ @@ -230,10 +230,7 @@ hookup(char *host, char *port) cause = "socket"; continue; } - while ((error = xconnect(s, res->ai_addr, res->ai_addrlen)) < 0 - && errno == EINTR) { - ; - } + error = xconnect(s, res->ai_addr, res->ai_addrlen); if (error) { /* this "if" clause is to prevent print warning twice */ if (res->ai_next) { @@ -276,7 +273,8 @@ hookup(char *host, char *port) int tos = IPTOS_LOWDELAY; if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) - warn("setsockopt TOS (ignored)"); + if (debug) + warn("setsockopt TOS (ignored)"); } #endif cin = fdopen(s, "r"); @@ -573,13 +571,13 @@ empty(FILE *cin, FILE *din, int sec) struct pollfd pfd[2]; if (cin) { - pfd[nfd].fd = fileno(cin); - pfd[nfd++].events = POLLIN; + pfd[nfd].fd = fileno(cin); + pfd[nfd++].events = POLLIN; } if (din) { - pfd[nfd].fd = fileno(din); - pfd[nfd++].events = POLLIN; + pfd[nfd].fd = fileno(din); + pfd[nfd++].events = POLLIN; } if ((nr = poll(pfd, nfd, sec * 1000)) <= 0) @@ -1325,7 +1323,8 @@ initconn(void) if ((options & SO_DEBUG) && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof(on)) < 0) - warn("setsockopt (ignored)"); + if (debug) + warn("setsockopt (ignored)"); result = COMPLETE + 1; switch (data_addr.su_family) { case AF_INET: @@ -1544,8 +1543,6 @@ initconn(void) while (xconnect(data, (struct sockaddr *)&data_addr.si_su, data_addr.su_len) < 0) { - if (errno == EINTR) - continue; if (activefallback) { (void)close(data); data = -1; @@ -1563,7 +1560,8 @@ initconn(void) on = IPTOS_THROUGHPUT; if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, sizeof(int)) < 0) - warn("setsockopt TOS (ignored)"); + if (debug) + warn("setsockopt TOS (ignored)"); } #endif return (0); @@ -1596,7 +1594,8 @@ initconn(void) if (options & SO_DEBUG && setsockopt(data, SOL_SOCKET, SO_DEBUG, (char *)&on, sizeof(on)) < 0) - warn("setsockopt (ignored)"); + if (debug) + warn("setsockopt (ignored)"); len = sizeof(data_addr.si_su); memset((char *)&data_addr, 0, sizeof (data_addr)); if (getsockname(data, (struct sockaddr *)&data_addr.si_su, &len) < 0) { @@ -1696,7 +1695,8 @@ initconn(void) on = IPTOS_THROUGHPUT; if (setsockopt(data, IPPROTO_IP, IP_TOS, (char *)&on, sizeof(int)) < 0) - warn("setsockopt TOS (ignored)"); + if (debug) + warn("setsockopt TOS (ignored)"); } #endif return (0); @@ -1729,7 +1729,8 @@ dataconn(const char *lmode) int tos = IPTOS_THROUGHPUT; if (setsockopt(s, IPPROTO_IP, IP_TOS, (char *)&tos, sizeof(int)) < 0) { - warn("setsockopt TOS (ignored)"); + if (debug) + warn("setsockopt TOS (ignored)"); } } #endif diff --git a/contrib/lukemftp/src/progressbar.c b/contrib/lukemftp/src/progressbar.c index 7ae2f7d..48332a6 100644 --- a/contrib/lukemftp/src/progressbar.c +++ b/contrib/lukemftp/src/progressbar.c @@ -1,4 +1,4 @@ -/* $NetBSD: progressbar.c,v 1.4 2003/07/17 12:06:18 lukem Exp $ */ +/* $NetBSD: progressbar.c,v 1.5 2004/03/09 17:04:24 hubertf Exp $ */ /*- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: progressbar.c,v 1.4 2003/07/17 12:06:18 lukem Exp $"); +__RCSID("$NetBSD: progressbar.c,v 1.5 2004/03/09 17:04:24 hubertf Exp $"); #endif /* not lint */ /* @@ -53,6 +53,7 @@ __RCSID("$NetBSD: progressbar.c,v 1.4 2003/07/17 12:06:18 lukem Exp $"); #include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> #include <time.h> #include <unistd.h> @@ -203,6 +204,8 @@ progressmeter(int flag) return; len += snprintf(buf + len, BUFLEFT, "\r"); + if (prefix) + len += snprintf(buf + len, BUFLEFT, "%s", prefix); if (filesize > 0) { ratio = (int)((double)cursize * 100.0 / (double)filesize); ratio = MAX(ratio, 0); @@ -214,6 +217,8 @@ progressmeter(int flag) * the number of stars won't exceed the buffer size */ barlength = MIN(sizeof(buf) - 1, ttywidth) - BAROVERHEAD; + if (prefix) + barlength -= strlen(prefix); if (barlength > 0) { i = barlength * ratio / 100; len += snprintf(buf + len, BUFLEFT, diff --git a/contrib/lukemftp/src/progressbar.h b/contrib/lukemftp/src/progressbar.h index b7ca63f..b8e416e 100644 --- a/contrib/lukemftp/src/progressbar.h +++ b/contrib/lukemftp/src/progressbar.h @@ -1,4 +1,4 @@ -/* $NetBSD: progressbar.h,v 1.3 2003/02/28 09:53:49 lukem Exp $ */ +/* $NetBSD: progressbar.h,v 1.4 2004/03/09 17:04:24 hubertf Exp $ */ /*- * Copyright (c) 1996-2003 The NetBSD Foundation, Inc. @@ -58,6 +58,7 @@ GLOBAL int ttywidth; /* width of tty */ GLOBAL off_t bytes; /* current # of bytes read */ GLOBAL off_t filesize; /* size of file being transferred */ GLOBAL off_t restart_point; /* offset to restart transfer */ +GLOBAL char *prefix; /* Text written left of progress bar */ #ifndef STANDALONE_PROGRESS diff --git a/contrib/lukemftp/src/util.c b/contrib/lukemftp/src/util.c index ebc75a4..56fbd79 100644 --- a/contrib/lukemftp/src/util.c +++ b/contrib/lukemftp/src/util.c @@ -1,4 +1,4 @@ -/* $NetBSD: util.c,v 1.114 2003/08/07 11:13:57 agc Exp $ */ +/* $NetBSD: util.c,v 1.115 2004/04/10 12:21:39 lukem Exp $ */ /*- * Copyright (c) 1997-2003 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: util.c,v 1.114 2003/08/07 11:13:57 agc Exp $"); +__RCSID("$NetBSD: util.c,v 1.115 2004/04/10 12:21:39 lukem Exp $"); #endif /* not lint */ /* @@ -1204,14 +1204,29 @@ isipv6addr(const char *addr) /* - * Internal version of connect(2); sets socket buffer sizes first. + * Internal version of connect(2); sets socket buffer sizes first and + * handles the syscall being interrupted. + * Returns -1 upon failure (with errno set to the problem), or 0 on success. */ int xconnect(int sock, const struct sockaddr *name, int namelen) { + int rv; setupsockbufsize(sock); - return (connect(sock, name, namelen)); + rv = connect(sock, name, namelen); + if (rv == -1 && errno == EINTR) { + fd_set connfd; + + FD_ZERO(&connfd); + FD_SET(sock, &connfd); + do { + rv = select(sock + 1, NULL, &connfd, NULL, NULL); + } while (rv == -1 && errno == EINTR); + if (rv > 0) + rv = 0; + } + return (rv); } /* diff --git a/contrib/lukemftp/src/version.h b/contrib/lukemftp/src/version.h index 1049de3..25307fb 100644 --- a/contrib/lukemftp/src/version.h +++ b/contrib/lukemftp/src/version.h @@ -1,4 +1,4 @@ -/* $NetBSD: version.h,v 1.33 2003/07/31 07:13:01 lukem Exp $ */ +/* $NetBSD: version.h,v 1.35 2004/04/10 12:21:39 lukem Exp $ */ /*- * Copyright (c) 1999-2003 The NetBSD Foundation, Inc. * All rights reserved. @@ -40,5 +40,5 @@ #endif #ifndef FTP_VERSION -#define FTP_VERSION "20030731b" +#define FTP_VERSION "20040410" #endif |