60f010e03b94941e1e9b771720fb55e9dafca5ae
[reactos.git] / reactos / dll / win32 / winhttp / winhttp_ros.diff
1 diff -pudN e:\wine\dlls\winhttp/net.c e:\reactos\dll\win32\winhttp/net.c
2 --- e:\wine\dlls\winhttp/net.c 2015-02-21 17:13:15.365542100 +0100
3 +++ e:\reactos\dll\win32\winhttp/net.c 2015-07-20 14:25:14.321893000 +0100
4 @@ -73,6 +50,7 @@ static CRITICAL_SECTION cs_gethostbyname
5 #endif
6
7 /* translate a unix error code into a winsock error code */
8 +#ifndef __REACTOS__
9 static int sock_get_error( int err )
10 {
11 #if !defined(__MINGW32__) && !defined (_MSC_VER)
12 @@ -138,6 +116,15 @@ static int sock_get_error( int err )
13 #endif
14 return err;
15 }
16 +#else
17 +#define sock_get_error(x) WSAGetLastError()
18 +
19 +static inline int unix_ioctl(int filedes, long request, void *arg)
20 +{
21 + return ioctlsocket(filedes, request, arg);
22 +}
23 +#define ioctlsocket unix_ioctl
24 +#endif
25
26 static int sock_send(int fd, const void *msg, size_t len, int flags)
27 {
28 @@ -366,11 +353,25 @@ BOOL netconn_connect( netconn_t *conn, c
29 res = sock_get_error( errno );
30 if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
31 {
32 +#ifdef __REACTOS__
33 + /* ReactOS: use select instead of poll */
34 + fd_set outfd;
35 + struct timeval tv;
36 +
37 + FD_ZERO(&outfd);
38 + FD_SET(conn->socket, &outfd);
39 +
40 + tv.tv_sec = 0;
41 + tv.tv_usec = timeout * 1000;
42 +
43 + if (select( 0, NULL, &outfd, NULL, &tv ) > 0)
44 +#else
45 struct pollfd pfd;
46
47 pfd.fd = conn->socket;
48 pfd.events = POLLOUT;
49 if (poll( &pfd, 1, timeout ) > 0)
50 +#endif
51 ret = TRUE;
52 else
53 res = sock_get_error( errno );
54 diff -pudN e:\wine\dlls\winhttp/request.c e:\reactos\dll\win32\winhttp/request.c
55 --- e:\wine\dlls\winhttp/request.c 2015-07-14 15:44:36.027191600 +0100
56 +++ e:\reactos\dll\win32\winhttp/request.c 2015-07-20 14:28:31.803188200 +0100
57 @@ -1263,6 +1252,7 @@ BOOL WINAPI WinHttpSendRequest( HINTERNE
58 return ret;
59 }
60
61 +#undef ARRAYSIZE
62 #define ARRAYSIZE(array) (sizeof(array) / sizeof((array)[0]))
63
64 static const WCHAR basicW[] = {'B','a','s','i','c',0};
65 @@ -2754,8 +2744,8 @@ static void free_request( struct winhttp
66 CloseHandle( request->thread );
67 CloseHandle( request->wait );
68 CloseHandle( request->cancel );
69 - heap_free( request->proxy.lpszProxy );
70 - heap_free( request->proxy.lpszProxyBypass );
71 + heap_free( (WCHAR *)request->proxy.lpszProxy );
72 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
73 heap_free( request->buffer );
74 heap_free( request->verb );
75 VariantClear( &request->data );
76 @@ -2959,16 +2949,16 @@ static HRESULT WINAPI winhttp_request_Se
77 {
78 case HTTPREQUEST_PROXYSETTING_DEFAULT:
79 request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
80 - heap_free( request->proxy.lpszProxy );
81 - heap_free( request->proxy.lpszProxyBypass );
82 + heap_free( (WCHAR *)request->proxy.lpszProxy );
83 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
84 request->proxy.lpszProxy = NULL;
85 request->proxy.lpszProxyBypass = NULL;
86 break;
87
88 case HTTPREQUEST_PROXYSETTING_DIRECT:
89 request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
90 - heap_free( request->proxy.lpszProxy );
91 - heap_free( request->proxy.lpszProxyBypass );
92 + heap_free( (WCHAR *)request->proxy.lpszProxy );
93 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
94 request->proxy.lpszProxy = NULL;
95 request->proxy.lpszProxyBypass = NULL;
96 break;
97 @@ -2977,12 +2967,12 @@ static HRESULT WINAPI winhttp_request_Se
98 request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
99 if (V_VT( &proxy_server ) == VT_BSTR)
100 {
101 - heap_free( request->proxy.lpszProxy );
102 + heap_free( (WCHAR *)request->proxy.lpszProxy );
103 request->proxy.lpszProxy = strdupW( V_BSTR( &proxy_server ) );
104 }
105 if (V_VT( &bypass_list ) == VT_BSTR)
106 {
107 - heap_free( request->proxy.lpszProxyBypass );
108 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
109 request->proxy.lpszProxyBypass = strdupW( V_BSTR( &bypass_list ) );
110 }
111 break;
112 diff -pudN e:\wine\dlls\winhttp/session.c e:\reactos\dll\win32\winhttp/session.c
113 --- e:\wine\dlls\winhttp/session.c 2015-07-14 15:44:36.029191700 +0100
114 +++ e:\reactos\dll\win32\winhttp/session.c 2015-07-20 14:29:15.686698200 +0100
115 @@ -109,6 +81,9 @@ static void session_destroy( object_head
116 heap_free( session->proxy_username );
117 heap_free( session->proxy_password );
118 heap_free( session );
119 +#ifdef __REACTOS__
120 + WSACleanup();
121 +#endif
122 }
123
124 static BOOL session_query_option( object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen )
125 @@ -220,6 +195,11 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR ag
126 {
127 session_t *session;
128 HINTERNET handle = NULL;
129 +#ifdef __REACTOS__
130 + WSADATA wsaData;
131 + int error = WSAStartup(MAKEWORD(2, 2), &wsaData);
132 + if (error) ERR("WSAStartup failed: %d\n", error);
133 +#endif
134
135 TRACE("%s, %u, %s, %s, 0x%08x\n", debugstr_w(agent), access, debugstr_w(proxy), debugstr_w(bypass), flags);
136
137 @@ -246,14 +226,14 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR ag
138 session->access = info.dwAccessType;
139 if (info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy )))
140 {
141 - GlobalFree( info.lpszProxy );
142 - GlobalFree( info.lpszProxyBypass );
143 + GlobalFree( (LPWSTR)info.lpszProxy );
144 + GlobalFree( (LPWSTR)info.lpszProxyBypass );
145 goto end;
146 }
147 if (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass )))
148 {
149 - GlobalFree( info.lpszProxy );
150 - GlobalFree( info.lpszProxyBypass );
151 + GlobalFree( (LPWSTR)info.lpszProxy );
152 + GlobalFree( (LPWSTR)info.lpszProxyBypass );
153 goto end;
154 }
155 }
156 @@ -624,7 +604,7 @@ static WCHAR *blob_to_str( DWORD encodin
157
158 static BOOL convert_sockaddr( const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage )
159 {
160 -#ifndef __MINGW32__
161 +#if !defined(__MINGW32__) && !defined(_MSC_VER)
162 switch (addr->sa_family)
163 {
164 case AF_INET: