mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Minor progress bar fixes.
Published in <sxsn11dh3fc.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
eb9a02b828
commit
905472770e
@ -1,3 +1,14 @@
|
|||||||
|
2001-11-23 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* progress.c: Renamed dp_* functions to dot_* for greater clarity
|
||||||
|
and consistency with bar_*.
|
||||||
|
(print_download_speed): Get rid of the unneeded '@' character.
|
||||||
|
(create_image): Fix download rate geometry.
|
||||||
|
|
||||||
|
* progress.c (print_elapsed): Remove spurious space.
|
||||||
|
(print_elapsed): Renamed to print_download_speed, since that's
|
||||||
|
what it does.
|
||||||
|
|
||||||
2001-11-23 Hrvoje Niksic <hniksic@arsdigita.com>
|
2001-11-23 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* progress.c (bar_update): If the downloaded amount becomes larger
|
* progress.c (bar_update): If the downloaded amount becomes larger
|
||||||
|
@ -85,7 +85,7 @@ CMD_DECLARE (cmd_spec_dirstruct);
|
|||||||
CMD_DECLARE (cmd_spec_header);
|
CMD_DECLARE (cmd_spec_header);
|
||||||
CMD_DECLARE (cmd_spec_htmlify);
|
CMD_DECLARE (cmd_spec_htmlify);
|
||||||
CMD_DECLARE (cmd_spec_mirror);
|
CMD_DECLARE (cmd_spec_mirror);
|
||||||
CMD_DECLARE (cmd_spec_progress);
|
/*CMD_DECLARE (cmd_spec_progress);*/
|
||||||
CMD_DECLARE (cmd_spec_recursive);
|
CMD_DECLARE (cmd_spec_recursive);
|
||||||
CMD_DECLARE (cmd_spec_useragent);
|
CMD_DECLARE (cmd_spec_useragent);
|
||||||
|
|
||||||
@ -155,7 +155,7 @@ static struct {
|
|||||||
{ "pagerequisites", &opt.page_requisites, cmd_boolean },
|
{ "pagerequisites", &opt.page_requisites, cmd_boolean },
|
||||||
{ "passiveftp", &opt.ftp_pasv, cmd_lockable_boolean },
|
{ "passiveftp", &opt.ftp_pasv, cmd_lockable_boolean },
|
||||||
{ "passwd", &opt.ftp_pass, cmd_string },
|
{ "passwd", &opt.ftp_pass, cmd_string },
|
||||||
{ "progress", NULL, cmd_spec_progress },
|
{ "progress", &opt.progress_type, cmd_string },
|
||||||
{ "proxypasswd", &opt.proxy_passwd, cmd_string },
|
{ "proxypasswd", &opt.proxy_passwd, cmd_string },
|
||||||
{ "proxyuser", &opt.proxy_user, cmd_string },
|
{ "proxyuser", &opt.proxy_user, cmd_string },
|
||||||
{ "quiet", &opt.quiet, cmd_boolean },
|
{ "quiet", &opt.quiet, cmd_boolean },
|
||||||
@ -249,7 +249,6 @@ defaults (void)
|
|||||||
|
|
||||||
opt.remove_listing = 1;
|
opt.remove_listing = 1;
|
||||||
|
|
||||||
set_progress_implementation ("dot");
|
|
||||||
opt.dot_bytes = 1024;
|
opt.dot_bytes = 1024;
|
||||||
opt.dot_spacing = 10;
|
opt.dot_spacing = 10;
|
||||||
opt.dots_in_line = 50;
|
opt.dots_in_line = 50;
|
||||||
@ -930,6 +929,7 @@ cmd_spec_mirror (const char *com, const char *val, void *closure)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static int
|
static int
|
||||||
cmd_spec_progress (const char *com, const char *val, void *closure)
|
cmd_spec_progress (const char *com, const char *val, void *closure)
|
||||||
{
|
{
|
||||||
@ -942,6 +942,7 @@ cmd_spec_progress (const char *com, const char *val, void *closure)
|
|||||||
set_progress_implementation (val);
|
set_progress_implementation (val);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static int
|
static int
|
||||||
cmd_spec_recursive (const char *com, const char *val, void *closure)
|
cmd_spec_recursive (const char *com, const char *val, void *closure)
|
||||||
|
@ -686,6 +686,11 @@ GNU General Public License for more details.\n"));
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Initialize progress. Have to do this after the options are
|
||||||
|
processed so we know where the log file is. */
|
||||||
|
if (opt.verbose)
|
||||||
|
set_progress_implementation (opt.progress_type);
|
||||||
|
|
||||||
/* All user options have now been processed, so it's now safe to do
|
/* All user options have now been processed, so it's now safe to do
|
||||||
interoption dependency checks. */
|
interoption dependency checks. */
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@ struct options
|
|||||||
char *http_proxy, *ftp_proxy, *https_proxy;
|
char *http_proxy, *ftp_proxy, *https_proxy;
|
||||||
char **no_proxy;
|
char **no_proxy;
|
||||||
char *base_href;
|
char *base_href;
|
||||||
|
char *progress_type; /* progress indicator type. */
|
||||||
char *proxy_user; /*oli*/
|
char *proxy_user; /*oli*/
|
||||||
char *proxy_passwd;
|
char *proxy_passwd;
|
||||||
#ifdef HAVE_SELECT
|
#ifdef HAVE_SELECT
|
||||||
|
@ -43,10 +43,10 @@ struct progress_implementation {
|
|||||||
|
|
||||||
/* Necessary forward declarations. */
|
/* Necessary forward declarations. */
|
||||||
|
|
||||||
static void *dp_create PARAMS ((long, long));
|
static void *dot_create PARAMS ((long, long));
|
||||||
static void dp_update PARAMS ((void *, long));
|
static void dot_update PARAMS ((void *, long));
|
||||||
static void dp_finish PARAMS ((void *));
|
static void dot_finish PARAMS ((void *));
|
||||||
static void dp_set_params PARAMS ((const char *));
|
static void dot_set_params PARAMS ((const char *));
|
||||||
|
|
||||||
static void *bar_create PARAMS ((long, long));
|
static void *bar_create PARAMS ((long, long));
|
||||||
static void bar_update PARAMS ((void *, long));
|
static void bar_update PARAMS ((void *, long));
|
||||||
@ -54,11 +54,19 @@ static void bar_finish PARAMS ((void *));
|
|||||||
static void bar_set_params PARAMS ((const char *));
|
static void bar_set_params PARAMS ((const char *));
|
||||||
|
|
||||||
static struct progress_implementation implementations[] = {
|
static struct progress_implementation implementations[] = {
|
||||||
{ "dot", dp_create, dp_update, dp_finish, dp_set_params },
|
{ "dot", dot_create, dot_update, dot_finish, dot_set_params },
|
||||||
{ "bar", bar_create, bar_update, bar_finish, bar_set_params }
|
{ "bar", bar_create, bar_update, bar_finish, bar_set_params }
|
||||||
};
|
};
|
||||||
static struct progress_implementation *current_impl;
|
static struct progress_implementation *current_impl;
|
||||||
|
|
||||||
|
/* Default progress implementation should be something that works
|
||||||
|
under all display types. If you put something other than "dot"
|
||||||
|
here, remember that bar_set_params tries to switch to this if we're
|
||||||
|
not running on a TTY. So changing this to "bar" could cause
|
||||||
|
infloop. */
|
||||||
|
|
||||||
|
#define DEFAULT_PROGRESS_IMPLEMENTATION "dot"
|
||||||
|
|
||||||
/* Return non-zero if NAME names a valid progress bar implementation.
|
/* Return non-zero if NAME names a valid progress bar implementation.
|
||||||
The characters after the first : will be ignored. */
|
The characters after the first : will be ignored. */
|
||||||
|
|
||||||
@ -81,10 +89,15 @@ valid_progress_implementation_p (const char *name)
|
|||||||
void
|
void
|
||||||
set_progress_implementation (const char *name)
|
set_progress_implementation (const char *name)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i, namelen;
|
||||||
struct progress_implementation *pi = implementations;
|
struct progress_implementation *pi = implementations;
|
||||||
char *colon = strchr (name, ':');
|
char *colon;
|
||||||
int namelen = colon ? colon - name : strlen (name);
|
|
||||||
|
if (!name)
|
||||||
|
name = DEFAULT_PROGRESS_IMPLEMENTATION;
|
||||||
|
|
||||||
|
colon = strchr (name, ':');
|
||||||
|
namelen = colon ? colon - name : strlen (name);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE (implementations); i++, pi++)
|
for (i = 0; i < ARRAY_SIZE (implementations); i++, pi++)
|
||||||
if (!strncmp (pi->name, name, namelen))
|
if (!strncmp (pi->name, name, namelen))
|
||||||
@ -154,7 +167,7 @@ struct dot_progress {
|
|||||||
/* Dot-progress backend for progress_create. */
|
/* Dot-progress backend for progress_create. */
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
dp_create (long initial, long total)
|
dot_create (long initial, long total)
|
||||||
{
|
{
|
||||||
struct dot_progress *dp = xmalloc (sizeof (struct dot_progress));
|
struct dot_progress *dp = xmalloc (sizeof (struct dot_progress));
|
||||||
|
|
||||||
@ -204,10 +217,10 @@ print_percentage (long bytes, long expected)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_elapsed (struct dot_progress *dp, long bytes)
|
print_download_speed (struct dot_progress *dp, long bytes)
|
||||||
{
|
{
|
||||||
long timer_value = wtimer_elapsed (dp->timer);
|
long timer_value = wtimer_elapsed (dp->timer);
|
||||||
logprintf (LOG_VERBOSE, " @ %s",
|
logprintf (LOG_VERBOSE, " %s",
|
||||||
rate (bytes, timer_value - dp->last_timer_value, 1));
|
rate (bytes, timer_value - dp->last_timer_value, 1));
|
||||||
dp->last_timer_value = timer_value;
|
dp->last_timer_value = timer_value;
|
||||||
}
|
}
|
||||||
@ -215,7 +228,7 @@ print_elapsed (struct dot_progress *dp, long bytes)
|
|||||||
/* Dot-progress backend for progress_update. */
|
/* Dot-progress backend for progress_update. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dp_update (void *progress, long howmuch)
|
dot_update (void *progress, long howmuch)
|
||||||
{
|
{
|
||||||
struct dot_progress *dp = progress;
|
struct dot_progress *dp = progress;
|
||||||
int dot_bytes = opt.dot_bytes;
|
int dot_bytes = opt.dot_bytes;
|
||||||
@ -242,7 +255,8 @@ dp_update (void *progress, long howmuch)
|
|||||||
if (dp->total_length)
|
if (dp->total_length)
|
||||||
print_percentage (dp->rows * row_bytes, dp->total_length);
|
print_percentage (dp->rows * row_bytes, dp->total_length);
|
||||||
|
|
||||||
print_elapsed (dp, row_bytes - (dp->initial_length % row_bytes));
|
print_download_speed (dp,
|
||||||
|
row_bytes - (dp->initial_length % row_bytes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +266,7 @@ dp_update (void *progress, long howmuch)
|
|||||||
/* Dot-progress backend for progress_finish. */
|
/* Dot-progress backend for progress_finish. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dp_finish (void *progress)
|
dot_finish (void *progress)
|
||||||
{
|
{
|
||||||
struct dot_progress *dp = progress;
|
struct dot_progress *dp = progress;
|
||||||
int dot_bytes = opt.dot_bytes;
|
int dot_bytes = opt.dot_bytes;
|
||||||
@ -275,7 +289,7 @@ dp_finish (void *progress)
|
|||||||
dp->total_length);
|
dp->total_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_elapsed (dp, dp->dots * dot_bytes
|
print_download_speed (dp, dp->dots * dot_bytes
|
||||||
+ dp->accumulated
|
+ dp->accumulated
|
||||||
- dp->initial_length % row_bytes);
|
- dp->initial_length % row_bytes);
|
||||||
logputs (LOG_VERBOSE, "\n\n");
|
logputs (LOG_VERBOSE, "\n\n");
|
||||||
@ -292,7 +306,7 @@ dp_finish (void *progress)
|
|||||||
giga. */
|
giga. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dp_set_params (const char *params)
|
dot_set_params (const char *params)
|
||||||
{
|
{
|
||||||
if (!params)
|
if (!params)
|
||||||
return;
|
return;
|
||||||
@ -449,7 +463,7 @@ create_image (struct bar_progress *bp, long dltime)
|
|||||||
|
|
||||||
"xxx% " - percentage - 5 chars
|
"xxx% " - percentage - 5 chars
|
||||||
"| ... | " - progress bar decorations - 3 chars
|
"| ... | " - progress bar decorations - 3 chars
|
||||||
"1234.56 K/s " - dl rate - 12 chars
|
"1012.56 K/s " - dl rate - 12 chars
|
||||||
"nnnn " - downloaded bytes - 11 chars
|
"nnnn " - downloaded bytes - 11 chars
|
||||||
"ETA: xx:xx:xx" - ETA - 13 chars
|
"ETA: xx:xx:xx" - ETA - 13 chars
|
||||||
|
|
||||||
@ -498,7 +512,7 @@ create_image (struct bar_progress *bp, long dltime)
|
|||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "2.3 KB/s " */
|
/* "1012.45 K/s " */
|
||||||
if (dltime && bp->count)
|
if (dltime && bp->count)
|
||||||
{
|
{
|
||||||
char *rt = rate (bp->count, dltime, 1);
|
char *rt = rate (bp->count, dltime, 1);
|
||||||
@ -508,8 +522,8 @@ create_image (struct bar_progress *bp, long dltime)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
strcpy (p, "----.-- KB/s ");
|
strcpy (p, "----.-- K/s ");
|
||||||
p += 13;
|
p += 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* "12376 " */
|
/* "12376 " */
|
||||||
@ -560,6 +574,9 @@ create_image (struct bar_progress *bp, long dltime)
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Print the contents of the buffer as a one-line ASCII "image" so
|
||||||
|
that it can be overwritten next time. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
display_image (char *buf)
|
display_image (char *buf)
|
||||||
{
|
{
|
||||||
@ -577,7 +594,23 @@ display_image (char *buf)
|
|||||||
static void
|
static void
|
||||||
bar_set_params (const char *ignored)
|
bar_set_params (const char *ignored)
|
||||||
{
|
{
|
||||||
int sw = determine_screen_width ();
|
int sw;
|
||||||
|
|
||||||
|
if (opt.lfilename
|
||||||
|
#ifdef HAVE_ISATTY
|
||||||
|
|| !isatty (fileno (stderr))
|
||||||
|
#else
|
||||||
|
1
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/* We're not printing to a TTY. Revert to the fallback
|
||||||
|
display. */
|
||||||
|
set_progress_implementation (NULL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sw = determine_screen_width ();
|
||||||
if (sw && sw >= MINIMUM_SCREEN_WIDTH)
|
if (sw && sw >= MINIMUM_SCREEN_WIDTH)
|
||||||
screen_width = sw;
|
screen_width = sw;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user