mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Fall back to dot progress when forced to background.
Published in <sxs1yi8n7lx.fsf@florida.arsdigita.de>.
This commit is contained in:
parent
00407b0762
commit
39b2248bde
@ -1,3 +1,18 @@
|
|||||||
|
2001-12-06 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
|
* progress.c (progress_create): Make sure that, when the output is
|
||||||
|
redirected, the progress implementation gets changed to the
|
||||||
|
fallback one.
|
||||||
|
(bar_set_params): Set current_impl_locked to 1 when "force" is
|
||||||
|
specified.
|
||||||
|
(progress_create): Don't change the progress implementation if
|
||||||
|
current_impl_locked is non-zero.
|
||||||
|
|
||||||
|
* main.c (redirect_output_signal): Call
|
||||||
|
progress_schedule_redirect.
|
||||||
|
|
||||||
|
* progress.c (progress_schedule_redirect): New function.
|
||||||
|
|
||||||
2001-12-06 Hrvoje Niksic <hniksic@arsdigita.com>
|
2001-12-06 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||||
|
|
||||||
* log.c (logvprintf): Restructure to allow being called multiple
|
* log.c (logvprintf): Restructure to allow being called multiple
|
||||||
|
@ -880,7 +880,11 @@ Can't timestamp and not clobber old files at the same time.\n"));
|
|||||||
#ifdef HAVE_SIGNAL
|
#ifdef HAVE_SIGNAL
|
||||||
/* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it
|
/* Hangup signal handler. When wget receives SIGHUP or SIGUSR1, it
|
||||||
will proceed operation as usual, trying to write into a log file.
|
will proceed operation as usual, trying to write into a log file.
|
||||||
If that is impossible, the output will be turned off. */
|
If that is impossible, the output will be turned off.
|
||||||
|
|
||||||
|
#### It is unsafe to do call libc functions from a signal handler.
|
||||||
|
What we should do is, set a global variable, and have the code in
|
||||||
|
log.c pick it up. */
|
||||||
|
|
||||||
static RETSIGTYPE
|
static RETSIGTYPE
|
||||||
redirect_output_signal (int sig)
|
redirect_output_signal (int sig)
|
||||||
@ -894,5 +898,6 @@ redirect_output_signal (int sig)
|
|||||||
(sig == SIGUSR1 ? "SIGUSR1" :
|
(sig == SIGUSR1 ? "SIGUSR1" :
|
||||||
"WTF?!")));
|
"WTF?!")));
|
||||||
redirect_output (tmp);
|
redirect_output (tmp);
|
||||||
|
progress_schedule_redirect ();
|
||||||
}
|
}
|
||||||
#endif /* HAVE_SIGNAL */
|
#endif /* HAVE_SIGNAL */
|
||||||
|
@ -61,6 +61,7 @@ static struct progress_implementation implementations[] = {
|
|||||||
{ "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;
|
||||||
|
int current_impl_locked;
|
||||||
|
|
||||||
/* Progress implementation used by default. Can be overriden in
|
/* Progress implementation used by default. Can be overriden in
|
||||||
wgetrc or by the fallback one. */
|
wgetrc or by the fallback one. */
|
||||||
@ -111,6 +112,7 @@ set_progress_implementation (const char *name)
|
|||||||
if (!strncmp (pi->name, name, namelen))
|
if (!strncmp (pi->name, name, namelen))
|
||||||
{
|
{
|
||||||
current_impl = pi;
|
current_impl = pi;
|
||||||
|
current_impl_locked = 0;
|
||||||
|
|
||||||
if (colon)
|
if (colon)
|
||||||
/* We call pi->set_params even if colon is NULL because we
|
/* We call pi->set_params even if colon is NULL because we
|
||||||
@ -125,6 +127,14 @@ set_progress_implementation (const char *name)
|
|||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int output_redirected;
|
||||||
|
|
||||||
|
void
|
||||||
|
progress_schedule_redirect (void)
|
||||||
|
{
|
||||||
|
output_redirected = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* Create a progress gauge. INITIAL is the number of bytes the
|
/* Create a progress gauge. INITIAL is the number of bytes the
|
||||||
download starts from (zero if the download starts from scratch).
|
download starts from (zero if the download starts from scratch).
|
||||||
TOTAL is the expected total number of bytes in this download. If
|
TOTAL is the expected total number of bytes in this download. If
|
||||||
@ -134,6 +144,14 @@ set_progress_implementation (const char *name)
|
|||||||
void *
|
void *
|
||||||
progress_create (long initial, long total)
|
progress_create (long initial, long total)
|
||||||
{
|
{
|
||||||
|
/* Check if the log status has changed under our feet. */
|
||||||
|
if (output_redirected)
|
||||||
|
{
|
||||||
|
if (!current_impl_locked)
|
||||||
|
set_progress_implementation (FALLBACK_PROGRESS_IMPLEMENTATION);
|
||||||
|
output_redirected = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return current_impl->create (initial, total);
|
return current_impl->create (initial, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,6 +671,10 @@ bar_set_params (const char *params)
|
|||||||
{
|
{
|
||||||
int sw;
|
int sw;
|
||||||
|
|
||||||
|
if (params
|
||||||
|
&& 0 == strcmp (params, "force"))
|
||||||
|
current_impl_locked = 1;
|
||||||
|
|
||||||
if ((opt.lfilename
|
if ((opt.lfilename
|
||||||
#ifdef HAVE_ISATTY
|
#ifdef HAVE_ISATTY
|
||||||
|| !isatty (fileno (stderr))
|
|| !isatty (fileno (stderr))
|
||||||
@ -660,8 +682,7 @@ bar_set_params (const char *params)
|
|||||||
1
|
1
|
||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
&& !(params != NULL
|
&& !current_impl_locked)
|
||||||
&& 0 == strcmp (params, "force")))
|
|
||||||
{
|
{
|
||||||
/* We're not printing to a TTY, so revert to the fallback
|
/* We're not printing to a TTY, so revert to the fallback
|
||||||
display. #### We're recursively calling
|
display. #### We're recursively calling
|
||||||
|
@ -22,6 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
|
|||||||
|
|
||||||
int valid_progress_implementation_p PARAMS ((const char *));
|
int valid_progress_implementation_p PARAMS ((const char *));
|
||||||
void set_progress_implementation PARAMS ((const char *));
|
void set_progress_implementation PARAMS ((const char *));
|
||||||
|
void progress_schedule_redirect PARAMS ((void));
|
||||||
|
|
||||||
void *progress_create PARAMS ((long, long));
|
void *progress_create PARAMS ((long, long));
|
||||||
void progress_update PARAMS ((void *, long, long));
|
void progress_update PARAMS ((void *, long, long));
|
||||||
|
Loading…
Reference in New Issue
Block a user