Commit c91ae456 authored by Steven Edwards's avatar Steven Edwards Committed by Alexandre Julliard

Use Windows sockets when building Wininet on Mingw.

parent 925d3c26
......@@ -311,7 +311,7 @@ ac_includes_default="\
# include <unistd.h>
#endif"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS WIN16_FILES WIN16_INSTALL build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPPBIN ac_ct_CPPBIN TOOLSDIR CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LEX LEXLIB LEX_OUTPUT_ROOT XLEX BISON AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN EGREP LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS DB2HTML DB2PDF DB2PS DB2TXT FONTFORGE LIBPTHREAD XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS GLUT_LIBS GLUT32FILES NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS ft_devel ft_devel2 FREETYPELIBS FREETYPEINCL FONTSSUBDIRS ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS CAPI4LINUXLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLLFLAGS LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS LDLIBWINEFLAGS COREFOUNDATIONLIB IOKITLIB CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS WINE_BINARIES MAIN_BINARY LDD ALLOCA LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS WIN16_FILES WIN16_INSTALL build build_cpu build_vendor build_os host host_cpu host_vendor host_os SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CXX CXXFLAGS ac_ct_CXX CPPBIN ac_ct_CPPBIN TOOLSDIR CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS LEX LEXLIB LEX_OUTPUT_ROOT XLEX BISON AS ac_ct_AS LD ac_ct_LD AR ac_ct_AR RANLIB ac_ct_RANLIB STRIP ac_ct_STRIP WINDRES ac_ct_WINDRES LN_S LN EGREP LDCONFIG INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LINT LINTFLAGS DB2HTML DB2PDF DB2PS DB2TXT FONTFORGE LIBPTHREAD XLIB XFILES OPENGLFILES GLU32FILES OPENGL_LIBS GLUT_LIBS GLUT32FILES NASLIBS CURSESLIBS sane_devel SANELIBS SANEINCL ICULIBS ft_devel ft_devel2 FREETYPELIBS FREETYPEINCL FONTSSUBDIRS ARTSCCONFIG ARTSLIBS ARTSINCL ALSALIBS AUDIOIOLIBS CAPI4LINUXLIBS EXTRACFLAGS DLLEXT DLLFLAGS DLLIBS LDSHARED LDDLLFLAGS LIBEXT IMPLIBEXT DLLTOOL ac_ct_DLLTOOL DLLWRAP ac_ct_DLLWRAP LDEXECFLAGS LDLIBWINEFLAGS COREFOUNDATIONLIB IOKITLIB CROSSTEST CROSSCC CROSSWINDRES LDPATH CRTLIBS SOCKETLIBS WINE_BINARIES MAIN_BINARY LDD ALLOCA LIBOBJS LTLIBOBJS'
ac_subst_files='MAKE_RULES MAKE_DLL_RULES MAKE_TEST_RULES MAKE_LIB_RULES MAKE_PROG_RULES'
# Initialize some variables set by options.
......@@ -14217,7 +14217,10 @@ esac
case $host_os in
mingw32*)
CRTLIBS="-lmsvcrt"
;;
SOCKETLIBS="-lws2_32"
;;
esac
case $host_os in
......@@ -20998,6 +21001,7 @@ s,@CROSSCC@,$CROSSCC,;t t
s,@CROSSWINDRES@,$CROSSWINDRES,;t t
s,@LDPATH@,$LDPATH,;t t
s,@CRTLIBS@,$CRTLIBS,;t t
s,@SOCKETLIBS@,$SOCKETLIBS,;t t
s,@WINE_BINARIES@,$WINE_BINARIES,;t t
s,@MAIN_BINARY@,$MAIN_BINARY,;t t
s,@LDD@,$LDD,;t t
......
......@@ -984,10 +984,12 @@ case $build_os in
AC_SUBST(LDPATH,"LD_LIBRARY_PATH=\"\$(TOOLSDIR)/libs/unicode:\$\$LD_LIBRARY_PATH\"") ;;
esac
dnl Mingw needs explicit msvcrt for linking libwine
dnl Mingw needs explicit msvcrt for linking libwine and winsock for wininet
case $host_os in
mingw32*)
AC_SUBST(CRTLIBS,"-lmsvcrt") ;;
AC_SUBST(CRTLIBS,"-lmsvcrt")
AC_SUBST(SOCKETLIBS,"-lws2_32")
;;
esac
case $host_os in
......
......@@ -5,7 +5,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = wininet.dll
IMPORTS = mpr shlwapi shell32 user32 advapi32 kernel32 ntdll
EXTRALIBS = $(LIBUNICODE)
EXTRALIBS = $(LIBUNICODE) @SOCKETLIBS@
C_SRCS = \
cookie.c \
......
......@@ -272,7 +272,7 @@ BOOL WINAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
if (FTP_GetDataSocket(lpwfs, &nDataSocket))
{
FTP_SendData(lpwfs, nDataSocket, hFile);
close(nDataSocket);
closesocket(nDataSocket);
nResCode = FTP_ReceiveResponse(lpwfs, dwContext);
if (nResCode)
{
......@@ -286,7 +286,7 @@ BOOL WINAPI FTP_FtpPutFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszLocalFile,
lend:
if (lpwfs->lstnSocket != -1)
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB)
{
......@@ -691,7 +691,7 @@ HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
if (FTP_GetDataSocket(lpwfs, &nDataSocket))
{
hFindNext = FTP_ReceiveFileList(lpwfs, nDataSocket, lpszSearchFile, lpFindFileData, dwContext);
close(nDataSocket);
closesocket(nDataSocket);
nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
if (nResCode != 226 && nResCode != 250)
INTERNET_SetLastError(ERROR_NO_MORE_FILES);
......@@ -703,7 +703,7 @@ HINTERNET WINAPI FTP_FtpFindFirstFileW(LPWININETFTPSESSIONW lpwfs,
lend:
if (lpwfs->lstnSocket != -1)
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB)
{
......@@ -1034,7 +1034,7 @@ HINTERNET FTP_FtpOpenFileW(LPWININETFTPSESSIONW lpwfs,
}
if (lpwfs->lstnSocket != -1)
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
hIC = (LPWININETAPPINFOW) lpwfs->hdr.lpwhparent;
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC && hIC->lpfnStatusCB)
......@@ -1207,13 +1207,13 @@ BOOL WINAPI FTP_FtpGetFileW(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile,
else
FTP_SetResponseError(nResCode);
}
close(nDataSocket);
closesocket(nDataSocket);
}
}
lend:
if (lpwfs->lstnSocket != -1)
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
if (hFile)
CloseHandle(hFile);
......@@ -1741,7 +1741,7 @@ HINTERNET FTP_Connect(LPWININETAPPINFOW hIC, LPCWSTR lpszServerName,
lerror:
if (!bSuccess && nsocket == -1)
close(nsocket);
closesocket(nsocket);
if (!bSuccess && lpwfs)
{
......@@ -2066,7 +2066,7 @@ BOOL FTP_SendStore(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, DWORD dwT
lend:
if (!bSuccess && lpwfs->lstnSocket != -1)
{
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
lpwfs->lstnSocket = -1;
}
......@@ -2122,7 +2122,7 @@ BOOL FTP_InitListenSocket(LPWININETFTPSESSIONW lpwfs)
lend:
if (!bSuccess && lpwfs->lstnSocket == -1)
{
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
lpwfs->lstnSocket = -1;
}
......@@ -2386,7 +2386,7 @@ BOOL FTP_GetDataSocket(LPWININETFTPSESSIONW lpwfs, LPINT nDataSocket)
else
{
*nDataSocket = accept(lpwfs->lstnSocket, (struct sockaddr *) &saddr, &addrlen);
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
lpwfs->lstnSocket = -1;
}
return *nDataSocket != -1;
......@@ -2518,7 +2518,7 @@ DWORD FTP_SendRetrieve(LPWININETFTPSESSIONW lpwfs, LPCWSTR lpszRemoteFile, DWORD
lend:
if (0 == nResult && lpwfs->lstnSocket != -1)
{
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
lpwfs->lstnSocket = -1;
}
......@@ -2600,10 +2600,10 @@ static void FTP_CloseSessionHandle(LPWININETHANDLEHEADER hdr)
lpwfs->download_in_progress->session_deleted = TRUE;
if (lpwfs->sndSocket != -1)
close(lpwfs->sndSocket);
closesocket(lpwfs->sndSocket);
if (lpwfs->lstnSocket != -1)
close(lpwfs->lstnSocket);
closesocket(lpwfs->lstnSocket);
if (lpwfs->lpszPassword)
HeapFree(GetProcessHeap(), 0, lpwfs->lpszPassword);
......@@ -2668,7 +2668,7 @@ static void FTP_CloseFileTransferHandle(LPWININETHANDLEHEADER hdr)
nResCode = FTP_ReceiveResponse(lpwfs, lpwfs->hdr.dwContext);
if (lpwh->nDataSocket != -1)
close(lpwh->nDataSocket);
closesocket(lpwh->nDataSocket);
HeapFree(GetProcessHeap(), 0, lpwh);
}
......
......@@ -45,6 +45,12 @@
# include <sys/socket.h>
#endif
#ifdef __MINGW32__
#include "winsock2.h"
#else
#define closesocket close
#endif /* __MINGW32__ */
/* used for netconnection.c stuff */
typedef struct
{
......
......@@ -228,7 +228,7 @@ BOOL NETCON_close(WININET_NETCONNECTION *connection)
if (!connection->useSSL)
{
int result;
result = close(connection->socketFD);
result = closesocket(connection->socketFD);
connection->socketFD = -1;
if (result == -1)
return FALSE;
......@@ -237,7 +237,7 @@ BOOL NETCON_close(WININET_NETCONNECTION *connection)
else
{
#ifdef HAVE_OPENSSL_SSL_H
close(connection->ssl_sock);
closesocket(connection->ssl_sock);
connection->ssl_sock = -1;
/* FIXME should we call SSL_shutdown here?? Probably on whatever is the
* opposite of NETCON_init.... */
......@@ -262,7 +262,7 @@ BOOL NETCON_connect(WININET_NETCONNECTION *connection, const struct sockaddr *se
result = connect(connection->socketFD, serv_addr, addrlen);
if (result == -1)
{
close(connection->socketFD);
closesocket(connection->socketFD);
connection->socketFD = -1;
return FALSE;
}
......
......@@ -408,11 +408,14 @@ typedef struct WS(fd_set)
# endif
} WS(fd_set), FD_SET, *PFD_SET, *LPFD_SET;
#ifndef _TIMEVAL_DEFINED
#define _TIMEVAL_DEFINED
typedef struct WS(timeval)
{
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
} TIMEVAL, *PTIMEVAL, *LPTIMEVAL;
#endif
#define WINE_FD_CLR(fd, set, cast) do { \
u_int __i; \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment