changeset 1960:22e3e829be13

Win: Switch to using winsock 2.x, this will remove support for ancient versions of Windows like 95 and NT 3.5 and older... This allows us to use unix domain sockets with Windows 10 for the sockpipe() macro... (used in my HandyFTP application) When compiled with Visual Studio 2017 5.5 and newer will use unix domain sockets, however this may fail on older Windows 10 versions and older versions of Windows. I am not sure it is worth the effort to dual mode it, when it can just be compiled with an older compiler and function on older versions of Windows if necessary.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 26 Jul 2019 06:58:41 +0000
parents 9ac432c8620c
children 824fdbc2f761
files dw.h dwcompat.h win/browser.c win/dirent.c win/dw.c
diffstat 5 files changed, 21 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Thu Jul 25 07:51:10 2019 +0000
+++ b/dw.h	Fri Jul 26 06:58:41 2019 +0000
@@ -491,6 +491,7 @@
 
 /* Windows specific section */
 #if defined(__WIN32__) || defined(WINNT)
+#include <winsock2.h>
 #include <windows.h>
 #include <commctrl.h>
 
--- a/dwcompat.h	Thu Jul 25 07:51:10 2019 +0000
+++ b/dwcompat.h	Fri Jul 26 06:58:41 2019 +0000
@@ -129,11 +129,7 @@
 #define BKS_TABBEDDIALOG          0x0800
 #endif
 
-#define PIPENAME "\\socket\\" __TARGET__ "%d"
-#define TPIPENAME "\\socket\\" __TARGET__ "%d"
-#else
-#define PIPENAME "/tmp/" __TARGET__ "%d"
-#define TPIPENAME "/tmp/" __TARGET__ "%d"
+#define PIPEROOT "\\socket\\"
 #endif /* __EMX__ || __IBMC__ */
 
 #if defined(__OS2__) && (defined(__IBMC__) || defined(__WATCOMC__))
@@ -163,8 +159,8 @@
 # endif
 #endif
 
+#include <winsock2.h>
 #include <windows.h>
-#include <winsock.h>
 #include <time.h>
 #include <process.h>
 #include <sys/stat.h>
@@ -185,13 +181,21 @@
 
 #include <stdarg.h>
 
-#if defined(__CYGWIN32__) /*|| defined(__MINGW32__)*/
+/* Cygwin and Visual Studio 15.4 (SDK 10.0.16299.15) support domain sockets */
+#if defined(__CYGWIN32__)
 #include <sys/un.h>
-#endif /* __CYGWIN32__ || __MINGW32__ */
+#elif defined(_MSC_VER) && _MSC_VER >= 1912
+#include <afunix.h>
+#define PIPEROOT "C:\\Windows\\Temp\\"
+#else
+#define NO_DOMAIN_SOCKETS
+#endif 
 
-#ifndef __CYGWIN32__
-#define NO_DOMAIN_SOCKETS
-#endif /* __CYGWIN32__ */
+#ifndef PIPEROOT
+#define PIPEROOT "/tmp/"
+#endif
+
+#define PIPENAME "%s" __TARGET__ "%d"
 
 #if defined(_P_NOWAIT) && !defined(P_NOWAIT)
 #define P_NOWAIT _P_NOWAIT
@@ -318,7 +322,7 @@
 #ifdef __IBMC__
 #define sockinit() sock_init();
 #elif defined(__WIN32__) || defined(WINNT)
-#define sockinit() { static WSADATA wsa; WSAStartup(MAKEWORD (1, 1), &wsa); }
+#define sockinit() { static WSADATA wsa; WSAStartup(MAKEWORD (2, 0), &wsa); }
 #else  /* !WIN32 */
 #define sockinit()
 #endif
@@ -338,7 +342,7 @@
 	pipes[1] = socket(AF_UNIX, SOCK_STREAM, 0); \
 	memset(&un, 0, sizeof(un)); \
 	un.sun_family=AF_UNIX; \
-	sprintf(un.sun_path, PIPENAME, pipes[1]); \
+	sprintf(un.sun_path, PIPENAME, PIPEROOT, pipes[1]); \
 	bind(tmpsock, (struct sockaddr *)&un, sizeof(un)); \
 	listen(tmpsock, 0); \
 	connect(pipes[1], (struct sockaddr *)&un, sizeof(un)); \
--- a/win/browser.c	Thu Jul 25 07:51:10 2019 +0000
+++ b/win/browser.c	Fri Jul 26 06:58:41 2019 +0000
@@ -21,6 +21,7 @@
 
 
 
+#include <winsock2.h>
 #include <windows.h>
 #include <exdisp.h>		// Defines of stuff like IWebBrowser2. This is an include file with Visual C 6 and above
 #include <mshtml.h>		// Defines of stuff like IHTMLDocument2. This is an include file with Visual C 6 and above
--- a/win/dirent.c	Thu Jul 25 07:51:10 2019 +0000
+++ b/win/dirent.c	Fri Jul 26 06:58:41 2019 +0000
@@ -6,6 +6,7 @@
 #include <string.h>
 #include <ctype.h>
 
+#include <winsock2.h>
 #include <windows.h>
 
 #define _DW_INTERNAL
--- a/win/dw.c	Thu Jul 25 07:51:10 2019 +0000
+++ b/win/dw.c	Fri Jul 26 06:58:41 2019 +0000
@@ -14,6 +14,7 @@
 #define _WIN32_IE 0x0500
 #define WINVER 0x500
 #endif
+#include <winsock2.h>
 #include <windows.h>
 #include <windowsx.h>
 #include <commctrl.h>