Commit 5436fef8 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Always use winsock sockets.

parent 5d6d2fda
EXTRADEFS = -D_WINX32_
MODULE = wininet.dll
IMPORTLIB = wininet
IMPORTS = mpr shlwapi shell32 user32 advapi32
IMPORTS = mpr shlwapi shell32 user32 ws2_32 advapi32
DELAYIMPORTS = secur32 crypt32 cryptui
EXTRALIBS = $(CORESERVICES_LIBS) $(SOCKET_LIBS) $(Z_LIBS)
EXTRALIBS = $(CORESERVICES_LIBS) $(Z_LIBS)
C_SRCS = \
cookie.c \
......
......@@ -20,21 +20,13 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <ws2tcpip.h>
#endif
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include "windef.h"
#include "winbase.h"
......
......@@ -18,12 +18,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <ws2tcpip.h>
#endif
#include "ws2tcpip.h"
#include <stdarg.h>
......
......@@ -27,36 +27,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <ws2tcpip.h>
#endif
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_POLL_H
#include <poll.h>
#endif
#ifdef HAVE_SYS_POLL_H
# include <sys/poll.h>
#endif
#include <time.h>
#include <assert.h>
......@@ -1286,13 +1262,9 @@ static DWORD FTPFILE_QueryDataAvailable(object_header_t *hdr, DWORD *available,
TRACE("(%p %p %x %lx)\n", file, available, flags, ctx);
#ifdef FIONREAD
retval = ioctlsocket(file->nDataSocket, FIONREAD, &unread);
if (!retval)
TRACE("%d bytes of queued, but unread data\n", unread);
#else
FIXME("FIONREAD not available\n");
#endif
*available = unread;
......@@ -2394,11 +2366,11 @@ static void FTPSESSION_CloseConnection(object_header_t *hdr)
if (lpwfs->download_in_progress != NULL)
lpwfs->download_in_progress->session_deleted = TRUE;
if (lpwfs->sndSocket != -1)
closesocket(lpwfs->sndSocket);
if (lpwfs->sndSocket != -1)
closesocket(lpwfs->sndSocket);
if (lpwfs->lstnSocket != -1)
closesocket(lpwfs->lstnSocket);
if (lpwfs->lstnSocket != -1)
closesocket(lpwfs->lstnSocket);
if (lpwfs->pasvSocket != -1)
closesocket(lpwfs->pasvSocket);
......@@ -2681,18 +2653,19 @@ lend:
static LPSTR FTP_GetNextLine(INT nSocket, LPDWORD dwLen)
{
struct pollfd pfd;
struct timeval tv = {RESPONSE_TIMEOUT,0};
FD_SET set;
INT nRecv = 0;
LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
TRACE("\n");
pfd.fd = nSocket;
pfd.events = POLLIN;
FD_ZERO(&set);
FD_SET(nSocket, &set);
while (nRecv < MAX_REPLY_LEN)
{
if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
if (select(nSocket+1, &set, NULL, NULL, &tv) > 0)
{
if (sock_recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
{
......@@ -2992,7 +2965,7 @@ static BOOL FTP_InitListenSocket(ftp_session_t *lpwfs)
TRACE("\n");
init_winsock();
lpwfs->lstnSocket = socket(PF_INET, SOCK_STREAM, 0);
lpwfs->lstnSocket = socket(AF_INET, SOCK_STREAM, 0);
if (lpwfs->lstnSocket == -1)
{
TRACE("Unable to create listening socket\n");
......@@ -3135,10 +3108,10 @@ static BOOL FTP_SendPort(ftp_session_t *lpwfs)
TRACE("\n");
sprintfW(szIPAddress, szIPFormat,
lpwfs->lstnSocketAddress.sin_addr.s_addr&0x000000FF,
(lpwfs->lstnSocketAddress.sin_addr.s_addr&0x0000FF00)>>8,
(lpwfs->lstnSocketAddress.sin_addr.s_addr&0x00FF0000)>>16,
(lpwfs->lstnSocketAddress.sin_addr.s_addr&0xFF000000)>>24,
lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x000000FF,
(lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x0000FF00)>>8,
(lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0x00FF0000)>>16,
(lpwfs->lstnSocketAddress.sin_addr.S_un.S_addr&0xFF000000)>>24,
lpwfs->lstnSocketAddress.sin_port & 0xFF,
(lpwfs->lstnSocketAddress.sin_port & 0xFF00)>>8);
......@@ -3211,7 +3184,7 @@ static BOOL FTP_DoPassive(ftp_session_t *lpwfs)
f[i] = f[i] & 0xff;
dataSocketAddress = lpwfs->socketAddress;
pAddr = (char *)&(dataSocketAddress.sin_addr.s_addr);
pAddr = (char *)&(dataSocketAddress.sin_addr.S_un.S_addr);
pPort = (char *)&(dataSocketAddress.sin_port);
pAddr[0] = f[0];
pAddr[1] = f[1];
......@@ -3274,7 +3247,7 @@ static BOOL FTP_SendPortOrPasv(ftp_session_t *lpwfs)
static BOOL FTP_GetDataSocket(ftp_session_t *lpwfs, LPINT nDataSocket)
{
struct sockaddr_in saddr;
socklen_t addrlen = sizeof(struct sockaddr);
socklen_t addrlen = sizeof(saddr);
TRACE("\n");
if (lpwfs->hdr.dwFlags & INTERNET_FLAG_PASSIVE)
......
......@@ -28,31 +28,19 @@
*/
#include "config.h"
#include "wine/port.h"
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <ws2tcpip.h>
#ifdef HAVE_ZLIB
# define Z_SOLO
# include <zlib.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h>
#endif
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <time.h>
#include <assert.h>
#ifdef HAVE_ZLIB
# include <zlib.h>
#endif
#include "windef.h"
#include "winbase.h"
#include "wininet.h"
......
......@@ -26,28 +26,14 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <ws2tcpip.h>
#endif
#include "ws2tcpip.h"
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
#include <stdlib.h>
#include <ctype.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <assert.h>
#ifdef HAVE_CORESERVICES_CORESERVICES_H
......@@ -3475,7 +3461,7 @@ BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwRe
{
if (connect(fd, (struct sockaddr *)&saddr, sa_len) == 0)
rc = TRUE;
close(fd);
closesocket(fd);
}
}
else
......
......@@ -23,38 +23,15 @@
#ifndef _WINE_INTERNET_H_
#define _WINE_INTERNET_H_
#ifndef __WINE_CONFIG_H
# error You must include config.h to use this header
#endif
#include "wine/unicode.h"
#include "wine/list.h"
#include <time.h>
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <sys/types.h>
# include <netinet/in.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#if !defined(__MINGW32__) && !defined(_MSC_VER)
#define closesocket close
#define ioctlsocket ioctl
#endif /* __MINGW32__ */
#include "winineti.h"
extern HMODULE WININET_hModule DECLSPEC_HIDDEN;
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46
#endif
typedef struct {
WCHAR *name;
INTERNET_PORT port;
......
......@@ -22,24 +22,15 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#define NONAMELESSUNION
#define NONAMELESSSTRUCT
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <ws2tcpip.h>
#endif
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
#include <time.h>
#include "windef.h"
......
......@@ -22,12 +22,7 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#if defined(__MINGW32__) || defined (_MSC_VER)
#include <ws2tcpip.h>
#endif
#include "ws2tcpip.h"
#include <stdarg.h>
#include <stdlib.h>
......@@ -44,20 +39,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wininet);
#ifndef HAVE_GETADDRINFO
/* critical section to protect non-reentrant gethostbyname() */
static CRITICAL_SECTION cs_gethostbyname;
static CRITICAL_SECTION_DEBUG critsect_debug =
{
0, 0, &cs_gethostbyname,
{ &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
0, 0, { (DWORD_PTR)(__FILE__ ": cs_gethostbyname") }
};
static CRITICAL_SECTION cs_gethostbyname = { &critsect_debug, -1, 0, 0, 0, 0 };
#endif
#define TIME_STRING_LEN 30
time_t ConvertTimeString(LPCWSTR asctime)
......@@ -147,16 +128,11 @@ time_t ConvertTimeString(LPCWSTR asctime)
BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
struct sockaddr *psa, socklen_t *sa_len)
{
struct addrinfo *res, hints;
WCHAR *found;
char *name;
int len, sz;
#ifdef HAVE_GETADDRINFO
struct addrinfo *res, hints;
int ret;
#else
struct hostent *phe;
struct sockaddr_in *sin = (struct sockaddr_in *)psa;
#endif
TRACE("%s\n", debugstr_w(lpszServerName));
......@@ -176,8 +152,7 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
WideCharToMultiByte( CP_UNIXCP, 0, lpszServerName, len, name, sz, NULL, NULL );
name[sz] = 0;
#ifdef HAVE_GETADDRINFO
memset( &hints, 0, sizeof(struct addrinfo) );
memset( &hints, 0, sizeof(hints) );
/* Prefer IPv4 to IPv6 addresses, since some servers do not listen on
* their IPv6 addresses even though they have IPv6 addresses in the DNS.
*/
......@@ -186,14 +161,14 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
ret = getaddrinfo( name, NULL, &hints, &res );
if (ret != 0)
{
TRACE("failed to get IPv4 address of %s (%s), retrying with IPv6\n", debugstr_w(lpszServerName), gai_strerror(ret));
TRACE("failed to get IPv4 address of %s, retrying with IPv6\n", debugstr_w(lpszServerName));
hints.ai_family = AF_INET6;
ret = getaddrinfo( name, NULL, &hints, &res );
}
heap_free( name );
if (ret != 0)
{
TRACE("failed to get address of %s (%s)\n", debugstr_w(lpszServerName), gai_strerror(ret));
TRACE("failed to get address of %s\n", debugstr_w(lpszServerName));
return FALSE;
}
if (*sa_len < res->ai_addrlen)
......@@ -216,31 +191,6 @@ BOOL GetAddress(LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
}
freeaddrinfo( res );
#else
EnterCriticalSection( &cs_gethostbyname );
phe = gethostbyname(name);
heap_free( name );
if (NULL == phe)
{
TRACE("failed to get address of %s (%d)\n", debugstr_w(lpszServerName), h_errno);
LeaveCriticalSection( &cs_gethostbyname );
return FALSE;
}
if (*sa_len < sizeof(struct sockaddr_in))
{
WARN("address too small\n");
LeaveCriticalSection( &cs_gethostbyname );
return FALSE;
}
*sa_len = sizeof(struct sockaddr_in);
memset(sin,0,sizeof(struct sockaddr_in));
memcpy((char *)&sin->sin_addr, phe->h_addr, phe->h_length);
sin->sin_family = phe->h_addrtype;
sin->sin_port = htons(nServerPort);
LeaveCriticalSection( &cs_gethostbyname );
#endif
return TRUE;
}
......
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