+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
#include <string.h>
#include <assert.h>
#include <errno.h>
+#include <math.h>
#ifdef HACK_BCC_UTIME_BUG
# include <io.h>
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;
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;
#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. */
#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 **);
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;