1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Display percentage in title bar.

By Gisle Vanem.
This commit is contained in:
hniksic 2003-09-30 14:24:36 -07:00
parent b307160959
commit 451ddf3cf9
4 changed files with 45 additions and 18 deletions

View File

@ -1,3 +1,12 @@
2003-09-26 Gisle Vanem <giva@bgnett.no>
* src/mswindows.c: Added ws_percenttitle() showing progress in the
window titlebar. Called from retr.c. Secured ws_mypath().
* windows/config.h.ms: alloca() prototype not needed. Removed
"#undef ENABLE_NLS"; should be in Makefile IMHO. Moved
WGET_USE_STDARG from mswindows.h to config.ms.h because of #ifdef
in log.c. (MSVC's vararg.h and stdarg.h are incompatible).
2003-09-29 Aaron Hawley <Aaron.Hawley@uvm.edu>
* ftp.c (getftp): --spider option should now work with FTP

View File

@ -37,6 +37,7 @@ so, delete this exception statement from your version. */
#include <string.h>
#include <assert.h>
#include <errno.h>
#include <math.h>
#ifdef HACK_BCC_UTIME_BUG
# include <io.h>
@ -176,22 +177,41 @@ ws_handler (DWORD dwEvent)
return TRUE;
}
static char *title_buf = NULL;
static char *curr_url = NULL;
static int num_urls = 0;
void
ws_changetitle (char *url, int nurl)
ws_changetitle (const char *url, int nurl)
{
char *title_buf;
if (!nurl)
return;
title_buf = (char *)alloca (strlen (url) + 20);
sprintf (title_buf, "Wget %s%s", url, nurl == 1 ? "" : " ...");
SetConsoleTitle (title_buf);
num_urls = nurl;
if (title_buf)
xfree(title_buf);
if (curr_url)
xfree(curr_url);
title_buf = (char *)xmalloc (strlen (url) + 20);
curr_url = xstrdup(url);
sprintf(title_buf, "Wget %s%s", url, nurl == 1 ? "" : " ...");
SetConsoleTitle(title_buf);
}
void
ws_percenttitle (double percent)
{
if (num_urls == 1 && title_buf && curr_url && fabs(percent) <= 100.0)
{
sprintf (title_buf, "Wget [%.1f%%] %s", percent, curr_url);
SetConsoleTitle (title_buf);
}
}
char *
ws_mypath (void)
{
static char *wspathsave;
static char *wspathsave = NULL;
char buffer[MAX_PATH];
char *ptr;
@ -200,14 +220,11 @@ ws_mypath (void)
return wspathsave;
}
GetModuleFileName (NULL, buffer, MAX_PATH);
ptr = strrchr (buffer, '\\');
if (ptr)
if (GetModuleFileName (NULL, buffer, MAX_PATH) &&
(ptr = strrchr (buffer, PATH_SEPARATOR)) != NULL)
{
*(ptr + 1) = '\0';
wspathsave = (char*) xmalloc (strlen (buffer) + 1);
strcpy (wspathsave, buffer);
wspathsave = xstrdup (buffer);
}
else
wspathsave = NULL;

View File

@ -65,10 +65,6 @@ so, delete this exception statement from your version. */
#endif
#endif
/* Use ANSI-style stdargs regardless of whether the compiler bothers
to define __STDC__. (Many don't when extensions are enabled.) */
#define WGET_USE_STDARG
#define REALCLOSE(x) closesocket (x)
/* read & write don't work with sockets on Windows 95. */
@ -135,7 +131,8 @@ int usleep (unsigned long);
#endif
void ws_startup (void);
void ws_changetitle (char*, int);
void ws_changetitle (const char*, int);
void ws_percenttitle (double);
char *ws_mypath (void);
void ws_help (const char *);
void windows_main_junk (int *, char **, char **);

View File

@ -236,9 +236,13 @@ get_contents (int fd, FILE *fp, long *len, long restval, long expected,
if (opt.limit_rate)
limit_bandwidth (res, &dltime, timer);
*len += res;
if (progress)
progress_update (progress, res, dltime);
*len += res;
#ifdef WINDOWS
if (use_expected && expected > 0)
ws_percenttitle (100.0 * (double)(*len) / (double)expected);
#endif
}
if (res < -1)
res = -1;