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 */
34 #if defined(__MINGW32__) || defined (_MSC_VER)
41 #include <sys/types.h>
42 #ifdef HAVE_SYS_SOCKET_H
43 # include <sys/socket.h>
48 #ifdef HAVE_SYS_POLL_H
49 # include <sys/poll.h>
51 #ifdef HAVE_SYS_TIME_H
52 # include <sys/time.h>
68 #include "wine/debug.h"
70 #define NO_SHLWAPI_STREAM
73 #include "wine/exception.h"
78 #include "wine/unicode.h"
80 WINE_DEFAULT_DEBUG_CHANNEL(wininet
);
82 #define RESPONSE_TIMEOUT 30
87 CHAR response
[MAX_REPLY_LEN
];
88 } WITHREADERROR
, *LPWITHREADERROR
;
90 static DWORD g_dwTlsErrIndex
= TLS_OUT_OF_INDEXES
;
91 static HMODULE WININET_hModule
;
93 #define HANDLE_CHUNK_SIZE 0x10
95 static CRITICAL_SECTION WININET_cs
;
96 static CRITICAL_SECTION_DEBUG WININET_cs_debug
=
99 { &WININET_cs_debug
.ProcessLocksList
, &WININET_cs_debug
.ProcessLocksList
},
100 0, 0, { (DWORD_PTR
)(__FILE__
": WININET_cs") }
102 static CRITICAL_SECTION WININET_cs
= { &WININET_cs_debug
, -1, 0, 0, 0, 0 };
104 static object_header_t
**WININET_Handles
;
105 static UINT WININET_dwNextHandle
;
106 static UINT WININET_dwMaxHandles
;
110 DWORD dwProxyEnabled
;
111 LPWSTR lpszProxyServer
;
112 LPWSTR lpszProxyBypass
;
115 static const WCHAR szInternetSettings
[] =
116 { 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
117 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
118 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0 };
119 static const WCHAR szProxyServer
[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
120 static const WCHAR szProxyEnable
[] = { 'P','r','o','x','y','E','n','a','b','l','e', 0 };
122 HINTERNET
WININET_AllocHandle( object_header_t
*info
)
125 UINT handle
= 0, num
;
127 list_init( &info
->children
);
129 EnterCriticalSection( &WININET_cs
);
130 if( !WININET_dwMaxHandles
)
132 num
= HANDLE_CHUNK_SIZE
;
133 p
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
134 sizeof (*WININET_Handles
)* num
);
138 WININET_dwMaxHandles
= num
;
140 if( WININET_dwMaxHandles
== WININET_dwNextHandle
)
142 num
= WININET_dwMaxHandles
+ HANDLE_CHUNK_SIZE
;
143 p
= HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
144 WININET_Handles
, sizeof (*WININET_Handles
)* num
);
148 WININET_dwMaxHandles
= num
;
151 handle
= WININET_dwNextHandle
;
152 if( WININET_Handles
[handle
] )
153 ERR("handle isn't free but should be\n");
154 WININET_Handles
[handle
] = WININET_AddRef( info
);
156 while( WININET_Handles
[WININET_dwNextHandle
] &&
157 (WININET_dwNextHandle
< WININET_dwMaxHandles
) )
158 WININET_dwNextHandle
++;
161 LeaveCriticalSection( &WININET_cs
);
163 return info
->hInternet
= (HINTERNET
) (handle
+1);
166 object_header_t
*WININET_AddRef( object_header_t
*info
)
168 ULONG refs
= InterlockedIncrement(&info
->refs
);
169 TRACE("%p -> refcount = %d\n", info
, refs
);
173 object_header_t
*WININET_GetObject( HINTERNET hinternet
)
175 object_header_t
*info
= NULL
;
176 UINT handle
= (UINT
) hinternet
;
178 EnterCriticalSection( &WININET_cs
);
180 if( (handle
> 0) && ( handle
<= WININET_dwMaxHandles
) &&
181 WININET_Handles
[handle
-1] )
182 info
= WININET_AddRef( WININET_Handles
[handle
-1] );
184 LeaveCriticalSection( &WININET_cs
);
186 TRACE("handle %d -> %p\n", handle
, info
);
191 BOOL
WININET_Release( object_header_t
*info
)
193 ULONG refs
= InterlockedDecrement(&info
->refs
);
194 TRACE( "object %p refcount = %d\n", info
, refs
);
197 if ( info
->vtbl
->CloseConnection
)
199 TRACE( "closing connection %p\n", info
);
200 info
->vtbl
->CloseConnection( info
);
202 /* Don't send a callback if this is a session handle created with InternetOpenUrl */
203 if ((info
->htype
!= WH_HHTTPSESSION
&& info
->htype
!= WH_HFTPSESSION
)
204 || !(info
->dwInternalFlags
& INET_OPENURL
))
206 INTERNET_SendCallback(info
, info
->dwContext
,
207 INTERNET_STATUS_HANDLE_CLOSING
, &info
->hInternet
,
210 TRACE( "destroying object %p\n", info
);
211 if ( info
->htype
!= WH_HINIT
)
212 list_remove( &info
->entry
);
213 info
->vtbl
->Destroy( info
);
218 BOOL
WININET_FreeHandle( HINTERNET hinternet
)
221 UINT handle
= (UINT
) hinternet
;
222 object_header_t
*info
= NULL
, *child
, *next
;
224 EnterCriticalSection( &WININET_cs
);
226 if( (handle
> 0) && ( handle
<= WININET_dwMaxHandles
) )
229 if( WININET_Handles
[handle
] )
231 info
= WININET_Handles
[handle
];
232 TRACE( "destroying handle %d for object %p\n", handle
+1, info
);
233 WININET_Handles
[handle
] = NULL
;
238 LeaveCriticalSection( &WININET_cs
);
240 /* As on native when the equivalent of WININET_Release is called, the handle
241 * is already invalid, but if a new handle is created at this time it does
242 * not yet get assigned the freed handle number */
245 /* Free all children as native does */
246 LIST_FOR_EACH_ENTRY_SAFE( child
, next
, &info
->children
, object_header_t
, entry
)
248 TRACE( "freeing child handle %d for parent handle %d\n",
249 (UINT
)child
->hInternet
, handle
+1);
250 WININET_FreeHandle( child
->hInternet
);
252 WININET_Release( info
);
255 EnterCriticalSection( &WININET_cs
);
257 if( WININET_dwNextHandle
> handle
&& !WININET_Handles
[handle
] )
258 WININET_dwNextHandle
= handle
;
260 LeaveCriticalSection( &WININET_cs
);
265 /***********************************************************************
266 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
269 * hinstDLL [I] handle to the DLL's instance
271 * lpvReserved [I] reserved, must be NULL
278 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
280 TRACE("%p,%x,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
283 case DLL_PROCESS_ATTACH
:
285 g_dwTlsErrIndex
= TlsAlloc();
287 if (g_dwTlsErrIndex
== TLS_OUT_OF_INDEXES
)
290 URLCacheContainers_CreateDefaults();
292 WININET_hModule
= hinstDLL
;
294 case DLL_THREAD_ATTACH
:
297 case DLL_THREAD_DETACH
:
298 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
300 LPVOID lpwite
= TlsGetValue(g_dwTlsErrIndex
);
301 HeapFree(GetProcessHeap(), 0, lpwite
);
305 case DLL_PROCESS_DETACH
:
309 URLCacheContainers_DeleteAll();
311 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
313 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex
));
314 TlsFree(g_dwTlsErrIndex
);
322 /***********************************************************************
323 * INTERNET_SaveProxySettings
325 * Stores the proxy settings given by lpwai into the registry
328 * ERROR_SUCCESS if no error, or error code on fail
330 static LONG
INTERNET_SaveProxySettings( proxyinfo_t
*lpwpi
)
335 if ((ret
= RegOpenKeyW( HKEY_CURRENT_USER
, szInternetSettings
, &key
)))
338 if ((ret
= RegSetValueExW( key
, szProxyEnable
, 0, REG_DWORD
, (BYTE
*)&lpwpi
->dwProxyEnabled
, sizeof(DWORD
))))
344 if (lpwpi
->lpszProxyServer
)
346 if ((ret
= RegSetValueExW( key
, szProxyServer
, 0, REG_SZ
, (BYTE
*)lpwpi
->lpszProxyServer
, sizeof(WCHAR
) * (lstrlenW(lpwpi
->lpszProxyServer
) + 1))))
354 if ((ret
= RegDeleteValueW( key
, szProxyServer
)))
362 return ERROR_SUCCESS
;
365 /***********************************************************************
366 * InternetInitializeAutoProxyDll (WININET.@)
368 * Setup the internal proxy
377 BOOL WINAPI
InternetInitializeAutoProxyDll(DWORD dwReserved
)
380 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
384 /***********************************************************************
385 * DetectAutoProxyUrl (WININET.@)
387 * Auto detect the proxy url
393 BOOL WINAPI
DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl
,
394 DWORD dwAutoProxyUrlLength
, DWORD dwDetectFlags
)
397 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
401 static void FreeProxyInfo( proxyinfo_t
*lpwpi
)
403 HeapFree(GetProcessHeap(), 0, lpwpi
->lpszProxyServer
);
404 HeapFree(GetProcessHeap(), 0, lpwpi
->lpszProxyBypass
);
407 /***********************************************************************
408 * INTERNET_LoadProxySettings
410 * Loads proxy information from the registry or environment into lpwpi.
412 * The caller should call FreeProxyInfo when done with lpwpi.
415 * The proxy may be specified in the form 'http=proxy.my.org'
416 * Presumably that means there can be ftp=ftpproxy.my.org too.
418 static LONG
INTERNET_LoadProxySettings( proxyinfo_t
*lpwpi
)
425 if ((ret
= RegOpenKeyW( HKEY_CURRENT_USER
, szInternetSettings
, &key
)))
429 if (RegQueryValueExW( key
, szProxyEnable
, NULL
, &type
, (BYTE
*)&lpwpi
->dwProxyEnabled
, &len
) || type
!= REG_DWORD
)
431 lpwpi
->dwProxyEnabled
= 0;
432 if((ret
= RegSetValueExW( key
, szProxyEnable
, 0, REG_DWORD
, (BYTE
*)&lpwpi
->dwProxyEnabled
, sizeof(DWORD
) )))
439 if (!(envproxy
= getenv( "http_proxy" )) || lpwpi
->dwProxyEnabled
)
441 TRACE("Proxy is enabled.\n");
443 /* figure out how much memory the proxy setting takes */
444 if (!RegQueryValueExW( key
, szProxyServer
, NULL
, &type
, NULL
, &len
) && len
&& (type
== REG_SZ
))
447 static const WCHAR szHttp
[] = {'h','t','t','p','=',0};
449 if (!(szProxy
= HeapAlloc( GetProcessHeap(), 0, len
)))
452 return ERROR_OUTOFMEMORY
;
454 RegQueryValueExW( key
, szProxyServer
, NULL
, &type
, (BYTE
*)szProxy
, &len
);
456 /* find the http proxy, and strip away everything else */
457 p
= strstrW( szProxy
, szHttp
);
460 p
+= lstrlenW( szHttp
);
461 lstrcpyW( szProxy
, p
);
463 p
= strchrW( szProxy
, ' ' );
466 lpwpi
->lpszProxyServer
= szProxy
;
468 TRACE("http proxy = %s\n", debugstr_w(lpwpi
->lpszProxyServer
));
472 TRACE("No proxy server settings in registry.\n");
473 lpwpi
->lpszProxyServer
= NULL
;
480 len
= MultiByteToWideChar( CP_UNIXCP
, 0, envproxy
, -1, NULL
, 0 );
481 if (!(envproxyW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
482 return ERROR_OUTOFMEMORY
;
483 MultiByteToWideChar( CP_UNIXCP
, 0, envproxy
, -1, envproxyW
, len
);
485 lpwpi
->dwProxyEnabled
= 1;
486 lpwpi
->lpszProxyServer
= envproxyW
;
488 TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi
->lpszProxyServer
));
492 lpwpi
->lpszProxyBypass
= NULL
;
494 return ERROR_SUCCESS
;
497 /***********************************************************************
498 * INTERNET_ConfigureProxy
500 static BOOL
INTERNET_ConfigureProxy( appinfo_t
*lpwai
)
504 if (INTERNET_LoadProxySettings( &wpi
))
507 if (wpi
.dwProxyEnabled
)
509 lpwai
->dwAccessType
= INTERNET_OPEN_TYPE_PROXY
;
510 lpwai
->lpszProxy
= wpi
.lpszProxyServer
;
514 lpwai
->dwAccessType
= INTERNET_OPEN_TYPE_DIRECT
;
518 /***********************************************************************
519 * dump_INTERNET_FLAGS
521 * Helper function to TRACE the internet flags.
527 static void dump_INTERNET_FLAGS(DWORD dwFlags
)
529 #define FE(x) { x, #x }
530 static const wininet_flag_info flag
[] = {
531 FE(INTERNET_FLAG_RELOAD
),
532 FE(INTERNET_FLAG_RAW_DATA
),
533 FE(INTERNET_FLAG_EXISTING_CONNECT
),
534 FE(INTERNET_FLAG_ASYNC
),
535 FE(INTERNET_FLAG_PASSIVE
),
536 FE(INTERNET_FLAG_NO_CACHE_WRITE
),
537 FE(INTERNET_FLAG_MAKE_PERSISTENT
),
538 FE(INTERNET_FLAG_FROM_CACHE
),
539 FE(INTERNET_FLAG_SECURE
),
540 FE(INTERNET_FLAG_KEEP_CONNECTION
),
541 FE(INTERNET_FLAG_NO_AUTO_REDIRECT
),
542 FE(INTERNET_FLAG_READ_PREFETCH
),
543 FE(INTERNET_FLAG_NO_COOKIES
),
544 FE(INTERNET_FLAG_NO_AUTH
),
545 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL
),
546 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
),
547 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
),
548 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
),
549 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID
),
550 FE(INTERNET_FLAG_RESYNCHRONIZE
),
551 FE(INTERNET_FLAG_HYPERLINK
),
552 FE(INTERNET_FLAG_NO_UI
),
553 FE(INTERNET_FLAG_PRAGMA_NOCACHE
),
554 FE(INTERNET_FLAG_CACHE_ASYNC
),
555 FE(INTERNET_FLAG_FORMS_SUBMIT
),
556 FE(INTERNET_FLAG_NEED_FILE
),
557 FE(INTERNET_FLAG_TRANSFER_ASCII
),
558 FE(INTERNET_FLAG_TRANSFER_BINARY
)
563 for (i
= 0; i
< (sizeof(flag
) / sizeof(flag
[0])); i
++) {
564 if (flag
[i
].val
& dwFlags
) {
565 TRACE(" %s", flag
[i
].name
);
566 dwFlags
&= ~flag
[i
].val
;
570 TRACE(" Unknown flags (%08x)\n", dwFlags
);
575 /***********************************************************************
576 * INTERNET_CloseHandle (internal)
578 * Close internet handle
581 static VOID
APPINFO_Destroy(object_header_t
*hdr
)
583 appinfo_t
*lpwai
= (appinfo_t
*)hdr
;
587 HeapFree(GetProcessHeap(), 0, lpwai
->lpszAgent
);
588 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxy
);
589 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyBypass
);
590 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyUsername
);
591 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyPassword
);
592 HeapFree(GetProcessHeap(), 0, lpwai
);
595 static DWORD
APPINFO_QueryOption(object_header_t
*hdr
, DWORD option
, void *buffer
, DWORD
*size
, BOOL unicode
)
597 appinfo_t
*ai
= (appinfo_t
*)hdr
;
600 case INTERNET_OPTION_HANDLE_TYPE
:
601 TRACE("INTERNET_OPTION_HANDLE_TYPE\n");
603 if (*size
< sizeof(ULONG
))
604 return ERROR_INSUFFICIENT_BUFFER
;
606 *size
= sizeof(DWORD
);
607 *(DWORD
*)buffer
= INTERNET_HANDLE_TYPE_INTERNET
;
608 return ERROR_SUCCESS
;
610 case INTERNET_OPTION_USER_AGENT
: {
613 TRACE("INTERNET_OPTION_USER_AGENT\n");
618 DWORD len
= ai
->lpszAgent
? strlenW(ai
->lpszAgent
) : 0;
620 *size
= (len
+ 1) * sizeof(WCHAR
);
621 if(!buffer
|| bufsize
< *size
)
622 return ERROR_INSUFFICIENT_BUFFER
;
625 strcpyW(buffer
, ai
->lpszAgent
);
627 *(WCHAR
*)buffer
= 0;
628 /* If the buffer is copied, the returned length doesn't include
629 * the NULL terminator.
631 *size
= len
* sizeof(WCHAR
);
634 *size
= WideCharToMultiByte(CP_ACP
, 0, ai
->lpszAgent
, -1, NULL
, 0, NULL
, NULL
);
637 if(!buffer
|| bufsize
< *size
)
638 return ERROR_INSUFFICIENT_BUFFER
;
641 WideCharToMultiByte(CP_ACP
, 0, ai
->lpszAgent
, -1, buffer
, *size
, NULL
, NULL
);
644 /* If the buffer is copied, the returned length doesn't include
645 * the NULL terminator.
650 return ERROR_SUCCESS
;
653 case INTERNET_OPTION_PROXY
:
655 INTERNET_PROXY_INFOW
*pi
= (INTERNET_PROXY_INFOW
*)buffer
;
656 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
657 LPWSTR proxy
, proxy_bypass
;
660 proxyBytesRequired
= (lstrlenW(ai
->lpszProxy
) + 1) * sizeof(WCHAR
);
661 if (ai
->lpszProxyBypass
)
662 proxyBypassBytesRequired
= (lstrlenW(ai
->lpszProxyBypass
) + 1) * sizeof(WCHAR
);
663 if (*size
< sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
)
665 *size
= sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
666 return ERROR_INSUFFICIENT_BUFFER
;
668 proxy
= (LPWSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOW
));
669 proxy_bypass
= (LPWSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
);
671 pi
->dwAccessType
= ai
->dwAccessType
;
672 pi
->lpszProxy
= NULL
;
673 pi
->lpszProxyBypass
= NULL
;
675 lstrcpyW(proxy
, ai
->lpszProxy
);
676 pi
->lpszProxy
= proxy
;
679 if (ai
->lpszProxyBypass
) {
680 lstrcpyW(proxy_bypass
, ai
->lpszProxyBypass
);
681 pi
->lpszProxyBypass
= proxy_bypass
;
684 *size
= sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
685 return ERROR_SUCCESS
;
687 INTERNET_PROXY_INFOA
*pi
= (INTERNET_PROXY_INFOA
*)buffer
;
688 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
689 LPSTR proxy
, proxy_bypass
;
692 proxyBytesRequired
= WideCharToMultiByte(CP_ACP
, 0, ai
->lpszProxy
, -1, NULL
, 0, NULL
, NULL
);
693 if (ai
->lpszProxyBypass
)
694 proxyBypassBytesRequired
= WideCharToMultiByte(CP_ACP
, 0, ai
->lpszProxyBypass
, -1,
695 NULL
, 0, NULL
, NULL
);
696 if (*size
< sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
)
698 *size
= sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
699 return ERROR_INSUFFICIENT_BUFFER
;
701 proxy
= (LPSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOA
));
702 proxy_bypass
= (LPSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
);
704 pi
->dwAccessType
= ai
->dwAccessType
;
705 pi
->lpszProxy
= NULL
;
706 pi
->lpszProxyBypass
= NULL
;
708 WideCharToMultiByte(CP_ACP
, 0, ai
->lpszProxy
, -1, proxy
, proxyBytesRequired
, NULL
, NULL
);
709 pi
->lpszProxy
= proxy
;
712 if (ai
->lpszProxyBypass
) {
713 WideCharToMultiByte(CP_ACP
, 0, ai
->lpszProxyBypass
, -1, proxy_bypass
,
714 proxyBypassBytesRequired
, NULL
, NULL
);
715 pi
->lpszProxyBypass
= proxy_bypass
;
718 *size
= sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
719 return ERROR_SUCCESS
;
723 return INET_QueryOption(option
, buffer
, size
, unicode
);
726 static const object_vtbl_t APPINFOVtbl
= {
739 /***********************************************************************
740 * InternetOpenW (WININET.@)
742 * Per-application initialization of wininet
745 * HINTERNET on success
749 HINTERNET WINAPI
InternetOpenW(LPCWSTR lpszAgent
, DWORD dwAccessType
,
750 LPCWSTR lpszProxy
, LPCWSTR lpszProxyBypass
, DWORD dwFlags
)
752 appinfo_t
*lpwai
= NULL
;
753 HINTERNET handle
= NULL
;
755 if (TRACE_ON(wininet
)) {
756 #define FE(x) { x, #x }
757 static const wininet_flag_info access_type
[] = {
758 FE(INTERNET_OPEN_TYPE_PRECONFIG
),
759 FE(INTERNET_OPEN_TYPE_DIRECT
),
760 FE(INTERNET_OPEN_TYPE_PROXY
),
761 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY
)
765 const char *access_type_str
= "Unknown";
767 TRACE("(%s, %i, %s, %s, %i)\n", debugstr_w(lpszAgent
), dwAccessType
,
768 debugstr_w(lpszProxy
), debugstr_w(lpszProxyBypass
), dwFlags
);
769 for (i
= 0; i
< (sizeof(access_type
) / sizeof(access_type
[0])); i
++) {
770 if (access_type
[i
].val
== dwAccessType
) {
771 access_type_str
= access_type
[i
].name
;
775 TRACE(" access type : %s\n", access_type_str
);
777 dump_INTERNET_FLAGS(dwFlags
);
780 /* Clear any error information */
781 INTERNET_SetLastError(0);
783 lpwai
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(appinfo_t
));
786 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
790 lpwai
->hdr
.htype
= WH_HINIT
;
791 lpwai
->hdr
.vtbl
= &APPINFOVtbl
;
792 lpwai
->hdr
.dwFlags
= dwFlags
;
794 lpwai
->dwAccessType
= dwAccessType
;
795 lpwai
->lpszProxyUsername
= NULL
;
796 lpwai
->lpszProxyPassword
= NULL
;
798 handle
= WININET_AllocHandle( &lpwai
->hdr
);
801 HeapFree( GetProcessHeap(), 0, lpwai
);
802 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
806 lpwai
->lpszAgent
= heap_strdupW(lpszAgent
);
807 if(dwAccessType
== INTERNET_OPEN_TYPE_PRECONFIG
)
808 INTERNET_ConfigureProxy( lpwai
);
810 lpwai
->lpszProxy
= heap_strdupW(lpszProxy
);
811 lpwai
->lpszProxyBypass
= heap_strdupW(lpszProxyBypass
);
815 WININET_Release( &lpwai
->hdr
);
817 TRACE("returning %p\n", lpwai
);
823 /***********************************************************************
824 * InternetOpenA (WININET.@)
826 * Per-application initialization of wininet
829 * HINTERNET on success
833 HINTERNET WINAPI
InternetOpenA(LPCSTR lpszAgent
, DWORD dwAccessType
,
834 LPCSTR lpszProxy
, LPCSTR lpszProxyBypass
, DWORD dwFlags
)
836 WCHAR
*szAgent
, *szProxy
, *szBypass
;
839 TRACE("(%s, 0x%08x, %s, %s, 0x%08x)\n", debugstr_a(lpszAgent
),
840 dwAccessType
, debugstr_a(lpszProxy
), debugstr_a(lpszProxyBypass
), dwFlags
);
842 szAgent
= heap_strdupAtoW(lpszAgent
);
843 szProxy
= heap_strdupAtoW(lpszProxy
);
844 szBypass
= heap_strdupAtoW(lpszProxyBypass
);
846 rc
= InternetOpenW(szAgent
, dwAccessType
, szProxy
, szBypass
, dwFlags
);
848 HeapFree(GetProcessHeap(), 0, szAgent
);
849 HeapFree(GetProcessHeap(), 0, szProxy
);
850 HeapFree(GetProcessHeap(), 0, szBypass
);
855 /***********************************************************************
856 * InternetGetLastResponseInfoA (WININET.@)
858 * Return last wininet error description on the calling thread
861 * TRUE on success of writing to buffer
865 BOOL WINAPI
InternetGetLastResponseInfoA(LPDWORD lpdwError
,
866 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
868 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
874 *lpdwError
= lpwite
->dwError
;
877 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
878 *lpdwBufferLength
= strlen(lpszBuffer
);
881 *lpdwBufferLength
= 0;
886 *lpdwBufferLength
= 0;
892 /***********************************************************************
893 * InternetGetLastResponseInfoW (WININET.@)
895 * Return last wininet error description on the calling thread
898 * TRUE on success of writing to buffer
902 BOOL WINAPI
InternetGetLastResponseInfoW(LPDWORD lpdwError
,
903 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
905 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
911 *lpdwError
= lpwite
->dwError
;
914 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
915 *lpdwBufferLength
= lstrlenW(lpszBuffer
);
918 *lpdwBufferLength
= 0;
923 *lpdwBufferLength
= 0;
929 /***********************************************************************
930 * InternetGetConnectedState (WININET.@)
932 * Return connected state
936 * if lpdwStatus is not null, return the status (off line,
937 * modem, lan...) in it.
938 * FALSE if not connected
940 BOOL WINAPI
InternetGetConnectedState(LPDWORD lpdwStatus
, DWORD dwReserved
)
942 TRACE("(%p, 0x%08x)\n", lpdwStatus
, dwReserved
);
945 WARN("always returning LAN connection.\n");
946 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
952 /***********************************************************************
953 * InternetGetConnectedStateExW (WININET.@)
955 * Return connected state
959 * lpdwStatus [O] Flags specifying the status of the internet connection.
960 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
961 * dwNameLen [I] Size of the buffer, in characters.
962 * dwReserved [I] Reserved. Must be set to 0.
966 * if lpdwStatus is not null, return the status (off line,
967 * modem, lan...) in it.
968 * FALSE if not connected
971 * If the system has no available network connections, an empty string is
972 * stored in lpszConnectionName. If there is a LAN connection, a localized
973 * "LAN Connection" string is stored. Presumably, if only a dial-up
974 * connection is available then the name of the dial-up connection is
975 * returned. Why any application, other than the "Internet Settings" CPL,
976 * would want to use this function instead of the simpler InternetGetConnectedStateW
977 * function is beyond me.
979 BOOL WINAPI
InternetGetConnectedStateExW(LPDWORD lpdwStatus
, LPWSTR lpszConnectionName
,
980 DWORD dwNameLen
, DWORD dwReserved
)
982 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
989 WARN("always returning LAN connection.\n");
990 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
992 return LoadStringW(WININET_hModule
, IDS_LANCONNECTION
, lpszConnectionName
, dwNameLen
);
996 /***********************************************************************
997 * InternetGetConnectedStateExA (WININET.@)
999 BOOL WINAPI
InternetGetConnectedStateExA(LPDWORD lpdwStatus
, LPSTR lpszConnectionName
,
1000 DWORD dwNameLen
, DWORD dwReserved
)
1002 LPWSTR lpwszConnectionName
= NULL
;
1005 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
1007 if (lpszConnectionName
&& dwNameLen
> 0)
1008 lpwszConnectionName
= HeapAlloc(GetProcessHeap(), 0, dwNameLen
* sizeof(WCHAR
));
1010 rc
= InternetGetConnectedStateExW(lpdwStatus
,lpwszConnectionName
, dwNameLen
,
1012 if (rc
&& lpwszConnectionName
)
1014 WideCharToMultiByte(CP_ACP
,0,lpwszConnectionName
,-1,lpszConnectionName
,
1015 dwNameLen
, NULL
, NULL
);
1017 HeapFree(GetProcessHeap(),0,lpwszConnectionName
);
1024 /***********************************************************************
1025 * InternetConnectW (WININET.@)
1027 * Open a ftp, gopher or http session
1030 * HINTERNET a session handle on success
1034 HINTERNET WINAPI
InternetConnectW(HINTERNET hInternet
,
1035 LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
1036 LPCWSTR lpszUserName
, LPCWSTR lpszPassword
,
1037 DWORD dwService
, DWORD dwFlags
, DWORD_PTR dwContext
)
1040 HINTERNET rc
= NULL
;
1041 DWORD res
= ERROR_SUCCESS
;
1043 TRACE("(%p, %s, %i, %s, %s, %i, %i, %lx)\n", hInternet
, debugstr_w(lpszServerName
),
1044 nServerPort
, debugstr_w(lpszUserName
), debugstr_w(lpszPassword
),
1045 dwService
, dwFlags
, dwContext
);
1047 if (!lpszServerName
)
1049 SetLastError(ERROR_INVALID_PARAMETER
);
1053 hIC
= (appinfo_t
*)WININET_GetObject( hInternet
);
1054 if ( (hIC
== NULL
) || (hIC
->hdr
.htype
!= WH_HINIT
) )
1056 res
= ERROR_INVALID_HANDLE
;
1062 case INTERNET_SERVICE_FTP
:
1063 rc
= FTP_Connect(hIC
, lpszServerName
, nServerPort
,
1064 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0);
1066 res
= INTERNET_GetLastError();
1069 case INTERNET_SERVICE_HTTP
:
1070 res
= HTTP_Connect(hIC
, lpszServerName
, nServerPort
,
1071 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0, &rc
);
1074 case INTERNET_SERVICE_GOPHER
:
1080 WININET_Release( &hIC
->hdr
);
1082 TRACE("returning %p\n", rc
);
1088 /***********************************************************************
1089 * InternetConnectA (WININET.@)
1091 * Open a ftp, gopher or http session
1094 * HINTERNET a session handle on success
1098 HINTERNET WINAPI
InternetConnectA(HINTERNET hInternet
,
1099 LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
1100 LPCSTR lpszUserName
, LPCSTR lpszPassword
,
1101 DWORD dwService
, DWORD dwFlags
, DWORD_PTR dwContext
)
1103 HINTERNET rc
= NULL
;
1104 LPWSTR szServerName
;
1108 szServerName
= heap_strdupAtoW(lpszServerName
);
1109 szUserName
= heap_strdupAtoW(lpszUserName
);
1110 szPassword
= heap_strdupAtoW(lpszPassword
);
1112 rc
= InternetConnectW(hInternet
, szServerName
, nServerPort
,
1113 szUserName
, szPassword
, dwService
, dwFlags
, dwContext
);
1115 HeapFree(GetProcessHeap(), 0, szServerName
);
1116 HeapFree(GetProcessHeap(), 0, szUserName
);
1117 HeapFree(GetProcessHeap(), 0, szPassword
);
1122 /***********************************************************************
1123 * InternetFindNextFileA (WININET.@)
1125 * Continues a file search from a previous call to FindFirstFile
1132 BOOL WINAPI
InternetFindNextFileA(HINTERNET hFind
, LPVOID lpvFindData
)
1135 WIN32_FIND_DATAW fd
;
1137 ret
= InternetFindNextFileW(hFind
, lpvFindData
?&fd
:NULL
);
1139 WININET_find_data_WtoA(&fd
, (LPWIN32_FIND_DATAA
)lpvFindData
);
1143 /***********************************************************************
1144 * InternetFindNextFileW (WININET.@)
1146 * Continues a file search from a previous call to FindFirstFile
1153 BOOL WINAPI
InternetFindNextFileW(HINTERNET hFind
, LPVOID lpvFindData
)
1155 object_header_t
*hdr
;
1160 hdr
= WININET_GetObject(hFind
);
1162 WARN("Invalid handle\n");
1163 SetLastError(ERROR_INVALID_HANDLE
);
1167 if(hdr
->vtbl
->FindNextFileW
) {
1168 res
= hdr
->vtbl
->FindNextFileW(hdr
, lpvFindData
);
1170 WARN("Handle doesn't support NextFile\n");
1171 res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
1174 WININET_Release(hdr
);
1176 if(res
!= ERROR_SUCCESS
)
1178 return res
== ERROR_SUCCESS
;
1181 /***********************************************************************
1182 * InternetCloseHandle (WININET.@)
1184 * Generic close handle function
1191 BOOL WINAPI
InternetCloseHandle(HINTERNET hInternet
)
1193 object_header_t
*lpwh
;
1195 TRACE("%p\n",hInternet
);
1197 lpwh
= WININET_GetObject( hInternet
);
1200 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
1204 WININET_Release( lpwh
);
1205 WININET_FreeHandle( hInternet
);
1211 /***********************************************************************
1212 * ConvertUrlComponentValue (Internal)
1214 * Helper function for InternetCrackUrlA
1217 static void ConvertUrlComponentValue(LPSTR
* lppszComponent
, LPDWORD dwComponentLen
,
1218 LPWSTR lpwszComponent
, DWORD dwwComponentLen
,
1219 LPCSTR lpszStart
, LPCWSTR lpwszStart
)
1221 TRACE("%p %d %p %d %p %p\n", *lppszComponent
, *dwComponentLen
, lpwszComponent
, dwwComponentLen
, lpszStart
, lpwszStart
);
1222 if (*dwComponentLen
!= 0)
1224 DWORD nASCIILength
=WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,NULL
,0,NULL
,NULL
);
1225 if (*lppszComponent
== NULL
)
1229 int offset
= WideCharToMultiByte(CP_ACP
, 0, lpwszStart
, lpwszComponent
-lpwszStart
, NULL
, 0, NULL
, NULL
);
1230 *lppszComponent
= (LPSTR
)lpszStart
+ offset
;
1233 *lppszComponent
= NULL
;
1235 *dwComponentLen
= nASCIILength
;
1239 DWORD ncpylen
= min((*dwComponentLen
)-1, nASCIILength
);
1240 WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,*lppszComponent
,ncpylen
+1,NULL
,NULL
);
1241 (*lppszComponent
)[ncpylen
]=0;
1242 *dwComponentLen
= ncpylen
;
1248 /***********************************************************************
1249 * InternetCrackUrlA (WININET.@)
1251 * See InternetCrackUrlW.
1253 BOOL WINAPI
InternetCrackUrlA(LPCSTR lpszUrl
, DWORD dwUrlLength
, DWORD dwFlags
,
1254 LPURL_COMPONENTSA lpUrlComponents
)
1257 URL_COMPONENTSW UCW
;
1259 WCHAR
*lpwszUrl
, *hostname
= NULL
, *username
= NULL
, *password
= NULL
, *path
= NULL
,
1260 *scheme
= NULL
, *extra
= NULL
;
1262 TRACE("(%s %u %x %p)\n",
1263 lpszUrl
? debugstr_an(lpszUrl
, dwUrlLength
? dwUrlLength
: strlen(lpszUrl
)) : "(null)",
1264 dwUrlLength
, dwFlags
, lpUrlComponents
);
1266 if (!lpszUrl
|| !*lpszUrl
|| !lpUrlComponents
||
1267 lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSA
))
1269 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1275 nLength
=MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,NULL
,0);
1277 /* if dwUrlLength=-1 then nLength includes null but length to
1278 InternetCrackUrlW should not include it */
1279 if (dwUrlLength
== -1) nLength
--;
1281 lpwszUrl
= HeapAlloc(GetProcessHeap(), 0, nLength
* sizeof(WCHAR
));
1282 MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,lpwszUrl
,nLength
);
1284 memset(&UCW
,0,sizeof(UCW
));
1285 UCW
.dwStructSize
= sizeof(URL_COMPONENTSW
);
1286 if (lpUrlComponents
->dwHostNameLength
)
1288 UCW
.dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
1289 if (lpUrlComponents
->lpszHostName
)
1291 hostname
= HeapAlloc(GetProcessHeap(), 0, UCW
.dwHostNameLength
* sizeof(WCHAR
));
1292 UCW
.lpszHostName
= hostname
;
1295 if (lpUrlComponents
->dwUserNameLength
)
1297 UCW
.dwUserNameLength
= lpUrlComponents
->dwUserNameLength
;
1298 if (lpUrlComponents
->lpszUserName
)
1300 username
= HeapAlloc(GetProcessHeap(), 0, UCW
.dwUserNameLength
* sizeof(WCHAR
));
1301 UCW
.lpszUserName
= username
;
1304 if (lpUrlComponents
->dwPasswordLength
)
1306 UCW
.dwPasswordLength
= lpUrlComponents
->dwPasswordLength
;
1307 if (lpUrlComponents
->lpszPassword
)
1309 password
= HeapAlloc(GetProcessHeap(), 0, UCW
.dwPasswordLength
* sizeof(WCHAR
));
1310 UCW
.lpszPassword
= password
;
1313 if (lpUrlComponents
->dwUrlPathLength
)
1315 UCW
.dwUrlPathLength
= lpUrlComponents
->dwUrlPathLength
;
1316 if (lpUrlComponents
->lpszUrlPath
)
1318 path
= HeapAlloc(GetProcessHeap(), 0, UCW
.dwUrlPathLength
* sizeof(WCHAR
));
1319 UCW
.lpszUrlPath
= path
;
1322 if (lpUrlComponents
->dwSchemeLength
)
1324 UCW
.dwSchemeLength
= lpUrlComponents
->dwSchemeLength
;
1325 if (lpUrlComponents
->lpszScheme
)
1327 scheme
= HeapAlloc(GetProcessHeap(), 0, UCW
.dwSchemeLength
* sizeof(WCHAR
));
1328 UCW
.lpszScheme
= scheme
;
1331 if (lpUrlComponents
->dwExtraInfoLength
)
1333 UCW
.dwExtraInfoLength
= lpUrlComponents
->dwExtraInfoLength
;
1334 if (lpUrlComponents
->lpszExtraInfo
)
1336 extra
= HeapAlloc(GetProcessHeap(), 0, UCW
.dwExtraInfoLength
* sizeof(WCHAR
));
1337 UCW
.lpszExtraInfo
= extra
;
1340 if ((ret
= InternetCrackUrlW(lpwszUrl
, nLength
, dwFlags
, &UCW
)))
1342 ConvertUrlComponentValue(&lpUrlComponents
->lpszHostName
, &lpUrlComponents
->dwHostNameLength
,
1343 UCW
.lpszHostName
, UCW
.dwHostNameLength
, lpszUrl
, lpwszUrl
);
1344 ConvertUrlComponentValue(&lpUrlComponents
->lpszUserName
, &lpUrlComponents
->dwUserNameLength
,
1345 UCW
.lpszUserName
, UCW
.dwUserNameLength
, lpszUrl
, lpwszUrl
);
1346 ConvertUrlComponentValue(&lpUrlComponents
->lpszPassword
, &lpUrlComponents
->dwPasswordLength
,
1347 UCW
.lpszPassword
, UCW
.dwPasswordLength
, lpszUrl
, lpwszUrl
);
1348 ConvertUrlComponentValue(&lpUrlComponents
->lpszUrlPath
, &lpUrlComponents
->dwUrlPathLength
,
1349 UCW
.lpszUrlPath
, UCW
.dwUrlPathLength
, lpszUrl
, lpwszUrl
);
1350 ConvertUrlComponentValue(&lpUrlComponents
->lpszScheme
, &lpUrlComponents
->dwSchemeLength
,
1351 UCW
.lpszScheme
, UCW
.dwSchemeLength
, lpszUrl
, lpwszUrl
);
1352 ConvertUrlComponentValue(&lpUrlComponents
->lpszExtraInfo
, &lpUrlComponents
->dwExtraInfoLength
,
1353 UCW
.lpszExtraInfo
, UCW
.dwExtraInfoLength
, lpszUrl
, lpwszUrl
);
1355 lpUrlComponents
->nScheme
= UCW
.nScheme
;
1356 lpUrlComponents
->nPort
= UCW
.nPort
;
1358 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl
,
1359 debugstr_an(lpUrlComponents
->lpszScheme
, lpUrlComponents
->dwSchemeLength
),
1360 debugstr_an(lpUrlComponents
->lpszHostName
, lpUrlComponents
->dwHostNameLength
),
1361 debugstr_an(lpUrlComponents
->lpszUrlPath
, lpUrlComponents
->dwUrlPathLength
),
1362 debugstr_an(lpUrlComponents
->lpszExtraInfo
, lpUrlComponents
->dwExtraInfoLength
));
1364 HeapFree(GetProcessHeap(), 0, lpwszUrl
);
1365 HeapFree(GetProcessHeap(), 0, hostname
);
1366 HeapFree(GetProcessHeap(), 0, username
);
1367 HeapFree(GetProcessHeap(), 0, password
);
1368 HeapFree(GetProcessHeap(), 0, path
);
1369 HeapFree(GetProcessHeap(), 0, scheme
);
1370 HeapFree(GetProcessHeap(), 0, extra
);
1374 static const WCHAR url_schemes
[][7] =
1377 {'g','o','p','h','e','r',0},
1378 {'h','t','t','p',0},
1379 {'h','t','t','p','s',0},
1380 {'f','i','l','e',0},
1381 {'n','e','w','s',0},
1382 {'m','a','i','l','t','o',0},
1386 /***********************************************************************
1387 * GetInternetSchemeW (internal)
1393 * INTERNET_SCHEME_UNKNOWN on failure
1396 static INTERNET_SCHEME
GetInternetSchemeW(LPCWSTR lpszScheme
, DWORD nMaxCmp
)
1400 TRACE("%s %d\n",debugstr_wn(lpszScheme
, nMaxCmp
), nMaxCmp
);
1402 if(lpszScheme
==NULL
)
1403 return INTERNET_SCHEME_UNKNOWN
;
1405 for (i
= 0; i
< sizeof(url_schemes
)/sizeof(url_schemes
[0]); i
++)
1406 if (!strncmpW(lpszScheme
, url_schemes
[i
], nMaxCmp
))
1407 return INTERNET_SCHEME_FIRST
+ i
;
1409 return INTERNET_SCHEME_UNKNOWN
;
1412 /***********************************************************************
1413 * SetUrlComponentValueW (Internal)
1415 * Helper function for InternetCrackUrlW
1418 * lppszComponent [O] Holds the returned string
1419 * dwComponentLen [I] Holds the size of lppszComponent
1420 * [O] Holds the length of the string in lppszComponent without '\0'
1421 * lpszStart [I] Holds the string to copy from
1422 * len [I] Holds the length of lpszStart without '\0'
1429 static BOOL
SetUrlComponentValueW(LPWSTR
* lppszComponent
, LPDWORD dwComponentLen
, LPCWSTR lpszStart
, DWORD len
)
1431 TRACE("%s (%d)\n", debugstr_wn(lpszStart
,len
), len
);
1433 if ( (*dwComponentLen
== 0) && (*lppszComponent
== NULL
) )
1436 if (*dwComponentLen
!= 0 || *lppszComponent
== NULL
)
1438 if (*lppszComponent
== NULL
)
1440 *lppszComponent
= (LPWSTR
)lpszStart
;
1441 *dwComponentLen
= len
;
1445 DWORD ncpylen
= min((*dwComponentLen
)-1, len
);
1446 memcpy(*lppszComponent
, lpszStart
, ncpylen
*sizeof(WCHAR
));
1447 (*lppszComponent
)[ncpylen
] = '\0';
1448 *dwComponentLen
= ncpylen
;
1455 /***********************************************************************
1456 * InternetCrackUrlW (WININET.@)
1458 * Break up URL into its components
1464 BOOL WINAPI
InternetCrackUrlW(LPCWSTR lpszUrl_orig
, DWORD dwUrlLength_orig
, DWORD dwFlags
,
1465 LPURL_COMPONENTSW lpUC
)
1469 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1472 LPCWSTR lpszParam
= NULL
;
1473 BOOL bIsAbsolute
= FALSE
;
1474 LPCWSTR lpszap
, lpszUrl
= lpszUrl_orig
;
1475 LPCWSTR lpszcp
= NULL
;
1476 LPWSTR lpszUrl_decode
= NULL
;
1477 DWORD dwUrlLength
= dwUrlLength_orig
;
1479 TRACE("(%s %u %x %p)\n",
1480 lpszUrl
? debugstr_wn(lpszUrl
, dwUrlLength
? dwUrlLength
: strlenW(lpszUrl
)) : "(null)",
1481 dwUrlLength
, dwFlags
, lpUC
);
1483 if (!lpszUrl_orig
|| !*lpszUrl_orig
|| !lpUC
)
1485 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1488 if (!dwUrlLength
) dwUrlLength
= strlenW(lpszUrl
);
1490 if (dwFlags
& ICU_DECODE
)
1493 DWORD len
= dwUrlLength
+ 1;
1495 if (!(url_tmp
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
1497 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
1500 memcpy(url_tmp
, lpszUrl_orig
, dwUrlLength
* sizeof(WCHAR
));
1501 url_tmp
[dwUrlLength
] = 0;
1502 if (!(lpszUrl_decode
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
1504 HeapFree(GetProcessHeap(), 0, url_tmp
);
1505 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
1508 if (InternetCanonicalizeUrlW(url_tmp
, lpszUrl_decode
, &len
, ICU_DECODE
| ICU_NO_ENCODE
))
1511 lpszUrl
= lpszUrl_decode
;
1513 HeapFree(GetProcessHeap(), 0, url_tmp
);
1517 /* Determine if the URI is absolute. */
1518 while (lpszap
- lpszUrl
< dwUrlLength
)
1520 if (isalnumW(*lpszap
) || *lpszap
== '+' || *lpszap
== '.' || *lpszap
== '-')
1525 if ((*lpszap
== ':') && (lpszap
- lpszUrl
>= 2))
1532 lpszcp
= lpszUrl
; /* Relative url */
1538 lpUC
->nScheme
= INTERNET_SCHEME_UNKNOWN
;
1539 lpUC
->nPort
= INTERNET_INVALID_PORT_NUMBER
;
1541 /* Parse <params> */
1542 lpszParam
= memchrW(lpszap
, ';', dwUrlLength
- (lpszap
- lpszUrl
));
1544 lpszParam
= memchrW(lpszap
, '?', dwUrlLength
- (lpszap
- lpszUrl
));
1546 lpszParam
= memchrW(lpszap
, '#', dwUrlLength
- (lpszap
- lpszUrl
));
1548 SetUrlComponentValueW(&lpUC
->lpszExtraInfo
, &lpUC
->dwExtraInfoLength
,
1549 lpszParam
, lpszParam
? dwUrlLength
-(lpszParam
-lpszUrl
) : 0);
1551 if (bIsAbsolute
) /* Parse <protocol>:[//<net_loc>] */
1555 /* Get scheme first. */
1556 lpUC
->nScheme
= GetInternetSchemeW(lpszUrl
, lpszcp
- lpszUrl
);
1557 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
,
1558 lpszUrl
, lpszcp
- lpszUrl
);
1560 /* Eat ':' in protocol. */
1563 /* double slash indicates the net_loc portion is present */
1564 if ((lpszcp
[0] == '/') && (lpszcp
[1] == '/'))
1568 lpszNetLoc
= memchrW(lpszcp
, '/', dwUrlLength
- (lpszcp
- lpszUrl
));
1572 lpszNetLoc
= min(lpszNetLoc
, lpszParam
);
1574 lpszNetLoc
= lpszParam
;
1576 else if (!lpszNetLoc
)
1577 lpszNetLoc
= lpszcp
+ dwUrlLength
-(lpszcp
-lpszUrl
);
1585 /* [<user>[<:password>]@]<host>[:<port>] */
1586 /* First find the user and password if they exist */
1588 lpszHost
= memchrW(lpszcp
, '@', dwUrlLength
- (lpszcp
- lpszUrl
));
1589 if (lpszHost
== NULL
|| lpszHost
> lpszNetLoc
)
1591 /* username and password not specified. */
1592 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1593 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1595 else /* Parse out username and password */
1597 LPCWSTR lpszUser
= lpszcp
;
1598 LPCWSTR lpszPasswd
= lpszHost
;
1600 while (lpszcp
< lpszHost
)
1603 lpszPasswd
= lpszcp
;
1608 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
,
1609 lpszUser
, lpszPasswd
- lpszUser
);
1611 if (lpszPasswd
!= lpszHost
)
1613 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
,
1614 lpszPasswd
== lpszHost
? NULL
: lpszPasswd
,
1615 lpszHost
- lpszPasswd
);
1617 lpszcp
++; /* Advance to beginning of host */
1620 /* Parse <host><:port> */
1623 lpszPort
= lpszNetLoc
;
1625 /* special case for res:// URLs: there is no port here, so the host is the
1626 entire string up to the first '/' */
1627 if(lpUC
->nScheme
==INTERNET_SCHEME_RES
)
1629 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1630 lpszHost
, lpszPort
- lpszHost
);
1635 while (lpszcp
< lpszNetLoc
)
1643 /* If the scheme is "file" and the host is just one letter, it's not a host */
1644 if(lpUC
->nScheme
==INTERNET_SCHEME_FILE
&& lpszPort
<= lpszHost
+1)
1647 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1652 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1653 lpszHost
, lpszPort
- lpszHost
);
1654 if (lpszPort
!= lpszNetLoc
)
1655 lpUC
->nPort
= atoiW(++lpszPort
);
1656 else switch (lpUC
->nScheme
)
1658 case INTERNET_SCHEME_HTTP
:
1659 lpUC
->nPort
= INTERNET_DEFAULT_HTTP_PORT
;
1661 case INTERNET_SCHEME_HTTPS
:
1662 lpUC
->nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
1664 case INTERNET_SCHEME_FTP
:
1665 lpUC
->nPort
= INTERNET_DEFAULT_FTP_PORT
;
1667 case INTERNET_SCHEME_GOPHER
:
1668 lpUC
->nPort
= INTERNET_DEFAULT_GOPHER_PORT
;
1679 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1680 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1681 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1686 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
, NULL
, 0);
1687 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1688 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1689 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1692 /* Here lpszcp points to:
1694 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1695 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1697 if (lpszcp
!= 0 && lpszcp
- lpszUrl
< dwUrlLength
&& (!lpszParam
|| lpszcp
<= lpszParam
))
1701 /* Only truncate the parameter list if it's already been saved
1702 * in lpUC->lpszExtraInfo.
1704 if (lpszParam
&& lpUC
->dwExtraInfoLength
&& lpUC
->lpszExtraInfo
)
1705 len
= lpszParam
- lpszcp
;
1708 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1709 * newlines if necessary.
1711 LPWSTR lpsznewline
= memchrW(lpszcp
, '\n', dwUrlLength
- (lpszcp
- lpszUrl
));
1712 if (lpsznewline
!= NULL
)
1713 len
= lpsznewline
- lpszcp
;
1715 len
= dwUrlLength
-(lpszcp
-lpszUrl
);
1717 SetUrlComponentValueW(&lpUC
->lpszUrlPath
, &lpUC
->dwUrlPathLength
,
1722 if (lpUC
->lpszUrlPath
&& (lpUC
->dwUrlPathLength
> 0))
1723 lpUC
->lpszUrlPath
[0] = 0;
1724 lpUC
->dwUrlPathLength
= 0;
1727 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl
,dwUrlLength
),
1728 debugstr_wn(lpUC
->lpszScheme
,lpUC
->dwSchemeLength
),
1729 debugstr_wn(lpUC
->lpszHostName
,lpUC
->dwHostNameLength
),
1730 debugstr_wn(lpUC
->lpszUrlPath
,lpUC
->dwUrlPathLength
),
1731 debugstr_wn(lpUC
->lpszExtraInfo
,lpUC
->dwExtraInfoLength
));
1733 HeapFree(GetProcessHeap(), 0, lpszUrl_decode
);
1737 /***********************************************************************
1738 * InternetAttemptConnect (WININET.@)
1740 * Attempt to make a connection to the internet
1743 * ERROR_SUCCESS on success
1744 * Error value on failure
1747 DWORD WINAPI
InternetAttemptConnect(DWORD dwReserved
)
1750 return ERROR_SUCCESS
;
1754 /***********************************************************************
1755 * InternetCanonicalizeUrlA (WININET.@)
1757 * Escape unsafe characters and spaces
1764 BOOL WINAPI
InternetCanonicalizeUrlA(LPCSTR lpszUrl
, LPSTR lpszBuffer
,
1765 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1768 DWORD dwURLFlags
= URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
;
1770 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl
), lpszBuffer
,
1771 lpdwBufferLength
, lpdwBufferLength
? *lpdwBufferLength
: -1, dwFlags
);
1773 if(dwFlags
& ICU_DECODE
)
1775 dwURLFlags
|= URL_UNESCAPE
;
1776 dwFlags
&= ~ICU_DECODE
;
1779 if(dwFlags
& ICU_ESCAPE
)
1781 dwURLFlags
|= URL_UNESCAPE
;
1782 dwFlags
&= ~ICU_ESCAPE
;
1785 if(dwFlags
& ICU_BROWSER_MODE
)
1787 dwURLFlags
|= URL_BROWSER_MODE
;
1788 dwFlags
&= ~ICU_BROWSER_MODE
;
1791 if(dwFlags
& ICU_NO_ENCODE
)
1793 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1794 dwURLFlags
^= URL_ESCAPE_UNSAFE
;
1795 dwFlags
&= ~ICU_NO_ENCODE
;
1798 if (dwFlags
) FIXME("Unhandled flags 0x%08x\n", dwFlags
);
1800 hr
= UrlCanonicalizeA(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1801 if (hr
== E_POINTER
) SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1802 if (hr
== E_INVALIDARG
) SetLastError(ERROR_INVALID_PARAMETER
);
1804 return (hr
== S_OK
) ? TRUE
: FALSE
;
1807 /***********************************************************************
1808 * InternetCanonicalizeUrlW (WININET.@)
1810 * Escape unsafe characters and spaces
1817 BOOL WINAPI
InternetCanonicalizeUrlW(LPCWSTR lpszUrl
, LPWSTR lpszBuffer
,
1818 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1821 DWORD dwURLFlags
= URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
;
1823 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl
), lpszBuffer
,
1824 lpdwBufferLength
, dwFlags
, lpdwBufferLength
? *lpdwBufferLength
: -1);
1826 if(dwFlags
& ICU_DECODE
)
1828 dwURLFlags
|= URL_UNESCAPE
;
1829 dwFlags
&= ~ICU_DECODE
;
1832 if(dwFlags
& ICU_ESCAPE
)
1834 dwURLFlags
|= URL_UNESCAPE
;
1835 dwFlags
&= ~ICU_ESCAPE
;
1838 if(dwFlags
& ICU_BROWSER_MODE
)
1840 dwURLFlags
|= URL_BROWSER_MODE
;
1841 dwFlags
&= ~ICU_BROWSER_MODE
;
1844 if(dwFlags
& ICU_NO_ENCODE
)
1846 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1847 dwURLFlags
^= URL_ESCAPE_UNSAFE
;
1848 dwFlags
&= ~ICU_NO_ENCODE
;
1851 if (dwFlags
) FIXME("Unhandled flags 0x%08x\n", dwFlags
);
1853 hr
= UrlCanonicalizeW(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1854 if (hr
== E_POINTER
) SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1855 if (hr
== E_INVALIDARG
) SetLastError(ERROR_INVALID_PARAMETER
);
1857 return (hr
== S_OK
) ? TRUE
: FALSE
;
1860 /* #################################################### */
1862 static INTERNET_STATUS_CALLBACK
set_status_callback(
1863 object_header_t
*lpwh
, INTERNET_STATUS_CALLBACK callback
, BOOL unicode
)
1865 INTERNET_STATUS_CALLBACK ret
;
1867 if (unicode
) lpwh
->dwInternalFlags
|= INET_CALLBACKW
;
1868 else lpwh
->dwInternalFlags
&= ~INET_CALLBACKW
;
1870 ret
= lpwh
->lpfnStatusCB
;
1871 lpwh
->lpfnStatusCB
= callback
;
1876 /***********************************************************************
1877 * InternetSetStatusCallbackA (WININET.@)
1879 * Sets up a callback function which is called as progress is made
1880 * during an operation.
1883 * Previous callback or NULL on success
1884 * INTERNET_INVALID_STATUS_CALLBACK on failure
1887 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackA(
1888 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
1890 INTERNET_STATUS_CALLBACK retVal
;
1891 object_header_t
*lpwh
;
1893 TRACE("%p\n", hInternet
);
1895 if (!(lpwh
= WININET_GetObject(hInternet
)))
1896 return INTERNET_INVALID_STATUS_CALLBACK
;
1898 retVal
= set_status_callback(lpwh
, lpfnIntCB
, FALSE
);
1900 WININET_Release( lpwh
);
1904 /***********************************************************************
1905 * InternetSetStatusCallbackW (WININET.@)
1907 * Sets up a callback function which is called as progress is made
1908 * during an operation.
1911 * Previous callback or NULL on success
1912 * INTERNET_INVALID_STATUS_CALLBACK on failure
1915 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackW(
1916 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
1918 INTERNET_STATUS_CALLBACK retVal
;
1919 object_header_t
*lpwh
;
1921 TRACE("%p\n", hInternet
);
1923 if (!(lpwh
= WININET_GetObject(hInternet
)))
1924 return INTERNET_INVALID_STATUS_CALLBACK
;
1926 retVal
= set_status_callback(lpwh
, lpfnIntCB
, TRUE
);
1928 WININET_Release( lpwh
);
1932 /***********************************************************************
1933 * InternetSetFilePointer (WININET.@)
1935 DWORD WINAPI
InternetSetFilePointer(HINTERNET hFile
, LONG lDistanceToMove
,
1936 PVOID pReserved
, DWORD dwMoveContext
, DWORD_PTR dwContext
)
1942 /***********************************************************************
1943 * InternetWriteFile (WININET.@)
1945 * Write data to an open internet file
1952 BOOL WINAPI
InternetWriteFile(HINTERNET hFile
, LPCVOID lpBuffer
,
1953 DWORD dwNumOfBytesToWrite
, LPDWORD lpdwNumOfBytesWritten
)
1955 object_header_t
*lpwh
;
1958 TRACE("(%p %p %d %p)\n", hFile
, lpBuffer
, dwNumOfBytesToWrite
, lpdwNumOfBytesWritten
);
1960 lpwh
= WININET_GetObject( hFile
);
1962 WARN("Invalid handle\n");
1963 SetLastError(ERROR_INVALID_HANDLE
);
1967 if(lpwh
->vtbl
->WriteFile
) {
1968 res
= lpwh
->vtbl
->WriteFile(lpwh
, lpBuffer
, dwNumOfBytesToWrite
, lpdwNumOfBytesWritten
);
1970 WARN("No Writefile method.\n");
1971 res
= ERROR_INVALID_HANDLE
;
1974 WININET_Release( lpwh
);
1976 if(res
!= ERROR_SUCCESS
)
1978 return res
== ERROR_SUCCESS
;
1982 /***********************************************************************
1983 * InternetReadFile (WININET.@)
1985 * Read data from an open internet file
1992 BOOL WINAPI
InternetReadFile(HINTERNET hFile
, LPVOID lpBuffer
,
1993 DWORD dwNumOfBytesToRead
, LPDWORD pdwNumOfBytesRead
)
1995 object_header_t
*hdr
;
1996 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
1998 TRACE("%p %p %d %p\n", hFile
, lpBuffer
, dwNumOfBytesToRead
, pdwNumOfBytesRead
);
2000 hdr
= WININET_GetObject(hFile
);
2002 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2006 if(hdr
->vtbl
->ReadFile
)
2007 res
= hdr
->vtbl
->ReadFile(hdr
, lpBuffer
, dwNumOfBytesToRead
, pdwNumOfBytesRead
);
2009 WININET_Release(hdr
);
2011 TRACE("-- %s (%u) (bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE", res
,
2012 pdwNumOfBytesRead
? *pdwNumOfBytesRead
: -1);
2014 if(res
!= ERROR_SUCCESS
)
2016 return res
== ERROR_SUCCESS
;
2019 /***********************************************************************
2020 * InternetReadFileExA (WININET.@)
2022 * Read data from an open internet file
2025 * hFile [I] Handle returned by InternetOpenUrl or HttpOpenRequest.
2026 * lpBuffersOut [I/O] Buffer.
2027 * dwFlags [I] Flags. See notes.
2028 * dwContext [I] Context for callbacks.
2035 * The parameter dwFlags include zero or more of the following flags:
2036 *|IRF_ASYNC - Makes the call asynchronous.
2037 *|IRF_SYNC - Makes the call synchronous.
2038 *|IRF_USE_CONTEXT - Forces dwContext to be used.
2039 *|IRF_NO_WAIT - Don't block if the data is not available, just return what is available.
2041 * However, in testing IRF_USE_CONTEXT seems to have no effect - dwContext isn't used.
2044 * InternetOpenUrlA(), HttpOpenRequestA()
2046 BOOL WINAPI
InternetReadFileExA(HINTERNET hFile
, LPINTERNET_BUFFERSA lpBuffersOut
,
2047 DWORD dwFlags
, DWORD_PTR dwContext
)
2049 object_header_t
*hdr
;
2050 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2052 TRACE("(%p %p 0x%x 0x%lx)\n", hFile
, lpBuffersOut
, dwFlags
, dwContext
);
2054 hdr
= WININET_GetObject(hFile
);
2056 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2060 if(hdr
->vtbl
->ReadFileExA
)
2061 res
= hdr
->vtbl
->ReadFileExA(hdr
, lpBuffersOut
, dwFlags
, dwContext
);
2063 WININET_Release(hdr
);
2065 TRACE("-- %s (%u, bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE",
2066 res
, lpBuffersOut
->dwBufferLength
);
2068 if(res
!= ERROR_SUCCESS
)
2070 return res
== ERROR_SUCCESS
;
2073 /***********************************************************************
2074 * InternetReadFileExW (WININET.@)
2076 * InternetReadFileExA()
2078 BOOL WINAPI
InternetReadFileExW(HINTERNET hFile
, LPINTERNET_BUFFERSW lpBuffer
,
2079 DWORD dwFlags
, DWORD_PTR dwContext
)
2081 object_header_t
*hdr
;
2082 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2084 TRACE("(%p %p 0x%x 0x%lx)\n", hFile
, lpBuffer
, dwFlags
, dwContext
);
2086 hdr
= WININET_GetObject(hFile
);
2088 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2092 if(hdr
->vtbl
->ReadFileExW
)
2093 res
= hdr
->vtbl
->ReadFileExW(hdr
, lpBuffer
, dwFlags
, dwContext
);
2095 WININET_Release(hdr
);
2097 TRACE("-- %s (%u, bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE",
2098 res
, lpBuffer
->dwBufferLength
);
2100 if(res
!= ERROR_SUCCESS
)
2102 return res
== ERROR_SUCCESS
;
2105 DWORD
INET_QueryOption(DWORD option
, void *buffer
, DWORD
*size
, BOOL unicode
)
2107 static BOOL warn
= TRUE
;
2110 case INTERNET_OPTION_REQUEST_FLAGS
:
2111 TRACE("INTERNET_OPTION_REQUEST_FLAGS\n");
2113 if (*size
< sizeof(ULONG
))
2114 return ERROR_INSUFFICIENT_BUFFER
;
2116 *(ULONG
*)buffer
= 4;
2117 *size
= sizeof(ULONG
);
2119 return ERROR_SUCCESS
;
2121 case INTERNET_OPTION_HTTP_VERSION
:
2122 if (*size
< sizeof(HTTP_VERSION_INFO
))
2123 return ERROR_INSUFFICIENT_BUFFER
;
2126 * Presently hardcoded to 1.1
2128 ((HTTP_VERSION_INFO
*)buffer
)->dwMajorVersion
= 1;
2129 ((HTTP_VERSION_INFO
*)buffer
)->dwMinorVersion
= 1;
2130 *size
= sizeof(HTTP_VERSION_INFO
);
2132 return ERROR_SUCCESS
;
2134 case INTERNET_OPTION_CONNECTED_STATE
:
2136 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
2139 if (*size
< sizeof(ULONG
))
2140 return ERROR_INSUFFICIENT_BUFFER
;
2142 *(ULONG
*)buffer
= INTERNET_STATE_CONNECTED
;
2143 *size
= sizeof(ULONG
);
2145 return ERROR_SUCCESS
;
2147 case INTERNET_OPTION_PROXY
: {
2151 TRACE("Getting global proxy info\n");
2152 memset(&ai
, 0, sizeof(appinfo_t
));
2153 INTERNET_ConfigureProxy(&ai
);
2155 ret
= APPINFO_QueryOption(&ai
.hdr
, INTERNET_OPTION_PROXY
, buffer
, size
, unicode
); /* FIXME */
2156 APPINFO_Destroy(&ai
.hdr
);
2160 case INTERNET_OPTION_MAX_CONNS_PER_SERVER
:
2161 TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER\n");
2163 if (*size
< sizeof(ULONG
))
2164 return ERROR_INSUFFICIENT_BUFFER
;
2166 *(ULONG
*)buffer
= 2;
2167 *size
= sizeof(ULONG
);
2169 return ERROR_SUCCESS
;
2171 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
:
2172 TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER\n");
2174 if (*size
< sizeof(ULONG
))
2175 return ERROR_INSUFFICIENT_BUFFER
;
2178 *size
= sizeof(ULONG
);
2180 return ERROR_SUCCESS
;
2182 case INTERNET_OPTION_SECURITY_FLAGS
:
2183 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2184 return ERROR_SUCCESS
;
2186 case INTERNET_OPTION_VERSION
: {
2187 static const INTERNET_VERSION_INFO info
= { 1, 2 };
2189 TRACE("INTERNET_OPTION_VERSION\n");
2191 if (*size
< sizeof(INTERNET_VERSION_INFO
))
2192 return ERROR_INSUFFICIENT_BUFFER
;
2194 memcpy(buffer
, &info
, sizeof(info
));
2195 *size
= sizeof(info
);
2197 return ERROR_SUCCESS
;
2200 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2201 INTERNET_PER_CONN_OPTION_LISTW
*con
= buffer
;
2202 INTERNET_PER_CONN_OPTION_LISTA
*conA
= buffer
;
2203 DWORD res
= ERROR_SUCCESS
, i
;
2207 TRACE("Getting global proxy info\n");
2208 if((ret
= INTERNET_LoadProxySettings(&pi
)))
2211 FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
2213 if (*size
< sizeof(INTERNET_PER_CONN_OPTION_LISTW
)) {
2215 return ERROR_INSUFFICIENT_BUFFER
;
2218 for (i
= 0; i
< con
->dwOptionCount
; i
++) {
2219 INTERNET_PER_CONN_OPTIONW
*option
= con
->pOptions
+ i
;
2220 INTERNET_PER_CONN_OPTIONA
*optionA
= conA
->pOptions
+ i
;
2222 switch (option
->dwOption
) {
2223 case INTERNET_PER_CONN_FLAGS
:
2224 if(pi
.dwProxyEnabled
)
2225 option
->Value
.dwValue
= PROXY_TYPE_PROXY
;
2227 option
->Value
.dwValue
= PROXY_TYPE_DIRECT
;
2230 case INTERNET_PER_CONN_PROXY_SERVER
:
2232 option
->Value
.pszValue
= heap_strdupW(pi
.lpszProxyServer
);
2234 optionA
->Value
.pszValue
= heap_strdupWtoA(pi
.lpszProxyServer
);
2237 case INTERNET_PER_CONN_PROXY_BYPASS
:
2239 option
->Value
.pszValue
= heap_strdupW(pi
.lpszProxyBypass
);
2241 optionA
->Value
.pszValue
= heap_strdupWtoA(pi
.lpszProxyBypass
);
2244 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2245 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2246 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2247 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2248 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2249 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2250 FIXME("Unhandled dwOption %d\n", option
->dwOption
);
2251 memset(&option
->Value
, 0, sizeof(option
->Value
));
2255 FIXME("Unknown dwOption %d\n", option
->dwOption
);
2256 res
= ERROR_INVALID_PARAMETER
;
2264 case INTERNET_OPTION_USER_AGENT
:
2265 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2266 case INTERNET_OPTION_POLICY
:
2267 return ERROR_INVALID_PARAMETER
;
2270 FIXME("Stub for %d\n", option
);
2271 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2274 /***********************************************************************
2275 * InternetQueryOptionW (WININET.@)
2277 * Queries an options on the specified handle
2284 BOOL WINAPI
InternetQueryOptionW(HINTERNET hInternet
, DWORD dwOption
,
2285 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2287 object_header_t
*hdr
;
2288 DWORD res
= ERROR_INVALID_HANDLE
;
2290 TRACE("%p %d %p %p\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2293 hdr
= WININET_GetObject(hInternet
);
2295 res
= hdr
->vtbl
->QueryOption(hdr
, dwOption
, lpBuffer
, lpdwBufferLength
, TRUE
);
2296 WININET_Release(hdr
);
2299 res
= INET_QueryOption(dwOption
, lpBuffer
, lpdwBufferLength
, TRUE
);
2302 if(res
!= ERROR_SUCCESS
)
2304 return res
== ERROR_SUCCESS
;
2307 /***********************************************************************
2308 * InternetQueryOptionA (WININET.@)
2310 * Queries an options on the specified handle
2317 BOOL WINAPI
InternetQueryOptionA(HINTERNET hInternet
, DWORD dwOption
,
2318 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2320 object_header_t
*hdr
;
2321 DWORD res
= ERROR_INVALID_HANDLE
;
2323 TRACE("%p %d %p %p\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2326 hdr
= WININET_GetObject(hInternet
);
2328 res
= hdr
->vtbl
->QueryOption(hdr
, dwOption
, lpBuffer
, lpdwBufferLength
, FALSE
);
2329 WININET_Release(hdr
);
2332 res
= INET_QueryOption(dwOption
, lpBuffer
, lpdwBufferLength
, FALSE
);
2335 if(res
!= ERROR_SUCCESS
)
2337 return res
== ERROR_SUCCESS
;
2341 /***********************************************************************
2342 * InternetSetOptionW (WININET.@)
2344 * Sets an options on the specified handle
2351 BOOL WINAPI
InternetSetOptionW(HINTERNET hInternet
, DWORD dwOption
,
2352 LPVOID lpBuffer
, DWORD dwBufferLength
)
2354 object_header_t
*lpwhh
;
2357 TRACE("(%p %d %p %d)\n", hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2359 lpwhh
= (object_header_t
*) WININET_GetObject( hInternet
);
2360 if(lpwhh
&& lpwhh
->vtbl
->SetOption
) {
2363 res
= lpwhh
->vtbl
->SetOption(lpwhh
, dwOption
, lpBuffer
, dwBufferLength
);
2364 if(res
!= ERROR_INTERNET_INVALID_OPTION
) {
2365 WININET_Release( lpwhh
);
2367 if(res
!= ERROR_SUCCESS
)
2370 return res
== ERROR_SUCCESS
;
2376 case INTERNET_OPTION_CALLBACK
:
2380 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2383 WININET_Release(lpwhh
);
2384 SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE
);
2387 case INTERNET_OPTION_HTTP_VERSION
:
2389 HTTP_VERSION_INFO
* pVersion
=(HTTP_VERSION_INFO
*)lpBuffer
;
2390 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%d,%d): STUB\n",pVersion
->dwMajorVersion
,pVersion
->dwMinorVersion
);
2393 case INTERNET_OPTION_ERROR_MASK
:
2395 ULONG flags
= *(ULONG
*)lpBuffer
;
2396 FIXME("Option INTERNET_OPTION_ERROR_MASK(%d): STUB\n", flags
);
2399 case INTERNET_OPTION_CODEPAGE
:
2401 ULONG codepage
= *(ULONG
*)lpBuffer
;
2402 FIXME("Option INTERNET_OPTION_CODEPAGE (%d): STUB\n", codepage
);
2405 case INTERNET_OPTION_REQUEST_PRIORITY
:
2407 ULONG priority
= *(ULONG
*)lpBuffer
;
2408 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%d): STUB\n", priority
);
2411 case INTERNET_OPTION_CONNECT_TIMEOUT
:
2413 ULONG connecttimeout
= *(ULONG
*)lpBuffer
;
2414 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%d): STUB\n", connecttimeout
);
2417 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
:
2419 ULONG receivetimeout
= *(ULONG
*)lpBuffer
;
2420 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%d): STUB\n", receivetimeout
);
2423 case INTERNET_OPTION_MAX_CONNS_PER_SERVER
:
2425 ULONG conns
= *(ULONG
*)lpBuffer
;
2426 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%d): STUB\n", conns
);
2429 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
:
2431 ULONG conns
= *(ULONG
*)lpBuffer
;
2432 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%d): STUB\n", conns
);
2435 case INTERNET_OPTION_RESET_URLCACHE_SESSION
:
2436 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2438 case INTERNET_OPTION_END_BROWSER_SESSION
:
2439 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2441 case INTERNET_OPTION_CONNECTED_STATE
:
2442 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2444 case INTERNET_OPTION_DISABLE_PASSPORT_AUTH
:
2445 TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
2447 case INTERNET_OPTION_SEND_TIMEOUT
:
2448 case INTERNET_OPTION_RECEIVE_TIMEOUT
:
2450 ULONG timeout
= *(ULONG
*)lpBuffer
;
2451 FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT %d\n", timeout
);
2454 case INTERNET_OPTION_CONNECT_RETRIES
:
2456 ULONG retries
= *(ULONG
*)lpBuffer
;
2457 FIXME("INTERNET_OPTION_CONNECT_RETRIES %d\n", retries
);
2460 case INTERNET_OPTION_CONTEXT_VALUE
:
2461 FIXME("Option INTERNET_OPTION_CONTEXT_VALUE; STUB\n");
2463 case INTERNET_OPTION_SECURITY_FLAGS
:
2464 FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n");
2466 case INTERNET_OPTION_DISABLE_AUTODIAL
:
2467 FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n");
2469 case INTERNET_OPTION_HTTP_DECODING
:
2470 FIXME("INTERNET_OPTION_HTTP_DECODING; STUB\n");
2471 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2474 case INTERNET_OPTION_COOKIES_3RD_PARTY
:
2475 FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n");
2476 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2479 case INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY
:
2480 FIXME("INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY; STUB\n");
2481 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2484 case INTERNET_OPTION_CODEPAGE_PATH
:
2485 FIXME("INTERNET_OPTION_CODEPAGE_PATH; STUB\n");
2486 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2489 case INTERNET_OPTION_CODEPAGE_EXTRA
:
2490 FIXME("INTERNET_OPTION_CODEPAGE_EXTRA; STUB\n");
2491 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2494 case INTERNET_OPTION_IDN
:
2495 FIXME("INTERNET_OPTION_IDN; STUB\n");
2496 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2499 case INTERNET_OPTION_POLICY
:
2500 SetLastError(ERROR_INVALID_PARAMETER
);
2503 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2504 INTERNET_PER_CONN_OPTION_LISTW
*con
= lpBuffer
;
2509 INTERNET_LoadProxySettings(&pi
);
2511 for (i
= 0; i
< con
->dwOptionCount
; i
++) {
2512 INTERNET_PER_CONN_OPTIONW
*option
= con
->pOptions
+ i
;
2514 switch (option
->dwOption
) {
2515 case INTERNET_PER_CONN_PROXY_SERVER
:
2516 HeapFree(GetProcessHeap(), 0, pi
.lpszProxyServer
);
2517 pi
.lpszProxyServer
= heap_strdupW(option
->Value
.pszValue
);
2520 case INTERNET_PER_CONN_FLAGS
:
2521 switch(option
->Value
.dwValue
) {
2522 case PROXY_TYPE_PROXY
:
2523 pi
.dwProxyEnabled
= 1;
2525 case PROXY_TYPE_DIRECT
:
2526 pi
.dwProxyEnabled
= 0;
2529 FIXME("Unhandled flag: %d\n", option
->Value
.dwValue
);
2534 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2535 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2536 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2537 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2538 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2539 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2540 case INTERNET_PER_CONN_PROXY_BYPASS
:
2541 FIXME("Unhandled dwOption %d\n", option
->dwOption
);
2545 FIXME("Unknown dwOption %d\n", option
->dwOption
);
2546 SetLastError(ERROR_INVALID_PARAMETER
);
2551 if ((res
= INTERNET_SaveProxySettings(&pi
)))
2556 ret
= (res
== ERROR_SUCCESS
);
2560 FIXME("Option %d STUB\n",dwOption
);
2561 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2567 WININET_Release( lpwhh
);
2573 /***********************************************************************
2574 * InternetSetOptionA (WININET.@)
2576 * Sets an options on the specified handle.
2583 BOOL WINAPI
InternetSetOptionA(HINTERNET hInternet
, DWORD dwOption
,
2584 LPVOID lpBuffer
, DWORD dwBufferLength
)
2592 case INTERNET_OPTION_CALLBACK
:
2594 object_header_t
*lpwh
;
2596 if (!(lpwh
= WININET_GetObject(hInternet
)))
2598 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2601 WININET_Release(lpwh
);
2602 INTERNET_SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE
);
2605 case INTERNET_OPTION_PROXY
:
2607 LPINTERNET_PROXY_INFOA pi
= (LPINTERNET_PROXY_INFOA
) lpBuffer
;
2608 LPINTERNET_PROXY_INFOW piw
;
2609 DWORD proxlen
, prbylen
;
2612 proxlen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, NULL
, 0);
2613 prbylen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, NULL
, 0);
2614 wlen
= sizeof(*piw
) + proxlen
+ prbylen
;
2615 wbuffer
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2616 piw
= (LPINTERNET_PROXY_INFOW
) wbuffer
;
2617 piw
->dwAccessType
= pi
->dwAccessType
;
2618 prox
= (LPWSTR
) &piw
[1];
2619 prby
= &prox
[proxlen
+1];
2620 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, prox
, proxlen
);
2621 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, prby
, prbylen
);
2622 piw
->lpszProxy
= prox
;
2623 piw
->lpszProxyBypass
= prby
;
2626 case INTERNET_OPTION_USER_AGENT
:
2627 case INTERNET_OPTION_USERNAME
:
2628 case INTERNET_OPTION_PASSWORD
:
2629 wlen
= MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2631 wbuffer
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2632 MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2635 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2637 INTERNET_PER_CONN_OPTION_LISTW
*listW
;
2638 INTERNET_PER_CONN_OPTION_LISTA
*listA
= lpBuffer
;
2639 wlen
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
2640 wbuffer
= HeapAlloc( GetProcessHeap(), 0, wlen
);
2643 listW
->dwSize
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
2644 if (listA
->pszConnection
)
2646 wlen
= MultiByteToWideChar( CP_ACP
, 0, listA
->pszConnection
, -1, NULL
, 0 );
2647 listW
->pszConnection
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2648 MultiByteToWideChar( CP_ACP
, 0, listA
->pszConnection
, -1, listW
->pszConnection
, wlen
);
2651 listW
->pszConnection
= NULL
;
2652 listW
->dwOptionCount
= listA
->dwOptionCount
;
2653 listW
->dwOptionError
= listA
->dwOptionError
;
2654 listW
->pOptions
= HeapAlloc( GetProcessHeap(), 0, sizeof(INTERNET_PER_CONN_OPTIONW
) * listA
->dwOptionCount
);
2656 for (i
= 0; i
< listA
->dwOptionCount
; ++i
) {
2657 INTERNET_PER_CONN_OPTIONA
*optA
= listA
->pOptions
+ i
;
2658 INTERNET_PER_CONN_OPTIONW
*optW
= listW
->pOptions
+ i
;
2660 optW
->dwOption
= optA
->dwOption
;
2662 switch (optA
->dwOption
) {
2663 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2664 case INTERNET_PER_CONN_PROXY_BYPASS
:
2665 case INTERNET_PER_CONN_PROXY_SERVER
:
2666 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2667 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2668 if (optA
->Value
.pszValue
)
2670 wlen
= MultiByteToWideChar( CP_ACP
, 0, optA
->Value
.pszValue
, -1, NULL
, 0 );
2671 optW
->Value
.pszValue
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2672 MultiByteToWideChar( CP_ACP
, 0, optA
->Value
.pszValue
, -1, optW
->Value
.pszValue
, wlen
);
2675 optW
->Value
.pszValue
= NULL
;
2677 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2678 case INTERNET_PER_CONN_FLAGS
:
2679 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2680 optW
->Value
.dwValue
= optA
->Value
.dwValue
;
2682 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2683 optW
->Value
.ftValue
= optA
->Value
.ftValue
;
2685 WARN("Unknown PER_CONN dwOption: %d, guessing at conversion to Wide\n", optA
->dwOption
);
2686 optW
->Value
.dwValue
= optA
->Value
.dwValue
;
2694 wlen
= dwBufferLength
;
2697 r
= InternetSetOptionW(hInternet
,dwOption
, wbuffer
, wlen
);
2699 if( lpBuffer
!= wbuffer
)
2701 if (dwOption
== INTERNET_OPTION_PER_CONNECTION_OPTION
)
2703 INTERNET_PER_CONN_OPTION_LISTW
*list
= wbuffer
;
2705 for (i
= 0; i
< list
->dwOptionCount
; ++i
) {
2706 INTERNET_PER_CONN_OPTIONW
*opt
= list
->pOptions
+ i
;
2707 switch (opt
->dwOption
) {
2708 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2709 case INTERNET_PER_CONN_PROXY_BYPASS
:
2710 case INTERNET_PER_CONN_PROXY_SERVER
:
2711 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2712 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2713 HeapFree( GetProcessHeap(), 0, opt
->Value
.pszValue
);
2719 HeapFree( GetProcessHeap(), 0, list
->pOptions
);
2721 HeapFree( GetProcessHeap(), 0, wbuffer
);
2728 /***********************************************************************
2729 * InternetSetOptionExA (WININET.@)
2731 BOOL WINAPI
InternetSetOptionExA(HINTERNET hInternet
, DWORD dwOption
,
2732 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2734 FIXME("Flags %08x ignored\n", dwFlags
);
2735 return InternetSetOptionA( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2738 /***********************************************************************
2739 * InternetSetOptionExW (WININET.@)
2741 BOOL WINAPI
InternetSetOptionExW(HINTERNET hInternet
, DWORD dwOption
,
2742 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2744 FIXME("Flags %08x ignored\n", dwFlags
);
2745 if( dwFlags
& ~ISO_VALID_FLAGS
)
2747 SetLastError( ERROR_INVALID_PARAMETER
);
2750 return InternetSetOptionW( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2753 static const WCHAR WININET_wkday
[7][4] =
2754 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2755 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2756 static const WCHAR WININET_month
[12][4] =
2757 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2758 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2759 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2761 /***********************************************************************
2762 * InternetTimeFromSystemTimeA (WININET.@)
2764 BOOL WINAPI
InternetTimeFromSystemTimeA( const SYSTEMTIME
* time
, DWORD format
, LPSTR string
, DWORD size
)
2767 WCHAR stringW
[INTERNET_RFC1123_BUFSIZE
];
2769 TRACE( "%p 0x%08x %p 0x%08x\n", time
, format
, string
, size
);
2771 if (!time
|| !string
|| format
!= INTERNET_RFC1123_FORMAT
)
2773 SetLastError(ERROR_INVALID_PARAMETER
);
2777 if (size
< INTERNET_RFC1123_BUFSIZE
* sizeof(*string
))
2779 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2783 ret
= InternetTimeFromSystemTimeW( time
, format
, stringW
, sizeof(stringW
) );
2784 if (ret
) WideCharToMultiByte( CP_ACP
, 0, stringW
, -1, string
, size
, NULL
, NULL
);
2789 /***********************************************************************
2790 * InternetTimeFromSystemTimeW (WININET.@)
2792 BOOL WINAPI
InternetTimeFromSystemTimeW( const SYSTEMTIME
* time
, DWORD format
, LPWSTR string
, DWORD size
)
2794 static const WCHAR date
[] =
2795 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2796 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
2798 TRACE( "%p 0x%08x %p 0x%08x\n", time
, format
, string
, size
);
2800 if (!time
|| !string
|| format
!= INTERNET_RFC1123_FORMAT
)
2802 SetLastError(ERROR_INVALID_PARAMETER
);
2806 if (size
< INTERNET_RFC1123_BUFSIZE
* sizeof(*string
))
2808 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2812 sprintfW( string
, date
,
2813 WININET_wkday
[time
->wDayOfWeek
],
2815 WININET_month
[time
->wMonth
- 1],
2824 /***********************************************************************
2825 * InternetTimeToSystemTimeA (WININET.@)
2827 BOOL WINAPI
InternetTimeToSystemTimeA( LPCSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
2832 TRACE( "%s %p 0x%08x\n", debugstr_a(string
), time
, reserved
);
2834 stringW
= heap_strdupAtoW(string
);
2837 ret
= InternetTimeToSystemTimeW( stringW
, time
, reserved
);
2838 HeapFree( GetProcessHeap(), 0, stringW
);
2843 /***********************************************************************
2844 * InternetTimeToSystemTimeW (WININET.@)
2846 BOOL WINAPI
InternetTimeToSystemTimeW( LPCWSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
2849 const WCHAR
*s
= string
;
2852 TRACE( "%s %p 0x%08x\n", debugstr_w(string
), time
, reserved
);
2854 if (!string
|| !time
) return FALSE
;
2856 /* Windows does this too */
2857 GetSystemTime( time
);
2859 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2860 * a SYSTEMTIME structure.
2863 while (*s
&& !isalphaW( *s
)) s
++;
2864 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
2865 time
->wDayOfWeek
= 7;
2867 for (i
= 0; i
< 7; i
++)
2869 if (toupperW( WININET_wkday
[i
][0] ) == toupperW( s
[0] ) &&
2870 toupperW( WININET_wkday
[i
][1] ) == toupperW( s
[1] ) &&
2871 toupperW( WININET_wkday
[i
][2] ) == toupperW( s
[2] ) )
2873 time
->wDayOfWeek
= i
;
2878 if (time
->wDayOfWeek
> 6) return TRUE
;
2879 while (*s
&& !isdigitW( *s
)) s
++;
2880 time
->wDay
= strtolW( s
, &end
, 10 );
2883 while (*s
&& !isalphaW( *s
)) s
++;
2884 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
2887 for (i
= 0; i
< 12; i
++)
2889 if (toupperW( WININET_month
[i
][0]) == toupperW( s
[0] ) &&
2890 toupperW( WININET_month
[i
][1]) == toupperW( s
[1] ) &&
2891 toupperW( WININET_month
[i
][2]) == toupperW( s
[2] ) )
2893 time
->wMonth
= i
+ 1;
2897 if (time
->wMonth
== 0) return TRUE
;
2899 while (*s
&& !isdigitW( *s
)) s
++;
2900 if (*s
== '\0') return TRUE
;
2901 time
->wYear
= strtolW( s
, &end
, 10 );
2904 while (*s
&& !isdigitW( *s
)) s
++;
2905 if (*s
== '\0') return TRUE
;
2906 time
->wHour
= strtolW( s
, &end
, 10 );
2909 while (*s
&& !isdigitW( *s
)) s
++;
2910 if (*s
== '\0') return TRUE
;
2911 time
->wMinute
= strtolW( s
, &end
, 10 );
2914 while (*s
&& !isdigitW( *s
)) s
++;
2915 if (*s
== '\0') return TRUE
;
2916 time
->wSecond
= strtolW( s
, &end
, 10 );
2919 time
->wMilliseconds
= 0;
2923 /***********************************************************************
2924 * InternetCheckConnectionW (WININET.@)
2926 * Pings a requested host to check internet connection
2929 * TRUE on success and FALSE on failure. If a failure then
2930 * ERROR_NOT_CONNECTED is placed into GetLastError
2933 BOOL WINAPI
InternetCheckConnectionW( LPCWSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
2936 * this is a kludge which runs the resident ping program and reads the output.
2938 * Anyone have a better idea?
2942 static const CHAR ping
[] = "ping -c 1 ";
2943 static const CHAR redirect
[] = " >/dev/null 2>/dev/null";
2944 CHAR
*command
= NULL
;
2953 * Crack or set the Address
2955 if (lpszUrl
== NULL
)
2958 * According to the doc we are supposed to use the ip for the next
2959 * server in the WnInet internal server database. I have
2960 * no idea what that is or how to get it.
2962 * So someone needs to implement this.
2964 FIXME("Unimplemented with URL of NULL\n");
2969 URL_COMPONENTSW components
;
2971 ZeroMemory(&components
,sizeof(URL_COMPONENTSW
));
2972 components
.lpszHostName
= (LPWSTR
)hostW
;
2973 components
.dwHostNameLength
= 1024;
2975 if (!InternetCrackUrlW(lpszUrl
,0,0,&components
))
2978 TRACE("host name : %s\n",debugstr_w(components
.lpszHostName
));
2979 port
= components
.nPort
;
2980 TRACE("port: %d\n", port
);
2983 if (dwFlags
& FLAG_ICC_FORCE_CONNECTION
)
2985 struct sockaddr_storage saddr
;
2986 socklen_t sa_len
= sizeof(saddr
);
2989 if (!GetAddress(hostW
, port
, (struct sockaddr
*)&saddr
, &sa_len
))
2991 fd
= socket(saddr
.ss_family
, SOCK_STREAM
, 0);
2994 if (connect(fd
, (struct sockaddr
*)&saddr
, sa_len
) == 0)
3002 * Build our ping command
3004 len
= WideCharToMultiByte(CP_UNIXCP
, 0, hostW
, -1, NULL
, 0, NULL
, NULL
);
3005 command
= HeapAlloc( GetProcessHeap(), 0, strlen(ping
)+len
+strlen(redirect
) );
3006 strcpy(command
,ping
);
3007 WideCharToMultiByte(CP_UNIXCP
, 0, hostW
, -1, command
+strlen(ping
), len
, NULL
, NULL
);
3008 strcat(command
,redirect
);
3010 TRACE("Ping command is : %s\n",command
);
3012 status
= system(command
);
3014 TRACE("Ping returned a code of %i\n",status
);
3016 /* Ping return code of 0 indicates success */
3023 HeapFree( GetProcessHeap(), 0, command
);
3025 INTERNET_SetLastError(ERROR_NOT_CONNECTED
);
3031 /***********************************************************************
3032 * InternetCheckConnectionA (WININET.@)
3034 * Pings a requested host to check internet connection
3037 * TRUE on success and FALSE on failure. If a failure then
3038 * ERROR_NOT_CONNECTED is placed into GetLastError
3041 BOOL WINAPI
InternetCheckConnectionA(LPCSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
3047 url
= heap_strdupAtoW(lpszUrl
);
3052 rc
= InternetCheckConnectionW(url
, dwFlags
, dwReserved
);
3054 HeapFree(GetProcessHeap(), 0, url
);
3059 /**********************************************************
3060 * INTERNET_InternetOpenUrlW (internal)
3065 * handle of connection or NULL on failure
3067 static HINTERNET
INTERNET_InternetOpenUrlW(appinfo_t
*hIC
, LPCWSTR lpszUrl
,
3068 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3070 URL_COMPONENTSW urlComponents
;
3071 WCHAR protocol
[32], hostName
[MAXHOSTNAME
], userName
[1024];
3072 WCHAR password
[1024], path
[2048], extra
[1024];
3073 HINTERNET client
= NULL
, client1
= NULL
;
3076 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hIC
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
3077 dwHeadersLength
, dwFlags
, dwContext
);
3079 urlComponents
.dwStructSize
= sizeof(URL_COMPONENTSW
);
3080 urlComponents
.lpszScheme
= protocol
;
3081 urlComponents
.dwSchemeLength
= 32;
3082 urlComponents
.lpszHostName
= hostName
;
3083 urlComponents
.dwHostNameLength
= MAXHOSTNAME
;
3084 urlComponents
.lpszUserName
= userName
;
3085 urlComponents
.dwUserNameLength
= 1024;
3086 urlComponents
.lpszPassword
= password
;
3087 urlComponents
.dwPasswordLength
= 1024;
3088 urlComponents
.lpszUrlPath
= path
;
3089 urlComponents
.dwUrlPathLength
= 2048;
3090 urlComponents
.lpszExtraInfo
= extra
;
3091 urlComponents
.dwExtraInfoLength
= 1024;
3092 if(!InternetCrackUrlW(lpszUrl
, strlenW(lpszUrl
), 0, &urlComponents
))
3094 switch(urlComponents
.nScheme
) {
3095 case INTERNET_SCHEME_FTP
:
3096 if(urlComponents
.nPort
== 0)
3097 urlComponents
.nPort
= INTERNET_DEFAULT_FTP_PORT
;
3098 client
= FTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
3099 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
);
3102 client1
= FtpOpenFileW(client
, path
, GENERIC_READ
, dwFlags
, dwContext
);
3103 if(client1
== NULL
) {
3104 InternetCloseHandle(client
);
3109 case INTERNET_SCHEME_HTTP
:
3110 case INTERNET_SCHEME_HTTPS
: {
3111 static const WCHAR szStars
[] = { '*','/','*', 0 };
3112 LPCWSTR accept
[2] = { szStars
, NULL
};
3113 if(urlComponents
.nPort
== 0) {
3114 if(urlComponents
.nScheme
== INTERNET_SCHEME_HTTP
)
3115 urlComponents
.nPort
= INTERNET_DEFAULT_HTTP_PORT
;
3117 urlComponents
.nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
3119 if (urlComponents
.nScheme
== INTERNET_SCHEME_HTTPS
) dwFlags
|= INTERNET_FLAG_SECURE
;
3121 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
3122 res
= HTTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
3123 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
, &client
);
3124 if(res
!= ERROR_SUCCESS
) {
3125 INTERNET_SetLastError(res
);
3129 if (urlComponents
.dwExtraInfoLength
) {
3131 DWORD len
= urlComponents
.dwUrlPathLength
+ urlComponents
.dwExtraInfoLength
+ 1;
3133 if (!(path_extra
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
))))
3135 InternetCloseHandle(client
);
3138 strcpyW(path_extra
, urlComponents
.lpszUrlPath
);
3139 strcatW(path_extra
, urlComponents
.lpszExtraInfo
);
3140 client1
= HttpOpenRequestW(client
, NULL
, path_extra
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
3141 HeapFree(GetProcessHeap(), 0, path_extra
);
3144 client1
= HttpOpenRequestW(client
, NULL
, path
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
3146 if(client1
== NULL
) {
3147 InternetCloseHandle(client
);
3150 HttpAddRequestHeadersW(client1
, lpszHeaders
, dwHeadersLength
, HTTP_ADDREQ_FLAG_ADD
);
3151 if (!HttpSendRequestW(client1
, NULL
, 0, NULL
, 0) &&
3152 GetLastError() != ERROR_IO_PENDING
) {
3153 InternetCloseHandle(client1
);
3158 case INTERNET_SCHEME_GOPHER
:
3159 /* gopher doesn't seem to be implemented in wine, but it's supposed
3160 * to be supported by InternetOpenUrlA. */
3162 SetLastError(ERROR_INTERNET_UNRECOGNIZED_SCHEME
);
3166 TRACE(" %p <--\n", client1
);
3171 /**********************************************************
3172 * InternetOpenUrlW (WININET.@)
3177 * handle of connection or NULL on failure
3179 static void AsyncInternetOpenUrlProc(WORKREQUEST
*workRequest
)
3181 struct WORKREQ_INTERNETOPENURLW
const *req
= &workRequest
->u
.InternetOpenUrlW
;
3182 appinfo_t
*hIC
= (appinfo_t
*) workRequest
->hdr
;
3186 INTERNET_InternetOpenUrlW(hIC
, req
->lpszUrl
,
3187 req
->lpszHeaders
, req
->dwHeadersLength
, req
->dwFlags
, req
->dwContext
);
3188 HeapFree(GetProcessHeap(), 0, req
->lpszUrl
);
3189 HeapFree(GetProcessHeap(), 0, req
->lpszHeaders
);
3192 HINTERNET WINAPI
InternetOpenUrlW(HINTERNET hInternet
, LPCWSTR lpszUrl
,
3193 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3195 HINTERNET ret
= NULL
;
3196 appinfo_t
*hIC
= NULL
;
3198 if (TRACE_ON(wininet
)) {
3199 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hInternet
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
3200 dwHeadersLength
, dwFlags
, dwContext
);
3202 dump_INTERNET_FLAGS(dwFlags
);
3207 SetLastError(ERROR_INVALID_PARAMETER
);
3211 hIC
= (appinfo_t
*)WININET_GetObject( hInternet
);
3212 if (NULL
== hIC
|| hIC
->hdr
.htype
!= WH_HINIT
) {
3213 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
3217 if (hIC
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
) {
3218 WORKREQUEST workRequest
;
3219 struct WORKREQ_INTERNETOPENURLW
*req
;
3221 workRequest
.asyncproc
= AsyncInternetOpenUrlProc
;
3222 workRequest
.hdr
= WININET_AddRef( &hIC
->hdr
);
3223 req
= &workRequest
.u
.InternetOpenUrlW
;
3224 req
->lpszUrl
= heap_strdupW(lpszUrl
);
3225 req
->lpszHeaders
= heap_strdupW(lpszHeaders
);
3226 req
->dwHeadersLength
= dwHeadersLength
;
3227 req
->dwFlags
= dwFlags
;
3228 req
->dwContext
= dwContext
;
3230 INTERNET_AsyncCall(&workRequest
);
3232 * This is from windows.
3234 SetLastError(ERROR_IO_PENDING
);
3236 ret
= INTERNET_InternetOpenUrlW(hIC
, lpszUrl
, lpszHeaders
, dwHeadersLength
, dwFlags
, dwContext
);
3241 WININET_Release( &hIC
->hdr
);
3242 TRACE(" %p <--\n", ret
);
3247 /**********************************************************
3248 * InternetOpenUrlA (WININET.@)
3253 * handle of connection or NULL on failure
3255 HINTERNET WINAPI
InternetOpenUrlA(HINTERNET hInternet
, LPCSTR lpszUrl
,
3256 LPCSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3258 HINTERNET rc
= NULL
;
3259 DWORD lenHeaders
= 0;
3260 LPWSTR szUrl
= NULL
;
3261 LPWSTR szHeaders
= NULL
;
3266 szUrl
= heap_strdupAtoW(lpszUrl
);
3272 lenHeaders
= MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, NULL
, 0 );
3273 szHeaders
= HeapAlloc(GetProcessHeap(), 0, lenHeaders
*sizeof(WCHAR
));
3275 HeapFree(GetProcessHeap(), 0, szUrl
);
3278 MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, szHeaders
, lenHeaders
);
3281 rc
= InternetOpenUrlW(hInternet
, szUrl
, szHeaders
,
3282 lenHeaders
, dwFlags
, dwContext
);
3284 HeapFree(GetProcessHeap(), 0, szUrl
);
3285 HeapFree(GetProcessHeap(), 0, szHeaders
);
3291 static LPWITHREADERROR
INTERNET_AllocThreadError(void)
3293 LPWITHREADERROR lpwite
= HeapAlloc(GetProcessHeap(), 0, sizeof(*lpwite
));
3297 lpwite
->dwError
= 0;
3298 lpwite
->response
[0] = '\0';
3301 if (!TlsSetValue(g_dwTlsErrIndex
, lpwite
))
3303 HeapFree(GetProcessHeap(), 0, lpwite
);
3311 /***********************************************************************
3312 * INTERNET_SetLastError (internal)
3314 * Set last thread specific error
3319 void INTERNET_SetLastError(DWORD dwError
)
3321 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3324 lpwite
= INTERNET_AllocThreadError();
3326 SetLastError(dwError
);
3328 lpwite
->dwError
= dwError
;
3332 /***********************************************************************
3333 * INTERNET_GetLastError (internal)
3335 * Get last thread specific error
3340 DWORD
INTERNET_GetLastError(void)
3342 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3343 if (!lpwite
) return 0;
3344 /* TlsGetValue clears last error, so set it again here */
3345 SetLastError(lpwite
->dwError
);
3346 return lpwite
->dwError
;
3350 /***********************************************************************
3351 * INTERNET_WorkerThreadFunc (internal)
3353 * Worker thread execution function
3358 static DWORD CALLBACK
INTERNET_WorkerThreadFunc(LPVOID lpvParam
)
3360 LPWORKREQUEST lpRequest
= lpvParam
;
3361 WORKREQUEST workRequest
;
3365 workRequest
= *lpRequest
;
3366 HeapFree(GetProcessHeap(), 0, lpRequest
);
3368 workRequest
.asyncproc(&workRequest
);
3369 WININET_Release( workRequest
.hdr
);
3371 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
3373 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex
));
3374 TlsSetValue(g_dwTlsErrIndex
, NULL
);
3380 /***********************************************************************
3381 * INTERNET_AsyncCall (internal)
3383 * Retrieves work request from queue
3388 DWORD
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
)
3391 LPWORKREQUEST lpNewRequest
;
3395 lpNewRequest
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST
));
3397 return ERROR_OUTOFMEMORY
;
3399 *lpNewRequest
= *lpWorkRequest
;
3401 bSuccess
= QueueUserWorkItem(INTERNET_WorkerThreadFunc
, lpNewRequest
, WT_EXECUTELONGFUNCTION
);
3404 HeapFree(GetProcessHeap(), 0, lpNewRequest
);
3405 return ERROR_INTERNET_ASYNC_THREAD_FAILED
;
3408 return ERROR_SUCCESS
;
3412 /***********************************************************************
3413 * INTERNET_GetResponseBuffer (internal)
3418 LPSTR
INTERNET_GetResponseBuffer(void)
3420 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3422 lpwite
= INTERNET_AllocThreadError();
3424 return lpwite
->response
;
3427 /***********************************************************************
3428 * INTERNET_GetNextLine (internal)
3430 * Parse next line in directory string listing
3433 * Pointer to beginning of next line
3438 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
)
3441 BOOL bSuccess
= FALSE
;
3443 LPSTR lpszBuffer
= INTERNET_GetResponseBuffer();
3448 pfd
.events
= POLLIN
;
3450 while (nRecv
< MAX_REPLY_LEN
)
3452 if (poll(&pfd
,1, RESPONSE_TIMEOUT
* 1000) > 0)
3454 if (recv(nSocket
, &lpszBuffer
[nRecv
], 1, 0) <= 0)
3456 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS
);
3460 if (lpszBuffer
[nRecv
] == '\n')
3465 if (lpszBuffer
[nRecv
] != '\r')
3470 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT
);
3478 lpszBuffer
[nRecv
] = '\0';
3480 TRACE(":%d %s\n", nRecv
, lpszBuffer
);
3489 /**********************************************************
3490 * InternetQueryDataAvailable (WININET.@)
3492 * Determines how much data is available to be read.
3495 * TRUE on success, FALSE if an error occurred. If
3496 * INTERNET_FLAG_ASYNC was specified in InternetOpen, and
3497 * no data is presently available, FALSE is returned with
3498 * the last error ERROR_IO_PENDING; a callback with status
3499 * INTERNET_STATUS_REQUEST_COMPLETE will be sent when more
3500 * data is available.
3502 BOOL WINAPI
InternetQueryDataAvailable( HINTERNET hFile
,
3503 LPDWORD lpdwNumberOfBytesAvailble
,
3504 DWORD dwFlags
, DWORD_PTR dwContext
)
3506 object_header_t
*hdr
;
3509 TRACE("(%p %p %x %lx)\n", hFile
, lpdwNumberOfBytesAvailble
, dwFlags
, dwContext
);
3511 hdr
= WININET_GetObject( hFile
);
3513 SetLastError(ERROR_INVALID_HANDLE
);
3517 if(hdr
->vtbl
->QueryDataAvailable
) {
3518 res
= hdr
->vtbl
->QueryDataAvailable(hdr
, lpdwNumberOfBytesAvailble
, dwFlags
, dwContext
);
3520 WARN("wrong handle\n");
3521 res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
3524 WININET_Release(hdr
);
3526 if(res
!= ERROR_SUCCESS
)
3528 return res
== ERROR_SUCCESS
;
3532 /***********************************************************************
3533 * InternetLockRequestFile (WININET.@)
3535 BOOL WINAPI
InternetLockRequestFile( HINTERNET hInternet
, HANDLE
3542 BOOL WINAPI
InternetUnlockRequestFile( HANDLE hLockHandle
)
3549 /***********************************************************************
3550 * InternetAutodial (WININET.@)
3552 * On windows this function is supposed to dial the default internet
3553 * connection. We don't want to have Wine dial out to the internet so
3554 * we return TRUE by default. It might be nice to check if we are connected.
3561 BOOL WINAPI
InternetAutodial(DWORD dwFlags
, HWND hwndParent
)
3565 /* Tell that we are connected to the internet. */
3569 /***********************************************************************
3570 * InternetAutodialHangup (WININET.@)
3572 * Hangs up a connection made with InternetAutodial
3581 BOOL WINAPI
InternetAutodialHangup(DWORD dwReserved
)
3585 /* we didn't dial, we don't disconnect */
3589 /***********************************************************************
3590 * InternetCombineUrlA (WININET.@)
3592 * Combine a base URL with a relative URL
3600 BOOL WINAPI
InternetCombineUrlA(LPCSTR lpszBaseUrl
, LPCSTR lpszRelativeUrl
,
3601 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3606 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_a(lpszBaseUrl
), debugstr_a(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3608 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3609 dwFlags
^= ICU_NO_ENCODE
;
3610 hr
=UrlCombineA(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3615 /***********************************************************************
3616 * InternetCombineUrlW (WININET.@)
3618 * Combine a base URL with a relative URL
3626 BOOL WINAPI
InternetCombineUrlW(LPCWSTR lpszBaseUrl
, LPCWSTR lpszRelativeUrl
,
3627 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3632 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(lpszBaseUrl
), debugstr_w(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3634 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3635 dwFlags
^= ICU_NO_ENCODE
;
3636 hr
=UrlCombineW(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3641 /* max port num is 65535 => 5 digits */
3642 #define MAX_WORD_DIGITS 5
3644 #define URL_GET_COMP_LENGTH(url, component) ((url)->dw##component##Length ? \
3645 (url)->dw##component##Length : strlenW((url)->lpsz##component))
3646 #define URL_GET_COMP_LENGTHA(url, component) ((url)->dw##component##Length ? \
3647 (url)->dw##component##Length : strlen((url)->lpsz##component))
3649 static BOOL
url_uses_default_port(INTERNET_SCHEME nScheme
, INTERNET_PORT nPort
)
3651 if ((nScheme
== INTERNET_SCHEME_HTTP
) &&
3652 (nPort
== INTERNET_DEFAULT_HTTP_PORT
))
3654 if ((nScheme
== INTERNET_SCHEME_HTTPS
) &&
3655 (nPort
== INTERNET_DEFAULT_HTTPS_PORT
))
3657 if ((nScheme
== INTERNET_SCHEME_FTP
) &&
3658 (nPort
== INTERNET_DEFAULT_FTP_PORT
))
3660 if ((nScheme
== INTERNET_SCHEME_GOPHER
) &&
3661 (nPort
== INTERNET_DEFAULT_GOPHER_PORT
))
3664 if (nPort
== INTERNET_INVALID_PORT_NUMBER
)
3670 /* opaque urls do not fit into the standard url hierarchy and don't have
3671 * two following slashes */
3672 static inline BOOL
scheme_is_opaque(INTERNET_SCHEME nScheme
)
3674 return (nScheme
!= INTERNET_SCHEME_FTP
) &&
3675 (nScheme
!= INTERNET_SCHEME_GOPHER
) &&
3676 (nScheme
!= INTERNET_SCHEME_HTTP
) &&
3677 (nScheme
!= INTERNET_SCHEME_HTTPS
) &&
3678 (nScheme
!= INTERNET_SCHEME_FILE
);
3681 static LPCWSTR
INTERNET_GetSchemeString(INTERNET_SCHEME scheme
)
3684 if (scheme
< INTERNET_SCHEME_FIRST
)
3686 index
= scheme
- INTERNET_SCHEME_FIRST
;
3687 if (index
>= sizeof(url_schemes
)/sizeof(url_schemes
[0]))
3689 return (LPCWSTR
)url_schemes
[index
];
3692 /* we can calculate using ansi strings because we're just
3693 * calculating string length, not size
3695 static BOOL
calc_url_length(LPURL_COMPONENTSW lpUrlComponents
,
3696 LPDWORD lpdwUrlLength
)
3698 INTERNET_SCHEME nScheme
;
3702 if (lpUrlComponents
->lpszScheme
)
3704 DWORD dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Scheme
);
3705 *lpdwUrlLength
+= dwLen
;
3706 nScheme
= GetInternetSchemeW(lpUrlComponents
->lpszScheme
, dwLen
);
3712 nScheme
= lpUrlComponents
->nScheme
;
3714 if (nScheme
== INTERNET_SCHEME_DEFAULT
)
3715 nScheme
= INTERNET_SCHEME_HTTP
;
3716 scheme
= INTERNET_GetSchemeString(nScheme
);
3717 *lpdwUrlLength
+= strlenW(scheme
);
3720 (*lpdwUrlLength
)++; /* ':' */
3721 if (!scheme_is_opaque(nScheme
) || lpUrlComponents
->lpszHostName
)
3722 *lpdwUrlLength
+= strlen("//");
3724 if (lpUrlComponents
->lpszUserName
)
3726 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, UserName
);
3727 *lpdwUrlLength
+= strlen("@");
3731 if (lpUrlComponents
->lpszPassword
)
3733 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
3738 if (lpUrlComponents
->lpszPassword
)
3740 *lpdwUrlLength
+= strlen(":");
3741 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, Password
);
3744 if (lpUrlComponents
->lpszHostName
)
3746 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, HostName
);
3748 if (!url_uses_default_port(nScheme
, lpUrlComponents
->nPort
))
3750 char szPort
[MAX_WORD_DIGITS
+1];
3752 sprintf(szPort
, "%d", lpUrlComponents
->nPort
);
3753 *lpdwUrlLength
+= strlen(szPort
);
3754 *lpdwUrlLength
+= strlen(":");
3757 if (lpUrlComponents
->lpszUrlPath
&& *lpUrlComponents
->lpszUrlPath
!= '/')
3758 (*lpdwUrlLength
)++; /* '/' */
3761 if (lpUrlComponents
->lpszUrlPath
)
3762 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, UrlPath
);
3764 if (lpUrlComponents
->lpszExtraInfo
)
3765 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, ExtraInfo
);
3770 static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents
, LPURL_COMPONENTSW urlCompW
)
3774 ZeroMemory(urlCompW
, sizeof(URL_COMPONENTSW
));
3776 urlCompW
->dwStructSize
= sizeof(URL_COMPONENTSW
);
3777 urlCompW
->dwSchemeLength
= lpUrlComponents
->dwSchemeLength
;
3778 urlCompW
->nScheme
= lpUrlComponents
->nScheme
;
3779 urlCompW
->dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
3780 urlCompW
->nPort
= lpUrlComponents
->nPort
;
3781 urlCompW
->dwUserNameLength
= lpUrlComponents
->dwUserNameLength
;
3782 urlCompW
->dwPasswordLength
= lpUrlComponents
->dwPasswordLength
;
3783 urlCompW
->dwUrlPathLength
= lpUrlComponents
->dwUrlPathLength
;
3784 urlCompW
->dwExtraInfoLength
= lpUrlComponents
->dwExtraInfoLength
;
3786 if (lpUrlComponents
->lpszScheme
)
3788 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, Scheme
) + 1;
3789 urlCompW
->lpszScheme
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
3790 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszScheme
,
3791 -1, urlCompW
->lpszScheme
, len
);
3794 if (lpUrlComponents
->lpszHostName
)
3796 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, HostName
) + 1;
3797 urlCompW
->lpszHostName
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
3798 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszHostName
,
3799 -1, urlCompW
->lpszHostName
, len
);
3802 if (lpUrlComponents
->lpszUserName
)
3804 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, UserName
) + 1;
3805 urlCompW
->lpszUserName
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
3806 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszUserName
,
3807 -1, urlCompW
->lpszUserName
, len
);
3810 if (lpUrlComponents
->lpszPassword
)
3812 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, Password
) + 1;
3813 urlCompW
->lpszPassword
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
3814 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszPassword
,
3815 -1, urlCompW
->lpszPassword
, len
);
3818 if (lpUrlComponents
->lpszUrlPath
)
3820 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, UrlPath
) + 1;
3821 urlCompW
->lpszUrlPath
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
3822 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszUrlPath
,
3823 -1, urlCompW
->lpszUrlPath
, len
);
3826 if (lpUrlComponents
->lpszExtraInfo
)
3828 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, ExtraInfo
) + 1;
3829 urlCompW
->lpszExtraInfo
= HeapAlloc(GetProcessHeap(), 0, len
* sizeof(WCHAR
));
3830 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszExtraInfo
,
3831 -1, urlCompW
->lpszExtraInfo
, len
);
3835 /***********************************************************************
3836 * InternetCreateUrlA (WININET.@)
3838 * See InternetCreateUrlW.
3840 BOOL WINAPI
InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents
, DWORD dwFlags
,
3841 LPSTR lpszUrl
, LPDWORD lpdwUrlLength
)
3845 URL_COMPONENTSW urlCompW
;
3847 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents
, dwFlags
, lpszUrl
, lpdwUrlLength
);
3849 if (!lpUrlComponents
|| lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSW
) || !lpdwUrlLength
)
3851 SetLastError(ERROR_INVALID_PARAMETER
);
3855 convert_urlcomp_atow(lpUrlComponents
, &urlCompW
);
3858 urlW
= HeapAlloc(GetProcessHeap(), 0, *lpdwUrlLength
* sizeof(WCHAR
));
3860 ret
= InternetCreateUrlW(&urlCompW
, dwFlags
, urlW
, lpdwUrlLength
);
3862 if (!ret
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
))
3863 *lpdwUrlLength
/= sizeof(WCHAR
);
3865 /* on success, lpdwUrlLength points to the size of urlW in WCHARS
3866 * minus one, so add one to leave room for NULL terminator
3869 WideCharToMultiByte(CP_ACP
, 0, urlW
, -1, lpszUrl
, *lpdwUrlLength
+ 1, NULL
, NULL
);
3871 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszScheme
);
3872 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszHostName
);
3873 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszUserName
);
3874 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszPassword
);
3875 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszUrlPath
);
3876 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszExtraInfo
);
3877 HeapFree(GetProcessHeap(), 0, urlW
);
3882 /***********************************************************************
3883 * InternetCreateUrlW (WININET.@)
3885 * Creates a URL from its component parts.
3888 * lpUrlComponents [I] URL Components.
3889 * dwFlags [I] Flags. See notes.
3890 * lpszUrl [I] Buffer in which to store the created URL.
3891 * lpdwUrlLength [I/O] On input, the length of the buffer pointed to by
3892 * lpszUrl in characters. On output, the number of bytes
3893 * required to store the URL including terminator.
3897 * The dwFlags parameter can be zero or more of the following:
3898 *|ICU_ESCAPE - Generates escape sequences for unsafe characters in the path and extra info of the URL.
3905 BOOL WINAPI
InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents
, DWORD dwFlags
,
3906 LPWSTR lpszUrl
, LPDWORD lpdwUrlLength
)
3909 INTERNET_SCHEME nScheme
;
3911 static const WCHAR slashSlashW
[] = {'/','/'};
3912 static const WCHAR percentD
[] = {'%','d',0};
3914 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents
, dwFlags
, lpszUrl
, lpdwUrlLength
);
3916 if (!lpUrlComponents
|| lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSW
) || !lpdwUrlLength
)
3918 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
3922 if (!calc_url_length(lpUrlComponents
, &dwLen
))
3925 if (!lpszUrl
|| *lpdwUrlLength
< dwLen
)
3927 *lpdwUrlLength
= (dwLen
+ 1) * sizeof(WCHAR
);
3928 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
3932 *lpdwUrlLength
= dwLen
;
3937 if (lpUrlComponents
->lpszScheme
)
3939 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Scheme
);
3940 memcpy(lpszUrl
, lpUrlComponents
->lpszScheme
, dwLen
* sizeof(WCHAR
));
3943 nScheme
= GetInternetSchemeW(lpUrlComponents
->lpszScheme
, dwLen
);
3948 nScheme
= lpUrlComponents
->nScheme
;
3950 if (nScheme
== INTERNET_SCHEME_DEFAULT
)
3951 nScheme
= INTERNET_SCHEME_HTTP
;
3953 scheme
= INTERNET_GetSchemeString(nScheme
);
3954 dwLen
= strlenW(scheme
);
3955 memcpy(lpszUrl
, scheme
, dwLen
* sizeof(WCHAR
));
3959 /* all schemes are followed by at least a colon */
3963 if (!scheme_is_opaque(nScheme
) || lpUrlComponents
->lpszHostName
)
3965 memcpy(lpszUrl
, slashSlashW
, sizeof(slashSlashW
));
3966 lpszUrl
+= sizeof(slashSlashW
)/sizeof(slashSlashW
[0]);
3969 if (lpUrlComponents
->lpszUserName
)
3971 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, UserName
);
3972 memcpy(lpszUrl
, lpUrlComponents
->lpszUserName
, dwLen
* sizeof(WCHAR
));
3975 if (lpUrlComponents
->lpszPassword
)
3980 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Password
);
3981 memcpy(lpszUrl
, lpUrlComponents
->lpszPassword
, dwLen
* sizeof(WCHAR
));
3989 if (lpUrlComponents
->lpszHostName
)
3991 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, HostName
);
3992 memcpy(lpszUrl
, lpUrlComponents
->lpszHostName
, dwLen
* sizeof(WCHAR
));
3995 if (!url_uses_default_port(nScheme
, lpUrlComponents
->nPort
))
3997 WCHAR szPort
[MAX_WORD_DIGITS
+1];
3999 sprintfW(szPort
, percentD
, lpUrlComponents
->nPort
);
4002 dwLen
= strlenW(szPort
);
4003 memcpy(lpszUrl
, szPort
, dwLen
* sizeof(WCHAR
));
4007 /* add slash between hostname and path if necessary */
4008 if (lpUrlComponents
->lpszUrlPath
&& *lpUrlComponents
->lpszUrlPath
!= '/')
4015 if (lpUrlComponents
->lpszUrlPath
)
4017 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, UrlPath
);
4018 memcpy(lpszUrl
, lpUrlComponents
->lpszUrlPath
, dwLen
* sizeof(WCHAR
));
4022 if (lpUrlComponents
->lpszExtraInfo
)
4024 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, ExtraInfo
);
4025 memcpy(lpszUrl
, lpUrlComponents
->lpszExtraInfo
, dwLen
* sizeof(WCHAR
));
4034 /***********************************************************************
4035 * InternetConfirmZoneCrossingA (WININET.@)
4038 DWORD WINAPI
InternetConfirmZoneCrossingA( HWND hWnd
, LPSTR szUrlPrev
, LPSTR szUrlNew
, BOOL bPost
)
4040 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_a(szUrlPrev
), debugstr_a(szUrlNew
), bPost
);
4041 return ERROR_SUCCESS
;
4044 /***********************************************************************
4045 * InternetConfirmZoneCrossingW (WININET.@)
4048 DWORD WINAPI
InternetConfirmZoneCrossingW( HWND hWnd
, LPWSTR szUrlPrev
, LPWSTR szUrlNew
, BOOL bPost
)
4050 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_w(szUrlPrev
), debugstr_w(szUrlNew
), bPost
);
4051 return ERROR_SUCCESS
;
4054 static DWORD zone_preference
= 3;
4056 /***********************************************************************
4057 * PrivacySetZonePreferenceW (WININET.@)
4059 DWORD WINAPI
PrivacySetZonePreferenceW( DWORD zone
, DWORD type
, DWORD
template, LPCWSTR preference
)
4061 FIXME( "%x %x %x %s: stub\n", zone
, type
, template, debugstr_w(preference
) );
4063 zone_preference
= template;
4067 /***********************************************************************
4068 * PrivacyGetZonePreferenceW (WININET.@)
4070 DWORD WINAPI
PrivacyGetZonePreferenceW( DWORD zone
, DWORD type
, LPDWORD
template,
4071 LPWSTR preference
, LPDWORD length
)
4073 FIXME( "%x %x %p %p %p: stub\n", zone
, type
, template, preference
, length
);
4075 if (template) *template = zone_preference
;
4079 DWORD WINAPI
InternetDialA( HWND hwndParent
, LPSTR lpszConnectoid
, DWORD dwFlags
,
4080 DWORD_PTR
* lpdwConnection
, DWORD dwReserved
)
4082 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
4083 lpdwConnection
, dwReserved
);
4084 return ERROR_SUCCESS
;
4087 DWORD WINAPI
InternetDialW( HWND hwndParent
, LPWSTR lpszConnectoid
, DWORD dwFlags
,
4088 DWORD_PTR
* lpdwConnection
, DWORD dwReserved
)
4090 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
4091 lpdwConnection
, dwReserved
);
4092 return ERROR_SUCCESS
;
4095 BOOL WINAPI
InternetGoOnlineA( LPSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
4097 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_a(lpszURL
), hwndParent
, dwReserved
);
4101 BOOL WINAPI
InternetGoOnlineW( LPWSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
4103 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_w(lpszURL
), hwndParent
, dwReserved
);
4107 DWORD WINAPI
InternetHangUp( DWORD_PTR dwConnection
, DWORD dwReserved
)
4109 FIXME("(0x%08lx, 0x%08x) stub\n", dwConnection
, dwReserved
);
4110 return ERROR_SUCCESS
;
4113 BOOL WINAPI
CreateMD5SSOHash( PWSTR pszChallengeInfo
, PWSTR pwszRealm
, PWSTR pwszTarget
,
4116 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo
), debugstr_w(pwszRealm
),
4117 debugstr_w(pwszTarget
), pbHexHash
);
4121 BOOL WINAPI
ResumeSuspendedDownload( HINTERNET hInternet
, DWORD dwError
)
4123 FIXME("(%p, 0x%08x) stub\n", hInternet
, dwError
);
4127 BOOL WINAPI
InternetQueryFortezzaStatus(DWORD
*a
, DWORD_PTR b
)
4129 FIXME("(%p, %08lx) stub\n", a
, b
);