Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Nov 2001 04:10:01 +0100 (CET)
From:      Cyrille Lefevre <clefevre@citeweb.net>
To:        Jerry Eriksson <eip@coredump.cx>
Cc:        freebsd-net@freebsd.org
Subject:   Re: ftp(1) patch
Message-ID:  <200111120310.fAC3A2729661@gits.dyndns.org>
In-Reply-To: <20011111222526.A895@coredump.cx>

next in thread | previous in thread | raw e-mail | index | archive | help
Jerry Eriksson wrote:
> Here's a quick patch for ftp(1) to show
> the transfer rate while downloading files.

@@ -668,6 +668,12 @@ progressmeter(flag)
 	} else {
 		remaining = 
 		    ((filesize - restart_point) / (bytes / elapsed) - elapsed);
+		bs = bytes / (elapsed == 0.0 ? 1 : elapsed);
+		meg = 0;
+		if (bs > (1024 * 1024))
                          ^^^^^^^^^^^ (1<<10)
well, this one would be converted to a constant by the compiler.
+			    meg = 1;
+		len += snprintf(buf + len, sizeof(buf) - len,
+				" (%.2f %sB/s)",  bs / (1024.0 * (meg ? 1024.0 : 1.0)), meg ? "M" : "K");
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 << (meg ? 10 : 0)
but not this one.
 		if (remaining >= 100 * SECSPERHOUR)
 			len += snprintf(buf + len, sizeof(buf) - len,
 			    "   --:-- ETA");

Cyrille.
-- 
Cyrille Lefevre                 mailto:clefevre@citeweb.net

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200111120310.fAC3A2729661>