Sync with trunk r63270.
[reactos.git] / dll / win32 / winhttp / winhttp_ros.diff
1 diff -prudN e:\Wine\dlls\winhttp/net.c e:\reactos-clean\dll\win32\winhttp/net.c
2 --- e:\Wine\dlls\winhttp/net.c 2013-03-16 11:54:52.602606100 +0100
3 +++ e:\reactos-clean\dll\win32\winhttp/net.c 2013-05-21 20:25:32.595598100 +0100
4 @@ -73,6 +77,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 +143,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 DWORD netconn_verify_cert( PCCERT_CONTEXT cert, WCHAR *server, DWORD security_flags )
27 {
28 @@ -344,11 +358,17 @@ BOOL netconn_connect( netconn_t *conn, c
29 res = sock_get_error( errno );
30 if (res == WSAEWOULDBLOCK || res == WSAEINPROGRESS)
31 {
32 - struct pollfd pfd;
33 + // ReactOS: use select instead of poll
34 + fd_set outfd;
35 + struct timeval tv;
36
37 - pfd.fd = conn->socket;
38 - pfd.events = POLLOUT;
39 - if (poll( &pfd, 1, timeout ) > 0)
40 + FD_ZERO(&outfd);
41 + FD_SET(conn->socket, &outfd);
42 +
43 + tv.tv_sec = 0;
44 + tv.tv_usec = timeout * 1000;
45 +
46 + if (select( 0, NULL, &outfd, NULL, &tv ) > 0)
47 ret = TRUE;
48 else
49 res = sock_get_error( errno );
50 @@ -442,7 +462,7 @@ BOOL netconn_secure_connect( netconn_t *
51 read_buf_size += 1024;
52 }
53
54 - size = recv(conn->socket, read_buf+in_bufs[0].cbBuffer, read_buf_size-in_bufs[0].cbBuffer, 0);
55 + size = recv(conn->socket, (char *)(read_buf+in_bufs[0].cbBuffer), read_buf_size-in_bufs[0].cbBuffer, 0);
56 if(size < 1) {
57 WARN("recv error\n");
58 status = ERROR_WINHTTP_SECURE_CHANNEL_ERROR;
59 @@ -754,7 +774,8 @@ BOOL netconn_query_data_available( netco
60
61 BOOL netconn_get_next_line( netconn_t *conn, char *buffer, DWORD *buflen )
62 {
63 - struct pollfd pfd;
64 + // ReactOS: use select instead of poll
65 + fd_set infd;
66 BOOL ret = FALSE;
67 DWORD recvd = 0;
68
69 @@ -786,19 +807,21 @@ BOOL netconn_get_next_line( netconn_t *c
70 return ret;
71 }
72
73 - pfd.fd = conn->socket;
74 - pfd.events = POLLIN;
75 + FD_ZERO(&infd);
76 + FD_SET(conn->socket, &infd);
77 +
78 while (recvd < *buflen)
79 {
80 - int timeout, res;
81 - struct timeval tv;
82 + int res;
83 + struct timeval tv, *ptv;
84 socklen_t len = sizeof(tv);
85
86 if ((res = getsockopt( conn->socket, SOL_SOCKET, SO_RCVTIMEO, (void*)&tv, &len ) != -1))
87 - timeout = tv.tv_sec * 1000 + tv.tv_usec / 1000;
88 + ptv = &tv;
89 else
90 - timeout = -1;
91 - if (poll( &pfd, 1, timeout ) > 0)
92 + ptv = NULL;
93 +
94 + if (select( 0, &infd, NULL, NULL, ptv ) > 0)
95 {
96 if ((res = recv( conn->socket, &buffer[recvd], 1, 0 )) <= 0)
97 {
98 diff -prudN e:\Wine\dlls\winhttp/request.c e:\reactos-clean\dll\win32\winhttp/request.c
99 --- e:\Wine\dlls\winhttp/request.c 2013-03-16 11:54:52.603606700 +0100
100 +++ e:\reactos-clean\dll\win32\winhttp/request.c 2013-05-21 20:05:12.642413600 +0100
101 @@ -2254,8 +2260,8 @@ static void free_request( struct winhttp
102 CloseHandle( request->thread );
103 CloseHandle( request->wait );
104 CloseHandle( request->cancel );
105 - heap_free( request->proxy.lpszProxy );
106 - heap_free( request->proxy.lpszProxyBypass );
107 + heap_free( (WCHAR *)request->proxy.lpszProxy );
108 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
109 heap_free( request->buffer );
110 heap_free( request->verb );
111 VariantClear( &request->data );
112 @@ -2446,16 +2452,16 @@ static HRESULT WINAPI winhttp_request_Se
113 {
114 case HTTPREQUEST_PROXYSETTING_DEFAULT:
115 request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY;
116 - heap_free( request->proxy.lpszProxy );
117 - heap_free( request->proxy.lpszProxyBypass );
118 + heap_free( (WCHAR *)request->proxy.lpszProxy );
119 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
120 request->proxy.lpszProxy = NULL;
121 request->proxy.lpszProxyBypass = NULL;
122 break;
123
124 case HTTPREQUEST_PROXYSETTING_DIRECT:
125 request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NO_PROXY;
126 - heap_free( request->proxy.lpszProxy );
127 - heap_free( request->proxy.lpszProxyBypass );
128 + heap_free( (WCHAR *)request->proxy.lpszProxy );
129 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
130 request->proxy.lpszProxy = NULL;
131 request->proxy.lpszProxyBypass = NULL;
132 break;
133 @@ -2464,12 +2470,12 @@ static HRESULT WINAPI winhttp_request_Se
134 request->proxy.dwAccessType = WINHTTP_ACCESS_TYPE_NAMED_PROXY;
135 if (V_VT( &proxy_server ) == VT_BSTR)
136 {
137 - heap_free( request->proxy.lpszProxy );
138 + heap_free( (WCHAR *)request->proxy.lpszProxy );
139 request->proxy.lpszProxy = strdupW( V_BSTR( &proxy_server ) );
140 }
141 if (V_VT( &bypass_list ) == VT_BSTR)
142 {
143 - heap_free( request->proxy.lpszProxyBypass );
144 + heap_free( (WCHAR *)request->proxy.lpszProxyBypass );
145 request->proxy.lpszProxyBypass = strdupW( V_BSTR( &bypass_list ) );
146 }
147 break;
148 diff -prudN e:\Wine\dlls\winhttp/rsrc.rc e:\reactos-clean\dll\win32\winhttp/rsrc.rc
149 --- e:\Wine\dlls\winhttp/rsrc.rc 2011-11-24 17:55:02.335439900 +0100
150 +++ e:\reactos-clean\dll\win32\winhttp/rsrc.rc 2012-07-20 21:40:58.173741700 +0100
151 @@ -16,6 +16,12 @@
152 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
153 */
154
155 +/* @makedep: winhttp_tlb.tlb */
156 +1 TYPELIB winhttp_tlb.tlb
157 +
158 +/* @makedep: winhttp_tlb.rgs */
159 +1 WINE_REGISTRY winhttp_tlb.rgs
160 +
161 /* @makedep: pac.js */
162 pac.js 40 "pac.js"
163
164 diff -prudN e:\Wine\dlls\winhttp/session.c e:\reactos-clean\dll\win32\winhttp/session.c
165 --- e:\Wine\dlls\winhttp/session.c 2013-03-16 11:54:52.604607400 +0100
166 +++ e:\reactos-clean\dll\win32\winhttp/session.c 2013-05-21 20:19:52.231665900 +0100
167 @@ -100,6 +100,9 @@ static void session_destroy( object_head
168 heap_free( session->proxy_username );
169 heap_free( session->proxy_password );
170 heap_free( session );
171 +#ifdef __REACTOS__
172 + WSACleanup();
173 +#endif
174 }
175
176 static BOOL session_query_option( object_header_t *hdr, DWORD option, LPVOID buffer, LPDWORD buflen )
177 @@ -211,6 +214,11 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR ag
178 {
179 session_t *session;
180 HINTERNET handle = NULL;
181 +#ifdef __REACTOS__
182 + WSADATA wsaData;
183 + int error = WSAStartup(MAKEWORD(2, 2), &wsaData);
184 + if (error) ERR("WSAStartup failed: %d\n", error);
185 +#endif
186
187 TRACE("%s, %u, %s, %s, 0x%08x\n", debugstr_w(agent), access, debugstr_w(proxy), debugstr_w(bypass), flags);
188
189 @@ -237,14 +245,14 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR ag
190 session->access = info.dwAccessType;
191 if (info.lpszProxy && !(session->proxy_server = strdupW( info.lpszProxy )))
192 {
193 - GlobalFree( info.lpszProxy );
194 - GlobalFree( info.lpszProxyBypass );
195 + GlobalFree( (LPWSTR)info.lpszProxy );
196 + GlobalFree( (LPWSTR)info.lpszProxyBypass );
197 goto end;
198 }
199 if (info.lpszProxyBypass && !(session->proxy_bypass = strdupW( info.lpszProxyBypass )))
200 {
201 - GlobalFree( info.lpszProxy );
202 - GlobalFree( info.lpszProxyBypass );
203 + GlobalFree( (LPWSTR)info.lpszProxy );
204 + GlobalFree( (LPWSTR)info.lpszProxyBypass );
205 goto end;
206 }
207 }
208 @@ -594,7 +602,7 @@ static WCHAR *blob_to_str( DWORD encodin
209
210 static BOOL convert_sockaddr( const struct sockaddr *addr, SOCKADDR_STORAGE *addr_storage )
211 {
212 -#ifndef __MINGW32__
213 +#if !defined(__MINGW32__) && !defined(_MSC_VER)
214 switch (addr->sa_family)
215 {
216 case AF_INET: