guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile 2.0.9 build on mingw


From: Eli Zaretskii
Subject: Re: guile 2.0.9 build on mingw
Date: Thu, 13 Jun 2013 16:41:44 +0300

The changes below work around the lack of h_error on Windows:

--- libguile/net_db.c~0 2013-03-25 23:44:46.000000000 +0200
+++ libguile/net_db.c   2013-06-13 13:30:20.448923200 +0300
@@ -55,6 +55,47 @@
 #include "libguile/net_db.h"
 #include "libguile/socket.h"
 
+#ifdef __MINGW32__
+# define h_errno        WSAGetLastError()
+# define HAVE_H_ERRNO   1
+# define HAVE_HSTRERROR 1
+# ifdef HAVE_DECL_HSTRERROR
+#  undef HAVE_DECL_HSTRERROR
+# endif
+# define HAVE_DECL_HSTRERROR 1
+# define HOST_NOT_FOUND WSAHOST_NOT_FOUND
+# define TRY_AGAIN      WSATRY_AGAIN
+# define NO_RECOVERY    WSANO_RECOVERY
+# define NO_DATA        WSANO_DATA
+
+char *hstrerror (int);
+
+char *
+hstrerror (int error_no)
+{
+  static char buf[500];
+  DWORD ret;
+
+  if (error_no == 0)
+    error_no = WSAGetLastError ();
+
+  ret = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
+                       FORMAT_MESSAGE_IGNORE_INSERTS,
+                       NULL,
+                       error_no,
+                       0, /* choose most suitable language */
+                       buf, sizeof (buf), NULL);
+
+  while (ret > 0 && (buf[ret - 1] == '\n' ||
+                     buf[ret - 1] == '\r' ))
+      --ret;
+  buf[ret] = '\0';
+  if (!ret)
+    sprintf (buf, "Winsock error %u", error_no);
+
+  return buf;
+}
+#endif /* __MINGW32__ */
 
 #if defined (HAVE_H_ERRNO)
 /* Only wrap gethostbyname / gethostbyaddr if h_errno is available.  */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]