[WININET]
[reactos.git] / reactos / dll / win32 / wininet / wininet_ros.diff
1 --- wine-1.5.4/dlls/wininet/internet.h 2012-06-20 14:38:39 +0200
2 +++ dll/win32/wininet/internet.h 2012-06-20 16:49:05 +0200
3 @@ -536,7 +536,30 @@ BOOL NETCON_is_alive(netconn_t*) DECLSPE
4 LPCVOID NETCON_GetCert(netconn_t *connection) DECLSPEC_HIDDEN;
5 int NETCON_GetCipherStrength(netconn_t*) DECLSPEC_HIDDEN;
6 DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC_HIDDEN;
7 +#ifndef __REACTOS__
8 int sock_get_error(int) DECLSPEC_HIDDEN;
9 +#else
10 +#define sock_get_error(x) WSAGetLastError()
11 +const char *inet_ntop(int, const void *, char *, socklen_t);
12 +
13 +static inline long unix_recv(int socket, void *buffer, size_t length, int flags)
14 +{
15 + return recv(socket, buffer, length, flags);
16 +}
17 +#define recv unix_recv
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 +
25 +static inline int unix_getsockopt(int socket, int level, int option_name, void *option_value, socklen_t *option_len)
26 +{
27 + return getsockopt(socket, level, option_name, option_value, option_len);
28 +}
29 +#define getsockopt unix_getsockopt
30 +#endif
31
32 extern void URLCacheContainers_CreateDefaults(void) DECLSPEC_HIDDEN;
33 extern void URLCacheContainers_DeleteAll(void) DECLSPEC_HIDDEN;
34 --- wine-1.5.4/dlls/wininet/netconnection.c 2012-06-20 14:38:39 +0200
35 +++ dll/win32/wininet/netconnection.c 2012-06-20 15:50:06 +0200
36 @@ -523,12 +523,16 @@ DWORD create_netconn(BOOL useSSL, server
37 if(result == -1)
38 {
39 if (sock_get_error(errno) == WSAEINPROGRESS) {
40 - struct pollfd pfd;
41 + // ReactOS: use select instead of poll
42 + fd_set outfd;
43 + struct timeval tv;
44 int res;
45
46 - pfd.fd = netconn->socketFD;
47 - pfd.events = POLLOUT;
48 - res = poll(&pfd, 1, timeout);
49 + FD_ZERO(&outfd);
50 + FD_SET(netconn->socketFD, &outfd);
51 + tv.tv_sec = timeout / 1000;
52 + tv.tv_usec = (timeout % 1000) * 1000;
53 + res = select(0, NULL, &outfd, NULL, &tv);
54 if (!res)
55 {
56 closesocket(netconn->socketFD);
57 @@ -612,6 +616,7 @@ void NETCON_unload(void)
58 #endif
59 }
60
61 +#ifndef __REACTOS__
62 /* translate a unix error code into a winsock one */
63 int sock_get_error( int err )
64 {
65 @@ -678,6 +683,7 @@ int sock_get_error( int err )
66 #endif
67 return err;
68 }
69 +#endif
70
71 /******************************************************************************
72 * NETCON_secure_connect
73 --- wine-1.5.4/dlls/wininet/internet.c 2012-06-20 14:38:38 +0200
74 +++ dll/win32/wininet/internet.c 2012-06-20 15:50:05 +0200
75 @@ -292,7 +292,9 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL,
76 if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
77 return FALSE;
78
79 +#ifndef __REACTOS__
80 URLCacheContainers_CreateDefaults();
81 +#endif
82
83 WININET_hModule = hinstDLL;
84 break;
85 @@ -3716,19 +3718,23 @@ LPSTR INTERNET_GetResponseBuffer(void)
86
87 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
88 {
89 - struct pollfd pfd;
90 + // ReactOS: use select instead of poll
91 + fd_set infd;
92 + struct timeval tv;
93 BOOL bSuccess = FALSE;
94 INT nRecv = 0;
95 LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
96
97 TRACE("\n");
98
99 - pfd.fd = nSocket;
100 - pfd.events = POLLIN;
101 + FD_ZERO(&infd);
102 + FD_SET(nSocket,&infd);
103 + tv.tv_sec = RESPONSE_TIMEOUT;
104 + tv.tv_usec = 0;
105
106 while (nRecv < MAX_REPLY_LEN)
107 {
108 - if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
109 + if (select(0, &infd, NULL, NULL, &tv) > 0)
110 {
111 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
112 {
113 --- wine-1.5.4/dlls/wininet/urlcache.c 2012-06-20 14:30:41 +0200
114 +++ dll/win32/wininet/urlcache.c 2012-06-20 15:50:06 +0200
115 @@ -189,6 +189,8 @@ typedef struct _URLCACHECONTAINER
116
117 /* List of all containers available */
118 static struct list UrlContainers = LIST_INIT(UrlContainers);
119 +// ReactOS r54992
120 +BOOL bDefaultContainersAdded = FALSE;
121
122 static DWORD URLCache_CreateHashTable(LPURLCACHE_HEADER pHeader, HASH_CACHEFILE_ENTRY *pPrevHash, HASH_CACHEFILE_ENTRY **ppHash);
123
124 @@ -538,6 +540,8 @@ void URLCacheContainers_CreateDefaults(v
125 static const WCHAR HistoryPrefix[] = {'V','i','s','i','t','e','d',':',0};
126 static const WCHAR CookieSuffix[] = {0};
127 static const WCHAR CookiePrefix[] = {'C','o','o','k','i','e',':',0};
128 + // ReactOS r50916
129 + static const WCHAR UserProfile[] = {'U','S','E','R','P','R','O','F','I','L','E',0};
130 static const struct
131 {
132 int nFolder; /* CSIDL_* constant */
133 @@ -551,6 +555,13 @@ void URLCacheContainers_CreateDefaults(v
134 };
135 DWORD i;
136
137 + // ReactOS r50916
138 + if (GetEnvironmentVariableW(UserProfile, NULL, 0) == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND)
139 + {
140 + TRACE("Environment variable 'USERPROFILE' does not exist!\n");
141 + return;
142 + }
143 +
144 for (i = 0; i < sizeof(DefaultContainerData) / sizeof(DefaultContainerData[0]); i++)
145 {
146 WCHAR wszCachePath[MAX_PATH];
147 @@ -604,6 +615,10 @@ static DWORD URLCacheContainers_FindCont
148 if(!lpwszUrl)
149 return ERROR_INVALID_PARAMETER;
150
151 + // ReactOS r54992
152 + if (!bDefaultContainersAdded)
153 + URLCacheContainers_CreateDefaults();
154 +
155 LIST_FOR_EACH_ENTRY(pContainer, &UrlContainers, URLCACHECONTAINER, entry)
156 {
157 int prefix_len = strlenW(pContainer->cache_prefix);
158 @@ -642,6 +657,10 @@ static BOOL URLCacheContainers_Enum(LPCW
159 if (lpwszSearchPattern && dwIndex > 0)
160 return FALSE;
161
162 + // ReactOS r54992
163 + if (!bDefaultContainersAdded)
164 + URLCacheContainers_CreateDefaults();
165 +
166 LIST_FOR_EACH_ENTRY(pContainer, &UrlContainers, URLCACHECONTAINER, entry)
167 {
168 if (lpwszSearchPattern)
169 @@ -1579,6 +1598,10 @@ BOOL WINAPI FreeUrlCacheSpaceW(LPCWSTR l
170 return FALSE;
171 }
172
173 + // ReactOS r54992
174 + if (!bDefaultContainersAdded)
175 + URLCacheContainers_CreateDefaults();
176 +
177 LIST_FOR_EACH_ENTRY(pContainer, &UrlContainers, URLCACHECONTAINER, entry)
178 {
179 /* The URL cache has prefix L"" (unlike Cookies and History) */
180 --- wine-1.5.4/dlls/wininet/http.c 2012-06-20 15:19:57 +0200
181 +++ dll/win32/wininet/http.c 2012-06-20 16:24:11 +0200
182 @@ -73,6 +73,9 @@
183 #include "wine/exception.h"
184 #include "wine/unicode.h"
185
186 +// ReactOS
187 +#include "inet_ntop.c"
188 +
189 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
190
191 static const WCHAR g_szHttp1_0[] = {'H','T','T','P','/','1','.','0',0};
192 @@ -241,8 +244,17 @@ void server_release(server_t *server)
193 if(InterlockedDecrement(&server->ref))
194 return;
195
196 +#ifndef __REACTOS__
197 if(!server->ref)
198 - server->keep_until = GetTickCount64() + COLLECT_TIME;
199 + server->keep_until = (DWORD64)GetTickCount() + COLLECT_TIME;
200 +#else
201 + EnterCriticalSection(&connection_pool_cs);
202 + list_remove(&server->entry);
203 + LeaveCriticalSection(&connection_pool_cs);
204 +
205 + heap_free(server->name);
206 + heap_free(server);
207 +#endif
208 }
209
210 static server_t *get_server(const WCHAR *name, INTERNET_PORT port)
211 @@ -288,7 +300,7 @@ BOOL collect_connections(BOOL collect_al
212 BOOL remaining = FALSE;
213 DWORD64 now;
214
215 - now = GetTickCount64();
216 + now = GetTickCount();
217
218 LIST_FOR_EACH_ENTRY_SAFE(server, server_safe, &connection_pool, server_t, entry) {
219 LIST_FOR_EACH_ENTRY_SAFE(netconn, netconn_safe, &server->conn_pool, netconn_t, pool_entry) {
220 @@ -1854,13 +1866,14 @@ static void http_release_netconn(http_re
221 if(!req->netconn)
222 return;
223
224 +#ifndef __REACTOS__
225 if(reuse && req->netconn->keep_alive) {
226 BOOL run_collector;
227
228 EnterCriticalSection(&connection_pool_cs);
229
230 list_add_head(&req->netconn->server->conn_pool, &req->netconn->pool_entry);
231 - req->netconn->keep_until = GetTickCount64() + COLLECT_TIME;
232 + req->netconn->keep_until = (DWORD64)GetTickCount() + COLLECT_TIME;
233 req->netconn = NULL;
234
235 run_collector = !collector_running;
236 @@ -1888,6 +1901,10 @@ static void http_release_netconn(http_re
237 }
238 return;
239 }
240 +#else
241 + // silence unused function warning
242 + (void)collect_connections_proc;
243 +#endif
244
245 INTERNET_SendCallback(&req->hdr, req->hdr.dwContext,
246 INTERNET_STATUS_CLOSING_CONNECTION, 0, 0);