[WININET]
[reactos.git] / reactos / dll / win32 / wininet / wininet_ros.diff
1 diff -prudN e:\Wine\dlls\wininet/cookie.c e:\reactos-clean\dll\win32\wininet/cookie.c
2 --- e:\Wine\dlls\wininet/cookie.c 2013-03-02 14:18:01.994544800 +0100
3 +++ e:\reactos-clean\dll\win32\wininet/cookie.c 2013-05-20 20:45:34.175815800 +0100
4 @@ -250,6 +254,7 @@ static BOOL save_persistent_cookie(cooki
5 BOOL do_save = FALSE;
6 char buf[64], *dyn_buf;
7 FILETIME time;
8 + DWORD dwBytesWritten;
9
10 if (!create_cookie_url(domain->lpCookieDomain, domain->lpCookiePath, cookie_url, sizeof(cookie_url)/sizeof(cookie_url[0])))
11 return FALSE;
12 @@ -288,31 +293,31 @@ static BOOL save_persistent_cookie(cooki
13 continue;
14
15 dyn_buf = heap_strdupWtoA(cookie_container->lpCookieName);
16 - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), NULL, NULL)) {
17 + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) {
18 heap_free(dyn_buf);
19 do_save = FALSE;
20 break;
21 }
22 heap_free(dyn_buf);
23 - if(!WriteFile(cookie_handle, "\n", 1, NULL, NULL)) {
24 + if(!WriteFile(cookie_handle, "\n", 1, &dwBytesWritten, NULL)) {
25 do_save = FALSE;
26 break;
27 }
28
29 dyn_buf = heap_strdupWtoA(cookie_container->lpCookieData);
30 - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), NULL, NULL)) {
31 + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) {
32 heap_free(dyn_buf);
33 do_save = FALSE;
34 break;
35 }
36 heap_free(dyn_buf);
37 - if(!WriteFile(cookie_handle, "\n", 1, NULL, NULL)) {
38 + if(!WriteFile(cookie_handle, "\n", 1, &dwBytesWritten, NULL)) {
39 do_save = FALSE;
40 break;
41 }
42
43 dyn_buf = heap_strdupWtoA(domain->lpCookieDomain);
44 - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), NULL, NULL)) {
45 + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) {
46 heap_free(dyn_buf);
47 do_save = FALSE;
48 break;
49 @@ -320,7 +325,7 @@ static BOOL save_persistent_cookie(cooki
50 heap_free(dyn_buf);
51
52 dyn_buf = heap_strdupWtoA(domain->lpCookiePath);
53 - if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), NULL, NULL)) {
54 + if(!dyn_buf || !WriteFile(cookie_handle, dyn_buf, strlen(dyn_buf), &dwBytesWritten, NULL)) {
55 heap_free(dyn_buf);
56 do_save = FALSE;
57 break;
58 @@ -330,7 +335,7 @@ static BOOL save_persistent_cookie(cooki
59 sprintf(buf, "\n%u\n%u\n%u\n%u\n%u\n*\n", cookie_container->flags,
60 cookie_container->expiry.dwLowDateTime, cookie_container->expiry.dwHighDateTime,
61 cookie_container->create.dwLowDateTime, cookie_container->create.dwHighDateTime);
62 - if(!WriteFile(cookie_handle, buf, strlen(buf), NULL, NULL)) {
63 + if(!WriteFile(cookie_handle, buf, strlen(buf), &dwBytesWritten, NULL)) {
64 do_save = FALSE;
65 break;
66 }
67 diff -prudN e:\Wine\dlls\wininet/http.c e:\reactos-clean\dll\win32\wininet/http.c
68 --- e:\Wine\dlls\wininet/http.c 2013-03-16 11:54:52.608610100 +0100
69 +++ e:\reactos-clean\dll\win32\wininet/http.c 2013-05-20 16:36:21.826074500 +0100
70 @@ -242,7 +249,13 @@ void server_release(server_t *server)
71 if(InterlockedDecrement(&server->ref))
72 return;
73
74 +#ifdef __REACTOS__
75 + EnterCriticalSection(&connection_pool_cs);
76 +#endif
77 list_remove(&server->entry);
78 +#ifdef __REACTOS__
79 + LeaveCriticalSection(&connection_pool_cs);
80 +#endif
81
82 if(server->cert_chain)
83 CertFreeCertificateChain(server->cert_chain);
84 @@ -324,7 +337,7 @@ BOOL collect_connections(collect_type_t
85 BOOL remaining = FALSE;
86 DWORD64 now;
87
88 - now = GetTickCount64();
89 + now = GetTickCount();
90
91 LIST_FOR_EACH_ENTRY_SAFE(server, server_safe, &connection_pool, server_t, entry) {
92 LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
93 @@ -1870,13 +1883,14 @@ static void http_release_netconn(http_re
94 if(!req->netconn)
95 return;
96
97 +#ifndef __REACTOS__
98 if(reuse && req->netconn->keep_alive) {
99 BOOL run_collector;
100
101 EnterCriticalSection(&connection_pool_cs);
102
103 list_add_head(&req->netconn->server->conn_pool, &req->netconn->pool_entry);
104 - req->netconn->keep_until = GetTickCount64() + COLLECT_TIME;
105 + req->netconn->keep_until = (DWORD64)GetTickCount() + COLLECT_TIME;
106 req->netconn = NULL;
107
108 run_collector = !collector_running;
109 @@ -1904,6 +1918,10 @@ static void http_release_netconn(http_re
110 }
111 return;
112 }
113 +#else
114 + // silence unused function warning
115 + (void)collect_connections_proc;
116 +#endif
117
118 INTERNET_SendCallback(&req->hdr, req->hdr.dwContext,
119 INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);
120 diff -prudN e:\Wine\dlls\wininet/internet.c e:\reactos-clean\dll\win32\wininet/internet.c
121 --- e:\Wine\dlls\wininet/internet.c 2013-03-16 11:54:52.609610800 +0100
122 +++ e:\reactos-clean\dll\win32\wininet/internet.c 2013-05-20 16:43:55.864085500 +0100
123 @@ -292,11 +297,9 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL,
124 if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
125 return FALSE;
126
127 - if(!init_urlcache())
128 - {
129 - TlsFree(g_dwTlsErrIndex);
130 - return FALSE;
131 - }
132 +#ifndef __REACTOS__
133 + URLCacheContainers_CreateDefaults();
134 +#endif
135
136 WININET_hModule = hinstDLL;
137 break;
138 @@ -750,6 +753,9 @@ static VOID APPINFO_Destroy(object_heade
139 heap_free(lpwai->proxyBypass);
140 heap_free(lpwai->proxyUsername);
141 heap_free(lpwai->proxyPassword);
142 +#ifdef __REACTOS__
143 + WSACleanup();
144 +#endif
145 }
146
147 static DWORD APPINFO_QueryOption(object_header_t *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
148 @@ -945,6 +951,11 @@ HINTERNET WINAPI InternetOpenW(LPCWSTR l
149 LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
150 {
151 appinfo_t *lpwai = NULL;
152 +#ifdef __REACTOS__
153 + WSADATA wsaData;
154 + int error = WSAStartup(MAKEWORD(2, 2), &wsaData);
155 + if (error) ERR("WSAStartup failed: %d\n", error);
156 +#endif
157
158 if (TRACE_ON(wininet)) {
159 #define FE(x) { x, #x }
160 @@ -3759,19 +3770,23 @@ LPSTR INTERNET_GetResponseBuffer(void)
161
162 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
163 {
164 - struct pollfd pfd;
165 + // ReactOS: use select instead of poll
166 + fd_set infd;
167 + struct timeval tv;
168 BOOL bSuccess = FALSE;
169 INT nRecv = 0;
170 LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
171
172 TRACE("\n");
173
174 - pfd.fd = nSocket;
175 - pfd.events = POLLIN;
176 + FD_ZERO(&infd);
177 + FD_SET(nSocket,&infd);
178 + tv.tv_sec = RESPONSE_TIMEOUT;
179 + tv.tv_usec = 0;
180
181 while (nRecv < MAX_REPLY_LEN)
182 {
183 - if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
184 + if (select(0, &infd, NULL, NULL, &tv) > 0)
185 {
186 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
187 {
188 diff -prudN e:\Wine\dlls\wininet/internet.h e:\reactos-clean\dll\win32\wininet/internet.h
189 --- e:\Wine\dlls\wininet/internet.h 2013-03-02 14:18:02.010553900 +0100
190 +++ e:\reactos-clean\dll\win32\wininet/internet.h 2013-05-20 17:12:12.531037400 +0100
191 @@ -419,7 +419,30 @@ BOOL NETCON_is_alive(netconn_t*) DECLSPE
192 LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN;
193 int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN;
194 DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN;
195 +#ifndef __REACTOS__
196 int sock_get_error(int) DECLSPEC_HIDDEN;
197 +#else
198 +#define sock_get_error(x) WSAGetLastError()
199 +const char *inet_ntop(int, const void *, char *, socklen_t);
200 +
201 +static inline long unix_recv(int socket, void *buffer, size_t length, int flags)
202 +{
203 + return recv(socket, buffer, length, flags);
204 +}
205 +#define recv unix_recv
206 +
207 +static inline int unix_ioctl(int filedes, long request, void *arg)
208 +{
209 + return ioctlsocket(filedes, request, arg);
210 +}
211 +#define ioctlsocket unix_ioctl
212 +
213 +static inline int unix_getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len)
214 +{
215 + return getsockopt(socket, level, option_name, option_value, option_len);
216 +}
217 +#define getsockopt unix_getsockopt
218 +#endif
219
220 server_t *get_server(const WCHAR*,INTERNET_PORT,BOOL,BOOL);
221
222 diff -prudN e:\Wine\dlls\wininet/netconnection.c e:\reactos-clean\dll\win32\wininet/netconnection.c
223 --- e:\Wine\dlls\wininet/netconnection.c 2013-03-16 11:54:52.610611400 +0100
224 +++ e:\reactos-clean\dll\win32\wininet/netconnection.c 2013-05-20 17:12:51.246334100 +0100
225 @@ -619,12 +624,16 @@ static DWORD create_netconn_socket(serve
226 if(result == -1)
227 {
228 if (sock_get_error(errno) == WSAEINPROGRESS) {
229 - struct pollfd pfd;
230 + // ReactOS: use select instead of poll
231 + fd_set outfd;
232 + struct timeval tv;
233 int res;
234
235 - pfd.fd = netconn->socket;
236 - pfd.events = POLLOUT;
237 - res = poll(&pfd, 1, timeout);
238 + FD_ZERO(&outfd);
239 + FD_SET(netconn->socket, &outfd);
240 + tv.tv_sec = timeout / 1000;
241 + tv.tv_usec = (timeout % 1000) * 1000;
242 + res = select(0, NULL, &outfd, NULL, &tv);
243 if (!res)
244 {
245 closesocket(netconn->socket);
246 @@ -741,6 +750,7 @@ void NETCON_unload(void)
247 #endif
248 }
249
250 +#ifndef __REACTOS__
251 /* translate a unix error code into a winsock one */
252 int sock_get_error( int err )
253 {
254 @@ -807,6 +817,7 @@ int sock_get_error( int err )
255 #endif
256 return err;
257 }
258 +#endif
259
260 #ifdef SONAME_LIBSSL
261 static DWORD netcon_secure_connect_setup(netconn_t *connection, long tls_option)
262 diff -prudN e:\Wine\dlls\wininet/urlcache.c e:\reactos-clean\dll\win32\wininet/urlcache.c
263 --- e:\Wine\dlls\wininet/urlcache.c 2013-03-16 11:54:52.613613400 +0100
264 +++ e:\reactos-clean\dll\win32\wininet/urlcache.c 2013-05-20 17:05:34.969949600 +0100
265 @@ -201,6 +205,8 @@ typedef struct _URLCACHECONTAINER
266
267 /* List of all containers available */
268 static struct list UrlContainers = LIST_INIT(UrlContainers);
269 +// ReactOS r54992
270 +BOOL bDefaultContainersAdded = FALSE;
271
272 static DWORD URLCache_CreateHashTable(LPURLCACHE_HEADER pHeader, HASH_CACHEFILE_ENTRY *pPrevHash, HASH_CACHEFILE_ENTRY **ppHash);
273
274 @@ -587,6 +593,8 @@ static void URLCacheContainers_CreateDef
275 static const WCHAR HistoryPrefix[] = {'V','i','s','i','t','e','d',':',0};
276 static const WCHAR CookieSuffix[] = {0};
277 static const WCHAR CookiePrefix[] = {'C','o','o','k','i','e',':',0};
278 + // ReactOS r50916
279 + static const WCHAR UserProfile[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
280 static const struct
281 {
282 int nFolder; /* CSIDL_* constant */
283 @@ -601,6 +609,13 @@ static void URLCacheContainers_CreateDef
284 };
285 DWORD i;
286
287 + // ReactOS r50916
288 + if (GetEnvironmentVariableW(UserProfile, NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
289 + {
290 + TRACE("Environment variable 'USERPROFILE' does not exist!\n");
291 + return;
292 + }
293 +
294 for (i = 0; i < sizeof(DefaultContainerData) / sizeof(DefaultContainerData[0]); i++)
295 {
296 WCHAR wszCachePath[MAX_PATH];
297 @@ -655,6 +670,10 @@ static DWORD URLCacheContainers_FindCont
298 if(!lpwszUrl)
299 return ERROR_INVALID_PARAMETER;
300
301 + // ReactOS r54992
302 + if (!bDefaultContainersAdded)
303 + URLCacheContainers_CreateDefaults();
304 +
305 LIST_FOR_EACH_ENTRY(pContainer, &UrlContainers, URLCACHECONTAINER, entry)
306 {
307 int prefix_len = strlenW(pContainer->cache_prefix);
308 @@ -693,6 +712,10 @@ static BOOL URLCacheContainers_Enum(LPCW
309 if (lpwszSearchPattern && dwIndex > 0)
310 return FALSE;
311
312 + // ReactOS r54992
313 + if (!bDefaultContainersAdded)
314 + URLCacheContainers_CreateDefaults();
315 +
316 LIST_FOR_EACH_ENTRY(pContainer, &UrlContainers, URLCACHECONTAINER, entry)
317 {
318 if (lpwszSearchPattern)