Subject: Re: NetBSD master CVS tree commits
To: John Nemeth <jnemeth@cue.bc.ca>
From: Luke Mewburn <lukem@connect.com.au>
List: current-users
Date: 12/06/1996 13:39:48
John Nemeth writes:
> } Update of /cvsroot/src/usr.bin/ftp
> } In directory netbsd1:/home/lukem/f/ftp
> } 
> } Modified Files:
> } 	cmds.c cmdtab.c extern.h ftp.1 ftp.c ftp_var.h main.c 
> } 	ruserpass.c 
> } Log Message:
> } functionality mods:
> } * implement 'progress bar/meter' (inspired by ncftp). use 'progress' to
> }   toggle on. it will display current file size to 5 digits, automatically
> }   determining suffix (up to 16384 P (petabytes) == 2^64).
> 
>      Isn't this kind of limiting?  I routinely transfer files with
> sizes that are seven or eight digits long.

Try it and see. You'll see what it does.

The suffix (well, called 'prefix' in the code 'cause I was originally
going to write 'xBytes', where x is the letter) is changed and the
number scaled as the file grows.

What the code does is something like:
	prefix_list[]="bKMGTP";
	current_prefix = 0;
	while (size >= 100000 && current_prefix < sizeof(prefix_list)) {
		current_prefix++;
		size >>= 10;	/* divide by 1024 */
	}

So, when the file hits 100000 bytes, the display changes from
	100000 b
to
	    97 K
etc. (97 because 100000 / 1024 == 97.65).

The overall status bar may look something like (the second line is
redrawn through the transfer):
---
150 Opening BINARY mode data connection for 'bigfile' (32768000 bytes).
 32% 0 ****************                                   10298 K  ETA:    00:00
---

I did it this way because 64 bit numbers are huge, and I preferred
for the total bar length not to change.