]> sjero.net Git - wget/blobdiff - src/mswindows.c
[svn] Convert URLs in <form action=...>.
[wget] / src / mswindows.c
index a938cab62f68f702603ce9d595bfb8ce20e405ca..b907b72e2057a05b1d5a15bcdc94f232470e9be7 100644 (file)
@@ -1,20 +1,20 @@
 /* mswindows.c -- Windows-specific support
    Copyright (C) 1995, 1996, 1997, 1998  Free Software Foundation, Inc.
 
-This file is part of Wget.
+This file is part of GNU Wget.
 
-This program is free software; you can redistribute it and/or modify
+GNU Wget is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
+GNU Wget is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
+along with Wget; if not, write to the Free Software
 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* #### Someone please document what these functions do!  */
@@ -28,7 +28,19 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include <assert.h>
 #include <errno.h>
 
+#ifdef HACK_BCC_UTIME_BUG
+# include <io.h>
+# include <fcntl.h>
+# ifdef HAVE_UTIME_H
+#  include <utime.h>
+# endif
+# ifdef HAVE_SYS_UTIME_H
+#  include <sys/utime.h>
+# endif
+#endif
+
 #include "wget.h"
+#include "utils.h"
 #include "url.h"
 
 #ifndef errno
@@ -36,18 +48,35 @@ extern int errno;
 #endif
 
 /* Defined in log.c.  */
-void redirect_output (const char *);
+void log_request_redirect_output PARAMS ((const char *));
 
 static int windows_nt_p;
 
 
 /* Emulation of Unix sleep.  */
+
 unsigned int
 sleep (unsigned seconds)
 {
   return SleepEx (1000 * seconds, TRUE) ? 0U : 1000 * seconds;
 }
 
+/* Emulation of Unix usleep().  This has a granularity of
+   milliseconds, but that's ok because:
+
+   a) Wget is only using it with milliseconds;
+
+   b) You can't rely on usleep's granularity anyway.  If a caller
+   expects usleep to respect every microsecond, he's in for a
+   surprise.  */
+
+int
+usleep (unsigned long usec)
+{
+  SleepEx (usec / 1000, TRUE);
+  return 0;
+}
+
 static char *
 read_registry (HKEY hkey, char *subkey, char *valuename, char *buf, int *len)
 {
@@ -63,32 +92,6 @@ read_registry (HKEY hkey, char *subkey, char *valuename, char *buf, int *len)
   return buf;
 }
 
-char *
-pwd_cuserid (char *where)
-{
-  char buf[32], *ptr;
-  int len = sizeof (buf);
-  if (GetUserName (buf, (LPDWORD) &len) == TRUE)
-    {
-      ;
-    }
-  else if (!!(ptr = getenv ("USERNAME")))
-    {
-      strcpy (buf, ptr);
-    }
-  else if (!read_registry (HKEY_LOCAL_MACHINE, "Network\\Logon",
-                         "username", buf, &len))
-    {
-      return NULL;
-    }
-  if (where)
-    {
-      strncpy (where, buf, len);
-      return where;
-    }
-  return xstrdup (buf);
-}
-
 void
 windows_main_junk (int *argc, char **argv, char **exec_name)
 {
@@ -112,10 +115,7 @@ ws_cleanup (void)
 static void
 ws_hangup (void)
 {
-  redirect_output (_("\n\
-CTRL+Break received, redirecting output to `%s'.\n\
-Execution continued in background.\n\
-You may stop Wget by pressing CTRL+ALT+DELETE.\n"));
+  log_request_redirect_output ("CTRL+Break");
 }
 
 void
@@ -253,3 +253,30 @@ ws_startup (void)
   atexit (ws_cleanup);
   SetConsoleCtrlHandler (ws_handler, TRUE);
 }
+
+/* Replacement utime function for buggy Borland C++Builder 5.5 compiler.
+   (The Borland utime function only works on Windows NT.)  */
+
+#ifdef HACK_BCC_UTIME_BUG
+int borland_utime(const char *path, const struct utimbuf *times)
+{
+  int fd;
+  int res;
+  struct ftime ft;
+  struct tm *ptr_tm;
+
+  if ((fd = open (path, O_RDWR)) < 0)
+    return -1;
+
+  ptr_tm = localtime (&times->modtime);
+  ft.ft_tsec = ptr_tm->tm_sec >> 1;
+  ft.ft_min = ptr_tm->tm_min;
+  ft.ft_hour = ptr_tm->tm_hour;
+  ft.ft_day = ptr_tm->tm_mday;
+  ft.ft_month = ptr_tm->tm_mon + 1;
+  ft.ft_year = ptr_tm->tm_year - 80;
+  res = setftime (fd, &ft);
+  close (fd);
+  return res;
+}
+#endif