From owner-freebsd-net Sun Nov 11 19:11:56 2001 Delivered-To: freebsd-net@freebsd.org Received: from smtp.noos.fr (aragon.noos.net [212.198.2.75]) by hub.freebsd.org (Postfix) with ESMTP id 58E2537B417 for ; Sun, 11 Nov 2001 19:11:53 -0800 (PST) Received: (qmail 52598295 invoked by uid 0); 12 Nov 2001 03:10:03 -0000 Received: from unknown (HELO gits.dyndns.org) ([212.198.229.145]) (envelope-sender ) by 212.198.2.75 (qmail-ldap-1.03) with DES-CBC3-SHA encrypted SMTP for ; 12 Nov 2001 03:10:03 -0000 Received: (from root@localhost) by gits.dyndns.org (8.11.6/8.11.6) id fAC3A2729661; Mon, 12 Nov 2001 04:10:02 +0100 (CET) (envelope-from root) Message-Id: <200111120310.fAC3A2729661@gits.dyndns.org> Subject: Re: ftp(1) patch In-Reply-To: <20011111222526.A895@coredump.cx> To: Jerry Eriksson Date: Mon, 12 Nov 2001 04:10:01 +0100 (CET) Cc: freebsd-net@freebsd.org Reply-To: clefevre@citeweb.net From: Cyrille Lefevre Organization: ACME X-Face: X-Mailer: ELM [version 2.4ME+ PL95a (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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