lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: lynx-dev when, where, why "kb/sec"?


From: Bela Lubkin
Subject: Re: lynx-dev when, where, why "kb/sec"?
Date: Wed, 9 Sep 1998 17:06:36 -0700

I like the counter, but I wish it was expressed in bytes, not Kbytes.  I
would much rather see:

  Read 36352 of 87401 bytes of data, 18176 bytes/sec.

than the current:

  Read 35 of 85 KB of data. 17 kb/sec.

Below is a patch relative to 2.8.1dev25.  It supports both display
styles, but has no tuning mechanism -- I just defaulted it to bytes.
Someone could add command-line flags, .lynxrc options, or whatever, if
desirable; I'd rather not.

>Bela<

*** src/HTAlert.c.orig  Sat Aug 29 16:22:40 1998
--- src/HTAlert.c       Wed Sep  9 15:02:02 1998
***************
*** 87,93 ****
      static long kb_units = 1024;
      static time_t first, last;
      static long bytes_last;
!     long transfer_rate;
      char line[80];
      time_t now = time((time_t *)0);  /* once per second */
      char *units = "bytes";
--- 87,93 ----
      static long kb_units = 1024;
      static time_t first, last;
      static long bytes_last;
!     long transfer_rate, divisor, prefer_K = 0;
      char line[80];
      time_t now = time((time_t *)0);  /* once per second */
      char *units = "bytes";
***************
*** 109,126 ****
                last = now;
                bytes_last = bytes;
            }
!           if (total >= kb_units || bytes >= kb_units) {
                bytes /= 1024;
                if (total > 0) total /= 1024;
                units = "KB";
            }
  
            if (total >  0)
!               sprintf (line, "Read %ld of %ld %s of data.", bytes, total, 
units);
!           if (total <= 0)
!               sprintf (line, "Read %ld %s of data.", bytes, units);
!            if (transfer_rate > 0)
!               sprintf (line + strlen(line), " %ld kb/sec.", transfer_rate / 
1024);
            if (total <  0) {
                if (total < -1)
                    strcat(line, " (Press 'z' to abort)");
--- 109,128 ----
                last = now;
                bytes_last = bytes;
            }
!           divisor = 1;
!           if (prefer_K && (total >= kb_units || bytes >= kb_units)) {
                bytes /= 1024;
                if (total > 0) total /= 1024;
+               divisor = 1024;
                units = "KB";
            }
  
            if (total >  0)
!               sprintf (line, "Read %ld of %ld %s of data", bytes, total, 
units);
!           else /* (total <= 0) */
!               sprintf (line, "Read %ld %s of data", bytes, units);
!           if (transfer_rate > 0)
!               sprintf (line + strlen(line), ", %ld %s/sec.", transfer_rate / 
divisor, units);
            if (total <  0) {
                if (total < -1)
                    strcat(line, " (Press 'z' to abort)");

reply via email to

[Prev in Thread] Current Thread [Next in Thread]