server: Added access rights mapping to token objects.
[wine/multimedia.git] / dlls / wininet / internet.c
blobb91c9ff4c5fb27ee5f34c665be09cf2ee9f436a2
1 /*
2 * Wininet
4 * Copyright 1999 Corel Corporation
5 * Copyright 2002 CodeWeavers Inc.
6 * Copyright 2002 Jaco Greeff
7 * Copyright 2002 TransGaming Technologies Inc.
8 * Copyright 2004 Mike McCormack for CodeWeavers
10 * Ulrich Czekalla
11 * Aric Stewart
12 * David Hammerton
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
24 * You should have received a copy of the GNU Lesser General Public
25 * License along with this library; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include "config.h"
30 #include "wine/port.h"
32 #define MAXHOSTNAME 100 /* from http.c */
34 #include <string.h>
35 #include <stdarg.h>
36 #include <stdio.h>
37 #include <sys/types.h>
38 #ifdef HAVE_SYS_SOCKET_H
39 # include <sys/socket.h>
40 #endif
41 #ifdef HAVE_SYS_TIME_H
42 # include <sys/time.h>
43 #endif
44 #include <stdlib.h>
45 #include <ctype.h>
46 #ifdef HAVE_UNISTD_H
47 # include <unistd.h>
48 #endif
49 #include <assert.h>
51 #include "windef.h"
52 #include "winbase.h"
53 #include "winreg.h"
54 #include "winuser.h"
55 #include "wininet.h"
56 #include "winnls.h"
57 #include "wine/debug.h"
58 #include "winerror.h"
59 #define NO_SHLWAPI_STREAM
60 #include "shlwapi.h"
62 #include "wine/exception.h"
63 #include "excpt.h"
65 #include "internet.h"
66 #include "resource.h"
68 #include "wine/unicode.h"
70 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
72 #define MAX_IDLE_WORKER 1000*60*1
73 #define MAX_WORKER_THREADS 10
74 #define RESPONSE_TIMEOUT 30
76 #define GET_HWININET_FROM_LPWININETFINDNEXT(lpwh) \
77 (LPWININETAPPINFOW)(((LPWININETFTPSESSIONW)(lpwh->hdr.lpwhparent))->hdr.lpwhparent)
80 typedef struct
82 DWORD dwError;
83 CHAR response[MAX_REPLY_LEN];
84 } WITHREADERROR, *LPWITHREADERROR;
86 static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr);
87 BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData);
88 HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
89 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext);
90 static VOID INTERNET_ExecuteWork(void);
92 static DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
93 static LONG dwNumThreads;
94 static LONG dwNumIdleThreads;
95 static LONG dwNumJobs;
96 static HANDLE hEventArray[2];
97 #define hQuitEvent hEventArray[0]
98 #define hWorkEvent hEventArray[1]
99 static CRITICAL_SECTION csQueue;
100 static LPWORKREQUEST lpHeadWorkQueue;
101 static LPWORKREQUEST lpWorkQueueTail;
102 static HMODULE WININET_hModule;
104 #define HANDLE_CHUNK_SIZE 0x10
106 static CRITICAL_SECTION WININET_cs;
107 static CRITICAL_SECTION_DEBUG WININET_cs_debug =
109 0, 0, &WININET_cs,
110 { &WININET_cs_debug.ProcessLocksList, &WININET_cs_debug.ProcessLocksList },
111 0, 0, { (DWORD_PTR)(__FILE__ ": WININET_cs") }
113 static CRITICAL_SECTION WININET_cs = { &WININET_cs_debug, -1, 0, 0, 0, 0 };
115 static LPWININETHANDLEHEADER *WININET_Handles;
116 static UINT WININET_dwNextHandle;
117 static UINT WININET_dwMaxHandles;
119 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info )
121 LPWININETHANDLEHEADER *p;
122 UINT handle = 0, num;
124 EnterCriticalSection( &WININET_cs );
125 if( !WININET_dwMaxHandles )
127 num = HANDLE_CHUNK_SIZE;
128 p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
129 sizeof (UINT)* num);
130 if( !p )
131 goto end;
132 WININET_Handles = p;
133 WININET_dwMaxHandles = num;
135 if( WININET_dwMaxHandles == WININET_dwNextHandle )
137 num = WININET_dwMaxHandles + HANDLE_CHUNK_SIZE;
138 p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
139 WININET_Handles, sizeof (UINT)* num);
140 if( !p )
141 goto end;
142 WININET_Handles = p;
143 WININET_dwMaxHandles = num;
146 handle = WININET_dwNextHandle;
147 if( WININET_Handles[handle] )
148 ERR("handle isn't free but should be\n");
149 WININET_Handles[handle] = WININET_AddRef( info );
151 while( WININET_Handles[WININET_dwNextHandle] &&
152 (WININET_dwNextHandle < WININET_dwMaxHandles ) )
153 WININET_dwNextHandle++;
155 end:
156 LeaveCriticalSection( &WININET_cs );
158 return (HINTERNET) (handle+1);
161 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info )
163 UINT i, handle = 0;
165 EnterCriticalSection( &WININET_cs );
166 for( i=0; i<WININET_dwMaxHandles; i++ )
168 if( info == WININET_Handles[i] )
170 WININET_AddRef( info );
171 handle = i+1;
172 break;
175 LeaveCriticalSection( &WININET_cs );
177 return (HINTERNET) handle;
180 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info )
182 info->dwRefCount++;
183 TRACE("%p -> refcount = %ld\n", info, info->dwRefCount );
184 return info;
187 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
189 LPWININETHANDLEHEADER info = NULL;
190 UINT handle = (UINT) hinternet;
192 EnterCriticalSection( &WININET_cs );
194 if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) &&
195 WININET_Handles[handle-1] )
196 info = WININET_AddRef( WININET_Handles[handle-1] );
198 LeaveCriticalSection( &WININET_cs );
200 TRACE("handle %d -> %p\n", handle, info);
202 return info;
205 BOOL WININET_Release( LPWININETHANDLEHEADER info )
207 info->dwRefCount--;
208 TRACE( "object %p refcount = %ld\n", info, info->dwRefCount );
209 if( !info->dwRefCount )
211 TRACE( "destroying object %p\n", info);
212 info->destroy( info );
214 return TRUE;
217 BOOL WININET_FreeHandle( HINTERNET hinternet )
219 BOOL ret = FALSE;
220 UINT handle = (UINT) hinternet;
221 LPWININETHANDLEHEADER info = NULL;
223 EnterCriticalSection( &WININET_cs );
225 if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) )
227 handle--;
228 if( WININET_Handles[handle] )
230 info = WININET_Handles[handle];
231 TRACE( "destroying handle %d for object %p\n", handle+1, info);
232 WININET_Handles[handle] = NULL;
233 ret = TRUE;
234 if( WININET_dwNextHandle > handle )
235 WININET_dwNextHandle = handle;
239 LeaveCriticalSection( &WININET_cs );
241 if( info )
242 WININET_Release( info );
244 return ret;
247 /***********************************************************************
248 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
250 * PARAMS
251 * hinstDLL [I] handle to the DLL's instance
252 * fdwReason [I]
253 * lpvReserved [I] reserved, must be NULL
255 * RETURNS
256 * Success: TRUE
257 * Failure: FALSE
260 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
262 TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
264 switch (fdwReason) {
265 case DLL_PROCESS_ATTACH:
267 g_dwTlsErrIndex = TlsAlloc();
269 if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
270 return FALSE;
272 hQuitEvent = CreateEventW(0, TRUE, FALSE, NULL);
273 hWorkEvent = CreateEventW(0, FALSE, FALSE, NULL);
274 InitializeCriticalSection(&csQueue);
276 URLCacheContainers_CreateDefaults();
278 dwNumThreads = 0;
279 dwNumIdleThreads = 0;
280 dwNumJobs = 0;
282 WININET_hModule = (HMODULE)hinstDLL;
284 case DLL_THREAD_ATTACH:
286 LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR));
287 if (NULL == lpwite)
288 return FALSE;
290 TlsSetValue(g_dwTlsErrIndex, (LPVOID)lpwite);
292 break;
294 case DLL_THREAD_DETACH:
295 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
297 LPVOID lpwite = TlsGetValue(g_dwTlsErrIndex);
298 HeapFree(GetProcessHeap(), 0, lpwite);
300 break;
302 case DLL_PROCESS_DETACH:
304 URLCacheContainers_DeleteAll();
306 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
308 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex));
309 TlsFree(g_dwTlsErrIndex);
312 SetEvent(hQuitEvent);
314 CloseHandle(hQuitEvent);
315 CloseHandle(hWorkEvent);
316 DeleteCriticalSection(&csQueue);
317 break;
320 return TRUE;
324 /***********************************************************************
325 * InternetInitializeAutoProxyDll (WININET.@)
327 * Setup the internal proxy
329 * PARAMETERS
330 * dwReserved
332 * RETURNS
333 * FALSE on failure
336 BOOL WINAPI InternetInitializeAutoProxyDll(DWORD dwReserved)
338 FIXME("STUB\n");
339 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
340 return FALSE;
343 /***********************************************************************
344 * DetectAutoProxyUrl (WININET.@)
346 * Auto detect the proxy url
348 * RETURNS
349 * FALSE on failure
352 BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl,
353 DWORD dwAutoProxyUrlLength, DWORD dwDetectFlags)
355 FIXME("STUB\n");
356 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
357 return FALSE;
361 /***********************************************************************
362 * INTERNET_ConfigureProxyFromReg
364 * FIXME:
365 * The proxy may be specified in the form 'http=proxy.my.org'
366 * Presumably that means there can be ftp=ftpproxy.my.org too.
368 static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOW lpwai )
370 HKEY key;
371 DWORD r, keytype, len, enabled;
372 LPCSTR lpszInternetSettings =
373 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
374 static const WCHAR szProxyServer[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
376 r = RegOpenKeyA(HKEY_CURRENT_USER, lpszInternetSettings, &key);
377 if ( r != ERROR_SUCCESS )
378 return FALSE;
380 len = sizeof enabled;
381 r = RegQueryValueExA( key, "ProxyEnable", NULL, &keytype,
382 (BYTE*)&enabled, &len);
383 if( (r == ERROR_SUCCESS) && enabled )
385 TRACE("Proxy is enabled.\n");
387 /* figure out how much memory the proxy setting takes */
388 r = RegQueryValueExW( key, szProxyServer, NULL, &keytype,
389 NULL, &len);
390 if( (r == ERROR_SUCCESS) && len && (keytype == REG_SZ) )
392 LPWSTR szProxy, p;
393 static const WCHAR szHttp[] = {'h','t','t','p','=',0};
395 szProxy=HeapAlloc( GetProcessHeap(), 0, len );
396 RegQueryValueExW( key, szProxyServer, NULL, &keytype,
397 (BYTE*)szProxy, &len);
399 /* find the http proxy, and strip away everything else */
400 p = strstrW( szProxy, szHttp );
401 if( p )
403 p += lstrlenW(szHttp);
404 lstrcpyW( szProxy, p );
406 p = strchrW( szProxy, ' ' );
407 if( p )
408 *p = 0;
410 lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY;
411 lpwai->lpszProxy = szProxy;
413 TRACE("http proxy = %s\n", debugstr_w(lpwai->lpszProxy));
415 else
416 ERR("Couldn't read proxy server settings.\n");
418 else
419 TRACE("Proxy is not enabled.\n");
420 RegCloseKey(key);
422 return enabled;
425 /***********************************************************************
426 * dump_INTERNET_FLAGS
428 * Helper function to TRACE the internet flags.
430 * RETURNS
431 * None
434 static void dump_INTERNET_FLAGS(DWORD dwFlags)
436 #define FE(x) { x, #x }
437 static const wininet_flag_info flag[] = {
438 FE(INTERNET_FLAG_RELOAD),
439 FE(INTERNET_FLAG_RAW_DATA),
440 FE(INTERNET_FLAG_EXISTING_CONNECT),
441 FE(INTERNET_FLAG_ASYNC),
442 FE(INTERNET_FLAG_PASSIVE),
443 FE(INTERNET_FLAG_NO_CACHE_WRITE),
444 FE(INTERNET_FLAG_MAKE_PERSISTENT),
445 FE(INTERNET_FLAG_FROM_CACHE),
446 FE(INTERNET_FLAG_SECURE),
447 FE(INTERNET_FLAG_KEEP_CONNECTION),
448 FE(INTERNET_FLAG_NO_AUTO_REDIRECT),
449 FE(INTERNET_FLAG_READ_PREFETCH),
450 FE(INTERNET_FLAG_NO_COOKIES),
451 FE(INTERNET_FLAG_NO_AUTH),
452 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL),
453 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP),
454 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS),
455 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID),
456 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID),
457 FE(INTERNET_FLAG_RESYNCHRONIZE),
458 FE(INTERNET_FLAG_HYPERLINK),
459 FE(INTERNET_FLAG_NO_UI),
460 FE(INTERNET_FLAG_PRAGMA_NOCACHE),
461 FE(INTERNET_FLAG_CACHE_ASYNC),
462 FE(INTERNET_FLAG_FORMS_SUBMIT),
463 FE(INTERNET_FLAG_NEED_FILE),
464 FE(INTERNET_FLAG_TRANSFER_ASCII),
465 FE(INTERNET_FLAG_TRANSFER_BINARY)
467 #undef FE
468 int i;
470 for (i = 0; i < (sizeof(flag) / sizeof(flag[0])); i++) {
471 if (flag[i].val & dwFlags) {
472 TRACE(" %s", flag[i].name);
473 dwFlags &= ~flag[i].val;
476 if (dwFlags)
477 TRACE(" Unknown flags (%08lx)\n", dwFlags);
478 else
479 TRACE("\n");
482 /***********************************************************************
483 * InternetOpenW (WININET.@)
485 * Per-application initialization of wininet
487 * RETURNS
488 * HINTERNET on success
489 * NULL on failure
492 HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
493 LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
495 LPWININETAPPINFOW lpwai = NULL;
496 HINTERNET handle = NULL;
498 if (TRACE_ON(wininet)) {
499 #define FE(x) { x, #x }
500 static const wininet_flag_info access_type[] = {
501 FE(INTERNET_OPEN_TYPE_PRECONFIG),
502 FE(INTERNET_OPEN_TYPE_DIRECT),
503 FE(INTERNET_OPEN_TYPE_PROXY),
504 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY)
506 #undef FE
507 DWORD i;
508 const char *access_type_str = "Unknown";
510 TRACE("(%s, %li, %s, %s, %li)\n", debugstr_w(lpszAgent), dwAccessType,
511 debugstr_w(lpszProxy), debugstr_w(lpszProxyBypass), dwFlags);
512 for (i = 0; i < (sizeof(access_type) / sizeof(access_type[0])); i++) {
513 if (access_type[i].val == dwAccessType) {
514 access_type_str = access_type[i].name;
515 break;
518 TRACE(" access type : %s\n", access_type_str);
519 TRACE(" flags :");
520 dump_INTERNET_FLAGS(dwFlags);
523 /* Clear any error information */
524 INTERNET_SetLastError(0);
526 lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOW));
527 if (NULL == lpwai)
529 INTERNET_SetLastError(ERROR_OUTOFMEMORY);
530 goto lend;
533 memset(lpwai, 0, sizeof(WININETAPPINFOW));
534 lpwai->hdr.htype = WH_HINIT;
535 lpwai->hdr.lpwhparent = NULL;
536 lpwai->hdr.dwFlags = dwFlags;
537 lpwai->hdr.dwRefCount = 1;
538 lpwai->hdr.destroy = INTERNET_CloseHandle;
539 lpwai->dwAccessType = dwAccessType;
540 lpwai->lpszProxyUsername = NULL;
541 lpwai->lpszProxyPassword = NULL;
543 handle = WININET_AllocHandle( &lpwai->hdr );
544 if( !handle )
546 HeapFree( GetProcessHeap(), 0, lpwai );
547 INTERNET_SetLastError(ERROR_OUTOFMEMORY);
548 goto lend;
551 if (NULL != lpszAgent)
553 lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,
554 (strlenW(lpszAgent)+1)*sizeof(WCHAR));
555 if (lpwai->lpszAgent)
556 lstrcpyW( lpwai->lpszAgent, lpszAgent );
558 if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG)
559 INTERNET_ConfigureProxyFromReg( lpwai );
560 else if (NULL != lpszProxy)
562 lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0,
563 (strlenW(lpszProxy)+1)*sizeof(WCHAR));
564 if (lpwai->lpszProxy)
565 lstrcpyW( lpwai->lpszProxy, lpszProxy );
568 if (NULL != lpszProxyBypass)
570 lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0,
571 (strlenW(lpszProxyBypass)+1)*sizeof(WCHAR));
572 if (lpwai->lpszProxyBypass)
573 lstrcpyW( lpwai->lpszProxyBypass, lpszProxyBypass );
576 lend:
577 if( lpwai )
578 WININET_Release( &lpwai->hdr );
580 TRACE("returning %p\n", lpwai);
582 return handle;
586 /***********************************************************************
587 * InternetOpenA (WININET.@)
589 * Per-application initialization of wininet
591 * RETURNS
592 * HINTERNET on success
593 * NULL on failure
596 HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
597 LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
599 HINTERNET rc = (HINTERNET)NULL;
600 INT len;
601 WCHAR *szAgent = NULL, *szProxy = NULL, *szBypass = NULL;
603 TRACE("(%s, 0x%08lx, %s, %s, 0x%08lx)\n", debugstr_a(lpszAgent),
604 dwAccessType, debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
606 if( lpszAgent )
608 len = MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, NULL, 0);
609 szAgent = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
610 MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, szAgent, len);
613 if( lpszProxy )
615 len = MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, NULL, 0);
616 szProxy = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
617 MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, szProxy, len);
620 if( lpszProxyBypass )
622 len = MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, NULL, 0);
623 szBypass = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
624 MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, szBypass, len);
627 rc = InternetOpenW(szAgent, dwAccessType, szProxy, szBypass, dwFlags);
629 HeapFree(GetProcessHeap(), 0, szAgent);
630 HeapFree(GetProcessHeap(), 0, szProxy);
631 HeapFree(GetProcessHeap(), 0, szBypass);
633 return rc;
636 /***********************************************************************
637 * InternetGetLastResponseInfoA (WININET.@)
639 * Return last wininet error description on the calling thread
641 * RETURNS
642 * TRUE on success of writing to buffer
643 * FALSE on failure
646 BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
647 LPSTR lpszBuffer, LPDWORD lpdwBufferLength)
649 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
651 TRACE("\n");
653 *lpdwError = lpwite->dwError;
654 if (lpwite->dwError)
656 memcpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
657 *lpdwBufferLength = strlen(lpszBuffer);
659 else
660 *lpdwBufferLength = 0;
662 return TRUE;
665 /***********************************************************************
666 * InternetGetLastResponseInfoW (WININET.@)
668 * Return last wininet error description on the calling thread
670 * RETURNS
671 * TRUE on success of writing to buffer
672 * FALSE on failure
675 BOOL WINAPI InternetGetLastResponseInfoW(LPDWORD lpdwError,
676 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength)
678 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
680 TRACE("\n");
682 *lpdwError = lpwite->dwError;
683 if (lpwite->dwError)
685 memcpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
686 *lpdwBufferLength = lstrlenW(lpszBuffer);
688 else
689 *lpdwBufferLength = 0;
691 return TRUE;
694 /***********************************************************************
695 * InternetGetConnectedState (WININET.@)
697 * Return connected state
699 * RETURNS
700 * TRUE if connected
701 * if lpdwStatus is not null, return the status (off line,
702 * modem, lan...) in it.
703 * FALSE if not connected
705 BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved)
707 TRACE("(%p, 0x%08lx)\n", lpdwStatus, dwReserved);
709 if (lpdwStatus) {
710 FIXME("always returning LAN connection.\n");
711 *lpdwStatus = INTERNET_CONNECTION_LAN;
713 return TRUE;
717 /***********************************************************************
718 * InternetGetConnectedStateExW (WININET.@)
720 * Return connected state
722 * PARAMS
724 * lpdwStatus [O] Flags specifying the status of the internet connection.
725 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
726 * dwNameLen [I] Size of the buffer, in characters.
727 * dwReserved [I] Reserved. Must be set to 0.
729 * RETURNS
730 * TRUE if connected
731 * if lpdwStatus is not null, return the status (off line,
732 * modem, lan...) in it.
733 * FALSE if not connected
735 * NOTES
736 * If the system has no available network connections, an empty string is
737 * stored in lpszConnectionName. If there is a LAN connection, a localized
738 * "LAN Connection" string is stored. Presumably, if only a dial-up
739 * connection is available then the name of the dial-up connection is
740 * returned. Why any application, other than the "Internet Settings" CPL,
741 * would want to use this function instead of the simpler InternetGetConnectedStateW
742 * function is beyond me.
744 BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnectionName,
745 DWORD dwNameLen, DWORD dwReserved)
747 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
749 /* Must be zero */
750 if(dwReserved)
751 return FALSE;
753 if (lpdwStatus) {
754 FIXME("always returning LAN connection.\n");
755 *lpdwStatus = INTERNET_CONNECTION_LAN;
757 return LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen);
761 /***********************************************************************
762 * InternetGetConnectedStateExA (WININET.@)
764 BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectionName,
765 DWORD dwNameLen, DWORD dwReserved)
767 LPWSTR lpwszConnectionName = NULL;
768 BOOL rc;
770 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
772 if (lpszConnectionName && dwNameLen > 0)
773 lpwszConnectionName= HeapAlloc(GetProcessHeap(), 0, dwNameLen * sizeof(WCHAR));
775 rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen,
776 dwReserved);
777 if (rc && lpwszConnectionName)
779 WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName,
780 dwNameLen, NULL, NULL);
782 HeapFree(GetProcessHeap(),0,lpwszConnectionName);
785 return rc;
789 /***********************************************************************
790 * InternetConnectW (WININET.@)
792 * Open a ftp, gopher or http session
794 * RETURNS
795 * HINTERNET a session handle on success
796 * NULL on failure
799 HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
800 LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
801 LPCWSTR lpszUserName, LPCWSTR lpszPassword,
802 DWORD dwService, DWORD dwFlags, DWORD dwContext)
804 LPWININETAPPINFOW hIC;
805 HINTERNET rc = (HINTERNET) NULL;
807 TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet, debugstr_w(lpszServerName),
808 nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword),
809 dwService, dwFlags, dwContext);
811 /* Clear any error information */
812 INTERNET_SetLastError(0);
813 hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
814 if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
815 goto lend;
817 switch (dwService)
819 case INTERNET_SERVICE_FTP:
820 rc = FTP_Connect(hIC, lpszServerName, nServerPort,
821 lpszUserName, lpszPassword, dwFlags, dwContext, 0);
822 break;
824 case INTERNET_SERVICE_HTTP:
825 rc = HTTP_Connect(hIC, lpszServerName, nServerPort,
826 lpszUserName, lpszPassword, dwFlags, dwContext, 0);
827 break;
829 case INTERNET_SERVICE_GOPHER:
830 default:
831 break;
833 lend:
834 if( hIC )
835 WININET_Release( &hIC->hdr );
837 TRACE("returning %p\n", rc);
838 return rc;
842 /***********************************************************************
843 * InternetConnectA (WININET.@)
845 * Open a ftp, gopher or http session
847 * RETURNS
848 * HINTERNET a session handle on success
849 * NULL on failure
852 HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
853 LPCSTR lpszServerName, INTERNET_PORT nServerPort,
854 LPCSTR lpszUserName, LPCSTR lpszPassword,
855 DWORD dwService, DWORD dwFlags, DWORD dwContext)
857 HINTERNET rc = (HINTERNET)NULL;
858 INT len = 0;
859 LPWSTR szServerName = NULL;
860 LPWSTR szUserName = NULL;
861 LPWSTR szPassword = NULL;
863 if (lpszServerName)
865 len = MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, NULL, 0);
866 szServerName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
867 MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, szServerName, len);
869 if (lpszUserName)
871 len = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
872 szUserName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
873 MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, szUserName, len);
875 if (lpszPassword)
877 len = MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, NULL, 0);
878 szPassword = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
879 MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, szPassword, len);
883 rc = InternetConnectW(hInternet, szServerName, nServerPort,
884 szUserName, szPassword, dwService, dwFlags, dwContext);
886 HeapFree(GetProcessHeap(), 0, szServerName);
887 HeapFree(GetProcessHeap(), 0, szUserName);
888 HeapFree(GetProcessHeap(), 0, szPassword);
889 return rc;
893 /***********************************************************************
894 * InternetFindNextFileA (WININET.@)
896 * Continues a file search from a previous call to FindFirstFile
898 * RETURNS
899 * TRUE on success
900 * FALSE on failure
903 BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
905 BOOL ret;
906 WIN32_FIND_DATAW fd;
908 ret = InternetFindNextFileW(hFind, lpvFindData?&fd:NULL);
909 if(lpvFindData)
910 WININET_find_data_WtoA(&fd, (LPWIN32_FIND_DATAA)lpvFindData);
911 return ret;
914 /***********************************************************************
915 * InternetFindNextFileW (WININET.@)
917 * Continues a file search from a previous call to FindFirstFile
919 * RETURNS
920 * TRUE on success
921 * FALSE on failure
924 BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
926 LPWININETAPPINFOW hIC = NULL;
927 LPWININETFINDNEXTW lpwh;
928 BOOL bSuccess = FALSE;
930 TRACE("\n");
932 lpwh = (LPWININETFINDNEXTW) WININET_GetObject( hFind );
933 if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
935 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
936 goto lend;
939 hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
940 if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
942 WORKREQUEST workRequest;
943 struct WORKREQ_INTERNETFINDNEXTW *req;
945 workRequest.asyncall = INTERNETFINDNEXTW;
946 workRequest.hdr = WININET_AddRef( &lpwh->hdr );
947 req = &workRequest.u.InternetFindNextW;
948 req->lpFindFileData = lpvFindData;
950 bSuccess = INTERNET_AsyncCall(&workRequest);
952 else
954 bSuccess = INTERNET_FindNextFileW(lpwh, lpvFindData);
956 lend:
957 if( lpwh )
958 WININET_Release( &lpwh->hdr );
959 return bSuccess;
962 /***********************************************************************
963 * INTERNET_FindNextFileW (Internal)
965 * Continues a file search from a previous call to FindFirstFile
967 * RETURNS
968 * TRUE on success
969 * FALSE on failure
972 BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData)
974 BOOL bSuccess = TRUE;
975 LPWIN32_FIND_DATAW lpFindFileData;
977 TRACE("\n");
979 assert (lpwh->hdr.htype == WH_HFINDNEXT);
981 /* Clear any error information */
982 INTERNET_SetLastError(0);
984 if (lpwh->hdr.lpwhparent->htype != WH_HFTPSESSION)
986 FIXME("Only FTP find next supported\n");
987 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
988 return FALSE;
991 TRACE("index(%ld) size(%ld)\n", lpwh->index, lpwh->size);
993 lpFindFileData = (LPWIN32_FIND_DATAW) lpvFindData;
994 ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
996 if (lpwh->index >= lpwh->size)
998 INTERNET_SetLastError(ERROR_NO_MORE_FILES);
999 bSuccess = FALSE;
1000 goto lend;
1003 FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
1004 lpwh->index++;
1006 TRACE("\nName: %s\nSize: %ld\n", debugstr_w(lpFindFileData->cFileName), lpFindFileData->nFileSizeLow);
1008 lend:
1010 if (lpwh->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1012 INTERNET_ASYNC_RESULT iar;
1014 iar.dwResult = (DWORD)bSuccess;
1015 iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
1016 INTERNET_GetLastError();
1018 INTERNET_SendCallback(&lpwh->hdr, lpwh->hdr.dwContext,
1019 INTERNET_STATUS_REQUEST_COMPLETE, &iar,
1020 sizeof(INTERNET_ASYNC_RESULT));
1023 return bSuccess;
1027 /***********************************************************************
1028 * INTERNET_CloseHandle (internal)
1030 * Close internet handle
1032 * RETURNS
1033 * Void
1036 static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr)
1038 LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW) hdr;
1040 TRACE("%p\n",lpwai);
1042 HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
1043 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxy);
1044 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
1045 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyUsername);
1046 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyPassword);
1047 HeapFree(GetProcessHeap(), 0, lpwai);
1051 /***********************************************************************
1052 * InternetCloseHandle (WININET.@)
1054 * Generic close handle function
1056 * RETURNS
1057 * TRUE on success
1058 * FALSE on failure
1061 BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
1063 LPWININETHANDLEHEADER lpwh;
1065 TRACE("%p\n",hInternet);
1067 lpwh = WININET_GetObject( hInternet );
1068 if (NULL == lpwh)
1070 INTERNET_SetLastError(ERROR_INVALID_HANDLE);
1071 return FALSE;
1074 /* FIXME: native appears to send this from the equivalent of
1075 * WININET_Release */
1076 INTERNET_SendCallback(lpwh, lpwh->dwContext,
1077 INTERNET_STATUS_HANDLE_CLOSING, &hInternet,
1078 sizeof(HINTERNET));
1080 if( lpwh->lpwhparent )
1081 WININET_Release( lpwh->lpwhparent );
1082 WININET_FreeHandle( hInternet );
1083 WININET_Release( lpwh );
1085 return TRUE;
1089 /***********************************************************************
1090 * ConvertUrlComponentValue (Internal)
1092 * Helper function for InternetCrackUrlW
1095 static void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
1096 LPWSTR lpwszComponent, DWORD dwwComponentLen,
1097 LPCSTR lpszStart, LPCWSTR lpwszStart)
1099 TRACE("%p %p %p %ld %p %p\n", lppszComponent, dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart);
1100 if (*dwComponentLen != 0)
1102 DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
1103 if (*lppszComponent == NULL)
1105 int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL);
1106 *lppszComponent = (LPSTR)lpszStart+nASCIIOffset;
1107 *dwComponentLen = nASCIILength;
1109 else
1111 DWORD ncpylen = min((*dwComponentLen)-1, nASCIILength);
1112 WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,*lppszComponent,ncpylen+1,NULL,NULL);
1113 (*lppszComponent)[ncpylen]=0;
1114 *dwComponentLen = ncpylen;
1120 /***********************************************************************
1121 * InternetCrackUrlA (WININET.@)
1123 * Break up URL into its components
1125 * TODO: Handle dwFlags
1127 * RETURNS
1128 * TRUE on success
1129 * FALSE on failure
1132 BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
1133 LPURL_COMPONENTSA lpUrlComponents)
1135 DWORD nLength;
1136 URL_COMPONENTSW UCW;
1137 WCHAR* lpwszUrl;
1139 TRACE("(%s %lu %lx %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents);
1140 if(dwUrlLength<=0)
1141 dwUrlLength=-1;
1142 nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,NULL,0);
1144 /* if dwUrlLength=-1 then nLength includes null but length to
1145 InternetCrackUrlW should not include it */
1146 if (dwUrlLength == -1) nLength--;
1148 lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength);
1149 MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
1151 memset(&UCW,0,sizeof(UCW));
1152 if(lpUrlComponents->dwHostNameLength!=0)
1153 UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength;
1154 if(lpUrlComponents->dwUserNameLength!=0)
1155 UCW.dwUserNameLength=lpUrlComponents->dwUserNameLength;
1156 if(lpUrlComponents->dwPasswordLength!=0)
1157 UCW.dwPasswordLength=lpUrlComponents->dwPasswordLength;
1158 if(lpUrlComponents->dwUrlPathLength!=0)
1159 UCW.dwUrlPathLength=lpUrlComponents->dwUrlPathLength;
1160 if(lpUrlComponents->dwSchemeLength!=0)
1161 UCW.dwSchemeLength=lpUrlComponents->dwSchemeLength;
1162 if(lpUrlComponents->dwExtraInfoLength!=0)
1163 UCW.dwExtraInfoLength=lpUrlComponents->dwExtraInfoLength;
1164 if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
1166 HeapFree(GetProcessHeap(), 0, lpwszUrl);
1167 return FALSE;
1170 ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
1171 UCW.lpszHostName, UCW.dwHostNameLength,
1172 lpszUrl, lpwszUrl);
1173 ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
1174 UCW.lpszUserName, UCW.dwUserNameLength,
1175 lpszUrl, lpwszUrl);
1176 ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
1177 UCW.lpszPassword, UCW.dwPasswordLength,
1178 lpszUrl, lpwszUrl);
1179 ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
1180 UCW.lpszUrlPath, UCW.dwUrlPathLength,
1181 lpszUrl, lpwszUrl);
1182 ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
1183 UCW.lpszScheme, UCW.dwSchemeLength,
1184 lpszUrl, lpwszUrl);
1185 ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
1186 UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
1187 lpszUrl, lpwszUrl);
1188 lpUrlComponents->nScheme=UCW.nScheme;
1189 lpUrlComponents->nPort=UCW.nPort;
1190 HeapFree(GetProcessHeap(), 0, lpwszUrl);
1192 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
1193 debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength),
1194 debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength),
1195 debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength),
1196 debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength));
1198 return TRUE;
1201 /***********************************************************************
1202 * GetInternetSchemeW (internal)
1204 * Get scheme of url
1206 * RETURNS
1207 * scheme on success
1208 * INTERNET_SCHEME_UNKNOWN on failure
1211 static INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, DWORD nMaxCmp)
1213 INTERNET_SCHEME iScheme=INTERNET_SCHEME_UNKNOWN;
1214 static const WCHAR lpszFtp[]={'f','t','p',0};
1215 static const WCHAR lpszGopher[]={'g','o','p','h','e','r',0};
1216 static const WCHAR lpszHttp[]={'h','t','t','p',0};
1217 static const WCHAR lpszHttps[]={'h','t','t','p','s',0};
1218 static const WCHAR lpszFile[]={'f','i','l','e',0};
1219 static const WCHAR lpszNews[]={'n','e','w','s',0};
1220 static const WCHAR lpszMailto[]={'m','a','i','l','t','o',0};
1221 static const WCHAR lpszRes[]={'r','e','s',0};
1222 WCHAR* tempBuffer=NULL;
1223 TRACE("%s %ld\n",debugstr_wn(lpszScheme, nMaxCmp), nMaxCmp);
1224 if(lpszScheme==NULL)
1225 return INTERNET_SCHEME_UNKNOWN;
1227 tempBuffer=HeapAlloc(GetProcessHeap(),0,(nMaxCmp+1)*sizeof(WCHAR));
1228 lstrcpynW(tempBuffer,lpszScheme,nMaxCmp+1);
1229 strlwrW(tempBuffer);
1230 if (nMaxCmp==strlenW(lpszFtp) && !strncmpW(lpszFtp, tempBuffer, nMaxCmp))
1231 iScheme=INTERNET_SCHEME_FTP;
1232 else if (nMaxCmp==strlenW(lpszGopher) && !strncmpW(lpszGopher, tempBuffer, nMaxCmp))
1233 iScheme=INTERNET_SCHEME_GOPHER;
1234 else if (nMaxCmp==strlenW(lpszHttp) && !strncmpW(lpszHttp, tempBuffer, nMaxCmp))
1235 iScheme=INTERNET_SCHEME_HTTP;
1236 else if (nMaxCmp==strlenW(lpszHttps) && !strncmpW(lpszHttps, tempBuffer, nMaxCmp))
1237 iScheme=INTERNET_SCHEME_HTTPS;
1238 else if (nMaxCmp==strlenW(lpszFile) && !strncmpW(lpszFile, tempBuffer, nMaxCmp))
1239 iScheme=INTERNET_SCHEME_FILE;
1240 else if (nMaxCmp==strlenW(lpszNews) && !strncmpW(lpszNews, tempBuffer, nMaxCmp))
1241 iScheme=INTERNET_SCHEME_NEWS;
1242 else if (nMaxCmp==strlenW(lpszMailto) && !strncmpW(lpszMailto, tempBuffer, nMaxCmp))
1243 iScheme=INTERNET_SCHEME_MAILTO;
1244 else if (nMaxCmp==strlenW(lpszRes) && !strncmpW(lpszRes, tempBuffer, nMaxCmp))
1245 iScheme=INTERNET_SCHEME_RES;
1246 HeapFree(GetProcessHeap(),0,tempBuffer);
1247 return iScheme;
1250 /***********************************************************************
1251 * SetUrlComponentValueW (Internal)
1253 * Helper function for InternetCrackUrlW
1255 * PARAMS
1256 * lppszComponent [O] Holds the returned string
1257 * dwComponentLen [I] Holds the size of lppszComponent
1258 * [O] Holds the length of the string in lppszComponent without '\0'
1259 * lpszStart [I] Holds the string to copy from
1260 * len [I] Holds the length of lpszStart without '\0'
1262 * RETURNS
1263 * TRUE on success
1264 * FALSE on failure
1267 static BOOL SetUrlComponentValueW(LPWSTR* lppszComponent, LPDWORD dwComponentLen, LPCWSTR lpszStart, DWORD len)
1269 TRACE("%s (%ld)\n", debugstr_wn(lpszStart,len), len);
1271 if ( (*dwComponentLen == 0) && (*lppszComponent == NULL) )
1272 return FALSE;
1274 if (*dwComponentLen != 0 || *lppszComponent == NULL)
1276 if (*lppszComponent == NULL)
1278 *lppszComponent = (LPWSTR)lpszStart;
1279 *dwComponentLen = len;
1281 else
1283 DWORD ncpylen = min((*dwComponentLen)-1, len);
1284 memcpy(*lppszComponent, lpszStart, ncpylen*sizeof(WCHAR));
1285 (*lppszComponent)[ncpylen] = '\0';
1286 *dwComponentLen = ncpylen;
1290 return TRUE;
1293 /***********************************************************************
1294 * InternetCrackUrlW (WININET.@)
1296 BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWORD dwFlags,
1297 LPURL_COMPONENTSW lpUC)
1300 * RFC 1808
1301 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1304 LPCWSTR lpszParam = NULL;
1305 BOOL bIsAbsolute = FALSE;
1306 LPCWSTR lpszap, lpszUrl = lpszUrl_orig;
1307 LPCWSTR lpszcp = NULL;
1308 LPWSTR lpszUrl_decode = NULL;
1309 DWORD dwUrlLength = dwUrlLength_orig;
1310 const WCHAR lpszSeparators[3]={';','?',0};
1311 const WCHAR lpszSlash[2]={'/',0};
1312 if(dwUrlLength==0)
1313 dwUrlLength=strlenW(lpszUrl);
1315 TRACE("(%s %lu %lx %p)\n", debugstr_w(lpszUrl), dwUrlLength, dwFlags, lpUC);
1316 if (dwFlags & ICU_DECODE)
1318 lpszUrl_decode=HeapAlloc( GetProcessHeap(), 0, dwUrlLength * sizeof (WCHAR) );
1319 if( InternetCanonicalizeUrlW(lpszUrl_orig, lpszUrl_decode, &dwUrlLength, dwFlags))
1321 lpszUrl = lpszUrl_decode;
1324 lpszap = lpszUrl;
1326 /* Determine if the URI is absolute. */
1327 while (*lpszap != '\0')
1329 if (isalnumW(*lpszap))
1331 lpszap++;
1332 continue;
1334 if ((*lpszap == ':') && (lpszap - lpszUrl >= 2))
1336 bIsAbsolute = TRUE;
1337 lpszcp = lpszap;
1339 else
1341 lpszcp = lpszUrl; /* Relative url */
1344 break;
1347 /* Parse <params> */
1348 lpszParam = strpbrkW(lpszap, lpszSeparators);
1349 if (lpszParam != NULL)
1351 SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
1352 lpszParam, dwUrlLength-(lpszParam-lpszUrl));
1355 if (bIsAbsolute) /* Parse <protocol>:[//<net_loc>] */
1357 LPCWSTR lpszNetLoc;
1358 static const WCHAR wszAbout[]={'a','b','o','u','t',':',0};
1360 /* Get scheme first. */
1361 lpUC->nScheme = GetInternetSchemeW(lpszUrl, lpszcp - lpszUrl);
1362 SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength,
1363 lpszUrl, lpszcp - lpszUrl);
1365 /* Eat ':' in protocol. */
1366 lpszcp++;
1368 /* if the scheme is "about", there is no host */
1369 if(strncmpW(wszAbout,lpszUrl, lpszcp - lpszUrl)==0)
1371 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1372 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1373 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
1374 lpUC->nPort = 0;
1376 else
1378 /* Skip over slashes. */
1379 if (*lpszcp == '/')
1381 lpszcp++;
1382 if (*lpszcp == '/')
1384 lpszcp++;
1385 if (*lpszcp == '/')
1386 lpszcp++;
1390 lpszNetLoc = strpbrkW(lpszcp, lpszSlash);
1391 if (lpszParam)
1393 if (lpszNetLoc)
1394 lpszNetLoc = min(lpszNetLoc, lpszParam);
1395 else
1396 lpszNetLoc = lpszParam;
1398 else if (!lpszNetLoc)
1399 lpszNetLoc = lpszcp + dwUrlLength-(lpszcp-lpszUrl);
1401 /* Parse net-loc */
1402 if (lpszNetLoc)
1404 LPCWSTR lpszHost;
1405 LPCWSTR lpszPort;
1407 /* [<user>[<:password>]@]<host>[:<port>] */
1408 /* First find the user and password if they exist */
1410 lpszHost = strchrW(lpszcp, '@');
1411 if (lpszHost == NULL || lpszHost > lpszNetLoc)
1413 /* username and password not specified. */
1414 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1415 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1417 else /* Parse out username and password */
1419 LPCWSTR lpszUser = lpszcp;
1420 LPCWSTR lpszPasswd = lpszHost;
1422 while (lpszcp < lpszHost)
1424 if (*lpszcp == ':')
1425 lpszPasswd = lpszcp;
1427 lpszcp++;
1430 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength,
1431 lpszUser, lpszPasswd - lpszUser);
1433 if (lpszPasswd != lpszHost)
1434 lpszPasswd++;
1435 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength,
1436 lpszPasswd == lpszHost ? NULL : lpszPasswd,
1437 lpszHost - lpszPasswd);
1439 lpszcp++; /* Advance to beginning of host */
1442 /* Parse <host><:port> */
1444 lpszHost = lpszcp;
1445 lpszPort = lpszNetLoc;
1447 /* special case for res:// URLs: there is no port here, so the host is the
1448 entire string up to the first '/' */
1449 if(lpUC->nScheme==INTERNET_SCHEME_RES)
1451 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1452 lpszHost, lpszPort - lpszHost);
1453 lpUC->nPort = 0;
1454 lpszcp=lpszNetLoc;
1456 else
1458 while (lpszcp < lpszNetLoc)
1460 if (*lpszcp == ':')
1461 lpszPort = lpszcp;
1463 lpszcp++;
1466 /* If the scheme is "file" and the host is just one letter, it's not a host */
1467 if(lpUC->nScheme==INTERNET_SCHEME_FILE && (lpszPort-lpszHost)==1)
1469 lpszcp=lpszHost;
1470 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1471 NULL, 0);
1472 lpUC->nPort = 0;
1474 else
1476 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1477 lpszHost, lpszPort - lpszHost);
1478 if (lpszPort != lpszNetLoc)
1479 lpUC->nPort = atoiW(++lpszPort);
1480 else
1481 lpUC->nPort = 0;
1488 /* Here lpszcp points to:
1490 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1491 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1493 if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam))
1495 INT len;
1497 /* Only truncate the parameter list if it's already been saved
1498 * in lpUC->lpszExtraInfo.
1500 if (lpszParam && lpUC->dwExtraInfoLength && lpUC->lpszExtraInfo)
1501 len = lpszParam - lpszcp;
1502 else
1504 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1505 * newlines if necessary.
1507 LPWSTR lpsznewline = strchrW(lpszcp, '\n');
1508 if (lpsznewline != NULL)
1509 len = lpsznewline - lpszcp;
1510 else
1511 len = dwUrlLength-(lpszcp-lpszUrl);
1513 SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
1514 lpszcp, len);
1516 else
1518 lpUC->dwUrlPathLength = 0;
1521 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
1522 debugstr_wn(lpUC->lpszScheme,lpUC->dwSchemeLength),
1523 debugstr_wn(lpUC->lpszHostName,lpUC->dwHostNameLength),
1524 debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
1525 debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
1527 if (lpszUrl_decode)
1528 HeapFree(GetProcessHeap(), 0, lpszUrl_decode );
1529 return TRUE;
1532 /***********************************************************************
1533 * InternetAttemptConnect (WININET.@)
1535 * Attempt to make a connection to the internet
1537 * RETURNS
1538 * ERROR_SUCCESS on success
1539 * Error value on failure
1542 DWORD WINAPI InternetAttemptConnect(DWORD dwReserved)
1544 FIXME("Stub\n");
1545 return ERROR_SUCCESS;
1549 /***********************************************************************
1550 * InternetCanonicalizeUrlA (WININET.@)
1552 * Escape unsafe characters and spaces
1554 * RETURNS
1555 * TRUE on success
1556 * FALSE on failure
1559 BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
1560 LPDWORD lpdwBufferLength, DWORD dwFlags)
1562 HRESULT hr;
1563 DWORD dwURLFlags= 0x80000000; /* Don't know what this means */
1564 if(dwFlags & ICU_DECODE)
1566 dwURLFlags |= URL_UNESCAPE;
1567 dwFlags &= ~ICU_DECODE;
1570 if(dwFlags & ICU_ESCAPE)
1572 dwURLFlags |= URL_UNESCAPE;
1573 dwFlags &= ~ICU_ESCAPE;
1575 if(dwFlags & ICU_BROWSER_MODE)
1577 dwURLFlags |= URL_BROWSER_MODE;
1578 dwFlags &= ~ICU_BROWSER_MODE;
1580 if(dwFlags)
1581 FIXME("Unhandled flags 0x%08lx\n", dwFlags);
1582 TRACE("%s %p %p %08lx\n", debugstr_a(lpszUrl), lpszBuffer,
1583 lpdwBufferLength, dwURLFlags);
1585 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1586 dwFlags ^= ICU_NO_ENCODE;
1588 hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
1590 return (hr == S_OK) ? TRUE : FALSE;
1593 /***********************************************************************
1594 * InternetCanonicalizeUrlW (WININET.@)
1596 * Escape unsafe characters and spaces
1598 * RETURNS
1599 * TRUE on success
1600 * FALSE on failure
1603 BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
1604 LPDWORD lpdwBufferLength, DWORD dwFlags)
1606 HRESULT hr;
1607 DWORD dwURLFlags= 0x80000000; /* Don't know what this means */
1608 if(dwFlags & ICU_DECODE)
1610 dwURLFlags |= URL_UNESCAPE;
1611 dwFlags &= ~ICU_DECODE;
1614 if(dwFlags & ICU_ESCAPE)
1616 dwURLFlags |= URL_UNESCAPE;
1617 dwFlags &= ~ICU_ESCAPE;
1619 if(dwFlags & ICU_BROWSER_MODE)
1621 dwURLFlags |= URL_BROWSER_MODE;
1622 dwFlags &= ~ICU_BROWSER_MODE;
1624 if(dwFlags)
1625 FIXME("Unhandled flags 0x%08lx\n", dwFlags);
1626 TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl), lpszBuffer,
1627 lpdwBufferLength, dwURLFlags);
1629 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1630 dwFlags ^= ICU_NO_ENCODE;
1632 hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
1634 return (hr == S_OK) ? TRUE : FALSE;
1638 /***********************************************************************
1639 * InternetSetStatusCallbackA (WININET.@)
1641 * Sets up a callback function which is called as progress is made
1642 * during an operation.
1644 * RETURNS
1645 * Previous callback or NULL on success
1646 * INTERNET_INVALID_STATUS_CALLBACK on failure
1649 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
1650 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1652 INTERNET_STATUS_CALLBACK retVal;
1653 LPWININETHANDLEHEADER lpwh;
1655 TRACE("0x%08lx\n", (ULONG)hInternet);
1657 lpwh = WININET_GetObject(hInternet);
1658 if (!lpwh)
1659 return INTERNET_INVALID_STATUS_CALLBACK;
1661 lpwh->dwInternalFlags &= ~INET_CALLBACKW;
1662 retVal = lpwh->lpfnStatusCB;
1663 lpwh->lpfnStatusCB = lpfnIntCB;
1665 WININET_Release( lpwh );
1667 return retVal;
1670 /***********************************************************************
1671 * InternetSetStatusCallbackW (WININET.@)
1673 * Sets up a callback function which is called as progress is made
1674 * during an operation.
1676 * RETURNS
1677 * Previous callback or NULL on success
1678 * INTERNET_INVALID_STATUS_CALLBACK on failure
1681 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(
1682 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1684 INTERNET_STATUS_CALLBACK retVal;
1685 LPWININETHANDLEHEADER lpwh;
1687 TRACE("0x%08lx\n", (ULONG)hInternet);
1689 lpwh = WININET_GetObject(hInternet);
1690 if (!lpwh)
1691 return INTERNET_INVALID_STATUS_CALLBACK;
1693 lpwh->dwInternalFlags |= INET_CALLBACKW;
1694 retVal = lpwh->lpfnStatusCB;
1695 lpwh->lpfnStatusCB = lpfnIntCB;
1697 WININET_Release( lpwh );
1699 return retVal;
1702 /***********************************************************************
1703 * InternetSetFilePointer (WININET.@)
1705 DWORD WINAPI InternetSetFilePointer(HINTERNET hFile, LONG lDistanceToMove,
1706 PVOID pReserved, DWORD dwMoveContext, DWORD dwContext)
1708 FIXME("stub\n");
1709 return FALSE;
1712 /***********************************************************************
1713 * InternetWriteFile (WININET.@)
1715 * Write data to an open internet file
1717 * RETURNS
1718 * TRUE on success
1719 * FALSE on failure
1722 BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
1723 DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
1725 BOOL retval = FALSE;
1726 int nSocket = -1;
1727 LPWININETHANDLEHEADER lpwh;
1729 TRACE("\n");
1730 lpwh = (LPWININETHANDLEHEADER) WININET_GetObject( hFile );
1731 if (NULL == lpwh)
1732 return FALSE;
1734 switch (lpwh->htype)
1736 case WH_HHTTPREQ:
1738 LPWININETHTTPREQW lpwhr;
1739 lpwhr = (LPWININETHTTPREQW)lpwh;
1741 TRACE("HTTPREQ %li\n",dwNumOfBytesToWrite);
1742 retval = NETCON_send(&lpwhr->netConnection, lpBuffer,
1743 dwNumOfBytesToWrite, 0, (LPINT)lpdwNumOfBytesWritten);
1745 WININET_Release( lpwh );
1746 return retval;
1748 break;
1750 case WH_HFILE:
1751 nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
1752 break;
1754 default:
1755 break;
1758 if (nSocket != -1)
1760 int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0);
1761 retval = (res >= 0);
1762 *lpdwNumOfBytesWritten = retval ? res : 0;
1764 WININET_Release( lpwh );
1766 return retval;
1770 static BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
1771 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead,
1772 BOOL bWait, BOOL bSendCompletionStatus)
1774 BOOL retval = FALSE;
1775 int nSocket = -1;
1777 /* FIXME: this should use NETCON functions! */
1778 switch (lpwh->htype)
1780 case WH_HHTTPREQ:
1781 if (!NETCON_recv(&((LPWININETHTTPREQW)lpwh)->netConnection, lpBuffer,
1782 dwNumOfBytesToRead, bWait ? MSG_WAITALL : 0, (int *)pdwNumOfBytesRead))
1784 *pdwNumOfBytesRead = 0;
1785 retval = TRUE; /* Under windows, it seems to return 0 even if nothing was read... */
1787 else
1788 retval = TRUE;
1789 break;
1791 case WH_HFILE:
1792 /* FIXME: FTP should use NETCON_ stuff */
1793 nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
1794 if (nSocket != -1)
1796 int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, bWait ? MSG_WAITALL : 0);
1797 retval = (res >= 0);
1798 *pdwNumOfBytesRead = retval ? res : 0;
1800 break;
1802 default:
1803 break;
1806 if (bSendCompletionStatus)
1808 INTERNET_ASYNC_RESULT iar;
1810 iar.dwResult = retval;
1811 iar.dwError = iar.dwError = retval ? ERROR_SUCCESS :
1812 INTERNET_GetLastError();
1814 INTERNET_SendCallback(lpwh, lpwh->dwContext,
1815 INTERNET_STATUS_REQUEST_COMPLETE, &iar,
1816 sizeof(INTERNET_ASYNC_RESULT));
1818 return retval;
1821 /***********************************************************************
1822 * InternetReadFile (WININET.@)
1824 * Read data from an open internet file
1826 * RETURNS
1827 * TRUE on success
1828 * FALSE on failure
1831 BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
1832 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
1834 LPWININETHANDLEHEADER lpwh;
1835 BOOL retval;
1837 TRACE("%p %p %ld %p\n", hFile, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead);
1839 lpwh = WININET_GetObject( hFile );
1840 if (!lpwh)
1842 SetLastError(ERROR_INVALID_HANDLE);
1843 return FALSE;
1846 retval = INTERNET_ReadFile(lpwh, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead, TRUE, FALSE);
1847 WININET_Release( lpwh );
1849 TRACE("-- %s (bytes read: %ld)\n", retval ? "TRUE": "FALSE", pdwNumOfBytesRead ? *pdwNumOfBytesRead : -1);
1850 return retval;
1853 /***********************************************************************
1854 * InternetReadFileExA (WININET.@)
1856 * Read data from an open internet file
1858 * PARAMS
1859 * hFile [I] Handle returned by InternetOpenUrl or HttpOpenRequest.
1860 * lpBuffersOut [I/O] Buffer.
1861 * dwFlags [I] Flags. See notes.
1862 * dwContext [I] Context for callbacks.
1864 * RETURNS
1865 * TRUE on success
1866 * FALSE on failure
1868 * NOTES
1869 * The parameter dwFlags include zero or more of the following flags:
1870 *|IRF_ASYNC - Makes the call asynchronous.
1871 *|IRF_SYNC - Makes the call synchronous.
1872 *|IRF_USE_CONTEXT - Forces dwContext to be used.
1873 *|IRF_NO_WAIT - Don't block if the data is not available, just return what is available.
1875 * However, in testing IRF_USE_CONTEXT seems to have no effect - dwContext isn't used.
1877 * SEE
1878 * InternetOpenUrlA(), HttpOpenRequestA()
1880 BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOut,
1881 DWORD dwFlags, DWORD dwContext)
1883 BOOL retval = FALSE;
1884 LPWININETHANDLEHEADER lpwh;
1886 TRACE("(%p %p 0x%lx 0x%lx)\n", hFile, lpBuffersOut, dwFlags, dwContext);
1888 if (dwFlags & ~(IRF_ASYNC|IRF_NO_WAIT))
1889 FIXME("these dwFlags aren't implemented: 0x%lx\n", dwFlags & ~(IRF_ASYNC|IRF_NO_WAIT));
1891 if (lpBuffersOut->dwStructSize != sizeof(*lpBuffersOut))
1893 SetLastError(ERROR_INVALID_PARAMETER);
1894 return FALSE;
1897 lpwh = (LPWININETHANDLEHEADER) WININET_GetObject( hFile );
1898 if (!lpwh)
1900 SetLastError(ERROR_INVALID_HANDLE);
1901 return FALSE;
1904 /* FIXME: native only does it asynchronously if the amount of data
1905 * requested isn't available. See NtReadFile. */
1906 /* FIXME: IRF_ASYNC may not be the right thing to test here;
1907 * hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC is probably better, but
1908 * we should implement the above first */
1909 if (dwFlags & IRF_ASYNC)
1911 WORKREQUEST workRequest;
1912 struct WORKREQ_INTERNETREADFILEEXA *req;
1914 workRequest.asyncall = INTERNETREADFILEEXA;
1915 workRequest.hdr = WININET_AddRef( lpwh );
1916 req = &workRequest.u.InternetReadFileExA;
1917 req->lpBuffersOut = lpBuffersOut;
1919 retval = INTERNET_AsyncCall(&workRequest);
1920 if (!retval) return FALSE;
1922 SetLastError(ERROR_IO_PENDING);
1923 return FALSE;
1926 retval = INTERNET_ReadFile(lpwh, lpBuffersOut->lpvBuffer,
1927 lpBuffersOut->dwBufferLength, &lpBuffersOut->dwBufferLength,
1928 !(dwFlags & IRF_NO_WAIT), FALSE);
1930 WININET_Release( lpwh );
1932 TRACE("-- %s (bytes read: %ld)\n", retval ? "TRUE": "FALSE", lpBuffersOut->dwBufferLength);
1933 return retval;
1936 /***********************************************************************
1937 * InternetReadFileExW (WININET.@)
1939 * Read data from an open internet file.
1941 * PARAMS
1942 * hFile [I] Handle returned by InternetOpenUrl() or HttpOpenRequest().
1943 * lpBuffersOut [I/O] Buffer.
1944 * dwFlags [I] Flags.
1945 * dwContext [I] Context for callbacks.
1947 * RETURNS
1948 * FALSE, last error is set to ERROR_CALL_NOT_IMPLEMENTED
1950 * NOTES
1951 * Not implemented in Wine or native either (as of IE6 SP2).
1954 BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
1955 DWORD dwFlags, DWORD dwContext)
1957 ERR("(%p, %p, 0x%lx, 0x%lx): not implemented in native\n", hFile, lpBuffer, dwFlags, dwContext);
1959 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1960 return FALSE;
1963 /***********************************************************************
1964 * INET_QueryOptionHelper (internal)
1966 static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
1967 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1969 LPWININETHANDLEHEADER lpwhh;
1970 BOOL bSuccess = FALSE;
1972 TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
1974 lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
1976 switch (dwOption)
1978 case INTERNET_OPTION_HANDLE_TYPE:
1980 ULONG type;
1982 if (!lpwhh)
1984 WARN("Invalid hInternet handle\n");
1985 SetLastError(ERROR_INVALID_HANDLE);
1986 return FALSE;
1989 type = lpwhh->htype;
1991 TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type);
1993 if (*lpdwBufferLength < sizeof(ULONG))
1994 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1995 else
1997 memcpy(lpBuffer, &type, sizeof(ULONG));
1998 bSuccess = TRUE;
2000 *lpdwBufferLength = sizeof(ULONG);
2001 break;
2004 case INTERNET_OPTION_REQUEST_FLAGS:
2006 ULONG flags = 4;
2007 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags);
2008 if (*lpdwBufferLength < sizeof(ULONG))
2009 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2010 else
2012 memcpy(lpBuffer, &flags, sizeof(ULONG));
2013 bSuccess = TRUE;
2015 *lpdwBufferLength = sizeof(ULONG);
2016 break;
2019 case INTERNET_OPTION_URL:
2020 case INTERNET_OPTION_DATAFILE_NAME:
2022 if (!lpwhh)
2024 WARN("Invalid hInternet handle\n");
2025 SetLastError(ERROR_INVALID_HANDLE);
2026 return FALSE;
2028 if (lpwhh->htype == WH_HHTTPREQ)
2030 LPWININETHTTPREQW lpreq = (LPWININETHTTPREQW) lpwhh;
2031 WCHAR url[1023];
2032 static const WCHAR szFmt[] = {'h','t','t','p',':','/','/','%','s','%','s',0};
2033 DWORD sizeRequired;
2035 sprintfW(url,szFmt,lpreq->StdHeaders[HTTP_QUERY_HOST].lpszValue,lpreq->lpszPath);
2036 TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url));
2037 if(!bIsUnicode)
2039 sizeRequired = WideCharToMultiByte(CP_ACP,0,url,-1,
2040 lpBuffer,*lpdwBufferLength,NULL,NULL);
2041 if (sizeRequired > *lpdwBufferLength)
2042 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2043 else
2044 bSuccess = TRUE;
2045 *lpdwBufferLength = sizeRequired;
2047 else
2049 sizeRequired = (lstrlenW(url)+1) * sizeof(WCHAR);
2050 if (*lpdwBufferLength < sizeRequired)
2051 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2052 else
2054 strcpyW(lpBuffer, url);
2055 bSuccess = TRUE;
2057 *lpdwBufferLength = sizeRequired;
2060 break;
2062 case INTERNET_OPTION_HTTP_VERSION:
2064 if (*lpdwBufferLength < sizeof(HTTP_VERSION_INFO))
2065 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2066 else
2069 * Presently hardcoded to 1.1
2071 ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
2072 ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
2073 bSuccess = TRUE;
2075 *lpdwBufferLength = sizeof(HTTP_VERSION_INFO);
2076 break;
2078 case INTERNET_OPTION_CONNECTED_STATE:
2080 DWORD *pdwConnectedState = (DWORD *)lpBuffer;
2081 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
2083 if (*lpdwBufferLength < sizeof(*pdwConnectedState))
2084 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2085 else
2087 *pdwConnectedState = INTERNET_STATE_CONNECTED;
2088 bSuccess = TRUE;
2090 *lpdwBufferLength = sizeof(*pdwConnectedState);
2091 break;
2093 case INTERNET_OPTION_PROXY:
2095 LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW)lpwhh;
2096 WININETAPPINFOW wai;
2098 if (lpwai == NULL)
2100 TRACE("Getting global proxy info\n");
2101 memset(&wai, 0, sizeof(WININETAPPINFOW));
2102 INTERNET_ConfigureProxyFromReg( &wai );
2103 lpwai = &wai;
2106 if (bIsUnicode)
2108 INTERNET_PROXY_INFOW *pPI = (INTERNET_PROXY_INFOW *)lpBuffer;
2109 DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
2111 if (lpwai->lpszProxy)
2112 proxyBytesRequired = (lstrlenW(lpwai->lpszProxy) + 1) *
2113 sizeof(WCHAR);
2114 if (lpwai->lpszProxyBypass)
2115 proxyBypassBytesRequired =
2116 (lstrlenW(lpwai->lpszProxyBypass) + 1) * sizeof(WCHAR);
2117 if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOW) +
2118 proxyBytesRequired + proxyBypassBytesRequired)
2119 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2120 else
2122 pPI->dwAccessType = lpwai->dwAccessType;
2123 if (lpwai->lpszProxy)
2125 pPI->lpszProxy = (LPWSTR)((LPBYTE)lpBuffer +
2126 sizeof(INTERNET_PROXY_INFOW));
2127 lstrcpyW((LPWSTR)pPI->lpszProxy, lpwai->lpszProxy);
2129 else
2131 pPI->lpszProxy = (LPWSTR)((LPBYTE)lpBuffer +
2132 sizeof(INTERNET_PROXY_INFOW));
2133 *((LPWSTR)(pPI->lpszProxy)) = 0;
2136 if (lpwai->lpszProxyBypass)
2138 pPI->lpszProxyBypass = (LPWSTR)((LPBYTE)lpBuffer +
2139 sizeof(INTERNET_PROXY_INFOW) +
2140 proxyBytesRequired);
2141 lstrcpyW((LPWSTR)pPI->lpszProxyBypass,
2142 lpwai->lpszProxyBypass);
2144 else
2146 pPI->lpszProxyBypass = (LPWSTR)((LPBYTE)lpBuffer +
2147 sizeof(INTERNET_PROXY_INFOW) +
2148 proxyBytesRequired);
2149 *((LPWSTR)(pPI->lpszProxyBypass)) = 0;
2151 bSuccess = TRUE;
2153 *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOW) +
2154 proxyBytesRequired + proxyBypassBytesRequired;
2156 else
2158 INTERNET_PROXY_INFOA *pPI = (INTERNET_PROXY_INFOA *)lpBuffer;
2159 DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
2161 if (lpwai->lpszProxy)
2162 proxyBytesRequired = WideCharToMultiByte(CP_ACP, 0,
2163 lpwai->lpszProxy, -1, NULL, 0, NULL, NULL);
2164 if (lpwai->lpszProxyBypass)
2165 proxyBypassBytesRequired = WideCharToMultiByte(CP_ACP, 0,
2166 lpwai->lpszProxyBypass, -1, NULL, 0, NULL, NULL);
2167 if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOA) +
2168 proxyBytesRequired + proxyBypassBytesRequired)
2169 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2170 else
2172 pPI->dwAccessType = lpwai->dwAccessType;
2173 if (lpwai->lpszProxy)
2175 pPI->lpszProxy = (LPSTR)((LPBYTE)lpBuffer +
2176 sizeof(INTERNET_PROXY_INFOA));
2177 WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxy, -1,
2178 (LPSTR)pPI->lpszProxy, proxyBytesRequired, NULL, NULL);
2180 else
2182 pPI->lpszProxy = (LPSTR)((LPBYTE)lpBuffer +
2183 sizeof(INTERNET_PROXY_INFOA));
2184 *((LPSTR)(pPI->lpszProxy)) = '\0';
2187 if (lpwai->lpszProxyBypass)
2189 pPI->lpszProxyBypass = (LPSTR)((LPBYTE)lpBuffer +
2190 sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired);
2191 WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxyBypass,
2192 -1, (LPSTR)pPI->lpszProxyBypass,
2193 proxyBypassBytesRequired,
2194 NULL, NULL);
2196 else
2198 pPI->lpszProxyBypass = (LPSTR)((LPBYTE)lpBuffer +
2199 sizeof(INTERNET_PROXY_INFOA) +
2200 proxyBytesRequired);
2201 *((LPSTR)(pPI->lpszProxyBypass)) = '\0';
2203 bSuccess = TRUE;
2205 *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOA) +
2206 proxyBytesRequired + proxyBypassBytesRequired;
2208 break;
2210 case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
2212 ULONG conn = 2;
2213 TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %ld\n", conn);
2214 if (*lpdwBufferLength < sizeof(ULONG))
2215 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2216 else
2218 memcpy(lpBuffer, &conn, sizeof(ULONG));
2219 bSuccess = TRUE;
2221 *lpdwBufferLength = sizeof(ULONG);
2222 break;
2224 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
2226 ULONG conn = 4;
2227 TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER: %ld\n", conn);
2228 if (*lpdwBufferLength < sizeof(ULONG))
2229 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2230 else
2232 memcpy(lpBuffer, &conn, sizeof(ULONG));
2233 bSuccess = TRUE;
2235 *lpdwBufferLength = sizeof(ULONG);
2236 break;
2238 case INTERNET_OPTION_SECURITY_FLAGS:
2239 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2240 break;
2242 default:
2243 FIXME("Stub! %ld\n", dwOption);
2244 break;
2246 if (lpwhh)
2247 WININET_Release( lpwhh );
2249 return bSuccess;
2252 /***********************************************************************
2253 * InternetQueryOptionW (WININET.@)
2255 * Queries an options on the specified handle
2257 * RETURNS
2258 * TRUE on success
2259 * FALSE on failure
2262 BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
2263 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
2265 return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
2268 /***********************************************************************
2269 * InternetQueryOptionA (WININET.@)
2271 * Queries an options on the specified handle
2273 * RETURNS
2274 * TRUE on success
2275 * FALSE on failure
2278 BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
2279 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
2281 return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
2285 /***********************************************************************
2286 * InternetSetOptionW (WININET.@)
2288 * Sets an options on the specified handle
2290 * RETURNS
2291 * TRUE on success
2292 * FALSE on failure
2295 BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
2296 LPVOID lpBuffer, DWORD dwBufferLength)
2298 LPWININETHANDLEHEADER lpwhh;
2299 BOOL ret = TRUE;
2301 TRACE("0x%08lx\n", dwOption);
2303 lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
2304 if( !lpwhh )
2305 return FALSE;
2307 switch (dwOption)
2309 case INTERNET_OPTION_HTTP_VERSION:
2311 HTTP_VERSION_INFO* pVersion=(HTTP_VERSION_INFO*)lpBuffer;
2312 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion->dwMajorVersion,pVersion->dwMinorVersion);
2314 break;
2315 case INTERNET_OPTION_ERROR_MASK:
2317 unsigned long flags=*(unsigned long*)lpBuffer;
2318 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
2320 break;
2321 case INTERNET_OPTION_CODEPAGE:
2323 unsigned long codepage=*(unsigned long*)lpBuffer;
2324 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
2326 break;
2327 case INTERNET_OPTION_REQUEST_PRIORITY:
2329 unsigned long priority=*(unsigned long*)lpBuffer;
2330 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
2332 break;
2333 case INTERNET_OPTION_CONNECT_TIMEOUT:
2335 unsigned long connecttimeout=*(unsigned long*)lpBuffer;
2336 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%ld): STUB\n",connecttimeout);
2338 break;
2339 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT:
2341 unsigned long receivetimeout=*(unsigned long*)lpBuffer;
2342 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%ld): STUB\n",receivetimeout);
2344 break;
2345 case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
2347 unsigned long conns=*(unsigned long*)lpBuffer;
2348 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%ld): STUB\n",conns);
2350 break;
2351 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
2353 unsigned long conns=*(unsigned long*)lpBuffer;
2354 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%ld): STUB\n",conns);
2356 break;
2357 case INTERNET_OPTION_RESET_URLCACHE_SESSION:
2358 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2359 break;
2360 case INTERNET_OPTION_END_BROWSER_SESSION:
2361 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2362 break;
2363 case INTERNET_OPTION_CONNECTED_STATE:
2364 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2365 break;
2366 case INTERNET_OPTION_DISABLE_PASSPORT_AUTH:
2367 TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
2368 break;
2369 case INTERNET_OPTION_RECEIVE_TIMEOUT:
2370 FIXME("Option INTERNET_OPTION_RECEIVE_TIMEOUT: STUB\n");
2371 break;
2372 case INTERNET_OPTION_SEND_TIMEOUT:
2373 FIXME("Option INTERNET_OPTION_SEND_TIMEOUT: STUB\n");
2374 break;
2375 case INTERNET_OPTION_CONNECT_RETRIES:
2376 FIXME("Option INTERNET_OPTION_CONNECT_RETRIES: STUB\n");
2377 break;
2378 default:
2379 FIXME("Option %ld STUB\n",dwOption);
2380 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
2381 ret = FALSE;
2382 break;
2384 WININET_Release( lpwhh );
2386 return ret;
2390 /***********************************************************************
2391 * InternetSetOptionA (WININET.@)
2393 * Sets an options on the specified handle.
2395 * RETURNS
2396 * TRUE on success
2397 * FALSE on failure
2400 BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
2401 LPVOID lpBuffer, DWORD dwBufferLength)
2403 LPVOID wbuffer;
2404 DWORD wlen;
2405 BOOL r;
2407 switch( dwOption )
2409 case INTERNET_OPTION_PROXY:
2411 LPINTERNET_PROXY_INFOA pi = (LPINTERNET_PROXY_INFOA) lpBuffer;
2412 LPINTERNET_PROXY_INFOW piw;
2413 DWORD proxlen, prbylen;
2414 LPWSTR prox, prby;
2416 proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0);
2417 prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0);
2418 wlen = sizeof(*piw) + proxlen + prbylen;
2419 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
2420 piw = (LPINTERNET_PROXY_INFOW) wbuffer;
2421 piw->dwAccessType = pi->dwAccessType;
2422 prox = (LPWSTR) &piw[1];
2423 prby = &prox[proxlen+1];
2424 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, prox, proxlen);
2425 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, prby, prbylen);
2426 piw->lpszProxy = prox;
2427 piw->lpszProxyBypass = prby;
2429 break;
2430 case INTERNET_OPTION_USER_AGENT:
2431 case INTERNET_OPTION_USERNAME:
2432 case INTERNET_OPTION_PASSWORD:
2433 wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
2434 NULL, 0 );
2435 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
2436 MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
2437 wbuffer, wlen );
2438 break;
2439 default:
2440 wbuffer = lpBuffer;
2441 wlen = dwBufferLength;
2444 r = InternetSetOptionW(hInternet,dwOption, wbuffer, wlen);
2446 if( lpBuffer != wbuffer )
2447 HeapFree( GetProcessHeap(), 0, wbuffer );
2449 return r;
2453 /***********************************************************************
2454 * InternetSetOptionExA (WININET.@)
2456 BOOL WINAPI InternetSetOptionExA(HINTERNET hInternet, DWORD dwOption,
2457 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
2459 FIXME("Flags %08lx ignored\n", dwFlags);
2460 return InternetSetOptionA( hInternet, dwOption, lpBuffer, dwBufferLength );
2463 /***********************************************************************
2464 * InternetSetOptionExW (WININET.@)
2466 BOOL WINAPI InternetSetOptionExW(HINTERNET hInternet, DWORD dwOption,
2467 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
2469 FIXME("Flags %08lx ignored\n", dwFlags);
2470 if( dwFlags & ~ISO_VALID_FLAGS )
2472 SetLastError( ERROR_INVALID_PARAMETER );
2473 return FALSE;
2475 return InternetSetOptionW( hInternet, dwOption, lpBuffer, dwBufferLength );
2478 static const WCHAR WININET_wkday[7][4] =
2479 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2480 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2481 static const WCHAR WININET_month[12][4] =
2482 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2483 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2484 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2486 /***********************************************************************
2487 * InternetTimeFromSystemTimeA (WININET.@)
2489 BOOL WINAPI InternetTimeFromSystemTimeA( const SYSTEMTIME* time, DWORD format, LPSTR string, DWORD size )
2491 BOOL ret;
2492 WCHAR stringW[INTERNET_RFC1123_BUFSIZE];
2494 TRACE( "%p 0x%08lx %p 0x%08lx\n", time, format, string, size );
2496 ret = InternetTimeFromSystemTimeW( time, format, stringW, sizeof(stringW) );
2497 if (ret) WideCharToMultiByte( CP_ACP, 0, stringW, -1, string, size, NULL, NULL );
2499 return ret;
2502 /***********************************************************************
2503 * InternetTimeFromSystemTimeW (WININET.@)
2505 BOOL WINAPI InternetTimeFromSystemTimeW( const SYSTEMTIME* time, DWORD format, LPWSTR string, DWORD size )
2507 static const WCHAR date[] =
2508 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2509 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
2511 TRACE( "%p 0x%08lx %p 0x%08lx\n", time, format, string, size );
2513 if (!time || !string) return FALSE;
2515 if (format != INTERNET_RFC1123_FORMAT || size < INTERNET_RFC1123_BUFSIZE * sizeof(WCHAR))
2516 return FALSE;
2518 sprintfW( string, date,
2519 WININET_wkday[time->wDayOfWeek],
2520 time->wDay,
2521 WININET_month[time->wMonth - 1],
2522 time->wYear,
2523 time->wHour,
2524 time->wMinute,
2525 time->wSecond );
2527 return TRUE;
2530 /***********************************************************************
2531 * InternetTimeToSystemTimeA (WININET.@)
2533 BOOL WINAPI InternetTimeToSystemTimeA( LPCSTR string, SYSTEMTIME* time, DWORD reserved )
2535 BOOL ret = FALSE;
2536 WCHAR *stringW;
2537 int len;
2539 TRACE( "%s %p 0x%08lx\n", debugstr_a(string), time, reserved );
2541 len = MultiByteToWideChar( CP_ACP, 0, string, -1, NULL, 0 );
2542 stringW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
2544 if (stringW)
2546 MultiByteToWideChar( CP_ACP, 0, string, -1, stringW, len );
2547 ret = InternetTimeToSystemTimeW( stringW, time, reserved );
2548 HeapFree( GetProcessHeap(), 0, stringW );
2550 return ret;
2553 /***********************************************************************
2554 * InternetTimeToSystemTimeW (WININET.@)
2556 BOOL WINAPI InternetTimeToSystemTimeW( LPCWSTR string, SYSTEMTIME* time, DWORD reserved )
2558 unsigned int i;
2559 WCHAR *s = (LPWSTR)string;
2561 TRACE( "%s %p 0x%08lx\n", debugstr_w(string), time, reserved );
2563 if (!string || !time) return FALSE;
2565 /* Windows does this too */
2566 GetSystemTime( time );
2568 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2569 * a SYSTEMTIME structure.
2572 while (*s && !isalphaW( *s )) s++;
2573 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2574 time->wDayOfWeek = 7;
2576 for (i = 0; i < 7; i++)
2578 if (toupperW( WININET_wkday[i][0] ) == toupperW( s[0] ) &&
2579 toupperW( WININET_wkday[i][1] ) == toupperW( s[1] ) &&
2580 toupperW( WININET_wkday[i][2] ) == toupperW( s[2] ) )
2582 time->wDayOfWeek = i;
2583 break;
2587 if (time->wDayOfWeek > 6) return TRUE;
2588 while (*s && !isdigitW( *s )) s++;
2589 time->wDay = strtolW( s, &s, 10 );
2591 while (*s && !isalphaW( *s )) s++;
2592 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2593 time->wMonth = 0;
2595 for (i = 0; i < 12; i++)
2597 if (toupperW( WININET_month[i][0]) == toupperW( s[0] ) &&
2598 toupperW( WININET_month[i][1]) == toupperW( s[1] ) &&
2599 toupperW( WININET_month[i][2]) == toupperW( s[2] ) )
2601 time->wMonth = i + 1;
2602 break;
2605 if (time->wMonth == 0) return TRUE;
2607 while (*s && !isdigitW( *s )) s++;
2608 if (*s == '\0') return TRUE;
2609 time->wYear = strtolW( s, &s, 10 );
2611 while (*s && !isdigitW( *s )) s++;
2612 if (*s == '\0') return TRUE;
2613 time->wHour = strtolW( s, &s, 10 );
2615 while (*s && !isdigitW( *s )) s++;
2616 if (*s == '\0') return TRUE;
2617 time->wMinute = strtolW( s, &s, 10 );
2619 while (*s && !isdigitW( *s )) s++;
2620 if (*s == '\0') return TRUE;
2621 time->wSecond = strtolW( s, &s, 10 );
2623 time->wMilliseconds = 0;
2624 return TRUE;
2627 /***********************************************************************
2628 * InternetCheckConnectionW (WININET.@)
2630 * Pings a requested host to check internet connection
2632 * RETURNS
2633 * TRUE on success and FALSE on failure. If a failure then
2634 * ERROR_NOT_CONNECTED is placed into GetLastError
2637 BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
2640 * this is a kludge which runs the resident ping program and reads the output.
2642 * Anyone have a better idea?
2645 BOOL rc = FALSE;
2646 static const CHAR ping[] = "ping -w 1 ";
2647 static const CHAR redirect[] = " >/dev/null 2>/dev/null";
2648 CHAR *command = NULL;
2649 WCHAR hostW[1024];
2650 DWORD len;
2651 int status = -1;
2653 FIXME("\n");
2656 * Crack or set the Address
2658 if (lpszUrl == NULL)
2661 * According to the doc we are supost to use the ip for the next
2662 * server in the WnInet internal server database. I have
2663 * no idea what that is or how to get it.
2665 * So someone needs to implement this.
2667 FIXME("Unimplemented with URL of NULL\n");
2668 return TRUE;
2670 else
2672 URL_COMPONENTSW components;
2674 ZeroMemory(&components,sizeof(URL_COMPONENTSW));
2675 components.lpszHostName = (LPWSTR)&hostW;
2676 components.dwHostNameLength = 1024;
2678 if (!InternetCrackUrlW(lpszUrl,0,0,&components))
2679 goto End;
2681 TRACE("host name : %s\n",debugstr_w(components.lpszHostName));
2685 * Build our ping command
2687 len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
2688 command = HeapAlloc( GetProcessHeap(), 0, strlen(ping)+len+strlen(redirect) );
2689 strcpy(command,ping);
2690 WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
2691 strcat(command,redirect);
2693 TRACE("Ping command is : %s\n",command);
2695 status = system(command);
2697 TRACE("Ping returned a code of %i\n",status);
2699 /* Ping return code of 0 indicates success */
2700 if (status == 0)
2701 rc = TRUE;
2703 End:
2705 HeapFree( GetProcessHeap(), 0, command );
2706 if (rc == FALSE)
2707 SetLastError(ERROR_NOT_CONNECTED);
2709 return rc;
2713 /***********************************************************************
2714 * InternetCheckConnectionA (WININET.@)
2716 * Pings a requested host to check internet connection
2718 * RETURNS
2719 * TRUE on success and FALSE on failure. If a failure then
2720 * ERROR_NOT_CONNECTED is placed into GetLastError
2723 BOOL WINAPI InternetCheckConnectionA(LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
2725 WCHAR *szUrl;
2726 INT len;
2727 BOOL rc;
2729 len = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0);
2730 if (!(szUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR))))
2731 return FALSE;
2732 MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, len);
2733 rc = InternetCheckConnectionW(szUrl, dwFlags, dwReserved);
2734 HeapFree(GetProcessHeap(), 0, szUrl);
2736 return rc;
2740 /**********************************************************
2741 * INTERNET_InternetOpenUrlW (internal)
2743 * Opens an URL
2745 * RETURNS
2746 * handle of connection or NULL on failure
2748 HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
2749 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
2751 URL_COMPONENTSW urlComponents;
2752 WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
2753 WCHAR password[1024], path[2048], extra[1024];
2754 HINTERNET client = NULL, client1 = NULL;
2756 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hIC, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
2757 dwHeadersLength, dwFlags, dwContext);
2759 urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
2760 urlComponents.lpszScheme = protocol;
2761 urlComponents.dwSchemeLength = 32;
2762 urlComponents.lpszHostName = hostName;
2763 urlComponents.dwHostNameLength = MAXHOSTNAME;
2764 urlComponents.lpszUserName = userName;
2765 urlComponents.dwUserNameLength = 1024;
2766 urlComponents.lpszPassword = password;
2767 urlComponents.dwPasswordLength = 1024;
2768 urlComponents.lpszUrlPath = path;
2769 urlComponents.dwUrlPathLength = 2048;
2770 urlComponents.lpszExtraInfo = extra;
2771 urlComponents.dwExtraInfoLength = 1024;
2772 if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents))
2773 return NULL;
2774 switch(urlComponents.nScheme) {
2775 case INTERNET_SCHEME_FTP:
2776 if(urlComponents.nPort == 0)
2777 urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
2778 client = FTP_Connect(hIC, hostName, urlComponents.nPort,
2779 userName, password, dwFlags, dwContext, INET_OPENURL);
2780 if(client == NULL)
2781 break;
2782 client1 = FtpOpenFileW(client, path, GENERIC_READ, dwFlags, dwContext);
2783 if(client1 == NULL) {
2784 InternetCloseHandle(client);
2785 break;
2787 break;
2789 case INTERNET_SCHEME_HTTP:
2790 case INTERNET_SCHEME_HTTPS: {
2791 static const WCHAR szStars[] = { '*','/','*', 0 };
2792 LPCWSTR accept[2] = { szStars, NULL };
2793 if(urlComponents.nPort == 0) {
2794 if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
2795 urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
2796 else
2797 urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
2799 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
2800 client = HTTP_Connect(hIC, hostName, urlComponents.nPort,
2801 userName, password, dwFlags, dwContext, INET_OPENURL);
2802 if(client == NULL)
2803 break;
2804 client1 = HttpOpenRequestW(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
2805 if(client1 == NULL) {
2806 InternetCloseHandle(client);
2807 break;
2809 HttpAddRequestHeadersW(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
2810 if (!HttpSendRequestW(client1, NULL, 0, NULL, 0)) {
2811 InternetCloseHandle(client1);
2812 client1 = NULL;
2813 break;
2816 case INTERNET_SCHEME_GOPHER:
2817 /* gopher doesn't seem to be implemented in wine, but it's supposed
2818 * to be supported by InternetOpenUrlA. */
2819 default:
2820 break;
2823 TRACE(" %p <--\n", client1);
2825 return client1;
2828 /**********************************************************
2829 * InternetOpenUrlW (WININET.@)
2831 * Opens an URL
2833 * RETURNS
2834 * handle of connection or NULL on failure
2836 HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
2837 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
2839 HINTERNET ret = NULL;
2840 LPWININETAPPINFOW hIC = NULL;
2842 if (TRACE_ON(wininet)) {
2843 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hInternet, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
2844 dwHeadersLength, dwFlags, dwContext);
2845 TRACE(" flags :");
2846 dump_INTERNET_FLAGS(dwFlags);
2849 hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
2850 if (NULL == hIC || hIC->hdr.htype != WH_HINIT) {
2851 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
2852 goto lend;
2855 if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) {
2856 WORKREQUEST workRequest;
2857 struct WORKREQ_INTERNETOPENURLW *req;
2859 workRequest.asyncall = INTERNETOPENURLW;
2860 workRequest.hdr = WININET_AddRef( &hIC->hdr );
2861 req = &workRequest.u.InternetOpenUrlW;
2862 if (lpszUrl)
2863 req->lpszUrl = WININET_strdupW(lpszUrl);
2864 else
2865 req->lpszUrl = 0;
2866 if (lpszHeaders)
2867 req->lpszHeaders = WININET_strdupW(lpszHeaders);
2868 else
2869 req->lpszHeaders = 0;
2870 req->dwHeadersLength = dwHeadersLength;
2871 req->dwFlags = dwFlags;
2872 req->dwContext = dwContext;
2874 INTERNET_AsyncCall(&workRequest);
2876 * This is from windows.
2878 SetLastError(ERROR_IO_PENDING);
2879 } else {
2880 ret = INTERNET_InternetOpenUrlW(hIC, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
2883 lend:
2884 if( hIC )
2885 WININET_Release( &hIC->hdr );
2886 TRACE(" %p <--\n", ret);
2888 return ret;
2891 /**********************************************************
2892 * InternetOpenUrlA (WININET.@)
2894 * Opens an URL
2896 * RETURNS
2897 * handle of connection or NULL on failure
2899 HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
2900 LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
2902 HINTERNET rc = (HINTERNET)NULL;
2904 INT lenUrl;
2905 INT lenHeaders = 0;
2906 LPWSTR szUrl = NULL;
2907 LPWSTR szHeaders = NULL;
2909 TRACE("\n");
2911 if(lpszUrl) {
2912 lenUrl = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0 );
2913 szUrl = HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(WCHAR));
2914 if(!szUrl)
2915 return (HINTERNET)NULL;
2916 MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl);
2919 if(lpszHeaders) {
2920 lenHeaders = MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, NULL, 0 );
2921 szHeaders = HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(WCHAR));
2922 if(!szHeaders) {
2923 HeapFree(GetProcessHeap(), 0, szUrl);
2924 return (HINTERNET)NULL;
2926 MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, szHeaders, lenHeaders);
2929 rc = InternetOpenUrlW(hInternet, szUrl, szHeaders,
2930 lenHeaders, dwFlags, dwContext);
2932 HeapFree(GetProcessHeap(), 0, szUrl);
2933 HeapFree(GetProcessHeap(), 0, szHeaders);
2935 return rc;
2939 /***********************************************************************
2940 * INTERNET_SetLastError (internal)
2942 * Set last thread specific error
2944 * RETURNS
2947 void INTERNET_SetLastError(DWORD dwError)
2949 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2951 SetLastError(dwError);
2952 if(lpwite)
2953 lpwite->dwError = dwError;
2957 /***********************************************************************
2958 * INTERNET_GetLastError (internal)
2960 * Get last thread specific error
2962 * RETURNS
2965 DWORD INTERNET_GetLastError(void)
2967 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2968 /* TlsGetValue clears last error, so set it again here */
2969 SetLastError(lpwite->dwError);
2970 return lpwite->dwError;
2974 /***********************************************************************
2975 * INTERNET_WorkerThreadFunc (internal)
2977 * Worker thread execution function
2979 * RETURNS
2982 static DWORD CALLBACK INTERNET_WorkerThreadFunc(LPVOID lpvParam)
2984 DWORD dwWaitRes;
2986 while (1)
2988 if(dwNumJobs > 0) {
2989 INTERNET_ExecuteWork();
2990 continue;
2992 dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
2994 if (dwWaitRes == WAIT_OBJECT_0 + 1)
2995 INTERNET_ExecuteWork();
2996 else
2997 break;
2999 InterlockedIncrement(&dwNumIdleThreads);
3002 InterlockedDecrement(&dwNumIdleThreads);
3003 InterlockedDecrement(&dwNumThreads);
3004 TRACE("Worker thread exiting\n");
3005 return TRUE;
3009 /***********************************************************************
3010 * INTERNET_InsertWorkRequest (internal)
3012 * Insert work request into queue
3014 * RETURNS
3017 static BOOL INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest)
3019 BOOL bSuccess = FALSE;
3020 LPWORKREQUEST lpNewRequest;
3022 TRACE("\n");
3024 lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
3025 if (lpNewRequest)
3027 memcpy(lpNewRequest, lpWorkRequest, sizeof(WORKREQUEST));
3028 lpNewRequest->prev = NULL;
3030 EnterCriticalSection(&csQueue);
3032 lpNewRequest->next = lpWorkQueueTail;
3033 if (lpWorkQueueTail)
3034 lpWorkQueueTail->prev = lpNewRequest;
3035 lpWorkQueueTail = lpNewRequest;
3036 if (!lpHeadWorkQueue)
3037 lpHeadWorkQueue = lpWorkQueueTail;
3039 LeaveCriticalSection(&csQueue);
3041 bSuccess = TRUE;
3042 InterlockedIncrement(&dwNumJobs);
3045 return bSuccess;
3049 /***********************************************************************
3050 * INTERNET_GetWorkRequest (internal)
3052 * Retrieves work request from queue
3054 * RETURNS
3057 static BOOL INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest)
3059 BOOL bSuccess = FALSE;
3060 LPWORKREQUEST lpRequest = NULL;
3062 TRACE("\n");
3064 EnterCriticalSection(&csQueue);
3066 if (lpHeadWorkQueue)
3068 lpRequest = lpHeadWorkQueue;
3069 lpHeadWorkQueue = lpHeadWorkQueue->prev;
3070 if (lpRequest == lpWorkQueueTail)
3071 lpWorkQueueTail = lpHeadWorkQueue;
3074 LeaveCriticalSection(&csQueue);
3076 if (lpRequest)
3078 memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
3079 HeapFree(GetProcessHeap(), 0, lpRequest);
3080 bSuccess = TRUE;
3081 InterlockedDecrement(&dwNumJobs);
3084 return bSuccess;
3088 /***********************************************************************
3089 * INTERNET_AsyncCall (internal)
3091 * Retrieves work request from queue
3093 * RETURNS
3096 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
3098 HANDLE hThread;
3099 DWORD dwTID;
3100 BOOL bSuccess = FALSE;
3102 TRACE("\n");
3104 if (InterlockedDecrement(&dwNumIdleThreads) < 0)
3106 InterlockedIncrement(&dwNumIdleThreads);
3108 if (InterlockedIncrement(&dwNumThreads) > MAX_WORKER_THREADS ||
3109 !(hThread = CreateThread(NULL, 0,
3110 INTERNET_WorkerThreadFunc, NULL, 0, &dwTID)))
3112 InterlockedDecrement(&dwNumThreads);
3113 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
3114 goto lerror;
3117 TRACE("Created new thread\n");
3120 bSuccess = TRUE;
3121 INTERNET_InsertWorkRequest(lpWorkRequest);
3122 SetEvent(hWorkEvent);
3124 lerror:
3126 return bSuccess;
3130 /***********************************************************************
3131 * INTERNET_ExecuteWork (internal)
3133 * RETURNS
3136 static VOID INTERNET_ExecuteWork(void)
3138 WORKREQUEST workRequest;
3140 TRACE("\n");
3142 if (!INTERNET_GetWorkRequest(&workRequest))
3143 return;
3145 switch (workRequest.asyncall)
3147 case FTPPUTFILEW:
3149 struct WORKREQ_FTPPUTFILEW *req = &workRequest.u.FtpPutFileW;
3150 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3152 TRACE("FTPPUTFILEW %p\n", lpwfs);
3154 FTP_FtpPutFileW(lpwfs, req->lpszLocalFile,
3155 req->lpszNewRemoteFile, req->dwFlags, req->dwContext);
3157 HeapFree(GetProcessHeap(), 0, req->lpszLocalFile);
3158 HeapFree(GetProcessHeap(), 0, req->lpszNewRemoteFile);
3160 break;
3162 case FTPSETCURRENTDIRECTORYW:
3164 struct WORKREQ_FTPSETCURRENTDIRECTORYW *req;
3165 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3167 TRACE("FTPSETCURRENTDIRECTORYW %p\n", lpwfs);
3169 req = &workRequest.u.FtpSetCurrentDirectoryW;
3170 FTP_FtpSetCurrentDirectoryW(lpwfs, req->lpszDirectory);
3171 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
3173 break;
3175 case FTPCREATEDIRECTORYW:
3177 struct WORKREQ_FTPCREATEDIRECTORYW *req;
3178 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3180 TRACE("FTPCREATEDIRECTORYW %p\n", lpwfs);
3182 req = &workRequest.u.FtpCreateDirectoryW;
3183 FTP_FtpCreateDirectoryW(lpwfs, req->lpszDirectory);
3184 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
3186 break;
3188 case FTPFINDFIRSTFILEW:
3190 struct WORKREQ_FTPFINDFIRSTFILEW *req;
3191 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3193 TRACE("FTPFINDFIRSTFILEW %p\n", lpwfs);
3195 req = &workRequest.u.FtpFindFirstFileW;
3196 FTP_FtpFindFirstFileW(lpwfs, req->lpszSearchFile,
3197 req->lpFindFileData, req->dwFlags, req->dwContext);
3198 HeapFree(GetProcessHeap(), 0, req->lpszSearchFile);
3200 break;
3202 case FTPGETCURRENTDIRECTORYW:
3204 struct WORKREQ_FTPGETCURRENTDIRECTORYW *req;
3205 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3207 TRACE("FTPGETCURRENTDIRECTORYW %p\n", lpwfs);
3209 req = &workRequest.u.FtpGetCurrentDirectoryW;
3210 FTP_FtpGetCurrentDirectoryW(lpwfs,
3211 req->lpszDirectory, req->lpdwDirectory);
3213 break;
3215 case FTPOPENFILEW:
3217 struct WORKREQ_FTPOPENFILEW *req = &workRequest.u.FtpOpenFileW;
3218 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3220 TRACE("FTPOPENFILEW %p\n", lpwfs);
3222 FTP_FtpOpenFileW(lpwfs, req->lpszFilename,
3223 req->dwAccess, req->dwFlags, req->dwContext);
3224 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
3226 break;
3228 case FTPGETFILEW:
3230 struct WORKREQ_FTPGETFILEW *req = &workRequest.u.FtpGetFileW;
3231 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3233 TRACE("FTPGETFILEW %p\n", lpwfs);
3235 FTP_FtpGetFileW(lpwfs, req->lpszRemoteFile,
3236 req->lpszNewFile, req->fFailIfExists,
3237 req->dwLocalFlagsAttribute, req->dwFlags, req->dwContext);
3238 HeapFree(GetProcessHeap(), 0, req->lpszRemoteFile);
3239 HeapFree(GetProcessHeap(), 0, req->lpszNewFile);
3241 break;
3243 case FTPDELETEFILEW:
3245 struct WORKREQ_FTPDELETEFILEW *req = &workRequest.u.FtpDeleteFileW;
3246 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3248 TRACE("FTPDELETEFILEW %p\n", lpwfs);
3250 FTP_FtpDeleteFileW(lpwfs, req->lpszFilename);
3251 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
3253 break;
3255 case FTPREMOVEDIRECTORYW:
3257 struct WORKREQ_FTPREMOVEDIRECTORYW *req;
3258 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3260 TRACE("FTPREMOVEDIRECTORYW %p\n", lpwfs);
3262 req = &workRequest.u.FtpRemoveDirectoryW;
3263 FTP_FtpRemoveDirectoryW(lpwfs, req->lpszDirectory);
3264 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
3266 break;
3268 case FTPRENAMEFILEW:
3270 struct WORKREQ_FTPRENAMEFILEW *req = &workRequest.u.FtpRenameFileW;
3271 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3273 TRACE("FTPRENAMEFILEW %p\n", lpwfs);
3275 FTP_FtpRenameFileW(lpwfs, req->lpszSrcFile, req->lpszDestFile);
3276 HeapFree(GetProcessHeap(), 0, req->lpszSrcFile);
3277 HeapFree(GetProcessHeap(), 0, req->lpszDestFile);
3279 break;
3281 case INTERNETFINDNEXTW:
3283 struct WORKREQ_INTERNETFINDNEXTW *req;
3284 LPWININETFINDNEXTW lpwh = (LPWININETFINDNEXTW) workRequest.hdr;
3286 TRACE("INTERNETFINDNEXTW %p\n", lpwh);
3288 req = &workRequest.u.InternetFindNextW;
3289 INTERNET_FindNextFileW(lpwh, req->lpFindFileData);
3291 break;
3293 case HTTPSENDREQUESTW:
3295 struct WORKREQ_HTTPSENDREQUESTW *req = &workRequest.u.HttpSendRequestW;
3296 LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) workRequest.hdr;
3298 TRACE("HTTPSENDREQUESTW %p\n", lpwhr);
3300 HTTP_HttpSendRequestW(lpwhr, req->lpszHeader,
3301 req->dwHeaderLength, req->lpOptional, req->dwOptionalLength,
3302 req->dwContentLength, req->bEndRequest);
3304 HeapFree(GetProcessHeap(), 0, req->lpszHeader);
3306 break;
3308 case HTTPOPENREQUESTW:
3310 struct WORKREQ_HTTPOPENREQUESTW *req = &workRequest.u.HttpOpenRequestW;
3311 LPWININETHTTPSESSIONW lpwhs = (LPWININETHTTPSESSIONW) workRequest.hdr;
3313 TRACE("HTTPOPENREQUESTW %p\n", lpwhs);
3315 HTTP_HttpOpenRequestW(lpwhs, req->lpszVerb,
3316 req->lpszObjectName, req->lpszVersion, req->lpszReferrer,
3317 req->lpszAcceptTypes, req->dwFlags, req->dwContext);
3319 HeapFree(GetProcessHeap(), 0, req->lpszVerb);
3320 HeapFree(GetProcessHeap(), 0, req->lpszObjectName);
3321 HeapFree(GetProcessHeap(), 0, req->lpszVersion);
3322 HeapFree(GetProcessHeap(), 0, req->lpszReferrer);
3324 break;
3326 case SENDCALLBACK:
3328 struct WORKREQ_SENDCALLBACK *req = &workRequest.u.SendCallback;
3330 TRACE("SENDCALLBACK %p\n", workRequest.hdr);
3332 INTERNET_SendCallback(workRequest.hdr,
3333 req->dwContext, req->dwInternetStatus, req->lpvStatusInfo,
3334 req->dwStatusInfoLength);
3336 /* And frees the copy of the status info */
3337 HeapFree(GetProcessHeap(), 0, req->lpvStatusInfo);
3339 break;
3341 case INTERNETOPENURLW:
3343 struct WORKREQ_INTERNETOPENURLW *req = &workRequest.u.InternetOpenUrlW;
3344 LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) workRequest.hdr;
3346 TRACE("INTERNETOPENURLW %p\n", hIC);
3348 INTERNET_InternetOpenUrlW(hIC, req->lpszUrl,
3349 req->lpszHeaders, req->dwHeadersLength, req->dwFlags, req->dwContext);
3350 HeapFree(GetProcessHeap(), 0, req->lpszUrl);
3351 HeapFree(GetProcessHeap(), 0, req->lpszHeaders);
3353 break;
3354 case INTERNETREADFILEEXA:
3356 struct WORKREQ_INTERNETREADFILEEXA *req = &workRequest.u.InternetReadFileExA;
3358 TRACE("INTERNETREADFILEEXA %p\n", workRequest.hdr);
3360 INTERNET_ReadFile(workRequest.hdr, req->lpBuffersOut->lpvBuffer,
3361 req->lpBuffersOut->dwBufferLength,
3362 &req->lpBuffersOut->dwBufferLength, TRUE, TRUE);
3364 break;
3366 WININET_Release( workRequest.hdr );
3370 /***********************************************************************
3371 * INTERNET_GetResponseBuffer (internal)
3373 * RETURNS
3376 LPSTR INTERNET_GetResponseBuffer(void)
3378 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
3379 TRACE("\n");
3380 return lpwite->response;
3383 /***********************************************************************
3384 * INTERNET_GetNextLine (internal)
3386 * Parse next line in directory string listing
3388 * RETURNS
3389 * Pointer to beginning of next line
3390 * NULL on failure
3394 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
3396 struct timeval tv;
3397 fd_set infd;
3398 BOOL bSuccess = FALSE;
3399 INT nRecv = 0;
3400 LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
3402 TRACE("\n");
3404 FD_ZERO(&infd);
3405 FD_SET(nSocket, &infd);
3406 tv.tv_sec=RESPONSE_TIMEOUT;
3407 tv.tv_usec=0;
3409 while (nRecv < MAX_REPLY_LEN)
3411 if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0)
3413 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
3415 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
3416 goto lend;
3419 if (lpszBuffer[nRecv] == '\n')
3421 bSuccess = TRUE;
3422 break;
3424 if (lpszBuffer[nRecv] != '\r')
3425 nRecv++;
3427 else
3429 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
3430 goto lend;
3434 lend:
3435 if (bSuccess)
3437 lpszBuffer[nRecv] = '\0';
3438 *dwLen = nRecv - 1;
3439 TRACE(":%d %s\n", nRecv, lpszBuffer);
3440 return lpszBuffer;
3442 else
3444 return NULL;
3448 /**********************************************************
3449 * InternetQueryDataAvailable (WININET.@)
3451 * Determines how much data is available to be read.
3453 * RETURNS
3454 * If there is data available then TRUE, otherwise if there
3455 * is not or an error occurred then FALSE. Use GetLastError() to
3456 * check for ERROR_NO_MORE_FILES to see if it was the former.
3458 BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
3459 LPDWORD lpdwNumberOfBytesAvailble,
3460 DWORD dwFlags, DWORD dwConext)
3462 LPWININETHTTPREQW lpwhr;
3463 BOOL retval = FALSE;
3464 char buffer[4048];
3466 lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hFile );
3467 if (NULL == lpwhr)
3469 SetLastError(ERROR_NO_MORE_FILES);
3470 return FALSE;
3473 TRACE("--> %p %i\n",lpwhr,lpwhr->hdr.htype);
3475 switch (lpwhr->hdr.htype)
3477 case WH_HHTTPREQ:
3478 if (!NETCON_recv(&lpwhr->netConnection, buffer,
3479 4048, MSG_PEEK, (int *)lpdwNumberOfBytesAvailble))
3481 SetLastError(ERROR_NO_MORE_FILES);
3482 retval = FALSE;
3484 else
3485 retval = TRUE;
3486 break;
3488 default:
3489 FIXME("unsupported file type\n");
3490 break;
3492 WININET_Release( &lpwhr->hdr );
3494 TRACE("<-- %i\n",retval);
3495 return retval;
3499 /***********************************************************************
3500 * InternetLockRequestFile (WININET.@)
3502 BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
3503 *lphLockReqHandle)
3505 FIXME("STUB\n");
3506 return FALSE;
3509 BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
3511 FIXME("STUB\n");
3512 return FALSE;
3516 /***********************************************************************
3517 * InternetAutodial (WININET.@)
3519 * On windows this function is supposed to dial the default internet
3520 * connection. We don't want to have Wine dial out to the internet so
3521 * we return TRUE by default. It might be nice to check if we are connected.
3523 * RETURNS
3524 * TRUE on success
3525 * FALSE on failure
3528 BOOL WINAPI InternetAutodial(DWORD dwFlags, HWND hwndParent)
3530 FIXME("STUB\n");
3532 /* Tell that we are connected to the internet. */
3533 return TRUE;
3536 /***********************************************************************
3537 * InternetAutodialHangup (WININET.@)
3539 * Hangs up a connection made with InternetAutodial
3541 * PARAM
3542 * dwReserved
3543 * RETURNS
3544 * TRUE on success
3545 * FALSE on failure
3548 BOOL WINAPI InternetAutodialHangup(DWORD dwReserved)
3550 FIXME("STUB\n");
3552 /* we didn't dial, we don't disconnect */
3553 return TRUE;
3556 /***********************************************************************
3557 * InternetCombineUrlA (WININET.@)
3559 * Combine a base URL with a relative URL
3561 * RETURNS
3562 * TRUE on success
3563 * FALSE on failure
3567 BOOL WINAPI InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl,
3568 LPSTR lpszBuffer, LPDWORD lpdwBufferLength,
3569 DWORD dwFlags)
3571 HRESULT hr=S_OK;
3573 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_a(lpszBaseUrl), debugstr_a(lpszRelativeUrl), lpszBuffer, lpdwBufferLength, dwFlags);
3575 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3576 dwFlags ^= ICU_NO_ENCODE;
3577 hr=UrlCombineA(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
3579 return (hr==S_OK);
3582 /***********************************************************************
3583 * InternetCombineUrlW (WININET.@)
3585 * Combine a base URL with a relative URL
3587 * RETURNS
3588 * TRUE on success
3589 * FALSE on failure
3593 BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl,
3594 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength,
3595 DWORD dwFlags)
3597 HRESULT hr=S_OK;
3599 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_w(lpszBaseUrl), debugstr_w(lpszRelativeUrl), lpszBuffer, lpdwBufferLength, dwFlags);
3601 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3602 dwFlags ^= ICU_NO_ENCODE;
3603 hr=UrlCombineW(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
3605 return (hr==S_OK);
3608 /* max port num is 65535 => 5 digits */
3609 #define MAX_WORD_DIGITS 5
3611 /* we can calculate using ansi strings because we're just
3612 * calculating string length, not size
3614 static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
3615 LPDWORD lpdwUrlLength, LPDWORD lpdwSchemeLength)
3617 static const WCHAR httpW[] = {'h','t','t','p',0};
3619 *lpdwUrlLength = 0;
3621 switch (lpUrlComponents->nScheme)
3623 case INTERNET_SCHEME_FTP:
3624 case INTERNET_SCHEME_RES:
3625 *lpdwSchemeLength = 3;
3626 break;
3627 case INTERNET_SCHEME_HTTP:
3628 case INTERNET_SCHEME_FILE:
3629 case INTERNET_SCHEME_NEWS:
3630 *lpdwSchemeLength = 4;
3631 break;
3633 default:
3634 *lpdwSchemeLength = 4;
3635 break;
3638 *lpdwUrlLength += *lpdwSchemeLength;
3639 *lpdwUrlLength += strlen("://");
3641 if (lpUrlComponents->lpszUserName)
3643 *lpdwUrlLength += lpUrlComponents->dwUserNameLength;
3644 *lpdwUrlLength += strlen("@");
3646 else
3648 if (lpUrlComponents->lpszPassword)
3650 SetLastError(ERROR_INVALID_PARAMETER);
3651 return FALSE;
3655 if (lpUrlComponents->lpszPassword)
3657 *lpdwUrlLength += strlen(":");
3658 *lpdwUrlLength += lpUrlComponents->dwPasswordLength;
3661 *lpdwUrlLength += lpUrlComponents->dwHostNameLength;
3663 if (lpUrlComponents->nPort != 80 ||
3664 (lpUrlComponents->lpszScheme && strncmpW(lpUrlComponents->lpszScheme, httpW, lpUrlComponents->dwSchemeLength)))
3666 char szPort[MAX_WORD_DIGITS];
3668 sprintf(szPort, "%d", lpUrlComponents->nPort);
3669 *lpdwUrlLength += strlen(szPort);
3670 *lpdwUrlLength += strlen(":");
3673 *lpdwUrlLength += lpUrlComponents->dwUrlPathLength;
3674 return TRUE;
3677 static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPONENTSW urlCompW)
3679 INT len;
3681 ZeroMemory(urlCompW, sizeof(URL_COMPONENTSW));
3683 urlCompW->dwStructSize = sizeof(URL_COMPONENTSW);
3684 urlCompW->dwSchemeLength = lpUrlComponents->dwSchemeLength;
3685 urlCompW->nScheme = lpUrlComponents->nScheme;
3686 urlCompW->dwHostNameLength = lpUrlComponents->dwHostNameLength;
3687 urlCompW->nPort = lpUrlComponents->nPort;
3688 urlCompW->dwUserNameLength = lpUrlComponents->dwUserNameLength;
3689 urlCompW->dwPasswordLength = lpUrlComponents->dwPasswordLength;
3690 urlCompW->dwUrlPathLength = lpUrlComponents->dwUrlPathLength;
3691 urlCompW->dwExtraInfoLength = lpUrlComponents->dwExtraInfoLength;
3693 if (lpUrlComponents->lpszScheme)
3695 len = lpUrlComponents->dwSchemeLength + 1;
3696 urlCompW->lpszScheme = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3697 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszScheme,
3698 -1, urlCompW->lpszScheme, len);
3701 if (lpUrlComponents->lpszHostName)
3703 len = lpUrlComponents->dwHostNameLength + 1;
3704 urlCompW->lpszHostName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3705 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszHostName,
3706 -1, urlCompW->lpszHostName, len);
3709 if (lpUrlComponents->lpszUserName)
3711 len = lpUrlComponents->dwUserNameLength + 1;
3712 urlCompW->lpszUserName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3713 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUserName,
3714 -1, urlCompW->lpszUserName, len);
3717 if (lpUrlComponents->lpszPassword)
3719 len = lpUrlComponents->dwPasswordLength + 1;
3720 urlCompW->lpszPassword = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3721 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszPassword,
3722 -1, urlCompW->lpszPassword, len);
3725 if (lpUrlComponents->lpszUrlPath)
3727 len = lpUrlComponents->dwUrlPathLength + 1;
3728 urlCompW->lpszUrlPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3729 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUrlPath,
3730 -1, urlCompW->lpszUrlPath, len);
3733 if (lpUrlComponents->lpszExtraInfo)
3735 len = lpUrlComponents->dwExtraInfoLength + 1;
3736 urlCompW->lpszExtraInfo = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3737 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszExtraInfo,
3738 -1, urlCompW->lpszExtraInfo, len);
3742 /***********************************************************************
3743 * InternetCreateUrlA (WININET.@)
3745 * RETURNS
3746 * TRUE on success
3747 * FALSE on failure
3750 BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags,
3751 LPSTR lpszUrl, LPDWORD lpdwUrlLength)
3753 BOOL ret;
3754 LPWSTR urlW = NULL;
3755 URL_COMPONENTSW urlCompW;
3757 TRACE("(%p,%ld,%s,%p)\n", lpUrlComponents, dwFlags, debugstr_a(lpszUrl), lpdwUrlLength);
3759 if (!lpUrlComponents)
3760 return FALSE;
3762 if (lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSW) || !lpdwUrlLength)
3764 SetLastError(ERROR_INVALID_PARAMETER);
3765 return FALSE;
3768 convert_urlcomp_atow(lpUrlComponents, &urlCompW);
3770 if (lpszUrl)
3771 urlW = HeapAlloc(GetProcessHeap(), 0, *lpdwUrlLength * sizeof(WCHAR));
3773 ret = InternetCreateUrlW(&urlCompW, dwFlags, urlW, lpdwUrlLength);
3775 /* on success, lpdwUrlLength points to the size of urlW in WCHARS
3776 * minus one, so add one to leave room for NULL terminator
3778 if (ret)
3779 WideCharToMultiByte(CP_ACP, 0, urlW, -1, lpszUrl, *lpdwUrlLength + 1, NULL, NULL);
3781 HeapFree(GetProcessHeap(), 0, urlCompW.lpszScheme);
3782 HeapFree(GetProcessHeap(), 0, urlCompW.lpszHostName);
3783 HeapFree(GetProcessHeap(), 0, urlCompW.lpszUserName);
3784 HeapFree(GetProcessHeap(), 0, urlCompW.lpszPassword);
3785 HeapFree(GetProcessHeap(), 0, urlCompW.lpszUrlPath);
3786 HeapFree(GetProcessHeap(), 0, urlCompW.lpszExtraInfo);
3787 HeapFree(GetProcessHeap(), 0, urlW);
3789 return ret;
3792 /***********************************************************************
3793 * InternetCreateUrlW (WININET.@)
3795 * RETURNS
3796 * TRUE on success
3797 * FALSE on failure
3800 BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
3801 LPWSTR lpszUrl, LPDWORD lpdwUrlLength)
3803 DWORD dwLen, dwSchemeLen;
3805 static const WCHAR colonSlashW[] = {':','/','/',0};
3806 static const WCHAR httpW[] = {'h','t','t','p',0};
3807 static const WCHAR colonW[] = {':',0};
3808 static const WCHAR atW[] = {'@',0};
3809 static const WCHAR percentD[] = {'%','d',0};
3811 TRACE("(%p,%ld,%s,%p)\n", lpUrlComponents, dwFlags, debugstr_w(lpszUrl), lpdwUrlLength);
3813 if (!lpUrlComponents)
3814 return FALSE;
3816 if (lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSW) || !lpdwUrlLength)
3818 SetLastError(ERROR_INVALID_PARAMETER);
3819 return FALSE;
3822 if (!calc_url_length(lpUrlComponents, &dwLen, &dwSchemeLen))
3823 return FALSE;
3825 if (!lpszUrl || *lpdwUrlLength < dwLen)
3827 *lpdwUrlLength = dwLen + 1; /* terminating null */
3828 SetLastError(ERROR_INSUFFICIENT_BUFFER);
3829 return FALSE;
3832 *lpdwUrlLength = dwLen;
3833 lpszUrl[0] = 0x00;
3835 if (lpUrlComponents->lpszScheme)
3836 lstrcpynW(lpszUrl, lpUrlComponents->lpszScheme,
3837 min(lpUrlComponents->dwSchemeLength, dwSchemeLen) + 1);
3839 lstrcatW(lpszUrl, colonSlashW);
3841 if (lpUrlComponents->lpszUserName)
3843 if (!*lpUrlComponents->lpszUserName)
3844 return TRUE;
3846 lstrcatW(lpszUrl, lpUrlComponents->lpszUserName);
3848 if (lpUrlComponents->lpszPassword)
3850 lstrcatW(lpszUrl, colonW);
3852 if (!*lpUrlComponents->lpszPassword)
3853 return TRUE;
3854 else
3855 lstrcatW(lpszUrl, lpUrlComponents->lpszPassword);
3858 lstrcatW(lpszUrl, atW);
3861 lstrcatW(lpszUrl, lpUrlComponents->lpszHostName);
3863 if (lpUrlComponents->nPort != 80 || (lpUrlComponents->lpszScheme &&
3864 strncmpW(lpUrlComponents->lpszScheme, httpW, lpUrlComponents->dwSchemeLength)))
3866 WCHAR szPort[MAX_WORD_DIGITS];
3868 sprintfW(szPort, percentD, lpUrlComponents->nPort);
3869 lstrcatW(lpszUrl, colonW);
3870 lstrcatW(lpszUrl, szPort);
3873 lstrcatW(lpszUrl, lpUrlComponents->lpszUrlPath);
3875 return TRUE;
3878 /***********************************************************************
3879 * InternetConfirmZoneCrossingA (WININET.@)
3882 DWORD WINAPI InternetConfirmZoneCrossingA( HWND hWnd, LPSTR szUrlPrev, LPSTR szUrlNew, BOOL bPost )
3884 FIXME("(%p, %s, %s, %x) stub\n", hWnd, debugstr_a(szUrlPrev), debugstr_a(szUrlNew), bPost);
3885 return ERROR_SUCCESS;
3888 /***********************************************************************
3889 * InternetConfirmZoneCrossingW (WININET.@)
3892 DWORD WINAPI InternetConfirmZoneCrossingW( HWND hWnd, LPWSTR szUrlPrev, LPWSTR szUrlNew, BOOL bPost )
3894 FIXME("(%p, %s, %s, %x) stub\n", hWnd, debugstr_w(szUrlPrev), debugstr_w(szUrlNew), bPost);
3895 return ERROR_SUCCESS;
3898 DWORD WINAPI InternetDialA( HWND hwndParent, LPSTR lpszConnectoid, DWORD dwFlags,
3899 LPDWORD lpdwConnection, DWORD dwReserved )
3901 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent, lpszConnectoid, dwFlags,
3902 lpdwConnection, dwReserved);
3903 return ERROR_SUCCESS;
3906 DWORD WINAPI InternetDialW( HWND hwndParent, LPWSTR lpszConnectoid, DWORD dwFlags,
3907 LPDWORD lpdwConnection, DWORD dwReserved )
3909 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent, lpszConnectoid, dwFlags,
3910 lpdwConnection, dwReserved);
3911 return ERROR_SUCCESS;
3914 BOOL WINAPI InternetGoOnlineA( LPSTR lpszURL, HWND hwndParent, DWORD dwReserved )
3916 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_a(lpszURL), hwndParent, dwReserved);
3917 return TRUE;
3920 BOOL WINAPI InternetGoOnlineW( LPWSTR lpszURL, HWND hwndParent, DWORD dwReserved )
3922 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_w(lpszURL), hwndParent, dwReserved);
3923 return TRUE;
3926 DWORD WINAPI InternetHangUp( DWORD dwConnection, DWORD dwReserved )
3928 FIXME("(0x%08lx, 0x%08lx) stub\n", dwConnection, dwReserved);
3929 return ERROR_SUCCESS;
3932 BOOL WINAPI CreateMD5SSOHash( PWSTR pszChallengeInfo, PWSTR pwszRealm, PWSTR pwszTarget,
3933 PBYTE pbHexHash )
3935 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo), debugstr_w(pwszRealm),
3936 debugstr_w(pwszTarget), pbHexHash);
3937 return FALSE;
3940 BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID )
3942 FIXME("stub\n");
3943 return TRUE;
3946 BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, unsigned long *pcSiteNameSize,
3947 unsigned long *pdwDecision, unsigned long dwIndex )
3949 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3950 debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
3951 return FALSE;
3954 BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, unsigned long *pcSiteNameSize,
3955 unsigned long *pdwDecision, unsigned long dwIndex )
3957 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3958 debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
3959 return FALSE;
3962 BOOL WINAPI InternetGetCookieExA( LPCSTR pchURL, LPCSTR pchCookieName, LPSTR pchCookieData,
3963 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
3965 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3966 debugstr_a(pchURL), debugstr_a(pchCookieName), debugstr_a(pchCookieData),
3967 pcchCookieData, dwFlags, lpReserved);
3968 return FALSE;
3971 BOOL WINAPI InternetGetCookieExW( LPCWSTR pchURL, LPCWSTR pchCookieName, LPWSTR pchCookieData,
3972 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
3974 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3975 debugstr_w(pchURL), debugstr_w(pchCookieName), debugstr_w(pchCookieData),
3976 pcchCookieData, dwFlags, lpReserved);
3977 return FALSE;
3980 BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, unsigned long *pResult )
3982 FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName), pResult);
3983 return FALSE;
3986 BOOL WINAPI InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName, unsigned long *pResult )
3988 FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName), pResult);
3989 return FALSE;
3992 BOOL WINAPI InternetSetPerSiteCookieDecisionA( LPCSTR pchHostName, DWORD dwDecision )
3994 FIXME("(%s, 0x%08lx) stub\n", debugstr_a(pchHostName), dwDecision);
3995 return FALSE;
3998 BOOL WINAPI InternetSetPerSiteCookieDecisionW( LPCWSTR pchHostName, DWORD dwDecision )
4000 FIXME("(%s, 0x%08lx) stub\n", debugstr_w(pchHostName), dwDecision);
4001 return FALSE;
4004 DWORD WINAPI InternetSetCookieExA( LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData,
4005 DWORD dwFlags, DWORD_PTR dwReserved)
4007 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
4008 debugstr_a(lpszURL), debugstr_a(lpszCookieName), debugstr_a(lpszCookieData),
4009 dwFlags, dwReserved);
4010 return TRUE;
4013 DWORD WINAPI InternetSetCookieExW( LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData,
4014 DWORD dwFlags, DWORD_PTR dwReserved)
4016 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
4017 debugstr_w(lpszURL), debugstr_w(lpszCookieName), debugstr_w(lpszCookieData),
4018 dwFlags, dwReserved);
4019 return TRUE;
4022 BOOL WINAPI ResumeSuspendedDownload( HINTERNET hInternet, DWORD dwError )
4024 FIXME("(%p, 0x%08lx) stub\n", hInternet, dwError);
4025 return FALSE;