Re: [Bug-wget] Fwd: [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits
hi, I will take a deeper look after your copyright assignment process is completed. As a suggestion for the futur: it will be better if you ask on the mailing list before start working on a task next time (unless it is a bug). Not all new feature requests can be accepted into wget. Cheers, Giuseppe Sasikanth sasikanth@gmail.com writes: Modified the calc_rate function to calculate bandwidth in powers of ten (SI-prefix format) for --bits option. Please review the changes Thanks Sasi -- Forwarded message -- From: Sasikanth sasikanth@gmail.com Date: Wed, Jan 18, 2012 at 5:43 PM Subject: Re: [Bug-wget] [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits To: Hrvoje Niksic hnik...@xemacs.org Cc: bug-wget@gnu.org On Sun, Jan 15, 2012 at 8:51 PM, Hrvoje Niksic hnik...@xemacs.org wrote: Sasikanth sasikanth@gmail.com writes: No one asked. i had just thought it will be good to display all the output in either bits or bytes to avoid confusion to the user (I had confused). I understand that, but I have never seen a downloading agent output data length in bits, so displaying the data in bits would likely cause much more confusion and/or be less useful. (Data throughput in bits, on the other hand, is quite common.) With the original implementation of --bits I expect that someone would soon ask for --bits-for-bandwidth-only. Anyhow thanks I will modify the patch. Thanks. Note that the patch has another problem: while Wget's K, M, and G refer to (what is now known as) kibibytes, mebibytes, and gibibytes, bandwidth is measured in kilobits, megabits, and gigabits per second. Bandwidth units all refer to powers of ten, not to powers of two, so it is incorrect for calc_rate to simply increase the byte multipliers by 8. Hrvoje Modified the calc_rate function to calculate bandwidth in powers of ten (SI-prefix format) for --bits option. Please review the changes Thanks Sasi diff -ur orig/wget-1.13.4/src/init.c wget-1.13.4/src/init.c --- orig/wget-1.13.4/src/init.c 2011-08-19 15:36:20.0 +0530 +++ wget-1.13.4/src/init.c2012-01-18 14:42:56.240973950 +0530 @@ -126,6 +126,7 @@ { backups, opt.backups, cmd_number }, { base, opt.base_href, cmd_string }, { bindaddress, opt.bind_address, cmd_string }, + { bits, opt.bits_fmt, cmd_boolean}, #ifdef HAVE_SSL { cacertificate,opt.ca_cert, cmd_file }, #endif diff -ur orig/wget-1.13.4/src/main.c wget-1.13.4/src/main.c --- orig/wget-1.13.4/src/main.c 2011-09-06 19:20:11.0 +0530 +++ wget-1.13.4/src/main.c2012-01-18 14:42:56.241973599 +0530 @@ -166,6 +166,7 @@ { backups, 0, OPT_BOOLEAN, backups, -1 }, { base, 'B', OPT_VALUE, base, -1 }, { bind-address, 0, OPT_VALUE, bindaddress, -1 }, +{ bits, 0, OPT_BOOLEAN, bits, -1 }, { IF_SSL (ca-certificate), 0, OPT_VALUE, cacertificate, -1 }, { IF_SSL (ca-directory), 0, OPT_VALUE, cadirectory, -1 }, { cache, 0, OPT_BOOLEAN, cache, -1 }, @@ -704,6 +705,11 @@ -np, --no-parent don't ascend to the parent directory.\n), \n, +N_(\ +Output format:\n), +N_(\ + --bits Output bandwidth in bits.\n), +\n, N_(Mail bug reports and suggestions to bug-wget@gnu.org.\n) }; diff -ur orig/wget-1.13.4/src/options.h wget-1.13.4/src/options.h --- orig/wget-1.13.4/src/options.h2011-08-06 15:54:32.0 +0530 +++ wget-1.13.4/src/options.h 2012-01-18 14:42:56.247982676 +0530 @@ -255,6 +255,7 @@ bool show_all_dns_entries; /* Show all the DNS entries when resolving a name. */ + bool bits_fmt; /*Output bandwidth in bits format*/ }; extern struct options opt; diff -ur orig/wget-1.13.4/src/progress.c wget-1.13.4/src/progress.c --- orig/wget-1.13.4/src/progress.c 2011-01-01 17:42:35.0 +0530 +++ wget-1.13.4/src/progress.c2012-01-18 14:42:56.249098685 +0530 @@ -861,7 +861,7 @@ struct bar_progress_hist *hist = bp-hist; /* The progress bar should look like this: - xx% [=== ] nn,nnn 12.34K/s eta 36m 51s + xx% [=== ] nn,nnn 12.34KB/s eta 36m 51s Calculate the geometry. The idea is to assign as much room as possible to the progress bar. The other idea is to never let @@ -873,7 +873,7 @@ xx% or 100% - percentage - 4 chars [] - progress bar decorations - 2 chars nnn,nnn,nnn- downloaded bytes - 12 chars or very rarely more - 12.5K/s- download rate - 8 chars + 12.5KB/s- download rate - 9 chars eta 36m 51s -
[Bug-wget] Fwd: [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits
Modified the calc_rate function to calculate bandwidth in powers of ten (SI-prefix format) for --bits option. Please review the changes Thanks Sasi -- Forwarded message -- From: Sasikanth sasikanth@gmail.com Date: Wed, Jan 18, 2012 at 5:43 PM Subject: Re: [Bug-wget] [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits To: Hrvoje Niksic hnik...@xemacs.org Cc: bug-wget@gnu.org On Sun, Jan 15, 2012 at 8:51 PM, Hrvoje Niksic hnik...@xemacs.org wrote: Sasikanth sasikanth@gmail.com writes: No one asked. i had just thought it will be good to display all the output in either bits or bytes to avoid confusion to the user (I had confused). I understand that, but I have never seen a downloading agent output data length in bits, so displaying the data in bits would likely cause much more confusion and/or be less useful. (Data throughput in bits, on the other hand, is quite common.) With the original implementation of --bits I expect that someone would soon ask for --bits-for-bandwidth-only. Anyhow thanks I will modify the patch. Thanks. Note that the patch has another problem: while Wget's K, M, and G refer to (what is now known as) kibibytes, mebibytes, and gibibytes, bandwidth is measured in kilobits, megabits, and gigabits per second. Bandwidth units all refer to powers of ten, not to powers of two, so it is incorrect for calc_rate to simply increase the byte multipliers by 8. Hrvoje Modified the calc_rate function to calculate bandwidth in powers of ten (SI-prefix format) for --bits option. Please review the changes Thanks Sasi diff -ur orig/wget-1.13.4/src/init.c wget-1.13.4/src/init.c --- orig/wget-1.13.4/src/init.c 2011-08-19 15:36:20.0 +0530 +++ wget-1.13.4/src/init.c 2012-01-18 14:42:56.240973950 +0530 @@ -126,6 +126,7 @@ { backups, opt.backups, cmd_number }, { base, opt.base_href, cmd_string }, { bindaddress, opt.bind_address, cmd_string }, + { bits, opt.bits_fmt, cmd_boolean}, #ifdef HAVE_SSL { cacertificate,opt.ca_cert, cmd_file }, #endif diff -ur orig/wget-1.13.4/src/main.c wget-1.13.4/src/main.c --- orig/wget-1.13.4/src/main.c 2011-09-06 19:20:11.0 +0530 +++ wget-1.13.4/src/main.c 2012-01-18 14:42:56.241973599 +0530 @@ -166,6 +166,7 @@ { backups, 0, OPT_BOOLEAN, backups, -1 }, { base, 'B', OPT_VALUE, base, -1 }, { bind-address, 0, OPT_VALUE, bindaddress, -1 }, +{ bits, 0, OPT_BOOLEAN, bits, -1 }, { IF_SSL (ca-certificate), 0, OPT_VALUE, cacertificate, -1 }, { IF_SSL (ca-directory), 0, OPT_VALUE, cadirectory, -1 }, { cache, 0, OPT_BOOLEAN, cache, -1 }, @@ -704,6 +705,11 @@ -np, --no-parent don't ascend to the parent directory.\n), \n, +N_(\ +Output format:\n), +N_(\ + --bits Output bandwidth in bits.\n), +\n, N_(Mail bug reports and suggestions to bug-wget@gnu.org.\n) }; diff -ur orig/wget-1.13.4/src/options.h wget-1.13.4/src/options.h --- orig/wget-1.13.4/src/options.h 2011-08-06 15:54:32.0 +0530 +++ wget-1.13.4/src/options.h 2012-01-18 14:42:56.247982676 +0530 @@ -255,6 +255,7 @@ bool show_all_dns_entries; /* Show all the DNS entries when resolving a name. */ + bool bits_fmt; /*Output bandwidth in bits format*/ }; extern struct options opt; diff -ur orig/wget-1.13.4/src/progress.c wget-1.13.4/src/progress.c --- orig/wget-1.13.4/src/progress.c 2011-01-01 17:42:35.0 +0530 +++ wget-1.13.4/src/progress.c 2012-01-18 14:42:56.249098685 +0530 @@ -861,7 +861,7 @@ struct bar_progress_hist *hist = bp-hist; /* The progress bar should look like this: - xx% [=== ] nn,nnn 12.34K/s eta 36m 51s + xx% [=== ] nn,nnn 12.34KB/s eta 36m 51s Calculate the geometry. The idea is to assign as much room as possible to the progress bar. The other idea is to never let @@ -873,7 +873,7 @@ xx% or 100% - percentage - 4 chars [] - progress bar decorations - 2 chars nnn,nnn,nnn- downloaded bytes - 12 chars or very rarely more - 12.5K/s- download rate - 8 chars + 12.5KB/s- download rate - 9 chars eta 36m 51s - ETA - 14 chars =... - progress bar - the rest @@ -977,10 +977,11 @@ *p++ = ' '; } - /* 12.52K/s */ + /* 12.52Kb/s or 12.52KB/s */ if (hist-total_time 0 hist-total_bytes) { - static const char *short_units[] = { B/s, K/s, M/s, G/s }; + static const char *short_units[] = { B/s, KB/s, MB/s, GB/s }; + static const char *short_units_bits[] = { b/s, Kb/s, Mb/s, Gb/s }; int units = 0; /* Calculate the download speed using the history ring
Re: [Bug-wget] Fwd: [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits
Thanks for the patch, except some minor esthetic changes, like an empty space between the function name and '(', that I can fix before apply it, the patch seems ok. Before I can apply it though, you need to get copyright assignments with the FSF. I am going to send more information in private to you. Cheers, Giuseppe Sasikanth sasikanth@gmail.com writes: Sorry guys In my previous mail I attached .patch extension file instead of .txt extension. Now correctly attached Thanks Sasi -- Forwarded message -- From: Sasikanth sasikanth@gmail.com Date: Wed, Jan 11, 2012 at 3:18 PM Subject: [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits To: bug-wget@gnu.org Hi all, I added a new option --bits as requested in https://savannah.gnu.org/bugs/?33210. This patch will display all data length in bits format for --bits option. I had verified it with http and ftp. Please let me know If I missed out anything. Attachments: patch and change log entry file Thanks Sasi diff -ru orig/wget-1.13.4/src/ftp.c wget-1.13.4/src/ftp.c --- orig/wget-1.13.4/src/ftp.c2012-01-09 14:06:31.273731044 +0530 +++ wget-1.13.4/src/ftp.c 2012-01-11 14:05:33.793990983 +0530 @@ -217,18 +217,18 @@ static void print_length (wgint size, wgint start, bool authoritative) { - logprintf (LOG_VERBOSE, _(Length: %s), number_to_static_string (size)); + logprintf (LOG_VERBOSE, _(Length: %s), number_to_static_string (convert_to_bits(size))); if (size = 1024) -logprintf (LOG_VERBOSE, (%s), human_readable (size)); +logprintf (LOG_VERBOSE, (%s), human_readable (convert_to_bits(size))); if (start 0) { if (size - start = 1024) logprintf (LOG_VERBOSE, _(, %s (%s) remaining), - number_to_static_string (size - start), - human_readable (size - start)); + number_to_static_string (convert_to_bits(size - start)), + human_readable (convert_to_bits(size - start))); else logprintf (LOG_VERBOSE, _(, %s remaining), - number_to_static_string (size - start)); + number_to_static_string (convert_to_bits(size - start))); } logputs (LOG_VERBOSE, !authoritative ? _( (unauthoritative)\n) : \n); } @@ -1564,7 +1564,7 @@ : _(%s (%s) - %s saved [%s]\n\n), tms, tmrate, write_to_stdout ? : quote (locf), - number_to_static_string (qtyread)); + number_to_static_string (convert_to_bits(qtyread))); } if (!opt.verbose !opt.quiet) { @@ -1573,7 +1573,7 @@ time. */ char *hurl = url_string (u, URL_AUTH_HIDE_PASSWD); logprintf (LOG_NONVERBOSE, %s URL: %s [%s] - \%s\ [%d]\n, - tms, hurl, number_to_static_string (qtyread), locf, count); + tms, hurl, number_to_static_string (convert_to_bits(qtyread)), locf, count); xfree (hurl); } @@ -1792,7 +1792,7 @@ /* Sizes do not match */ logprintf (LOG_VERBOSE, _(\ The sizes do not match (local %s) -- retrieving.\n\n), - number_to_static_string (local_size)); + number_to_static_string (convert_to_bits(local_size))); } } } /* opt.timestamping f-type == FT_PLAINFILE */ @@ -2206,7 +2206,7 @@ sz = -1; logprintf (LOG_NOTQUIET, _(Wrote HTML-ized index to %s [%s].\n), - quote (filename), number_to_static_string (sz)); + quote (filename), number_to_static_string (convert_to_bits(sz))); } else logprintf (LOG_NOTQUIET, diff -ru orig/wget-1.13.4/src/http.c wget-1.13.4/src/http.c --- orig/wget-1.13.4/src/http.c 2012-01-09 14:06:31.274730346 +0530 +++ wget-1.13.4/src/http.c2012-01-11 14:24:02.721099726 +0530 @@ -2423,19 +2423,19 @@ logputs (LOG_VERBOSE, _(Length: )); if (contlen != -1) { - logputs (LOG_VERBOSE, number_to_static_string (contlen + contrange)); + logputs (LOG_VERBOSE, number_to_static_string (convert_to_bits (contlen) + contrange)); if (contlen + contrange = 1024) logprintf (LOG_VERBOSE, (%s), - human_readable (contlen + contrange)); + human_readable (convert_to_bits(contlen) + contrange)); if (contrange) { if (contlen = 1024) logprintf (LOG_VERBOSE, _(, %s (%s) remaining), -
Re: [Bug-wget] Fwd: [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits
I addressed esthetic changes in the patch. please find the modified patch attached. Thanks Sasi On Wed, Jan 11, 2012 at 8:06 PM, Giuseppe Scrivano gscriv...@gnu.orgwrote: Thanks for the patch, except some minor esthetic changes, like an empty space between the function name and '(', that I can fix before apply it, the patch seems ok. Before I can apply it though, you need to get copyright assignments with the FSF. I am going to send more information in private to you. Cheers, Giuseppe Sasikanth sasikanth@gmail.com writes: Sorry guys In my previous mail I attached .patch extension file instead of .txt extension. Now correctly attached Thanks Sasi -- Forwarded message -- From: Sasikanth sasikanth@gmail.com Date: Wed, Jan 11, 2012 at 3:18 PM Subject: [PATCH] [wget-bug #33210], Add an option to output bandwidth in bits To: bug-wget@gnu.org Hi all, I added a new option --bits as requested in https://savannah.gnu.org/bugs/?33210. This patch will display all data length in bits format for --bits option. I had verified it with http and ftp. Please let me know If I missed out anything. Attachments: patch and change log entry file Thanks Sasi diff -ru orig/wget-1.13.4/src/ftp.c wget-1.13.4/src/ftp.c --- orig/wget-1.13.4/src/ftp.c2012-01-09 14:06:31.273731044 +0530 +++ wget-1.13.4/src/ftp.c 2012-01-11 14:05:33.793990983 +0530 @@ -217,18 +217,18 @@ static void print_length (wgint size, wgint start, bool authoritative) { - logprintf (LOG_VERBOSE, _(Length: %s), number_to_static_string (size)); + logprintf (LOG_VERBOSE, _(Length: %s), number_to_static_string (convert_to_bits(size))); if (size = 1024) -logprintf (LOG_VERBOSE, (%s), human_readable (size)); +logprintf (LOG_VERBOSE, (%s), human_readable (convert_to_bits(size))); if (start 0) { if (size - start = 1024) logprintf (LOG_VERBOSE, _(, %s (%s) remaining), - number_to_static_string (size - start), - human_readable (size - start)); + number_to_static_string (convert_to_bits(size - start)), + human_readable (convert_to_bits(size - start))); else logprintf (LOG_VERBOSE, _(, %s remaining), - number_to_static_string (size - start)); + number_to_static_string (convert_to_bits(size - start))); } logputs (LOG_VERBOSE, !authoritative ? _( (unauthoritative)\n) : \n); } @@ -1564,7 +1564,7 @@ : _(%s (%s) - %s saved [%s]\n\n), tms, tmrate, write_to_stdout ? : quote (locf), - number_to_static_string (qtyread)); + number_to_static_string (convert_to_bits(qtyread))); } if (!opt.verbose !opt.quiet) { @@ -1573,7 +1573,7 @@ time. */ char *hurl = url_string (u, URL_AUTH_HIDE_PASSWD); logprintf (LOG_NONVERBOSE, %s URL: %s [%s] - \%s\ [%d]\n, - tms, hurl, number_to_static_string (qtyread), locf, count); + tms, hurl, number_to_static_string (convert_to_bits(qtyread)), locf, count); xfree (hurl); } @@ -1792,7 +1792,7 @@ /* Sizes do not match */ logprintf (LOG_VERBOSE, _(\ The sizes do not match (local %s) -- retrieving.\n\n), - number_to_static_string (local_size)); + number_to_static_string (convert_to_bits(local_size))); } } } /* opt.timestamping f-type == FT_PLAINFILE */ @@ -2206,7 +2206,7 @@ sz = -1; logprintf (LOG_NOTQUIET, _(Wrote HTML-ized index to %s [%s].\n), - quote (filename), number_to_static_string (sz)); + quote (filename), number_to_static_string (convert_to_bits(sz))); } else logprintf (LOG_NOTQUIET, diff -ru orig/wget-1.13.4/src/http.c wget-1.13.4/src/http.c --- orig/wget-1.13.4/src/http.c 2012-01-09 14:06:31.274730346 +0530 +++ wget-1.13.4/src/http.c2012-01-11 14:24:02.721099726 +0530 @@ -2423,19 +2423,19 @@ logputs (LOG_VERBOSE, _(Length: )); if (contlen != -1) { - logputs (LOG_VERBOSE, number_to_static_string (contlen + contrange)); + logputs (LOG_VERBOSE, number_to_static_string (convert_to_bits (contlen) + contrange)); if (contlen + contrange = 1024) logprintf (LOG_VERBOSE, (%s), - human_readable (contlen +