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
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/port.h"
32 #define MAXHOSTNAME 100 /* from http.c */
37 #include <sys/types.h>
38 #ifdef HAVE_SYS_SOCKET_H
39 # include <sys/socket.h>
44 #ifdef HAVE_SYS_POLL_H
45 # include <sys/poll.h>
47 #ifdef HAVE_SYS_TIME_H
48 # include <sys/time.h>
64 #include "wine/debug.h"
66 #define NO_SHLWAPI_STREAM
69 #include "wine/exception.h"
74 #include "wine/unicode.h"
76 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
78 #define RESPONSE_TIMEOUT 30
83 CHAR response[MAX_REPLY_LEN];
84 } WITHREADERROR, *LPWITHREADERROR;
86 HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
87 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext);
89 static DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
90 static HMODULE WININET_hModule;
92 #define HANDLE_CHUNK_SIZE 0x10
94 static CRITICAL_SECTION WININET_cs;
95 static CRITICAL_SECTION_DEBUG WININET_cs_debug =
98 { &WININET_cs_debug.ProcessLocksList, &WININET_cs_debug.ProcessLocksList },
99 0, 0, { (DWORD_PTR)(__FILE__ ": WININET_cs") }
101 static CRITICAL_SECTION WININET_cs = { &WININET_cs_debug, -1, 0, 0, 0, 0 };
103 static LPWININETHANDLEHEADER *WININET_Handles;
104 static UINT WININET_dwNextHandle;
105 static UINT WININET_dwMaxHandles;
107 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info )
109 LPWININETHANDLEHEADER *p;
110 UINT handle = 0, num;
112 list_init( &info->children );
114 EnterCriticalSection( &WININET_cs );
115 if( !WININET_dwMaxHandles )
117 num = HANDLE_CHUNK_SIZE;
118 p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
123 WININET_dwMaxHandles = num;
125 if( WININET_dwMaxHandles == WININET_dwNextHandle )
127 num = WININET_dwMaxHandles + HANDLE_CHUNK_SIZE;
128 p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
129 WININET_Handles, sizeof (UINT)* num);
133 WININET_dwMaxHandles = num;
136 handle = WININET_dwNextHandle;
137 if( WININET_Handles[handle] )
138 ERR("handle isn't free but should be\n");
139 WININET_Handles[handle] = WININET_AddRef( info );
141 while( WININET_Handles[WININET_dwNextHandle] &&
142 (WININET_dwNextHandle < WININET_dwMaxHandles ) )
143 WININET_dwNextHandle++;
146 LeaveCriticalSection( &WININET_cs );
148 return info->hInternet = (HINTERNET) (handle+1);
151 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info )
153 ULONG refs = InterlockedIncrement(&info->refs);
154 TRACE("%p -> refcount = %d\n", info, refs );
158 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
160 LPWININETHANDLEHEADER info = NULL;
161 UINT handle = (UINT) hinternet;
163 EnterCriticalSection( &WININET_cs );
165 if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) &&
166 WININET_Handles[handle-1] )
167 info = WININET_AddRef( WININET_Handles[handle-1] );
169 LeaveCriticalSection( &WININET_cs );
171 TRACE("handle %d -> %p\n", handle, info);
176 BOOL WININET_Release( LPWININETHANDLEHEADER info )
178 ULONG refs = InterlockedDecrement(&info->refs);
179 TRACE( "object %p refcount = %d\n", info, refs );
182 if ( info->vtbl->CloseConnection )
184 TRACE( "closing connection %p\n", info);
185 info->vtbl->CloseConnection( info );
187 INTERNET_SendCallback(info, info->dwContext,
188 INTERNET_STATUS_HANDLE_CLOSING, &info->hInternet,
190 TRACE( "destroying object %p\n", info);
191 if ( info->htype != WH_HINIT )
192 list_remove( &info->entry );
193 info->vtbl->Destroy( info );
198 BOOL WININET_FreeHandle( HINTERNET hinternet )
201 UINT handle = (UINT) hinternet;
202 LPWININETHANDLEHEADER info = NULL, child, next;
204 EnterCriticalSection( &WININET_cs );
206 if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) )
209 if( WININET_Handles[handle] )
211 info = WININET_Handles[handle];
212 TRACE( "destroying handle %d for object %p\n", handle+1, info);
213 WININET_Handles[handle] = NULL;
218 LeaveCriticalSection( &WININET_cs );
220 /* As on native when the equivalent of WININET_Release is called, the handle
221 * is already invalid, but if a new handle is created at this time it does
222 * not yet get assigned the freed handle number */
225 /* Free all children as native does */
226 LIST_FOR_EACH_ENTRY_SAFE( child, next, &info->children, WININETHANDLEHEADER, entry )
228 TRACE( "freeing child handle %d for parent handle %d\n",
229 (UINT)child->hInternet, handle+1);
230 WININET_FreeHandle( child->hInternet );
232 WININET_Release( info );
235 EnterCriticalSection( &WININET_cs );
237 if( WININET_dwNextHandle > handle && !WININET_Handles[handle] )
238 WININET_dwNextHandle = handle;
240 LeaveCriticalSection( &WININET_cs );
245 /***********************************************************************
246 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
249 * hinstDLL [I] handle to the DLL's instance
251 * lpvReserved [I] reserved, must be NULL
258 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
260 TRACE("%p,%x,%p\n", hinstDLL, fdwReason, lpvReserved);
263 case DLL_PROCESS_ATTACH:
265 g_dwTlsErrIndex = TlsAlloc();
267 if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
270 URLCacheContainers_CreateDefaults();
272 WININET_hModule = hinstDLL;
274 case DLL_THREAD_ATTACH:
277 case DLL_THREAD_DETACH:
278 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
280 LPVOID lpwite = TlsGetValue(g_dwTlsErrIndex);
281 HeapFree(GetProcessHeap(), 0, lpwite);
285 case DLL_PROCESS_DETACH:
287 URLCacheContainers_DeleteAll();
289 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
291 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex));
292 TlsFree(g_dwTlsErrIndex);
301 /***********************************************************************
302 * InternetInitializeAutoProxyDll (WININET.@)
304 * Setup the internal proxy
313 BOOL WINAPI InternetInitializeAutoProxyDll(DWORD dwReserved)
316 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
320 /***********************************************************************
321 * DetectAutoProxyUrl (WININET.@)
323 * Auto detect the proxy url
329 BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl,
330 DWORD dwAutoProxyUrlLength, DWORD dwDetectFlags)
333 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
338 /***********************************************************************
339 * INTERNET_ConfigureProxy
342 * The proxy may be specified in the form 'http=proxy.my.org'
343 * Presumably that means there can be ftp=ftpproxy.my.org too.
345 static BOOL INTERNET_ConfigureProxy( LPWININETAPPINFOW lpwai )
348 DWORD type, len, enabled = 0;
350 static const WCHAR szInternetSettings[] =
351 { 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
352 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
353 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0 };
354 static const WCHAR szProxyServer[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
355 static const WCHAR szProxyEnable[] = { 'P','r','o','x','y','E','n','a','b','l','e', 0 };
357 if (RegOpenKeyW( HKEY_CURRENT_USER, szInternetSettings, &key )) return FALSE;
359 len = sizeof enabled;
360 if (RegQueryValueExW( key, szProxyEnable, NULL, &type, (BYTE *)&enabled, &len ) || type != REG_DWORD)
361 RegSetValueExW( key, szProxyEnable, 0, REG_DWORD, (BYTE *)&enabled, sizeof(REG_DWORD) );
365 TRACE("Proxy is enabled.\n");
367 /* figure out how much memory the proxy setting takes */
368 if (!RegQueryValueExW( key, szProxyServer, NULL, &type, NULL, &len ) && len && (type == REG_SZ))
371 static const WCHAR szHttp[] = {'h','t','t','p','=',0};
373 if (!(szProxy = HeapAlloc( GetProcessHeap(), 0, len )))
378 RegQueryValueExW( key, szProxyServer, NULL, &type, (BYTE*)szProxy, &len );
380 /* find the http proxy, and strip away everything else */
381 p = strstrW( szProxy, szHttp );
384 p += lstrlenW( szHttp );
385 lstrcpyW( szProxy, p );
387 p = strchrW( szProxy, ' ' );
390 lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY;
391 lpwai->lpszProxy = szProxy;
393 TRACE("http proxy = %s\n", debugstr_w(lpwai->lpszProxy));
396 ERR("Couldn't read proxy server settings from registry.\n");
398 else if ((envproxy = getenv( "http_proxy" )))
402 len = MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, NULL, 0 );
403 if (!(envproxyW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR)))) return FALSE;
404 MultiByteToWideChar( CP_UNIXCP, 0, envproxy, -1, envproxyW, len );
406 lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY;
407 lpwai->lpszProxy = envproxyW;
409 TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwai->lpszProxy));
412 if (!enabled) TRACE("Proxy is not enabled.\n");
415 return (enabled > 0);
418 /***********************************************************************
419 * dump_INTERNET_FLAGS
421 * Helper function to TRACE the internet flags.
427 static void dump_INTERNET_FLAGS(DWORD dwFlags)
429 #define FE(x) { x, #x }
430 static const wininet_flag_info flag[] = {
431 FE(INTERNET_FLAG_RELOAD),
432 FE(INTERNET_FLAG_RAW_DATA),
433 FE(INTERNET_FLAG_EXISTING_CONNECT),
434 FE(INTERNET_FLAG_ASYNC),
435 FE(INTERNET_FLAG_PASSIVE),
436 FE(INTERNET_FLAG_NO_CACHE_WRITE),
437 FE(INTERNET_FLAG_MAKE_PERSISTENT),
438 FE(INTERNET_FLAG_FROM_CACHE),
439 FE(INTERNET_FLAG_SECURE),
440 FE(INTERNET_FLAG_KEEP_CONNECTION),
441 FE(INTERNET_FLAG_NO_AUTO_REDIRECT),
442 FE(INTERNET_FLAG_READ_PREFETCH),
443 FE(INTERNET_FLAG_NO_COOKIES),
444 FE(INTERNET_FLAG_NO_AUTH),
445 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL),
446 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP),
447 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS),
448 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID),
449 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID),
450 FE(INTERNET_FLAG_RESYNCHRONIZE),
451 FE(INTERNET_FLAG_HYPERLINK),
452 FE(INTERNET_FLAG_NO_UI),
453 FE(INTERNET_FLAG_PRAGMA_NOCACHE),
454 FE(INTERNET_FLAG_CACHE_ASYNC),
455 FE(INTERNET_FLAG_FORMS_SUBMIT),
456 FE(INTERNET_FLAG_NEED_FILE),
457 FE(INTERNET_FLAG_TRANSFER_ASCII),
458 FE(INTERNET_FLAG_TRANSFER_BINARY)
463 for (i = 0; i < (sizeof(flag) / sizeof(flag[0])); i++) {
464 if (flag[i].val & dwFlags) {
465 TRACE(" %s", flag[i].name);
466 dwFlags &= ~flag[i].val;
470 TRACE(" Unknown flags (%08x)\n", dwFlags);
475 /***********************************************************************
476 * INTERNET_CloseHandle (internal)
478 * Close internet handle
481 static VOID APPINFO_Destroy(WININETHANDLEHEADER *hdr)
483 LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW) hdr;
487 HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
488 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxy);
489 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
490 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyUsername);
491 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyPassword);
492 HeapFree(GetProcessHeap(), 0, lpwai);
495 static DWORD APPINFO_QueryOption(WININETHANDLEHEADER *hdr, DWORD option, void *buffer, DWORD *size, BOOL unicode)
498 case INTERNET_OPTION_HANDLE_TYPE:
499 TRACE("INTERNET_OPTION_HANDLE_TYPE\n");
501 if (*size < sizeof(ULONG))
502 return ERROR_INSUFFICIENT_BUFFER;
504 *size = sizeof(DWORD);
505 *(DWORD*)buffer = INTERNET_HANDLE_TYPE_INTERNET;
506 return ERROR_SUCCESS;
509 FIXME("Not implemented option %d\n", option);
510 return ERROR_INTERNET_INVALID_OPTION;
513 static const HANDLEHEADERVtbl APPINFOVtbl = {
526 /***********************************************************************
527 * InternetOpenW (WININET.@)
529 * Per-application initialization of wininet
532 * HINTERNET on success
536 HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
537 LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
539 LPWININETAPPINFOW lpwai = NULL;
540 HINTERNET handle = NULL;
542 if (TRACE_ON(wininet)) {
543 #define FE(x) { x, #x }
544 static const wininet_flag_info access_type[] = {
545 FE(INTERNET_OPEN_TYPE_PRECONFIG),
546 FE(INTERNET_OPEN_TYPE_DIRECT),
547 FE(INTERNET_OPEN_TYPE_PROXY),
548 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY)
552 const char *access_type_str = "Unknown";
554 TRACE("(%s, %i, %s, %s, %i)\n", debugstr_w(lpszAgent), dwAccessType,
555 debugstr_w(lpszProxy), debugstr_w(lpszProxyBypass), dwFlags);
556 for (i = 0; i < (sizeof(access_type) / sizeof(access_type[0])); i++) {
557 if (access_type[i].val == dwAccessType) {
558 access_type_str = access_type[i].name;
562 TRACE(" access type : %s\n", access_type_str);
564 dump_INTERNET_FLAGS(dwFlags);
567 /* Clear any error information */
568 INTERNET_SetLastError(0);
570 lpwai = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETAPPINFOW));
573 INTERNET_SetLastError(ERROR_OUTOFMEMORY);
577 lpwai->hdr.htype = WH_HINIT;
578 lpwai->hdr.vtbl = &APPINFOVtbl;
579 lpwai->hdr.dwFlags = dwFlags;
581 lpwai->dwAccessType = dwAccessType;
582 lpwai->lpszProxyUsername = NULL;
583 lpwai->lpszProxyPassword = NULL;
585 handle = WININET_AllocHandle( &lpwai->hdr );
588 HeapFree( GetProcessHeap(), 0, lpwai );
589 INTERNET_SetLastError(ERROR_OUTOFMEMORY);
593 if (NULL != lpszAgent)
595 lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,
596 (strlenW(lpszAgent)+1)*sizeof(WCHAR));
597 if (lpwai->lpszAgent)
598 lstrcpyW( lpwai->lpszAgent, lpszAgent );
600 if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG)
601 INTERNET_ConfigureProxy( lpwai );
602 else if (NULL != lpszProxy)
604 lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0,
605 (strlenW(lpszProxy)+1)*sizeof(WCHAR));
606 if (lpwai->lpszProxy)
607 lstrcpyW( lpwai->lpszProxy, lpszProxy );
610 if (NULL != lpszProxyBypass)
612 lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0,
613 (strlenW(lpszProxyBypass)+1)*sizeof(WCHAR));
614 if (lpwai->lpszProxyBypass)
615 lstrcpyW( lpwai->lpszProxyBypass, lpszProxyBypass );
620 WININET_Release( &lpwai->hdr );
622 TRACE("returning %p\n", lpwai);
628 /***********************************************************************
629 * InternetOpenA (WININET.@)
631 * Per-application initialization of wininet
634 * HINTERNET on success
638 HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
639 LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
643 WCHAR *szAgent = NULL, *szProxy = NULL, *szBypass = NULL;
645 TRACE("(%s, 0x%08x, %s, %s, 0x%08x)\n", debugstr_a(lpszAgent),
646 dwAccessType, debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
650 len = MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, NULL, 0);
651 szAgent = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
652 MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, szAgent, len);
657 len = MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, NULL, 0);
658 szProxy = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
659 MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, szProxy, len);
662 if( lpszProxyBypass )
664 len = MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, NULL, 0);
665 szBypass = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
666 MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, szBypass, len);
669 rc = InternetOpenW(szAgent, dwAccessType, szProxy, szBypass, dwFlags);
671 HeapFree(GetProcessHeap(), 0, szAgent);
672 HeapFree(GetProcessHeap(), 0, szProxy);
673 HeapFree(GetProcessHeap(), 0, szBypass);
678 /***********************************************************************
679 * InternetGetLastResponseInfoA (WININET.@)
681 * Return last wininet error description on the calling thread
684 * TRUE on success of writing to buffer
688 BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
689 LPSTR lpszBuffer, LPDWORD lpdwBufferLength)
691 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
697 *lpdwError = lpwite->dwError;
700 memcpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
701 *lpdwBufferLength = strlen(lpszBuffer);
704 *lpdwBufferLength = 0;
709 *lpdwBufferLength = 0;
715 /***********************************************************************
716 * InternetGetLastResponseInfoW (WININET.@)
718 * Return last wininet error description on the calling thread
721 * TRUE on success of writing to buffer
725 BOOL WINAPI InternetGetLastResponseInfoW(LPDWORD lpdwError,
726 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength)
728 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
734 *lpdwError = lpwite->dwError;
737 memcpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
738 *lpdwBufferLength = lstrlenW(lpszBuffer);
741 *lpdwBufferLength = 0;
746 *lpdwBufferLength = 0;
752 /***********************************************************************
753 * InternetGetConnectedState (WININET.@)
755 * Return connected state
759 * if lpdwStatus is not null, return the status (off line,
760 * modem, lan...) in it.
761 * FALSE if not connected
763 BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved)
765 TRACE("(%p, 0x%08x)\n", lpdwStatus, dwReserved);
768 FIXME("always returning LAN connection.\n");
769 *lpdwStatus = INTERNET_CONNECTION_LAN;
775 /***********************************************************************
776 * InternetGetConnectedStateExW (WININET.@)
778 * Return connected state
782 * lpdwStatus [O] Flags specifying the status of the internet connection.
783 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
784 * dwNameLen [I] Size of the buffer, in characters.
785 * dwReserved [I] Reserved. Must be set to 0.
789 * if lpdwStatus is not null, return the status (off line,
790 * modem, lan...) in it.
791 * FALSE if not connected
794 * If the system has no available network connections, an empty string is
795 * stored in lpszConnectionName. If there is a LAN connection, a localized
796 * "LAN Connection" string is stored. Presumably, if only a dial-up
797 * connection is available then the name of the dial-up connection is
798 * returned. Why any application, other than the "Internet Settings" CPL,
799 * would want to use this function instead of the simpler InternetGetConnectedStateW
800 * function is beyond me.
802 BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnectionName,
803 DWORD dwNameLen, DWORD dwReserved)
805 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
812 FIXME("always returning LAN connection.\n");
813 *lpdwStatus = INTERNET_CONNECTION_LAN;
815 return LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen);
819 /***********************************************************************
820 * InternetGetConnectedStateExA (WININET.@)
822 BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectionName,
823 DWORD dwNameLen, DWORD dwReserved)
825 LPWSTR lpwszConnectionName = NULL;
828 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
830 if (lpszConnectionName && dwNameLen > 0)
831 lpwszConnectionName= HeapAlloc(GetProcessHeap(), 0, dwNameLen * sizeof(WCHAR));
833 rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen,
835 if (rc && lpwszConnectionName)
837 WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName,
838 dwNameLen, NULL, NULL);
840 HeapFree(GetProcessHeap(),0,lpwszConnectionName);
847 /***********************************************************************
848 * InternetConnectW (WININET.@)
850 * Open a ftp, gopher or http session
853 * HINTERNET a session handle on success
857 HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
858 LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
859 LPCWSTR lpszUserName, LPCWSTR lpszPassword,
860 DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
862 LPWININETAPPINFOW hIC;
865 TRACE("(%p, %s, %i, %s, %s, %i, %i, %lx)\n", hInternet, debugstr_w(lpszServerName),
866 nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword),
867 dwService, dwFlags, dwContext);
871 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
875 /* Clear any error information */
876 INTERNET_SetLastError(0);
877 hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
878 if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
880 INTERNET_SetLastError(ERROR_INVALID_HANDLE);
886 case INTERNET_SERVICE_FTP:
887 rc = FTP_Connect(hIC, lpszServerName, nServerPort,
888 lpszUserName, lpszPassword, dwFlags, dwContext, 0);
891 case INTERNET_SERVICE_HTTP:
892 rc = HTTP_Connect(hIC, lpszServerName, nServerPort,
893 lpszUserName, lpszPassword, dwFlags, dwContext, 0);
896 case INTERNET_SERVICE_GOPHER:
902 WININET_Release( &hIC->hdr );
904 TRACE("returning %p\n", rc);
909 /***********************************************************************
910 * InternetConnectA (WININET.@)
912 * Open a ftp, gopher or http session
915 * HINTERNET a session handle on success
919 HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
920 LPCSTR lpszServerName, INTERNET_PORT nServerPort,
921 LPCSTR lpszUserName, LPCSTR lpszPassword,
922 DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
926 LPWSTR szServerName = NULL;
927 LPWSTR szUserName = NULL;
928 LPWSTR szPassword = NULL;
932 len = MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, NULL, 0);
933 szServerName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
934 MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, szServerName, len);
938 len = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
939 szUserName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
940 MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, szUserName, len);
944 len = MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, NULL, 0);
945 szPassword = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
946 MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, szPassword, len);
950 rc = InternetConnectW(hInternet, szServerName, nServerPort,
951 szUserName, szPassword, dwService, dwFlags, dwContext);
953 HeapFree(GetProcessHeap(), 0, szServerName);
954 HeapFree(GetProcessHeap(), 0, szUserName);
955 HeapFree(GetProcessHeap(), 0, szPassword);
960 /***********************************************************************
961 * InternetFindNextFileA (WININET.@)
963 * Continues a file search from a previous call to FindFirstFile
970 BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
975 ret = InternetFindNextFileW(hFind, lpvFindData?&fd:NULL);
977 WININET_find_data_WtoA(&fd, (LPWIN32_FIND_DATAA)lpvFindData);
981 /***********************************************************************
982 * InternetFindNextFileW (WININET.@)
984 * Continues a file search from a previous call to FindFirstFile
991 BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
993 WININETHANDLEHEADER *hdr;
998 hdr = WININET_GetObject(hFind);
1000 WARN("Invalid handle\n");
1001 SetLastError(ERROR_INVALID_HANDLE);
1005 if(hdr->vtbl->FindNextFileW) {
1006 res = hdr->vtbl->FindNextFileW(hdr, lpvFindData);
1008 WARN("Handle doesn't support NextFile\n");
1009 res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
1012 WININET_Release(hdr);
1014 if(res != ERROR_SUCCESS)
1016 return res == ERROR_SUCCESS;
1019 /***********************************************************************
1020 * InternetCloseHandle (WININET.@)
1022 * Generic close handle function
1029 BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
1031 LPWININETHANDLEHEADER lpwh;
1033 TRACE("%p\n",hInternet);
1035 lpwh = WININET_GetObject( hInternet );
1038 INTERNET_SetLastError(ERROR_INVALID_HANDLE);
1042 WININET_Release( lpwh );
1043 WININET_FreeHandle( hInternet );
1049 /***********************************************************************
1050 * ConvertUrlComponentValue (Internal)
1052 * Helper function for InternetCrackUrlW
1055 static void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
1056 LPWSTR lpwszComponent, DWORD dwwComponentLen,
1057 LPCSTR lpszStart, LPCWSTR lpwszStart)
1059 TRACE("%p %d %p %d %p %p\n", lppszComponent, *dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart);
1060 if (*dwComponentLen != 0)
1062 DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
1063 if (*lppszComponent == NULL)
1065 int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL);
1067 *lppszComponent = (LPSTR)lpszStart+nASCIIOffset;
1069 *lppszComponent = NULL;
1070 *dwComponentLen = nASCIILength;
1074 DWORD ncpylen = min((*dwComponentLen)-1, nASCIILength);
1075 WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,*lppszComponent,ncpylen+1,NULL,NULL);
1076 (*lppszComponent)[ncpylen]=0;
1077 *dwComponentLen = ncpylen;
1083 /***********************************************************************
1084 * InternetCrackUrlA (WININET.@)
1086 * See InternetCrackUrlW.
1088 BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
1089 LPURL_COMPONENTSA lpUrlComponents)
1092 URL_COMPONENTSW UCW;
1095 TRACE("(%s %u %x %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents);
1097 if (!lpszUrl || !*lpszUrl || !lpUrlComponents ||
1098 lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSA))
1100 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
1106 nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,NULL,0);
1108 /* if dwUrlLength=-1 then nLength includes null but length to
1109 InternetCrackUrlW should not include it */
1110 if (dwUrlLength == -1) nLength--;
1112 lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength);
1113 MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
1115 memset(&UCW,0,sizeof(UCW));
1116 UCW.dwStructSize = sizeof(URL_COMPONENTSW);
1117 if(lpUrlComponents->dwHostNameLength!=0)
1118 UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength;
1119 if(lpUrlComponents->dwUserNameLength!=0)
1120 UCW.dwUserNameLength=lpUrlComponents->dwUserNameLength;
1121 if(lpUrlComponents->dwPasswordLength!=0)
1122 UCW.dwPasswordLength=lpUrlComponents->dwPasswordLength;
1123 if(lpUrlComponents->dwUrlPathLength!=0)
1124 UCW.dwUrlPathLength=lpUrlComponents->dwUrlPathLength;
1125 if(lpUrlComponents->dwSchemeLength!=0)
1126 UCW.dwSchemeLength=lpUrlComponents->dwSchemeLength;
1127 if(lpUrlComponents->dwExtraInfoLength!=0)
1128 UCW.dwExtraInfoLength=lpUrlComponents->dwExtraInfoLength;
1129 if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
1131 HeapFree(GetProcessHeap(), 0, lpwszUrl);
1135 ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
1136 UCW.lpszHostName, UCW.dwHostNameLength,
1138 ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
1139 UCW.lpszUserName, UCW.dwUserNameLength,
1141 ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
1142 UCW.lpszPassword, UCW.dwPasswordLength,
1144 ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
1145 UCW.lpszUrlPath, UCW.dwUrlPathLength,
1147 ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
1148 UCW.lpszScheme, UCW.dwSchemeLength,
1150 ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
1151 UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
1153 lpUrlComponents->nScheme=UCW.nScheme;
1154 lpUrlComponents->nPort=UCW.nPort;
1155 HeapFree(GetProcessHeap(), 0, lpwszUrl);
1157 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
1158 debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength),
1159 debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength),
1160 debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength),
1161 debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength));
1166 static const WCHAR url_schemes[][7] =
1169 {'g','o','p','h','e','r',0},
1170 {'h','t','t','p',0},
1171 {'h','t','t','p','s',0},
1172 {'f','i','l','e',0},
1173 {'n','e','w','s',0},
1174 {'m','a','i','l','t','o',0},
1178 /***********************************************************************
1179 * GetInternetSchemeW (internal)
1185 * INTERNET_SCHEME_UNKNOWN on failure
1188 static INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, DWORD nMaxCmp)
1192 TRACE("%s %d\n",debugstr_wn(lpszScheme, nMaxCmp), nMaxCmp);
1194 if(lpszScheme==NULL)
1195 return INTERNET_SCHEME_UNKNOWN;
1197 for (i = 0; i < sizeof(url_schemes)/sizeof(url_schemes[0]); i++)
1198 if (!strncmpW(lpszScheme, url_schemes[i], nMaxCmp))
1199 return INTERNET_SCHEME_FIRST + i;
1201 return INTERNET_SCHEME_UNKNOWN;
1204 /***********************************************************************
1205 * SetUrlComponentValueW (Internal)
1207 * Helper function for InternetCrackUrlW
1210 * lppszComponent [O] Holds the returned string
1211 * dwComponentLen [I] Holds the size of lppszComponent
1212 * [O] Holds the length of the string in lppszComponent without '\0'
1213 * lpszStart [I] Holds the string to copy from
1214 * len [I] Holds the length of lpszStart without '\0'
1221 static BOOL SetUrlComponentValueW(LPWSTR* lppszComponent, LPDWORD dwComponentLen, LPCWSTR lpszStart, DWORD len)
1223 TRACE("%s (%d)\n", debugstr_wn(lpszStart,len), len);
1225 if ( (*dwComponentLen == 0) && (*lppszComponent == NULL) )
1228 if (*dwComponentLen != 0 || *lppszComponent == NULL)
1230 if (*lppszComponent == NULL)
1232 *lppszComponent = (LPWSTR)lpszStart;
1233 *dwComponentLen = len;
1237 DWORD ncpylen = min((*dwComponentLen)-1, len);
1238 memcpy(*lppszComponent, lpszStart, ncpylen*sizeof(WCHAR));
1239 (*lppszComponent)[ncpylen] = '\0';
1240 *dwComponentLen = ncpylen;
1247 /***********************************************************************
1248 * InternetCrackUrlW (WININET.@)
1250 * Break up URL into its components
1256 BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWORD dwFlags,
1257 LPURL_COMPONENTSW lpUC)
1261 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1264 LPCWSTR lpszParam = NULL;
1265 BOOL bIsAbsolute = FALSE;
1266 LPCWSTR lpszap, lpszUrl = lpszUrl_orig;
1267 LPCWSTR lpszcp = NULL;
1268 LPWSTR lpszUrl_decode = NULL;
1269 DWORD dwUrlLength = dwUrlLength_orig;
1270 const WCHAR lpszSeparators[3]={';','?',0};
1271 const WCHAR lpszSlash[2]={'/',0};
1273 TRACE("(%s %u %x %p)\n", debugstr_w(lpszUrl), dwUrlLength, dwFlags, lpUC);
1275 if (!lpszUrl_orig || !*lpszUrl_orig || !lpUC)
1277 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
1280 if (!dwUrlLength) dwUrlLength = strlenW(lpszUrl);
1282 if (dwFlags & ICU_DECODE)
1284 lpszUrl_decode=HeapAlloc( GetProcessHeap(), 0, dwUrlLength * sizeof (WCHAR) );
1285 if( InternetCanonicalizeUrlW(lpszUrl_orig, lpszUrl_decode, &dwUrlLength, dwFlags))
1287 lpszUrl = lpszUrl_decode;
1292 /* Determine if the URI is absolute. */
1293 while (*lpszap != '\0')
1295 if (isalnumW(*lpszap))
1300 if ((*lpszap == ':') && (lpszap - lpszUrl >= 2))
1307 lpszcp = lpszUrl; /* Relative url */
1313 lpUC->nScheme = INTERNET_SCHEME_UNKNOWN;
1314 lpUC->nPort = INTERNET_INVALID_PORT_NUMBER;
1316 /* Parse <params> */
1317 lpszParam = strpbrkW(lpszap, lpszSeparators);
1318 SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
1319 lpszParam, lpszParam ? dwUrlLength-(lpszParam-lpszUrl) : 0);
1321 if (bIsAbsolute) /* Parse <protocol>:[//<net_loc>] */
1325 /* Get scheme first. */
1326 lpUC->nScheme = GetInternetSchemeW(lpszUrl, lpszcp - lpszUrl);
1327 SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength,
1328 lpszUrl, lpszcp - lpszUrl);
1330 /* Eat ':' in protocol. */
1333 /* double slash indicates the net_loc portion is present */
1334 if ((lpszcp[0] == '/') && (lpszcp[1] == '/'))
1338 lpszNetLoc = strpbrkW(lpszcp, lpszSlash);
1342 lpszNetLoc = min(lpszNetLoc, lpszParam);
1344 lpszNetLoc = lpszParam;
1346 else if (!lpszNetLoc)
1347 lpszNetLoc = lpszcp + dwUrlLength-(lpszcp-lpszUrl);
1355 /* [<user>[<:password>]@]<host>[:<port>] */
1356 /* First find the user and password if they exist */
1358 lpszHost = strchrW(lpszcp, '@');
1359 if (lpszHost == NULL || lpszHost > lpszNetLoc)
1361 /* username and password not specified. */
1362 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1363 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1365 else /* Parse out username and password */
1367 LPCWSTR lpszUser = lpszcp;
1368 LPCWSTR lpszPasswd = lpszHost;
1370 while (lpszcp < lpszHost)
1373 lpszPasswd = lpszcp;
1378 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength,
1379 lpszUser, lpszPasswd - lpszUser);
1381 if (lpszPasswd != lpszHost)
1383 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength,
1384 lpszPasswd == lpszHost ? NULL : lpszPasswd,
1385 lpszHost - lpszPasswd);
1387 lpszcp++; /* Advance to beginning of host */
1390 /* Parse <host><:port> */
1393 lpszPort = lpszNetLoc;
1395 /* special case for res:// URLs: there is no port here, so the host is the
1396 entire string up to the first '/' */
1397 if(lpUC->nScheme==INTERNET_SCHEME_RES)
1399 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1400 lpszHost, lpszPort - lpszHost);
1405 while (lpszcp < lpszNetLoc)
1413 /* If the scheme is "file" and the host is just one letter, it's not a host */
1414 if(lpUC->nScheme==INTERNET_SCHEME_FILE && (lpszPort-lpszHost)==1)
1417 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1422 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1423 lpszHost, lpszPort - lpszHost);
1424 if (lpszPort != lpszNetLoc)
1425 lpUC->nPort = atoiW(++lpszPort);
1426 else switch (lpUC->nScheme)
1428 case INTERNET_SCHEME_HTTP:
1429 lpUC->nPort = INTERNET_DEFAULT_HTTP_PORT;
1431 case INTERNET_SCHEME_HTTPS:
1432 lpUC->nPort = INTERNET_DEFAULT_HTTPS_PORT;
1434 case INTERNET_SCHEME_FTP:
1435 lpUC->nPort = INTERNET_DEFAULT_FTP_PORT;
1437 case INTERNET_SCHEME_GOPHER:
1438 lpUC->nPort = INTERNET_DEFAULT_GOPHER_PORT;
1449 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1450 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1451 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
1456 SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength, NULL, 0);
1457 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1458 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1459 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
1462 /* Here lpszcp points to:
1464 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1465 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1467 if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam))
1471 /* Only truncate the parameter list if it's already been saved
1472 * in lpUC->lpszExtraInfo.
1474 if (lpszParam && lpUC->dwExtraInfoLength && lpUC->lpszExtraInfo)
1475 len = lpszParam - lpszcp;
1478 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1479 * newlines if necessary.
1481 LPWSTR lpsznewline = strchrW(lpszcp, '\n');
1482 if (lpsznewline != NULL)
1483 len = lpsznewline - lpszcp;
1485 len = dwUrlLength-(lpszcp-lpszUrl);
1487 SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
1492 lpUC->dwUrlPathLength = 0;
1495 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
1496 debugstr_wn(lpUC->lpszScheme,lpUC->dwSchemeLength),
1497 debugstr_wn(lpUC->lpszHostName,lpUC->dwHostNameLength),
1498 debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
1499 debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
1501 HeapFree(GetProcessHeap(), 0, lpszUrl_decode );
1505 /***********************************************************************
1506 * InternetAttemptConnect (WININET.@)
1508 * Attempt to make a connection to the internet
1511 * ERROR_SUCCESS on success
1512 * Error value on failure
1515 DWORD WINAPI InternetAttemptConnect(DWORD dwReserved)
1518 return ERROR_SUCCESS;
1522 /***********************************************************************
1523 * InternetCanonicalizeUrlA (WININET.@)
1525 * Escape unsafe characters and spaces
1532 BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
1533 LPDWORD lpdwBufferLength, DWORD dwFlags)
1536 DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE;
1538 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl), lpszBuffer,
1539 lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags);
1541 if(dwFlags & ICU_DECODE)
1543 dwURLFlags |= URL_UNESCAPE;
1544 dwFlags &= ~ICU_DECODE;
1547 if(dwFlags & ICU_ESCAPE)
1549 dwURLFlags |= URL_UNESCAPE;
1550 dwFlags &= ~ICU_ESCAPE;
1553 if(dwFlags & ICU_BROWSER_MODE)
1555 dwURLFlags |= URL_BROWSER_MODE;
1556 dwFlags &= ~ICU_BROWSER_MODE;
1559 if(dwFlags & ICU_NO_ENCODE)
1561 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1562 dwURLFlags ^= URL_ESCAPE_UNSAFE;
1563 dwFlags &= ~ICU_NO_ENCODE;
1566 if (dwFlags) FIXME("Unhandled flags 0x%08x\n", dwFlags);
1568 hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
1569 if (hr == E_POINTER) SetLastError(ERROR_INSUFFICIENT_BUFFER);
1570 if (hr == E_INVALIDARG) SetLastError(ERROR_INVALID_PARAMETER);
1572 return (hr == S_OK) ? TRUE : FALSE;
1575 /***********************************************************************
1576 * InternetCanonicalizeUrlW (WININET.@)
1578 * Escape unsafe characters and spaces
1585 BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
1586 LPDWORD lpdwBufferLength, DWORD dwFlags)
1589 DWORD dwURLFlags = URL_WININET_COMPATIBILITY | URL_ESCAPE_UNSAFE;
1591 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl), lpszBuffer,
1592 lpdwBufferLength, lpdwBufferLength ? *lpdwBufferLength : -1, dwFlags);
1594 if(dwFlags & ICU_DECODE)
1596 dwURLFlags |= URL_UNESCAPE;
1597 dwFlags &= ~ICU_DECODE;
1600 if(dwFlags & ICU_ESCAPE)
1602 dwURLFlags |= URL_UNESCAPE;
1603 dwFlags &= ~ICU_ESCAPE;
1606 if(dwFlags & ICU_BROWSER_MODE)
1608 dwURLFlags |= URL_BROWSER_MODE;
1609 dwFlags &= ~ICU_BROWSER_MODE;
1612 if(dwFlags & ICU_NO_ENCODE)
1614 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1615 dwURLFlags ^= URL_ESCAPE_UNSAFE;
1616 dwFlags &= ~ICU_NO_ENCODE;
1619 if (dwFlags) FIXME("Unhandled flags 0x%08x\n", dwFlags);
1621 hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
1622 if (hr == E_POINTER) SetLastError(ERROR_INSUFFICIENT_BUFFER);
1623 if (hr == E_INVALIDARG) SetLastError(ERROR_INVALID_PARAMETER);
1625 return (hr == S_OK) ? TRUE : FALSE;
1628 /* #################################################### */
1630 static INTERNET_STATUS_CALLBACK set_status_callback(
1631 LPWININETHANDLEHEADER lpwh, INTERNET_STATUS_CALLBACK callback, BOOL unicode)
1633 INTERNET_STATUS_CALLBACK ret;
1635 if (unicode) lpwh->dwInternalFlags |= INET_CALLBACKW;
1636 else lpwh->dwInternalFlags &= ~INET_CALLBACKW;
1638 ret = lpwh->lpfnStatusCB;
1639 lpwh->lpfnStatusCB = callback;
1644 /***********************************************************************
1645 * InternetSetStatusCallbackA (WININET.@)
1647 * Sets up a callback function which is called as progress is made
1648 * during an operation.
1651 * Previous callback or NULL on success
1652 * INTERNET_INVALID_STATUS_CALLBACK on failure
1655 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
1656 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1658 INTERNET_STATUS_CALLBACK retVal;
1659 LPWININETHANDLEHEADER lpwh;
1661 TRACE("0x%08x\n", (ULONG)hInternet);
1663 if (!(lpwh = WININET_GetObject(hInternet)))
1664 return INTERNET_INVALID_STATUS_CALLBACK;
1666 retVal = set_status_callback(lpwh, lpfnIntCB, FALSE);
1668 WININET_Release( lpwh );
1672 /***********************************************************************
1673 * InternetSetStatusCallbackW (WININET.@)
1675 * Sets up a callback function which is called as progress is made
1676 * during an operation.
1679 * Previous callback or NULL on success
1680 * INTERNET_INVALID_STATUS_CALLBACK on failure
1683 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(
1684 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1686 INTERNET_STATUS_CALLBACK retVal;
1687 LPWININETHANDLEHEADER lpwh;
1689 TRACE("0x%08x\n", (ULONG)hInternet);
1691 if (!(lpwh = WININET_GetObject(hInternet)))
1692 return INTERNET_INVALID_STATUS_CALLBACK;
1694 retVal = set_status_callback(lpwh, lpfnIntCB, TRUE);
1696 WININET_Release( lpwh );
1700 /***********************************************************************
1701 * InternetSetFilePointer (WININET.@)
1703 DWORD WINAPI InternetSetFilePointer(HINTERNET hFile, LONG lDistanceToMove,
1704 PVOID pReserved, DWORD dwMoveContext, DWORD_PTR dwContext)
1710 /***********************************************************************
1711 * InternetWriteFile (WININET.@)
1713 * Write data to an open internet file
1720 BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer,
1721 DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
1723 LPWININETHANDLEHEADER lpwh;
1724 BOOL retval = FALSE;
1726 TRACE("(%p %p %d %p)\n", hFile, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
1728 lpwh = WININET_GetObject( hFile );
1730 WARN("Invalid handle\n");
1731 SetLastError(ERROR_INVALID_HANDLE);
1735 if(lpwh->vtbl->WriteFile) {
1736 retval = lpwh->vtbl->WriteFile(lpwh, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
1738 WARN("No Writefile method.\n");
1739 SetLastError(ERROR_INVALID_HANDLE);
1743 WININET_Release( lpwh );
1749 /***********************************************************************
1750 * InternetReadFile (WININET.@)
1752 * Read data from an open internet file
1759 BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
1760 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
1762 LPWININETHANDLEHEADER hdr;
1763 DWORD res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
1765 TRACE("%p %p %d %p\n", hFile, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead);
1767 hdr = WININET_GetObject(hFile);
1769 INTERNET_SetLastError(ERROR_INVALID_HANDLE);
1773 if(hdr->vtbl->ReadFile)
1774 res = hdr->vtbl->ReadFile(hdr, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead);
1776 WININET_Release(hdr);
1778 TRACE("-- %s (%u) (bytes read: %d)\n", res == ERROR_SUCCESS ? "TRUE": "FALSE", res,
1779 pdwNumOfBytesRead ? *pdwNumOfBytesRead : -1);
1781 if(res != ERROR_SUCCESS)
1783 return res == ERROR_SUCCESS;
1786 /***********************************************************************
1787 * InternetReadFileExA (WININET.@)
1789 * Read data from an open internet file
1792 * hFile [I] Handle returned by InternetOpenUrl or HttpOpenRequest.
1793 * lpBuffersOut [I/O] Buffer.
1794 * dwFlags [I] Flags. See notes.
1795 * dwContext [I] Context for callbacks.
1802 * The parameter dwFlags include zero or more of the following flags:
1803 *|IRF_ASYNC - Makes the call asynchronous.
1804 *|IRF_SYNC - Makes the call synchronous.
1805 *|IRF_USE_CONTEXT - Forces dwContext to be used.
1806 *|IRF_NO_WAIT - Don't block if the data is not available, just return what is available.
1808 * However, in testing IRF_USE_CONTEXT seems to have no effect - dwContext isn't used.
1811 * InternetOpenUrlA(), HttpOpenRequestA()
1813 BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOut,
1814 DWORD dwFlags, DWORD_PTR dwContext)
1816 LPWININETHANDLEHEADER hdr;
1817 DWORD res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
1819 TRACE("(%p %p 0x%x 0x%lx)\n", hFile, lpBuffersOut, dwFlags, dwContext);
1821 hdr = WININET_GetObject(hFile);
1823 INTERNET_SetLastError(ERROR_INVALID_HANDLE);
1827 if(hdr->vtbl->ReadFileExA)
1828 res = hdr->vtbl->ReadFileExA(hdr, lpBuffersOut, dwFlags, dwContext);
1830 WININET_Release(hdr);
1832 TRACE("-- %s (%u, bytes read: %d)\n", res == ERROR_SUCCESS ? "TRUE": "FALSE",
1833 res, lpBuffersOut->dwBufferLength);
1835 if(res != ERROR_SUCCESS)
1837 return res == ERROR_SUCCESS;
1840 /***********************************************************************
1841 * InternetReadFileExW (WININET.@)
1843 * Read data from an open internet file.
1846 * hFile [I] Handle returned by InternetOpenUrl() or HttpOpenRequest().
1847 * lpBuffersOut [I/O] Buffer.
1848 * dwFlags [I] Flags.
1849 * dwContext [I] Context for callbacks.
1852 * FALSE, last error is set to ERROR_CALL_NOT_IMPLEMENTED
1855 * Not implemented in Wine or native either (as of IE6 SP2).
1858 BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
1859 DWORD dwFlags, DWORD_PTR dwContext)
1861 ERR("(%p, %p, 0x%x, 0x%lx): not implemented in native\n", hFile, lpBuffer, dwFlags, dwContext);
1863 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1867 /***********************************************************************
1868 * INET_QueryOptionHelper (internal)
1870 static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
1871 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1873 LPWININETHANDLEHEADER lpwhh;
1874 BOOL bSuccess = FALSE;
1876 TRACE("(%p, 0x%08x, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
1878 lpwhh = WININET_GetObject( hInternet );
1882 case INTERNET_OPTION_REQUEST_FLAGS:
1885 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %d\n", flags);
1886 if (*lpdwBufferLength < sizeof(ULONG))
1887 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1890 memcpy(lpBuffer, &flags, sizeof(ULONG));
1893 *lpdwBufferLength = sizeof(ULONG);
1897 case INTERNET_OPTION_USER_AGENT:
1900 LPWININETAPPINFOW ai = (LPWININETAPPINFOW)lpwhh;
1902 TRACE("INTERNET_OPTION_USER_AGENT\n");
1904 if (lpwhh->htype != INTERNET_HANDLE_TYPE_INTERNET)
1906 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
1911 required = (strlenW(ai->lpszAgent) + 1) * sizeof(WCHAR);
1912 if (*lpdwBufferLength < required)
1913 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1916 strcpyW(lpBuffer, ai->lpszAgent);
1922 required = WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, NULL, 0, NULL, NULL);
1923 if (*lpdwBufferLength < required)
1924 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1927 WideCharToMultiByte(CP_ACP, 0, ai->lpszAgent, -1, lpBuffer, required, NULL, NULL);
1931 *lpdwBufferLength = required;
1934 case INTERNET_OPTION_HTTP_VERSION:
1936 if (*lpdwBufferLength < sizeof(HTTP_VERSION_INFO))
1937 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1941 * Presently hardcoded to 1.1
1943 ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
1944 ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
1947 *lpdwBufferLength = sizeof(HTTP_VERSION_INFO);
1950 case INTERNET_OPTION_CONNECTED_STATE:
1952 DWORD *pdwConnectedState = (DWORD *)lpBuffer;
1953 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
1955 if (*lpdwBufferLength < sizeof(*pdwConnectedState))
1956 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1959 *pdwConnectedState = INTERNET_STATE_CONNECTED;
1962 *lpdwBufferLength = sizeof(*pdwConnectedState);
1965 case INTERNET_OPTION_PROXY:
1967 LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW)lpwhh;
1968 WININETAPPINFOW wai;
1972 TRACE("Getting global proxy info\n");
1973 memset(&wai, 0, sizeof(WININETAPPINFOW));
1974 INTERNET_ConfigureProxy( &wai );
1980 INTERNET_PROXY_INFOW *pPI = (INTERNET_PROXY_INFOW *)lpBuffer;
1981 DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
1983 if (lpwai->lpszProxy)
1984 proxyBytesRequired = (lstrlenW(lpwai->lpszProxy) + 1) *
1986 if (lpwai->lpszProxyBypass)
1987 proxyBypassBytesRequired =
1988 (lstrlenW(lpwai->lpszProxyBypass) + 1) * sizeof(WCHAR);
1989 if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOW) +
1990 proxyBytesRequired + proxyBypassBytesRequired)
1991 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1994 LPWSTR proxy = (LPWSTR)((LPBYTE)lpBuffer +
1995 sizeof(INTERNET_PROXY_INFOW));
1996 LPWSTR proxy_bypass = (LPWSTR)((LPBYTE)lpBuffer +
1997 sizeof(INTERNET_PROXY_INFOW) +
1998 proxyBytesRequired);
2000 pPI->dwAccessType = lpwai->dwAccessType;
2001 pPI->lpszProxy = NULL;
2002 pPI->lpszProxyBypass = NULL;
2003 if (lpwai->lpszProxy)
2005 lstrcpyW(proxy, lpwai->lpszProxy);
2006 pPI->lpszProxy = proxy;
2009 if (lpwai->lpszProxyBypass)
2011 lstrcpyW(proxy_bypass, lpwai->lpszProxyBypass);
2012 pPI->lpszProxyBypass = proxy_bypass;
2016 *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOW) +
2017 proxyBytesRequired + proxyBypassBytesRequired;
2021 INTERNET_PROXY_INFOA *pPI = (INTERNET_PROXY_INFOA *)lpBuffer;
2022 DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
2024 if (lpwai->lpszProxy)
2025 proxyBytesRequired = WideCharToMultiByte(CP_ACP, 0,
2026 lpwai->lpszProxy, -1, NULL, 0, NULL, NULL);
2027 if (lpwai->lpszProxyBypass)
2028 proxyBypassBytesRequired = WideCharToMultiByte(CP_ACP, 0,
2029 lpwai->lpszProxyBypass, -1, NULL, 0, NULL, NULL);
2030 if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOA) +
2031 proxyBytesRequired + proxyBypassBytesRequired)
2032 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2035 LPSTR proxy = (LPSTR)((LPBYTE)lpBuffer +
2036 sizeof(INTERNET_PROXY_INFOA));
2037 LPSTR proxy_bypass = (LPSTR)((LPBYTE)lpBuffer +
2038 sizeof(INTERNET_PROXY_INFOA) +
2039 proxyBytesRequired);
2041 pPI->dwAccessType = lpwai->dwAccessType;
2042 pPI->lpszProxy = NULL;
2043 pPI->lpszProxyBypass = NULL;
2044 if (lpwai->lpszProxy)
2046 WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxy, -1,
2047 proxy, proxyBytesRequired, NULL, NULL);
2048 pPI->lpszProxy = proxy;
2051 if (lpwai->lpszProxyBypass)
2053 WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxyBypass,
2054 -1, proxy_bypass, proxyBypassBytesRequired,
2056 pPI->lpszProxyBypass = proxy_bypass;
2060 *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOA) +
2061 proxyBytesRequired + proxyBypassBytesRequired;
2065 case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
2068 TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %d\n", conn);
2069 if (*lpdwBufferLength < sizeof(ULONG))
2070 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2073 memcpy(lpBuffer, &conn, sizeof(ULONG));
2076 *lpdwBufferLength = sizeof(ULONG);
2079 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
2082 TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER: %d\n", conn);
2083 if (*lpdwBufferLength < sizeof(ULONG))
2084 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2087 memcpy(lpBuffer, &conn, sizeof(ULONG));
2090 *lpdwBufferLength = sizeof(ULONG);
2093 case INTERNET_OPTION_SECURITY_FLAGS:
2094 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2098 case INTERNET_OPTION_VERSION:
2100 TRACE("INTERNET_OPTION_VERSION\n");
2101 if (*lpdwBufferLength < sizeof(INTERNET_VERSION_INFO))
2102 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2105 static const INTERNET_VERSION_INFO info = { 1, 2 };
2106 memcpy(lpBuffer, &info, sizeof(info));
2107 *lpdwBufferLength = sizeof(info);
2112 case INTERNET_OPTION_PER_CONNECTION_OPTION:
2113 FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
2114 if (*lpdwBufferLength < sizeof(INTERNET_PER_CONN_OPTION_LISTW))
2115 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2118 INTERNET_PER_CONN_OPTION_LISTW *con = lpBuffer;
2121 for (x = 0; x < con->dwOptionCount; ++x)
2123 INTERNET_PER_CONN_OPTIONW *option = con->pOptions + x;
2124 switch (option->dwOption)
2126 case INTERNET_PER_CONN_FLAGS:
2127 option->Value.dwValue = PROXY_TYPE_DIRECT;
2130 case INTERNET_PER_CONN_PROXY_SERVER:
2131 case INTERNET_PER_CONN_PROXY_BYPASS:
2132 case INTERNET_PER_CONN_AUTOCONFIG_URL:
2133 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS:
2134 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL:
2135 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS:
2136 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME:
2137 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL:
2138 FIXME("Unhandled dwOption %d\n", option->dwOption);
2139 option->Value.dwValue = 0;
2144 FIXME("Unknown dwOption %d\n", option->dwOption);
2150 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
2161 res = lpwhh->vtbl->QueryOption(lpwhh, dwOption, lpBuffer, lpdwBufferLength, bIsUnicode);
2162 if(res == ERROR_SUCCESS)
2167 FIXME("Stub! %d\n", dwOption);
2173 WININET_Release( lpwhh );
2178 /***********************************************************************
2179 * InternetQueryOptionW (WININET.@)
2181 * Queries an options on the specified handle
2188 BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
2189 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
2191 return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
2194 /***********************************************************************
2195 * InternetQueryOptionA (WININET.@)
2197 * Queries an options on the specified handle
2204 BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
2205 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
2207 return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
2211 /***********************************************************************
2212 * InternetSetOptionW (WININET.@)
2214 * Sets an options on the specified handle
2221 BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
2222 LPVOID lpBuffer, DWORD dwBufferLength)
2224 LPWININETHANDLEHEADER lpwhh;
2227 TRACE("(%p %d %p %d)\n", hInternet, dwOption, lpBuffer, dwBufferLength);
2229 lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
2230 if(lpwhh && lpwhh->vtbl->SetOption) {
2233 res = lpwhh->vtbl->SetOption(lpwhh, dwOption, lpBuffer, dwBufferLength);
2234 if(res != ERROR_INTERNET_INVALID_OPTION) {
2235 WININET_Release( lpwhh );
2237 if(res != ERROR_SUCCESS)
2240 return res == ERROR_SUCCESS;
2246 case INTERNET_OPTION_CALLBACK:
2248 INTERNET_STATUS_CALLBACK callback = *(INTERNET_STATUS_CALLBACK *)lpBuffer;
2249 ret = (set_status_callback(lpwhh, callback, TRUE) != INTERNET_INVALID_STATUS_CALLBACK);
2252 case INTERNET_OPTION_HTTP_VERSION:
2254 HTTP_VERSION_INFO* pVersion=(HTTP_VERSION_INFO*)lpBuffer;
2255 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%d,%d): STUB\n",pVersion->dwMajorVersion,pVersion->dwMinorVersion);
2258 case INTERNET_OPTION_ERROR_MASK:
2260 unsigned long flags=*(unsigned long*)lpBuffer;
2261 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
2264 case INTERNET_OPTION_CODEPAGE:
2266 unsigned long codepage=*(unsigned long*)lpBuffer;
2267 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
2270 case INTERNET_OPTION_REQUEST_PRIORITY:
2272 unsigned long priority=*(unsigned long*)lpBuffer;
2273 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
2276 case INTERNET_OPTION_CONNECT_TIMEOUT:
2278 unsigned long connecttimeout=*(unsigned long*)lpBuffer;
2279 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%ld): STUB\n",connecttimeout);
2282 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT:
2284 unsigned long receivetimeout=*(unsigned long*)lpBuffer;
2285 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%ld): STUB\n",receivetimeout);
2288 case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
2290 unsigned long conns=*(unsigned long*)lpBuffer;
2291 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%ld): STUB\n",conns);
2294 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
2296 unsigned long conns=*(unsigned long*)lpBuffer;
2297 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%ld): STUB\n",conns);
2300 case INTERNET_OPTION_RESET_URLCACHE_SESSION:
2301 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2303 case INTERNET_OPTION_END_BROWSER_SESSION:
2304 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2306 case INTERNET_OPTION_CONNECTED_STATE:
2307 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2309 case INTERNET_OPTION_DISABLE_PASSPORT_AUTH:
2310 TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
2312 case INTERNET_OPTION_SEND_TIMEOUT:
2313 case INTERNET_OPTION_RECEIVE_TIMEOUT:
2314 FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT\n");
2316 case INTERNET_OPTION_CONNECT_RETRIES:
2317 FIXME("Option INTERNET_OPTION_CONNECT_RETRIES: STUB\n");
2319 case INTERNET_OPTION_CONTEXT_VALUE:
2320 FIXME("Option INTERNET_OPTION_CONTEXT_VALUE; STUB\n");
2322 case INTERNET_OPTION_SECURITY_FLAGS:
2323 FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n");
2329 FIXME("Option %d STUB\n",dwOption);
2330 INTERNET_SetLastError(ERROR_INTERNET_INVALID_OPTION);
2336 WININET_Release( lpwhh );
2342 /***********************************************************************
2343 * InternetSetOptionA (WININET.@)
2345 * Sets an options on the specified handle.
2352 BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
2353 LPVOID lpBuffer, DWORD dwBufferLength)
2361 case INTERNET_OPTION_CALLBACK:
2363 LPWININETHANDLEHEADER lpwh;
2364 INTERNET_STATUS_CALLBACK callback = *(INTERNET_STATUS_CALLBACK *)lpBuffer;
2366 if (!(lpwh = WININET_GetObject(hInternet))) return FALSE;
2367 r = (set_status_callback(lpwh, callback, FALSE) != INTERNET_INVALID_STATUS_CALLBACK);
2368 WININET_Release(lpwh);
2371 case INTERNET_OPTION_PROXY:
2373 LPINTERNET_PROXY_INFOA pi = (LPINTERNET_PROXY_INFOA) lpBuffer;
2374 LPINTERNET_PROXY_INFOW piw;
2375 DWORD proxlen, prbylen;
2378 proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0);
2379 prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0);
2380 wlen = sizeof(*piw) + proxlen + prbylen;
2381 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
2382 piw = (LPINTERNET_PROXY_INFOW) wbuffer;
2383 piw->dwAccessType = pi->dwAccessType;
2384 prox = (LPWSTR) &piw[1];
2385 prby = &prox[proxlen+1];
2386 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, prox, proxlen);
2387 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, prby, prbylen);
2388 piw->lpszProxy = prox;
2389 piw->lpszProxyBypass = prby;
2392 case INTERNET_OPTION_USER_AGENT:
2393 case INTERNET_OPTION_USERNAME:
2394 case INTERNET_OPTION_PASSWORD:
2395 wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
2397 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
2398 MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
2403 wlen = dwBufferLength;
2406 r = InternetSetOptionW(hInternet,dwOption, wbuffer, wlen);
2408 if( lpBuffer != wbuffer )
2409 HeapFree( GetProcessHeap(), 0, wbuffer );
2415 /***********************************************************************
2416 * InternetSetOptionExA (WININET.@)
2418 BOOL WINAPI InternetSetOptionExA(HINTERNET hInternet, DWORD dwOption,
2419 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
2421 FIXME("Flags %08x ignored\n", dwFlags);
2422 return InternetSetOptionA( hInternet, dwOption, lpBuffer, dwBufferLength );
2425 /***********************************************************************
2426 * InternetSetOptionExW (WININET.@)
2428 BOOL WINAPI InternetSetOptionExW(HINTERNET hInternet, DWORD dwOption,
2429 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
2431 FIXME("Flags %08x ignored\n", dwFlags);
2432 if( dwFlags & ~ISO_VALID_FLAGS )
2434 INTERNET_SetLastError( ERROR_INVALID_PARAMETER );
2437 return InternetSetOptionW( hInternet, dwOption, lpBuffer, dwBufferLength );
2440 static const WCHAR WININET_wkday[7][4] =
2441 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2442 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2443 static const WCHAR WININET_month[12][4] =
2444 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2445 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2446 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2448 /***********************************************************************
2449 * InternetTimeFromSystemTimeA (WININET.@)
2451 BOOL WINAPI InternetTimeFromSystemTimeA( const SYSTEMTIME* time, DWORD format, LPSTR string, DWORD size )
2454 WCHAR stringW[INTERNET_RFC1123_BUFSIZE];
2456 TRACE( "%p 0x%08x %p 0x%08x\n", time, format, string, size );
2458 ret = InternetTimeFromSystemTimeW( time, format, stringW, sizeof(stringW) );
2459 if (ret) WideCharToMultiByte( CP_ACP, 0, stringW, -1, string, size, NULL, NULL );
2464 /***********************************************************************
2465 * InternetTimeFromSystemTimeW (WININET.@)
2467 BOOL WINAPI InternetTimeFromSystemTimeW( const SYSTEMTIME* time, DWORD format, LPWSTR string, DWORD size )
2469 static const WCHAR date[] =
2470 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2471 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
2473 TRACE( "%p 0x%08x %p 0x%08x\n", time, format, string, size );
2475 if (!time || !string) return FALSE;
2477 if (format != INTERNET_RFC1123_FORMAT || size < INTERNET_RFC1123_BUFSIZE * sizeof(WCHAR))
2480 sprintfW( string, date,
2481 WININET_wkday[time->wDayOfWeek],
2483 WININET_month[time->wMonth - 1],
2492 /***********************************************************************
2493 * InternetTimeToSystemTimeA (WININET.@)
2495 BOOL WINAPI InternetTimeToSystemTimeA( LPCSTR string, SYSTEMTIME* time, DWORD reserved )
2501 TRACE( "%s %p 0x%08x\n", debugstr_a(string), time, reserved );
2503 len = MultiByteToWideChar( CP_ACP, 0, string, -1, NULL, 0 );
2504 stringW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
2508 MultiByteToWideChar( CP_ACP, 0, string, -1, stringW, len );
2509 ret = InternetTimeToSystemTimeW( stringW, time, reserved );
2510 HeapFree( GetProcessHeap(), 0, stringW );
2515 /***********************************************************************
2516 * InternetTimeToSystemTimeW (WININET.@)
2518 BOOL WINAPI InternetTimeToSystemTimeW( LPCWSTR string, SYSTEMTIME* time, DWORD reserved )
2521 const WCHAR *s = string;
2524 TRACE( "%s %p 0x%08x\n", debugstr_w(string), time, reserved );
2526 if (!string || !time) return FALSE;
2528 /* Windows does this too */
2529 GetSystemTime( time );
2531 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2532 * a SYSTEMTIME structure.
2535 while (*s && !isalphaW( *s )) s++;
2536 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2537 time->wDayOfWeek = 7;
2539 for (i = 0; i < 7; i++)
2541 if (toupperW( WININET_wkday[i][0] ) == toupperW( s[0] ) &&
2542 toupperW( WININET_wkday[i][1] ) == toupperW( s[1] ) &&
2543 toupperW( WININET_wkday[i][2] ) == toupperW( s[2] ) )
2545 time->wDayOfWeek = i;
2550 if (time->wDayOfWeek > 6) return TRUE;
2551 while (*s && !isdigitW( *s )) s++;
2552 time->wDay = strtolW( s, &end, 10 );
2555 while (*s && !isalphaW( *s )) s++;
2556 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2559 for (i = 0; i < 12; i++)
2561 if (toupperW( WININET_month[i][0]) == toupperW( s[0] ) &&
2562 toupperW( WININET_month[i][1]) == toupperW( s[1] ) &&
2563 toupperW( WININET_month[i][2]) == toupperW( s[2] ) )
2565 time->wMonth = i + 1;
2569 if (time->wMonth == 0) return TRUE;
2571 while (*s && !isdigitW( *s )) s++;
2572 if (*s == '\0') return TRUE;
2573 time->wYear = strtolW( s, &end, 10 );
2576 while (*s && !isdigitW( *s )) s++;
2577 if (*s == '\0') return TRUE;
2578 time->wHour = strtolW( s, &end, 10 );
2581 while (*s && !isdigitW( *s )) s++;
2582 if (*s == '\0') return TRUE;
2583 time->wMinute = strtolW( s, &end, 10 );
2586 while (*s && !isdigitW( *s )) s++;
2587 if (*s == '\0') return TRUE;
2588 time->wSecond = strtolW( s, &end, 10 );
2591 time->wMilliseconds = 0;
2595 /***********************************************************************
2596 * InternetCheckConnectionW (WININET.@)
2598 * Pings a requested host to check internet connection
2601 * TRUE on success and FALSE on failure. If a failure then
2602 * ERROR_NOT_CONNECTED is placed into GetLastError
2605 BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
2608 * this is a kludge which runs the resident ping program and reads the output.
2610 * Anyone have a better idea?
2614 static const CHAR ping[] = "ping -c 1 ";
2615 static const CHAR redirect[] = " >/dev/null 2>/dev/null";
2616 CHAR *command = NULL;
2625 * Crack or set the Address
2627 if (lpszUrl == NULL)
2630 * According to the doc we are supposed to use the ip for the next
2631 * server in the WnInet internal server database. I have
2632 * no idea what that is or how to get it.
2634 * So someone needs to implement this.
2636 FIXME("Unimplemented with URL of NULL\n");
2641 URL_COMPONENTSW components;
2643 ZeroMemory(&components,sizeof(URL_COMPONENTSW));
2644 components.lpszHostName = (LPWSTR)&hostW;
2645 components.dwHostNameLength = 1024;
2647 if (!InternetCrackUrlW(lpszUrl,0,0,&components))
2650 TRACE("host name : %s\n",debugstr_w(components.lpszHostName));
2651 port = components.nPort;
2652 TRACE("port: %d\n", port);
2655 if (dwFlags & FLAG_ICC_FORCE_CONNECTION)
2657 struct sockaddr_in sin;
2660 if (!GetAddress(hostW, port, &sin))
2662 fd = socket(sin.sin_family, SOCK_STREAM, 0);
2665 if (connect(fd, (struct sockaddr *)&sin, sizeof(sin)) == 0)
2673 * Build our ping command
2675 len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
2676 command = HeapAlloc( GetProcessHeap(), 0, strlen(ping)+len+strlen(redirect) );
2677 strcpy(command,ping);
2678 WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
2679 strcat(command,redirect);
2681 TRACE("Ping command is : %s\n",command);
2683 status = system(command);
2685 TRACE("Ping returned a code of %i\n",status);
2687 /* Ping return code of 0 indicates success */
2694 HeapFree( GetProcessHeap(), 0, command );
2696 INTERNET_SetLastError(ERROR_NOT_CONNECTED);
2702 /***********************************************************************
2703 * InternetCheckConnectionA (WININET.@)
2705 * Pings a requested host to check internet connection
2708 * TRUE on success and FALSE on failure. If a failure then
2709 * ERROR_NOT_CONNECTED is placed into GetLastError
2712 BOOL WINAPI InternetCheckConnectionA(LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
2718 len = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0);
2719 if (!(szUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR))))
2721 MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, len);
2722 rc = InternetCheckConnectionW(szUrl, dwFlags, dwReserved);
2723 HeapFree(GetProcessHeap(), 0, szUrl);
2729 /**********************************************************
2730 * INTERNET_InternetOpenUrlW (internal)
2735 * handle of connection or NULL on failure
2737 HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
2738 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
2740 URL_COMPONENTSW urlComponents;
2741 WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
2742 WCHAR password[1024], path[2048], extra[1024];
2743 HINTERNET client = NULL, client1 = NULL;
2745 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hIC, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
2746 dwHeadersLength, dwFlags, dwContext);
2748 urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
2749 urlComponents.lpszScheme = protocol;
2750 urlComponents.dwSchemeLength = 32;
2751 urlComponents.lpszHostName = hostName;
2752 urlComponents.dwHostNameLength = MAXHOSTNAME;
2753 urlComponents.lpszUserName = userName;
2754 urlComponents.dwUserNameLength = 1024;
2755 urlComponents.lpszPassword = password;
2756 urlComponents.dwPasswordLength = 1024;
2757 urlComponents.lpszUrlPath = path;
2758 urlComponents.dwUrlPathLength = 2048;
2759 urlComponents.lpszExtraInfo = extra;
2760 urlComponents.dwExtraInfoLength = 1024;
2761 if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents))
2763 switch(urlComponents.nScheme) {
2764 case INTERNET_SCHEME_FTP:
2765 if(urlComponents.nPort == 0)
2766 urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
2767 client = FTP_Connect(hIC, hostName, urlComponents.nPort,
2768 userName, password, dwFlags, dwContext, INET_OPENURL);
2771 client1 = FtpOpenFileW(client, path, GENERIC_READ, dwFlags, dwContext);
2772 if(client1 == NULL) {
2773 InternetCloseHandle(client);
2778 case INTERNET_SCHEME_HTTP:
2779 case INTERNET_SCHEME_HTTPS: {
2780 static const WCHAR szStars[] = { '*','/','*', 0 };
2781 LPCWSTR accept[2] = { szStars, NULL };
2782 if(urlComponents.nPort == 0) {
2783 if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
2784 urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
2786 urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
2788 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
2789 client = HTTP_Connect(hIC, hostName, urlComponents.nPort,
2790 userName, password, dwFlags, dwContext, INET_OPENURL);
2794 if (urlComponents.dwExtraInfoLength) {
2796 DWORD len = urlComponents.dwUrlPathLength + urlComponents.dwExtraInfoLength + 1;
2798 if (!(path_extra = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR))))
2800 InternetCloseHandle(client);
2803 strcpyW(path_extra, urlComponents.lpszUrlPath);
2804 strcatW(path_extra, urlComponents.lpszExtraInfo);
2805 client1 = HttpOpenRequestW(client, NULL, path_extra, NULL, NULL, accept, dwFlags, dwContext);
2806 HeapFree(GetProcessHeap(), 0, path_extra);
2809 client1 = HttpOpenRequestW(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
2811 if(client1 == NULL) {
2812 InternetCloseHandle(client);
2815 HttpAddRequestHeadersW(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
2816 if (!HttpSendRequestW(client1, NULL, 0, NULL, 0) &&
2817 GetLastError() != ERROR_IO_PENDING) {
2818 InternetCloseHandle(client1);
2823 case INTERNET_SCHEME_GOPHER:
2824 /* gopher doesn't seem to be implemented in wine, but it's supposed
2825 * to be supported by InternetOpenUrlA. */
2827 INTERNET_SetLastError(ERROR_INTERNET_UNRECOGNIZED_SCHEME);
2831 TRACE(" %p <--\n", client1);
2836 /**********************************************************
2837 * InternetOpenUrlW (WININET.@)
2842 * handle of connection or NULL on failure
2844 static void AsyncInternetOpenUrlProc(WORKREQUEST *workRequest)
2846 struct WORKREQ_INTERNETOPENURLW const *req = &workRequest->u.InternetOpenUrlW;
2847 LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) workRequest->hdr;
2851 INTERNET_InternetOpenUrlW(hIC, req->lpszUrl,
2852 req->lpszHeaders, req->dwHeadersLength, req->dwFlags, req->dwContext);
2853 HeapFree(GetProcessHeap(), 0, req->lpszUrl);
2854 HeapFree(GetProcessHeap(), 0, req->lpszHeaders);
2857 HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
2858 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
2860 HINTERNET ret = NULL;
2861 LPWININETAPPINFOW hIC = NULL;
2863 if (TRACE_ON(wininet)) {
2864 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hInternet, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
2865 dwHeadersLength, dwFlags, dwContext);
2867 dump_INTERNET_FLAGS(dwFlags);
2872 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
2876 hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
2877 if (NULL == hIC || hIC->hdr.htype != WH_HINIT) {
2878 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
2882 if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) {
2883 WORKREQUEST workRequest;
2884 struct WORKREQ_INTERNETOPENURLW *req;
2886 workRequest.asyncproc = AsyncInternetOpenUrlProc;
2887 workRequest.hdr = WININET_AddRef( &hIC->hdr );
2888 req = &workRequest.u.InternetOpenUrlW;
2889 req->lpszUrl = WININET_strdupW(lpszUrl);
2891 req->lpszHeaders = WININET_strdupW(lpszHeaders);
2893 req->lpszHeaders = 0;
2894 req->dwHeadersLength = dwHeadersLength;
2895 req->dwFlags = dwFlags;
2896 req->dwContext = dwContext;
2898 INTERNET_AsyncCall(&workRequest);
2900 * This is from windows.
2902 INTERNET_SetLastError(ERROR_IO_PENDING);
2904 ret = INTERNET_InternetOpenUrlW(hIC, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
2909 WININET_Release( &hIC->hdr );
2910 TRACE(" %p <--\n", ret);
2915 /**********************************************************
2916 * InternetOpenUrlA (WININET.@)
2921 * handle of connection or NULL on failure
2923 HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
2924 LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
2926 HINTERNET rc = NULL;
2930 LPWSTR szUrl = NULL;
2931 LPWSTR szHeaders = NULL;
2936 lenUrl = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0 );
2937 szUrl = HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(WCHAR));
2940 MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl);
2944 lenHeaders = MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, NULL, 0 );
2945 szHeaders = HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(WCHAR));
2947 HeapFree(GetProcessHeap(), 0, szUrl);
2950 MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, szHeaders, lenHeaders);
2953 rc = InternetOpenUrlW(hInternet, szUrl, szHeaders,
2954 lenHeaders, dwFlags, dwContext);
2956 HeapFree(GetProcessHeap(), 0, szUrl);
2957 HeapFree(GetProcessHeap(), 0, szHeaders);
2963 static LPWITHREADERROR INTERNET_AllocThreadError(void)
2965 LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite));
2969 lpwite->dwError = 0;
2970 lpwite->response[0] = '\0';
2973 if (!TlsSetValue(g_dwTlsErrIndex, lpwite))
2975 HeapFree(GetProcessHeap(), 0, lpwite);
2983 /***********************************************************************
2984 * INTERNET_SetLastError (internal)
2986 * Set last thread specific error
2991 void INTERNET_SetLastError(DWORD dwError)
2993 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2996 lpwite = INTERNET_AllocThreadError();
2998 SetLastError(dwError);
3000 lpwite->dwError = dwError;
3004 /***********************************************************************
3005 * INTERNET_GetLastError (internal)
3007 * Get last thread specific error
3012 DWORD INTERNET_GetLastError(void)
3014 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
3015 if (!lpwite) return 0;
3016 /* TlsGetValue clears last error, so set it again here */
3017 SetLastError(lpwite->dwError);
3018 return lpwite->dwError;
3022 /***********************************************************************
3023 * INTERNET_WorkerThreadFunc (internal)
3025 * Worker thread execution function
3030 static DWORD CALLBACK INTERNET_WorkerThreadFunc(LPVOID lpvParam)
3032 LPWORKREQUEST lpRequest = lpvParam;
3033 WORKREQUEST workRequest;
3037 workRequest = *lpRequest;
3038 HeapFree(GetProcessHeap(), 0, lpRequest);
3040 workRequest.asyncproc(&workRequest);
3042 WININET_Release( workRequest.hdr );
3047 /***********************************************************************
3048 * INTERNET_AsyncCall (internal)
3050 * Retrieves work request from queue
3055 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
3058 LPWORKREQUEST lpNewRequest;
3062 lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
3066 *lpNewRequest = *lpWorkRequest;
3068 bSuccess = QueueUserWorkItem(INTERNET_WorkerThreadFunc, lpNewRequest, WT_EXECUTELONGFUNCTION);
3071 HeapFree(GetProcessHeap(), 0, lpNewRequest);
3072 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
3079 /***********************************************************************
3080 * INTERNET_GetResponseBuffer (internal)
3085 LPSTR INTERNET_GetResponseBuffer(void)
3087 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
3089 lpwite = INTERNET_AllocThreadError();
3091 return lpwite->response;
3094 /***********************************************************************
3095 * INTERNET_GetNextLine (internal)
3097 * Parse next line in directory string listing
3100 * Pointer to beginning of next line
3105 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
3108 BOOL bSuccess = FALSE;
3110 LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
3115 pfd.events = POLLIN;
3117 while (nRecv < MAX_REPLY_LEN)
3119 if (poll(&pfd,1, RESPONSE_TIMEOUT * 1000) > 0)
3121 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
3123 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
3127 if (lpszBuffer[nRecv] == '\n')
3132 if (lpszBuffer[nRecv] != '\r')
3137 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
3145 lpszBuffer[nRecv] = '\0';
3147 TRACE(":%d %s\n", nRecv, lpszBuffer);
3156 /**********************************************************
3157 * InternetQueryDataAvailable (WININET.@)
3159 * Determines how much data is available to be read.
3162 * TRUE on success, FALSE if an error occurred. If
3163 * INTERNET_FLAG_ASYNC was specified in InternetOpen, and
3164 * no data is presently available, FALSE is returned with
3165 * the last error ERROR_IO_PENDING; a callback with status
3166 * INTERNET_STATUS_REQUEST_COMPLETE will be sent when more
3167 * data is available.
3169 BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
3170 LPDWORD lpdwNumberOfBytesAvailble,
3171 DWORD dwFlags, DWORD_PTR dwContext)
3173 WININETHANDLEHEADER *hdr;
3176 TRACE("(%p %p %x %lx)\n", hFile, lpdwNumberOfBytesAvailble, dwFlags, dwContext);
3178 hdr = WININET_GetObject( hFile );
3180 INTERNET_SetLastError(ERROR_INVALID_HANDLE);
3184 if(hdr->vtbl->QueryDataAvailable) {
3185 res = hdr->vtbl->QueryDataAvailable(hdr, lpdwNumberOfBytesAvailble, dwFlags, dwContext);
3187 WARN("wrong handle\n");
3188 res = ERROR_INTERNET_INCORRECT_HANDLE_TYPE;
3191 WININET_Release(hdr);
3193 if(res != ERROR_SUCCESS)
3195 return res == ERROR_SUCCESS;
3199 /***********************************************************************
3200 * InternetLockRequestFile (WININET.@)
3202 BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
3209 BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
3216 /***********************************************************************
3217 * InternetAutodial (WININET.@)
3219 * On windows this function is supposed to dial the default internet
3220 * connection. We don't want to have Wine dial out to the internet so
3221 * we return TRUE by default. It might be nice to check if we are connected.
3228 BOOL WINAPI InternetAutodial(DWORD dwFlags, HWND hwndParent)
3232 /* Tell that we are connected to the internet. */
3236 /***********************************************************************
3237 * InternetAutodialHangup (WININET.@)
3239 * Hangs up a connection made with InternetAutodial
3248 BOOL WINAPI InternetAutodialHangup(DWORD dwReserved)
3252 /* we didn't dial, we don't disconnect */
3256 /***********************************************************************
3257 * InternetCombineUrlA (WININET.@)
3259 * Combine a base URL with a relative URL
3267 BOOL WINAPI InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl,
3268 LPSTR lpszBuffer, LPDWORD lpdwBufferLength,
3273 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_a(lpszBaseUrl), debugstr_a(lpszRelativeUrl), lpszBuffer, lpdwBufferLength, dwFlags);
3275 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3276 dwFlags ^= ICU_NO_ENCODE;
3277 hr=UrlCombineA(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
3282 /***********************************************************************
3283 * InternetCombineUrlW (WININET.@)
3285 * Combine a base URL with a relative URL
3293 BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl,
3294 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength,
3299 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(lpszBaseUrl), debugstr_w(lpszRelativeUrl), lpszBuffer, lpdwBufferLength, dwFlags);
3301 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3302 dwFlags ^= ICU_NO_ENCODE;
3303 hr=UrlCombineW(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
3308 /* max port num is 65535 => 5 digits */
3309 #define MAX_WORD_DIGITS 5
3311 #define URL_GET_COMP_LENGTH(url, component) ((url)->dw##component##Length ? \
3312 (url)->dw##component##Length : strlenW((url)->lpsz##component))
3313 #define URL_GET_COMP_LENGTHA(url, component) ((url)->dw##component##Length ? \
3314 (url)->dw##component##Length : strlen((url)->lpsz##component))
3316 static BOOL url_uses_default_port(INTERNET_SCHEME nScheme, INTERNET_PORT nPort)
3318 if ((nScheme == INTERNET_SCHEME_HTTP) &&
3319 (nPort == INTERNET_DEFAULT_HTTP_PORT))
3321 if ((nScheme == INTERNET_SCHEME_HTTPS) &&
3322 (nPort == INTERNET_DEFAULT_HTTPS_PORT))
3324 if ((nScheme == INTERNET_SCHEME_FTP) &&
3325 (nPort == INTERNET_DEFAULT_FTP_PORT))
3327 if ((nScheme == INTERNET_SCHEME_GOPHER) &&
3328 (nPort == INTERNET_DEFAULT_GOPHER_PORT))
3331 if (nPort == INTERNET_INVALID_PORT_NUMBER)
3337 /* opaque urls do not fit into the standard url hierarchy and don't have
3338 * two following slashes */
3339 static inline BOOL scheme_is_opaque(INTERNET_SCHEME nScheme)
3341 return (nScheme != INTERNET_SCHEME_FTP) &&
3342 (nScheme != INTERNET_SCHEME_GOPHER) &&
3343 (nScheme != INTERNET_SCHEME_HTTP) &&
3344 (nScheme != INTERNET_SCHEME_HTTPS) &&
3345 (nScheme != INTERNET_SCHEME_FILE);
3348 static LPCWSTR INTERNET_GetSchemeString(INTERNET_SCHEME scheme)
3351 if (scheme < INTERNET_SCHEME_FIRST)
3353 index = scheme - INTERNET_SCHEME_FIRST;
3354 if (index >= sizeof(url_schemes)/sizeof(url_schemes[0]))
3356 return (LPCWSTR)&url_schemes[index];
3359 /* we can calculate using ansi strings because we're just
3360 * calculating string length, not size
3362 static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
3363 LPDWORD lpdwUrlLength)
3365 INTERNET_SCHEME nScheme;
3369 if (lpUrlComponents->lpszScheme)
3371 DWORD dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, Scheme);
3372 *lpdwUrlLength += dwLen;
3373 nScheme = GetInternetSchemeW(lpUrlComponents->lpszScheme, dwLen);
3379 nScheme = lpUrlComponents->nScheme;
3381 if (nScheme == INTERNET_SCHEME_DEFAULT)
3382 nScheme = INTERNET_SCHEME_HTTP;
3383 scheme = INTERNET_GetSchemeString(nScheme);
3384 *lpdwUrlLength += strlenW(scheme);
3387 (*lpdwUrlLength)++; /* ':' */
3388 if (!scheme_is_opaque(nScheme) || lpUrlComponents->lpszHostName)
3389 *lpdwUrlLength += strlen("//");
3391 if (lpUrlComponents->lpszUserName)
3393 *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, UserName);
3394 *lpdwUrlLength += strlen("@");
3398 if (lpUrlComponents->lpszPassword)
3400 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
3405 if (lpUrlComponents->lpszPassword)
3407 *lpdwUrlLength += strlen(":");
3408 *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, Password);
3411 if (lpUrlComponents->lpszHostName)
3413 *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, HostName);
3415 if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
3417 char szPort[MAX_WORD_DIGITS+1];
3419 sprintf(szPort, "%d", lpUrlComponents->nPort);
3420 *lpdwUrlLength += strlen(szPort);
3421 *lpdwUrlLength += strlen(":");
3424 if (lpUrlComponents->lpszUrlPath && *lpUrlComponents->lpszUrlPath != '/')
3425 (*lpdwUrlLength)++; /* '/' */
3428 if (lpUrlComponents->lpszUrlPath)
3429 *lpdwUrlLength += URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
3434 static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPONENTSW urlCompW)
3438 ZeroMemory(urlCompW, sizeof(URL_COMPONENTSW));
3440 urlCompW->dwStructSize = sizeof(URL_COMPONENTSW);
3441 urlCompW->dwSchemeLength = lpUrlComponents->dwSchemeLength;
3442 urlCompW->nScheme = lpUrlComponents->nScheme;
3443 urlCompW->dwHostNameLength = lpUrlComponents->dwHostNameLength;
3444 urlCompW->nPort = lpUrlComponents->nPort;
3445 urlCompW->dwUserNameLength = lpUrlComponents->dwUserNameLength;
3446 urlCompW->dwPasswordLength = lpUrlComponents->dwPasswordLength;
3447 urlCompW->dwUrlPathLength = lpUrlComponents->dwUrlPathLength;
3448 urlCompW->dwExtraInfoLength = lpUrlComponents->dwExtraInfoLength;
3450 if (lpUrlComponents->lpszScheme)
3452 len = URL_GET_COMP_LENGTHA(lpUrlComponents, Scheme) + 1;
3453 urlCompW->lpszScheme = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3454 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszScheme,
3455 -1, urlCompW->lpszScheme, len);
3458 if (lpUrlComponents->lpszHostName)
3460 len = URL_GET_COMP_LENGTHA(lpUrlComponents, HostName) + 1;
3461 urlCompW->lpszHostName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3462 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszHostName,
3463 -1, urlCompW->lpszHostName, len);
3466 if (lpUrlComponents->lpszUserName)
3468 len = URL_GET_COMP_LENGTHA(lpUrlComponents, UserName) + 1;
3469 urlCompW->lpszUserName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3470 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUserName,
3471 -1, urlCompW->lpszUserName, len);
3474 if (lpUrlComponents->lpszPassword)
3476 len = URL_GET_COMP_LENGTHA(lpUrlComponents, Password) + 1;
3477 urlCompW->lpszPassword = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3478 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszPassword,
3479 -1, urlCompW->lpszPassword, len);
3482 if (lpUrlComponents->lpszUrlPath)
3484 len = URL_GET_COMP_LENGTHA(lpUrlComponents, UrlPath) + 1;
3485 urlCompW->lpszUrlPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3486 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUrlPath,
3487 -1, urlCompW->lpszUrlPath, len);
3490 if (lpUrlComponents->lpszExtraInfo)
3492 len = URL_GET_COMP_LENGTHA(lpUrlComponents, ExtraInfo) + 1;
3493 urlCompW->lpszExtraInfo = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3494 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszExtraInfo,
3495 -1, urlCompW->lpszExtraInfo, len);
3499 /***********************************************************************
3500 * InternetCreateUrlA (WININET.@)
3502 * See InternetCreateUrlW.
3504 BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags,
3505 LPSTR lpszUrl, LPDWORD lpdwUrlLength)
3509 URL_COMPONENTSW urlCompW;
3511 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents, dwFlags, lpszUrl, lpdwUrlLength);
3513 if (!lpUrlComponents || lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSW) || !lpdwUrlLength)
3515 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
3519 convert_urlcomp_atow(lpUrlComponents, &urlCompW);
3522 urlW = HeapAlloc(GetProcessHeap(), 0, *lpdwUrlLength * sizeof(WCHAR));
3524 ret = InternetCreateUrlW(&urlCompW, dwFlags, urlW, lpdwUrlLength);
3526 if (!ret && (GetLastError() == ERROR_INSUFFICIENT_BUFFER))
3527 *lpdwUrlLength /= sizeof(WCHAR);
3529 /* on success, lpdwUrlLength points to the size of urlW in WCHARS
3530 * minus one, so add one to leave room for NULL terminator
3533 WideCharToMultiByte(CP_ACP, 0, urlW, -1, lpszUrl, *lpdwUrlLength + 1, NULL, NULL);
3535 HeapFree(GetProcessHeap(), 0, urlCompW.lpszScheme);
3536 HeapFree(GetProcessHeap(), 0, urlCompW.lpszHostName);
3537 HeapFree(GetProcessHeap(), 0, urlCompW.lpszUserName);
3538 HeapFree(GetProcessHeap(), 0, urlCompW.lpszPassword);
3539 HeapFree(GetProcessHeap(), 0, urlCompW.lpszUrlPath);
3540 HeapFree(GetProcessHeap(), 0, urlCompW.lpszExtraInfo);
3541 HeapFree(GetProcessHeap(), 0, urlW);
3546 /***********************************************************************
3547 * InternetCreateUrlW (WININET.@)
3549 * Creates a URL from its component parts.
3552 * lpUrlComponents [I] URL Components.
3553 * dwFlags [I] Flags. See notes.
3554 * lpszUrl [I] Buffer in which to store the created URL.
3555 * lpdwUrlLength [I/O] On input, the length of the buffer pointed to by
3556 * lpszUrl in characters. On output, the number of bytes
3557 * required to store the URL including terminator.
3561 * The dwFlags parameter can be zero or more of the following:
3562 *|ICU_ESCAPE - Generates escape sequences for unsafe characters in the path and extra info of the URL.
3569 BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
3570 LPWSTR lpszUrl, LPDWORD lpdwUrlLength)
3573 INTERNET_SCHEME nScheme;
3575 static const WCHAR slashSlashW[] = {'/','/'};
3576 static const WCHAR percentD[] = {'%','d',0};
3578 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents, dwFlags, lpszUrl, lpdwUrlLength);
3580 if (!lpUrlComponents || lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSW) || !lpdwUrlLength)
3582 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
3586 if (!calc_url_length(lpUrlComponents, &dwLen))
3589 if (!lpszUrl || *lpdwUrlLength < dwLen)
3591 *lpdwUrlLength = (dwLen + 1) * sizeof(WCHAR);
3592 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
3596 *lpdwUrlLength = dwLen;
3601 if (lpUrlComponents->lpszScheme)
3603 dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, Scheme);
3604 memcpy(lpszUrl, lpUrlComponents->lpszScheme, dwLen * sizeof(WCHAR));
3607 nScheme = GetInternetSchemeW(lpUrlComponents->lpszScheme, dwLen);
3612 nScheme = lpUrlComponents->nScheme;
3614 if (nScheme == INTERNET_SCHEME_DEFAULT)
3615 nScheme = INTERNET_SCHEME_HTTP;
3617 scheme = INTERNET_GetSchemeString(nScheme);
3618 dwLen = strlenW(scheme);
3619 memcpy(lpszUrl, scheme, dwLen * sizeof(WCHAR));
3623 /* all schemes are followed by at least a colon */
3627 if (!scheme_is_opaque(nScheme) || lpUrlComponents->lpszHostName)
3629 memcpy(lpszUrl, slashSlashW, sizeof(slashSlashW));
3630 lpszUrl += sizeof(slashSlashW)/sizeof(slashSlashW[0]);
3633 if (lpUrlComponents->lpszUserName)
3635 dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, UserName);
3636 memcpy(lpszUrl, lpUrlComponents->lpszUserName, dwLen * sizeof(WCHAR));
3639 if (lpUrlComponents->lpszPassword)
3644 dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, Password);
3645 memcpy(lpszUrl, lpUrlComponents->lpszPassword, dwLen * sizeof(WCHAR));
3653 if (lpUrlComponents->lpszHostName)
3655 dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, HostName);
3656 memcpy(lpszUrl, lpUrlComponents->lpszHostName, dwLen * sizeof(WCHAR));
3659 if (!url_uses_default_port(nScheme, lpUrlComponents->nPort))
3661 WCHAR szPort[MAX_WORD_DIGITS+1];
3663 sprintfW(szPort, percentD, lpUrlComponents->nPort);
3666 dwLen = strlenW(szPort);
3667 memcpy(lpszUrl, szPort, dwLen * sizeof(WCHAR));
3671 /* add slash between hostname and path if necessary */
3672 if (lpUrlComponents->lpszUrlPath && *lpUrlComponents->lpszUrlPath != '/')
3680 if (lpUrlComponents->lpszUrlPath)
3682 dwLen = URL_GET_COMP_LENGTH(lpUrlComponents, UrlPath);
3683 memcpy(lpszUrl, lpUrlComponents->lpszUrlPath, dwLen * sizeof(WCHAR));
3692 /***********************************************************************
3693 * InternetConfirmZoneCrossingA (WININET.@)
3696 DWORD WINAPI InternetConfirmZoneCrossingA( HWND hWnd, LPSTR szUrlPrev, LPSTR szUrlNew, BOOL bPost )
3698 FIXME("(%p, %s, %s, %x) stub\n", hWnd, debugstr_a(szUrlPrev), debugstr_a(szUrlNew), bPost);
3699 return ERROR_SUCCESS;
3702 /***********************************************************************
3703 * InternetConfirmZoneCrossingW (WININET.@)
3706 DWORD WINAPI InternetConfirmZoneCrossingW( HWND hWnd, LPWSTR szUrlPrev, LPWSTR szUrlNew, BOOL bPost )
3708 FIXME("(%p, %s, %s, %x) stub\n", hWnd, debugstr_w(szUrlPrev), debugstr_w(szUrlNew), bPost);
3709 return ERROR_SUCCESS;
3712 DWORD WINAPI InternetDialA( HWND hwndParent, LPSTR lpszConnectoid, DWORD dwFlags,
3713 DWORD_PTR* lpdwConnection, DWORD dwReserved )
3715 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent, lpszConnectoid, dwFlags,
3716 lpdwConnection, dwReserved);
3717 return ERROR_SUCCESS;
3720 DWORD WINAPI InternetDialW( HWND hwndParent, LPWSTR lpszConnectoid, DWORD dwFlags,
3721 DWORD_PTR* lpdwConnection, DWORD dwReserved )
3723 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent, lpszConnectoid, dwFlags,
3724 lpdwConnection, dwReserved);
3725 return ERROR_SUCCESS;
3728 BOOL WINAPI InternetGoOnlineA( LPSTR lpszURL, HWND hwndParent, DWORD dwReserved )
3730 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_a(lpszURL), hwndParent, dwReserved);
3734 BOOL WINAPI InternetGoOnlineW( LPWSTR lpszURL, HWND hwndParent, DWORD dwReserved )
3736 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_w(lpszURL), hwndParent, dwReserved);
3740 DWORD WINAPI InternetHangUp( DWORD_PTR dwConnection, DWORD dwReserved )
3742 FIXME("(0x%08lx, 0x%08x) stub\n", dwConnection, dwReserved);
3743 return ERROR_SUCCESS;
3746 BOOL WINAPI CreateMD5SSOHash( PWSTR pszChallengeInfo, PWSTR pwszRealm, PWSTR pwszTarget,
3749 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo), debugstr_w(pwszRealm),
3750 debugstr_w(pwszTarget), pbHexHash);
3754 BOOL WINAPI ResumeSuspendedDownload( HINTERNET hInternet, DWORD dwError )
3756 FIXME("(%p, 0x%08x) stub\n", hInternet, dwError);
3760 BOOL WINAPI InternetQueryFortezzaStatus(DWORD *a, DWORD_PTR b)
3762 FIXME("(%p, %08lx) stub\n", a, b);