]> sjero.net Git - wget/blobdiff - src/mswindows.c
Eschew config-post.h.
[wget] / src / mswindows.c
index 3aeafa33b9d62bed495d352238e571e43cfaf0a1..2844c025eed7b8340a8eedf24162668e11dc1d2c 100644 (file)
@@ -1,5 +1,6 @@
 /* mswindows.c -- Windows-specific support
-   Copyright (C) 1996-2006 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
 This file is part of GNU Wget.
 
@@ -26,7 +27,7 @@ modify this file, you may extend this exception to your version of the
 file, but you are not obligated to do so.  If you do not wish to do
 so, delete this exception statement from your version.  */
 
-#include <config.h>
+#include "wget.h"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -37,7 +38,6 @@ so, delete this exception statement from your version.  */
 
 #define INHIBIT_WRAP /* avoid wrapping of socket, bind, ... */
 
-#include "wget.h"
 #include "utils.h"
 #include "url.h"
 
@@ -72,7 +72,7 @@ xsleep (double seconds)
 }
 
 void
-windows_main (int *argc, char **argv, char **exec_name)
+windows_main (char **exec_name)
 {
   char *p;
 
@@ -86,6 +86,7 @@ windows_main (int *argc, char **argv, char **exec_name)
 static void
 ws_cleanup (void)
 {
+  xfree ((char*)exec_name);
   WSACleanup ();
 }
 
@@ -159,12 +160,12 @@ fake_fork_child (void)
       /* See utils:fork_to_background for explanation. */
       FILE *new_log_fp = unique_create (DEFAULT_LOGFILE, false, &opt.lfilename);
       if (new_log_fp)
-       {
-         info->logfile_changed = true;
-         strncpy (info->lfilename, opt.lfilename, sizeof (info->lfilename));
-         info->lfilename[sizeof (info->lfilename) - 1] = '\0';
-         fclose (new_log_fp);
-       }
+        {
+          info->logfile_changed = true;
+          strncpy (info->lfilename, opt.lfilename, sizeof (info->lfilename));
+          info->lfilename[sizeof (info->lfilename) - 1] = '\0';
+          fclose (new_log_fp);
+        }
     }
 
   UnmapViewOfFile (info);
@@ -457,14 +458,14 @@ ws_startup (void)
   if (err != 0)
     {
       fprintf (stderr, _("%s: Couldn't find usable socket driver.\n"),
-              exec_name);
+               exec_name);
       exit (1);
     }
 
   if (data.wVersion < requested)
     {
       fprintf (stderr, _("%s: Couldn't find usable socket driver.\n"),
-              exec_name);
+               exec_name);
       WSACleanup ();
       exit (1);
     }
@@ -542,10 +543,11 @@ run_with_timeout (double seconds, void (*fun) (void *), void *arg)
   thread_arg.arg = arg;
   thread_arg.ws_error = WSAGetLastError ();
   thread_hnd = CreateThread (NULL, THREAD_STACK_SIZE, thread_helper,
-                            &thread_arg, 0, &thread_id);
+                             &thread_arg, 0, &thread_id);
   if (!thread_hnd)
     {
-      DEBUGP (("CreateThread() failed; [0x%x]\n", GetLastError ()));
+      DEBUGP (("CreateThread() failed; [%#lx]\n",
+               (unsigned long) GetLastError ()));
       goto blocking_fallback;
     }
 
@@ -553,7 +555,7 @@ run_with_timeout (double seconds, void (*fun) (void *), void *arg)
       == WAIT_OBJECT_0)
     {
       /* Propagate error state (which is per-thread) to this thread,
-        so the caller can inspect it.  */
+         so the caller can inspect it.  */
       WSASetLastError (thread_arg.ws_error);
       DEBUGP (("Winsock error: %d\n", WSAGetLastError ()));
       rc = false;
@@ -564,7 +566,7 @@ run_with_timeout (double seconds, void (*fun) (void *), void *arg)
       rc = true;
     }
 
-  CloseHandle (thread_hnd);    /* Clear-up after TerminateThread().  */
+  CloseHandle (thread_hnd);     /* Clear-up after TerminateThread().  */
   thread_hnd = NULL;
   return rc;
 }
@@ -578,11 +580,11 @@ run_with_timeout (double seconds, void (*fun) (void *), void *arg)
 /* Define a macro that creates a function definition that wraps FUN into
    a function that sets errno the way the rest of the code expects. */
 
-#define WRAP(fun, decl, call) int wrapped_##fun decl { \
-  int retval = fun call;                               \
-  if (retval < 0)                                      \
-    errno = WSAGetLastError ();                                \
-  return retval;                                       \
+#define WRAP(fun, decl, call) int wrapped_##fun decl {  \
+  int retval = fun call;                                \
+  if (retval < 0)                                       \
+    errno = WSAGetLastError ();                         \
+  return retval;                                        \
 }
 
 WRAP (socket, (int domain, int type, int protocol), (domain, type, protocol))