I've made a patch to show percentage downloaded in addition
to URL in the titlebar. Real handy IMHO on minimised windows
sitting in the bottom toolbar.
2003-09-26 Gisle Vanem [EMAIL PROTECTED]
* 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).
diff -u3 -H -B -r src/mswindows.c.orig src/mswindows.c
--- src/mswindows.c.orig Sat Sep 27 02:35:28 2003
+++ src/mswindows.c Tue Sep 30 03:15:37 2003
@@ -37,6 +37,7 @@
#include string.h
#include assert.h
#include errno.h
+#include math.h
#ifdef HACK_BCC_UTIME_BUG
# include io.h
@@ -176,22 +178,41 @@
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 +221,11 @@
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;
diff -u3 -H -B -r src/mswindows.h.orig src/mswindows.h
--- src/mswindows.h.orig Sat Sep 27 02:35:28 2003
+++ src/mswindows.h Sat Sep 27 06:36:44 2003
@@ -65,10 +65,6 @@
#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 +132,8 @@
#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 **);
diff -u3 -H -B -r src/retr.c.orig src/retr.c
--- src/retr.c.orig Mon Sep 22 15:34:55 2003
+++ src/retr.c Sat Sep 27 07:00:25 2003
@@ -238,7 +238,13 @@
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;
diff -u3 -H -B -r windows/config.h.ms.orig windows/config.h.ms
--- windows/config.h.ms.orig Sat Sep 27 02:35:31 2003
+++ windows/config.h.ms Sat Sep 27 05:14:41 2003
@@ -32,11 +32,6 @@
/* Define if you have the alloca.h header file. */
#undef HAVE_ALLOCA_H
-#if !defined(__GNUC__) !defined(__DMC__) !defined(__WATCOMC__)
-/* Microsoft and Watcom libraries have an alloca function. */
-char *alloca ();
-#endif
-
/* Define to empty if the keyword does not work. */
/* #undef const */
@@ -53,9 +48,6 @@
significant byte first). */
#undef WORDS_BIGENDIAN
-/* Define this if you want the NLS support. */
-#undef ENABLE_NLS
-
/* Define if you want the FTP support for Opie compiled in. */
#define USE_OPIE 1
@@ -127,6 +119,11 @@
/* Define if you have the stdarg.h header file. */
#define HAVE_STDARG_H 1
+
+/* Use ANSI-style stdargs regardless of whether the compiler bothers
+ to define __STDC__. (Many don't when extensions are enabled.)
+ This define used to be in mswindows.h, but wheren't making any use there */
+#define WGET_USE_STDARG
/* Define if you have the stdlib.h header file. */
#define HAVE_STDLIB_H 1
---
Gisle V.
# rm /bin/laden
/bin/laden: Not found