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 HMODULE WININET_hModule
;
93 static CRITICAL_SECTION WININET_cs
;
94 static CRITICAL_SECTION_DEBUG WININET_cs_debug
=
97 { &WININET_cs_debug
.ProcessLocksList
, &WININET_cs_debug
.ProcessLocksList
},
98 0, 0, { (DWORD_PTR
)(__FILE__
": WININET_cs") }
100 static CRITICAL_SECTION WININET_cs
= { &WININET_cs_debug
, -1, 0, 0, 0, 0 };
102 static object_header_t
**handle_table
;
103 static UINT_PTR next_handle
;
104 static UINT_PTR handle_table_size
;
113 static const WCHAR szInternetSettings
[] =
114 { 'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
115 'W','i','n','d','o','w','s','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
116 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0 };
117 static const WCHAR szProxyServer
[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
118 static const WCHAR szProxyEnable
[] = { 'P','r','o','x','y','E','n','a','b','l','e', 0 };
120 void *alloc_object(object_header_t
*parent
, const object_vtbl_t
*vtbl
, size_t size
)
122 UINT_PTR handle
= 0, num
;
123 object_header_t
*ret
;
127 ret
= heap_alloc_zero(size
);
131 list_init(&ret
->children
);
133 EnterCriticalSection( &WININET_cs
);
135 if(!handle_table_size
) {
137 p
= heap_alloc_zero(sizeof(handle_table
[0]) * num
);
140 handle_table_size
= num
;
145 }else if(next_handle
== handle_table_size
) {
146 num
= handle_table_size
* 2;
147 p
= heap_realloc_zero(handle_table
, sizeof(handle_table
[0]) * num
);
150 handle_table_size
= num
;
157 handle
= next_handle
;
158 if(handle_table
[handle
])
159 ERR("handle isn't free but should be\n");
160 handle_table
[handle
] = ret
;
161 ret
->valid_handle
= TRUE
;
163 while(handle_table
[next_handle
] && next_handle
< handle_table_size
)
167 LeaveCriticalSection( &WININET_cs
);
176 ret
->hInternet
= (HINTERNET
)handle
;
179 ret
->lpfnStatusCB
= parent
->lpfnStatusCB
;
180 ret
->dwInternalFlags
= parent
->dwInternalFlags
& INET_CALLBACKW
;
186 object_header_t
*WININET_AddRef( object_header_t
*info
)
188 ULONG refs
= InterlockedIncrement(&info
->refs
);
189 TRACE("%p -> refcount = %d\n", info
, refs
);
193 object_header_t
*get_handle_object( HINTERNET hinternet
)
195 object_header_t
*info
= NULL
;
196 UINT_PTR handle
= (UINT_PTR
) hinternet
;
198 EnterCriticalSection( &WININET_cs
);
200 if(handle
> 0 && handle
< handle_table_size
&& handle_table
[handle
] && handle_table
[handle
]->valid_handle
)
201 info
= WININET_AddRef(handle_table
[handle
]);
203 LeaveCriticalSection( &WININET_cs
);
205 TRACE("handle %ld -> %p\n", handle
, info
);
210 static void invalidate_handle(object_header_t
*info
)
212 object_header_t
*child
, *next
;
214 if(!info
->valid_handle
)
216 info
->valid_handle
= FALSE
;
218 /* Free all children as native does */
219 LIST_FOR_EACH_ENTRY_SAFE( child
, next
, &info
->children
, object_header_t
, entry
)
221 TRACE("invalidating child handle %p for parent %p\n", child
->hInternet
, info
);
222 invalidate_handle( child
);
225 WININET_Release(info
);
228 BOOL
WININET_Release( object_header_t
*info
)
230 ULONG refs
= InterlockedDecrement(&info
->refs
);
231 TRACE( "object %p refcount = %d\n", info
, refs
);
234 invalidate_handle(info
);
235 if ( info
->vtbl
->CloseConnection
)
237 TRACE( "closing connection %p\n", info
);
238 info
->vtbl
->CloseConnection( info
);
240 /* Don't send a callback if this is a session handle created with InternetOpenUrl */
241 if ((info
->htype
!= WH_HHTTPSESSION
&& info
->htype
!= WH_HFTPSESSION
)
242 || !(info
->dwInternalFlags
& INET_OPENURL
))
244 INTERNET_SendCallback(info
, info
->dwContext
,
245 INTERNET_STATUS_HANDLE_CLOSING
, &info
->hInternet
,
248 TRACE( "destroying object %p\n", info
);
249 if ( info
->htype
!= WH_HINIT
)
250 list_remove( &info
->entry
);
251 info
->vtbl
->Destroy( info
);
253 if(info
->hInternet
) {
254 UINT_PTR handle
= (UINT_PTR
)info
->hInternet
;
256 EnterCriticalSection( &WININET_cs
);
258 handle_table
[handle
] = NULL
;
259 if(next_handle
> handle
)
260 next_handle
= handle
;
262 LeaveCriticalSection( &WININET_cs
);
270 /***********************************************************************
271 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
274 * hinstDLL [I] handle to the DLL's instance
276 * lpvReserved [I] reserved, must be NULL
283 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
285 TRACE("%p,%x,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
288 case DLL_PROCESS_ATTACH
:
290 g_dwTlsErrIndex
= TlsAlloc();
292 if (g_dwTlsErrIndex
== TLS_OUT_OF_INDEXES
)
295 URLCacheContainers_CreateDefaults();
297 WININET_hModule
= hinstDLL
;
299 case DLL_THREAD_ATTACH
:
302 case DLL_THREAD_DETACH
:
303 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
305 heap_free(TlsGetValue(g_dwTlsErrIndex
));
309 case DLL_PROCESS_DETACH
:
310 collect_connections(TRUE
);
312 URLCacheContainers_DeleteAll();
314 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
316 heap_free(TlsGetValue(g_dwTlsErrIndex
));
317 TlsFree(g_dwTlsErrIndex
);
324 /***********************************************************************
325 * INTERNET_SaveProxySettings
327 * Stores the proxy settings given by lpwai into the registry
330 * ERROR_SUCCESS if no error, or error code on fail
332 static LONG
INTERNET_SaveProxySettings( proxyinfo_t
*lpwpi
)
337 if ((ret
= RegOpenKeyW( HKEY_CURRENT_USER
, szInternetSettings
, &key
)))
340 if ((ret
= RegSetValueExW( key
, szProxyEnable
, 0, REG_DWORD
, (BYTE
*)&lpwpi
->proxyEnabled
, sizeof(DWORD
))))
348 if ((ret
= RegSetValueExW( key
, szProxyServer
, 0, REG_SZ
, (BYTE
*)lpwpi
->proxy
, sizeof(WCHAR
) * (lstrlenW(lpwpi
->proxy
) + 1))))
356 if ((ret
= RegDeleteValueW( key
, szProxyServer
)))
364 return ERROR_SUCCESS
;
367 /***********************************************************************
368 * INTERNET_FindProxyForProtocol
370 * Searches the proxy string for a proxy of the given protocol.
371 * Returns the found proxy, or the default proxy if none of the given
375 * szProxy [In] proxy string to search
376 * proto [In] protocol to search for, e.g. "http"
377 * foundProxy [Out] found proxy
378 * foundProxyLen [In/Out] length of foundProxy buffer, in WCHARs
381 * TRUE if a proxy is found, FALSE if not. If foundProxy is too short,
382 * *foundProxyLen is set to the required size in WCHARs, including the
383 * NULL terminator, and the last error is set to ERROR_INSUFFICIENT_BUFFER.
385 BOOL
INTERNET_FindProxyForProtocol(LPCWSTR szProxy
, LPCWSTR proto
, WCHAR
*foundProxy
, DWORD
*foundProxyLen
)
390 TRACE("(%s, %s)\n", debugstr_w(szProxy
), debugstr_w(proto
));
392 /* First, look for the specified protocol (proto=scheme://host:port) */
393 for (ptr
= szProxy
; !ret
&& ptr
&& *ptr
; )
397 if (!(end
= strchrW(ptr
, ' ')))
398 end
= ptr
+ strlenW(ptr
);
399 if ((equal
= strchrW(ptr
, '=')) && equal
< end
&&
400 equal
- ptr
== strlenW(proto
) &&
401 !strncmpiW(proto
, ptr
, strlenW(proto
)))
403 if (end
- equal
> *foundProxyLen
)
405 WARN("buffer too short for %s\n",
406 debugstr_wn(equal
+ 1, end
- equal
- 1));
407 *foundProxyLen
= end
- equal
;
408 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
412 memcpy(foundProxy
, equal
+ 1, (end
- equal
) * sizeof(WCHAR
));
413 foundProxy
[end
- equal
] = 0;
424 /* It wasn't found: look for no protocol */
425 for (ptr
= szProxy
; !ret
&& ptr
&& *ptr
; )
429 if (!(end
= strchrW(ptr
, ' ')))
430 end
= ptr
+ strlenW(ptr
);
431 if (!(equal
= strchrW(ptr
, '=')))
433 if (end
- ptr
+ 1 > *foundProxyLen
)
435 WARN("buffer too short for %s\n",
436 debugstr_wn(ptr
, end
- ptr
));
437 *foundProxyLen
= end
- ptr
+ 1;
438 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
442 memcpy(foundProxy
, ptr
, (end
- ptr
) * sizeof(WCHAR
));
443 foundProxy
[end
- ptr
] = 0;
454 TRACE("found proxy for %s: %s\n", debugstr_w(proto
),
455 debugstr_w(foundProxy
));
459 /***********************************************************************
460 * InternetInitializeAutoProxyDll (WININET.@)
462 * Setup the internal proxy
471 BOOL WINAPI
InternetInitializeAutoProxyDll(DWORD dwReserved
)
474 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
478 /***********************************************************************
479 * DetectAutoProxyUrl (WININET.@)
481 * Auto detect the proxy url
487 BOOL WINAPI
DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl
,
488 DWORD dwAutoProxyUrlLength
, DWORD dwDetectFlags
)
491 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
495 static void FreeProxyInfo( proxyinfo_t
*lpwpi
)
497 heap_free(lpwpi
->proxy
);
498 heap_free(lpwpi
->proxyBypass
);
501 static proxyinfo_t
*global_proxy
;
503 static void free_global_proxy( void )
505 EnterCriticalSection( &WININET_cs
);
508 FreeProxyInfo( global_proxy
);
509 heap_free( global_proxy
);
511 LeaveCriticalSection( &WININET_cs
);
514 /***********************************************************************
515 * INTERNET_LoadProxySettings
517 * Loads proxy information from process-wide global settings, the registry,
518 * or the environment into lpwpi.
520 * The caller should call FreeProxyInfo when done with lpwpi.
523 * The proxy may be specified in the form 'http=proxy.my.org'
524 * Presumably that means there can be ftp=ftpproxy.my.org too.
526 static LONG
INTERNET_LoadProxySettings( proxyinfo_t
*lpwpi
)
533 EnterCriticalSection( &WININET_cs
);
536 lpwpi
->proxyEnabled
= global_proxy
->proxyEnabled
;
537 lpwpi
->proxy
= heap_strdupW( global_proxy
->proxy
);
538 lpwpi
->proxyBypass
= heap_strdupW( global_proxy
->proxyBypass
);
540 LeaveCriticalSection( &WININET_cs
);
542 if ((ret
= RegOpenKeyW( HKEY_CURRENT_USER
, szInternetSettings
, &key
)))
546 if (RegQueryValueExW( key
, szProxyEnable
, NULL
, &type
, (BYTE
*)&lpwpi
->proxyEnabled
, &len
) || type
!= REG_DWORD
)
548 lpwpi
->proxyEnabled
= 0;
549 if((ret
= RegSetValueExW( key
, szProxyEnable
, 0, REG_DWORD
, (BYTE
*)&lpwpi
->proxyEnabled
, sizeof(DWORD
) )))
556 if (!(envproxy
= getenv( "http_proxy" )) || lpwpi
->proxyEnabled
)
558 TRACE("Proxy is enabled.\n");
560 /* figure out how much memory the proxy setting takes */
561 if (!RegQueryValueExW( key
, szProxyServer
, NULL
, &type
, NULL
, &len
) && len
&& (type
== REG_SZ
))
564 static const WCHAR szHttp
[] = {'h','t','t','p','=',0};
566 if (!(szProxy
= heap_alloc(len
)))
569 return ERROR_OUTOFMEMORY
;
571 RegQueryValueExW( key
, szProxyServer
, NULL
, &type
, (BYTE
*)szProxy
, &len
);
573 /* find the http proxy, and strip away everything else */
574 p
= strstrW( szProxy
, szHttp
);
577 p
+= lstrlenW( szHttp
);
578 lstrcpyW( szProxy
, p
);
580 p
= strchrW( szProxy
, ' ' );
583 lpwpi
->proxy
= szProxy
;
585 TRACE("http proxy = %s\n", debugstr_w(lpwpi
->proxy
));
589 TRACE("No proxy server settings in registry.\n");
597 len
= MultiByteToWideChar( CP_UNIXCP
, 0, envproxy
, -1, NULL
, 0 );
598 if (!(envproxyW
= heap_alloc(len
* sizeof(WCHAR
))))
599 return ERROR_OUTOFMEMORY
;
600 MultiByteToWideChar( CP_UNIXCP
, 0, envproxy
, -1, envproxyW
, len
);
602 lpwpi
->proxyEnabled
= 1;
603 lpwpi
->proxy
= envproxyW
;
605 TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi
->proxy
));
609 lpwpi
->proxyBypass
= NULL
;
611 return ERROR_SUCCESS
;
614 /***********************************************************************
615 * INTERNET_ConfigureProxy
617 static BOOL
INTERNET_ConfigureProxy( appinfo_t
*lpwai
)
621 if (INTERNET_LoadProxySettings( &wpi
))
624 if (wpi
.proxyEnabled
)
626 lpwai
->accessType
= INTERNET_OPEN_TYPE_PROXY
;
627 lpwai
->proxy
= wpi
.proxy
;
631 lpwai
->accessType
= INTERNET_OPEN_TYPE_DIRECT
;
635 /***********************************************************************
636 * dump_INTERNET_FLAGS
638 * Helper function to TRACE the internet flags.
644 static void dump_INTERNET_FLAGS(DWORD dwFlags
)
646 #define FE(x) { x, #x }
647 static const wininet_flag_info flag
[] = {
648 FE(INTERNET_FLAG_RELOAD
),
649 FE(INTERNET_FLAG_RAW_DATA
),
650 FE(INTERNET_FLAG_EXISTING_CONNECT
),
651 FE(INTERNET_FLAG_ASYNC
),
652 FE(INTERNET_FLAG_PASSIVE
),
653 FE(INTERNET_FLAG_NO_CACHE_WRITE
),
654 FE(INTERNET_FLAG_MAKE_PERSISTENT
),
655 FE(INTERNET_FLAG_FROM_CACHE
),
656 FE(INTERNET_FLAG_SECURE
),
657 FE(INTERNET_FLAG_KEEP_CONNECTION
),
658 FE(INTERNET_FLAG_NO_AUTO_REDIRECT
),
659 FE(INTERNET_FLAG_READ_PREFETCH
),
660 FE(INTERNET_FLAG_NO_COOKIES
),
661 FE(INTERNET_FLAG_NO_AUTH
),
662 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL
),
663 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
),
664 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
),
665 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
),
666 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID
),
667 FE(INTERNET_FLAG_RESYNCHRONIZE
),
668 FE(INTERNET_FLAG_HYPERLINK
),
669 FE(INTERNET_FLAG_NO_UI
),
670 FE(INTERNET_FLAG_PRAGMA_NOCACHE
),
671 FE(INTERNET_FLAG_CACHE_ASYNC
),
672 FE(INTERNET_FLAG_FORMS_SUBMIT
),
673 FE(INTERNET_FLAG_NEED_FILE
),
674 FE(INTERNET_FLAG_TRANSFER_ASCII
),
675 FE(INTERNET_FLAG_TRANSFER_BINARY
)
680 for (i
= 0; i
< (sizeof(flag
) / sizeof(flag
[0])); i
++) {
681 if (flag
[i
].val
& dwFlags
) {
682 TRACE(" %s", flag
[i
].name
);
683 dwFlags
&= ~flag
[i
].val
;
687 TRACE(" Unknown flags (%08x)\n", dwFlags
);
692 /***********************************************************************
693 * INTERNET_CloseHandle (internal)
695 * Close internet handle
698 static VOID
APPINFO_Destroy(object_header_t
*hdr
)
700 appinfo_t
*lpwai
= (appinfo_t
*)hdr
;
704 heap_free(lpwai
->agent
);
705 heap_free(lpwai
->proxy
);
706 heap_free(lpwai
->proxyBypass
);
707 heap_free(lpwai
->proxyUsername
);
708 heap_free(lpwai
->proxyPassword
);
711 static DWORD
APPINFO_QueryOption(object_header_t
*hdr
, DWORD option
, void *buffer
, DWORD
*size
, BOOL unicode
)
713 appinfo_t
*ai
= (appinfo_t
*)hdr
;
716 case INTERNET_OPTION_HANDLE_TYPE
:
717 TRACE("INTERNET_OPTION_HANDLE_TYPE\n");
719 if (*size
< sizeof(ULONG
))
720 return ERROR_INSUFFICIENT_BUFFER
;
722 *size
= sizeof(DWORD
);
723 *(DWORD
*)buffer
= INTERNET_HANDLE_TYPE_INTERNET
;
724 return ERROR_SUCCESS
;
726 case INTERNET_OPTION_USER_AGENT
: {
729 TRACE("INTERNET_OPTION_USER_AGENT\n");
734 DWORD len
= ai
->agent
? strlenW(ai
->agent
) : 0;
736 *size
= (len
+ 1) * sizeof(WCHAR
);
737 if(!buffer
|| bufsize
< *size
)
738 return ERROR_INSUFFICIENT_BUFFER
;
741 strcpyW(buffer
, ai
->agent
);
743 *(WCHAR
*)buffer
= 0;
744 /* If the buffer is copied, the returned length doesn't include
745 * the NULL terminator.
747 *size
= len
* sizeof(WCHAR
);
750 *size
= WideCharToMultiByte(CP_ACP
, 0, ai
->agent
, -1, NULL
, 0, NULL
, NULL
);
753 if(!buffer
|| bufsize
< *size
)
754 return ERROR_INSUFFICIENT_BUFFER
;
757 WideCharToMultiByte(CP_ACP
, 0, ai
->agent
, -1, buffer
, *size
, NULL
, NULL
);
760 /* If the buffer is copied, the returned length doesn't include
761 * the NULL terminator.
766 return ERROR_SUCCESS
;
769 case INTERNET_OPTION_PROXY
:
771 INTERNET_PROXY_INFOW
*pi
= (INTERNET_PROXY_INFOW
*)buffer
;
772 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
773 LPWSTR proxy
, proxy_bypass
;
776 proxyBytesRequired
= (lstrlenW(ai
->proxy
) + 1) * sizeof(WCHAR
);
778 proxyBypassBytesRequired
= (lstrlenW(ai
->proxyBypass
) + 1) * sizeof(WCHAR
);
779 if (*size
< sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
)
781 *size
= sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
782 return ERROR_INSUFFICIENT_BUFFER
;
784 proxy
= (LPWSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOW
));
785 proxy_bypass
= (LPWSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
);
787 pi
->dwAccessType
= ai
->accessType
;
788 pi
->lpszProxy
= NULL
;
789 pi
->lpszProxyBypass
= NULL
;
791 lstrcpyW(proxy
, ai
->proxy
);
792 pi
->lpszProxy
= proxy
;
795 if (ai
->proxyBypass
) {
796 lstrcpyW(proxy_bypass
, ai
->proxyBypass
);
797 pi
->lpszProxyBypass
= proxy_bypass
;
800 *size
= sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
801 return ERROR_SUCCESS
;
803 INTERNET_PROXY_INFOA
*pi
= (INTERNET_PROXY_INFOA
*)buffer
;
804 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
805 LPSTR proxy
, proxy_bypass
;
808 proxyBytesRequired
= WideCharToMultiByte(CP_ACP
, 0, ai
->proxy
, -1, NULL
, 0, NULL
, NULL
);
810 proxyBypassBytesRequired
= WideCharToMultiByte(CP_ACP
, 0, ai
->proxyBypass
, -1,
811 NULL
, 0, NULL
, NULL
);
812 if (*size
< sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
)
814 *size
= sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
815 return ERROR_INSUFFICIENT_BUFFER
;
817 proxy
= (LPSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOA
));
818 proxy_bypass
= (LPSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
);
820 pi
->dwAccessType
= ai
->accessType
;
821 pi
->lpszProxy
= NULL
;
822 pi
->lpszProxyBypass
= NULL
;
824 WideCharToMultiByte(CP_ACP
, 0, ai
->proxy
, -1, proxy
, proxyBytesRequired
, NULL
, NULL
);
825 pi
->lpszProxy
= proxy
;
828 if (ai
->proxyBypass
) {
829 WideCharToMultiByte(CP_ACP
, 0, ai
->proxyBypass
, -1, proxy_bypass
,
830 proxyBypassBytesRequired
, NULL
, NULL
);
831 pi
->lpszProxyBypass
= proxy_bypass
;
834 *size
= sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
835 return ERROR_SUCCESS
;
839 return INET_QueryOption(hdr
, option
, buffer
, size
, unicode
);
842 static const object_vtbl_t APPINFOVtbl
= {
855 /***********************************************************************
856 * InternetOpenW (WININET.@)
858 * Per-application initialization of wininet
861 * HINTERNET on success
865 HINTERNET WINAPI
InternetOpenW(LPCWSTR lpszAgent
, DWORD dwAccessType
,
866 LPCWSTR lpszProxy
, LPCWSTR lpszProxyBypass
, DWORD dwFlags
)
868 appinfo_t
*lpwai
= NULL
;
870 if (TRACE_ON(wininet
)) {
871 #define FE(x) { x, #x }
872 static const wininet_flag_info access_type
[] = {
873 FE(INTERNET_OPEN_TYPE_PRECONFIG
),
874 FE(INTERNET_OPEN_TYPE_DIRECT
),
875 FE(INTERNET_OPEN_TYPE_PROXY
),
876 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY
)
880 const char *access_type_str
= "Unknown";
882 TRACE("(%s, %i, %s, %s, %i)\n", debugstr_w(lpszAgent
), dwAccessType
,
883 debugstr_w(lpszProxy
), debugstr_w(lpszProxyBypass
), dwFlags
);
884 for (i
= 0; i
< (sizeof(access_type
) / sizeof(access_type
[0])); i
++) {
885 if (access_type
[i
].val
== dwAccessType
) {
886 access_type_str
= access_type
[i
].name
;
890 TRACE(" access type : %s\n", access_type_str
);
892 dump_INTERNET_FLAGS(dwFlags
);
895 /* Clear any error information */
896 INTERNET_SetLastError(0);
898 lpwai
= alloc_object(NULL
, &APPINFOVtbl
, sizeof(appinfo_t
));
900 SetLastError(ERROR_OUTOFMEMORY
);
904 lpwai
->hdr
.htype
= WH_HINIT
;
905 lpwai
->hdr
.dwFlags
= dwFlags
;
906 lpwai
->accessType
= dwAccessType
;
907 lpwai
->proxyUsername
= NULL
;
908 lpwai
->proxyPassword
= NULL
;
910 lpwai
->agent
= heap_strdupW(lpszAgent
);
911 if(dwAccessType
== INTERNET_OPEN_TYPE_PRECONFIG
)
912 INTERNET_ConfigureProxy( lpwai
);
914 lpwai
->proxy
= heap_strdupW(lpszProxy
);
915 lpwai
->proxyBypass
= heap_strdupW(lpszProxyBypass
);
917 TRACE("returning %p\n", lpwai
);
919 return lpwai
->hdr
.hInternet
;
923 /***********************************************************************
924 * InternetOpenA (WININET.@)
926 * Per-application initialization of wininet
929 * HINTERNET on success
933 HINTERNET WINAPI
InternetOpenA(LPCSTR lpszAgent
, DWORD dwAccessType
,
934 LPCSTR lpszProxy
, LPCSTR lpszProxyBypass
, DWORD dwFlags
)
936 WCHAR
*szAgent
, *szProxy
, *szBypass
;
939 TRACE("(%s, 0x%08x, %s, %s, 0x%08x)\n", debugstr_a(lpszAgent
),
940 dwAccessType
, debugstr_a(lpszProxy
), debugstr_a(lpszProxyBypass
), dwFlags
);
942 szAgent
= heap_strdupAtoW(lpszAgent
);
943 szProxy
= heap_strdupAtoW(lpszProxy
);
944 szBypass
= heap_strdupAtoW(lpszProxyBypass
);
946 rc
= InternetOpenW(szAgent
, dwAccessType
, szProxy
, szBypass
, dwFlags
);
954 /***********************************************************************
955 * InternetGetLastResponseInfoA (WININET.@)
957 * Return last wininet error description on the calling thread
960 * TRUE on success of writing to buffer
964 BOOL WINAPI
InternetGetLastResponseInfoA(LPDWORD lpdwError
,
965 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
967 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
973 *lpdwError
= lpwite
->dwError
;
976 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
977 *lpdwBufferLength
= strlen(lpszBuffer
);
980 *lpdwBufferLength
= 0;
985 *lpdwBufferLength
= 0;
991 /***********************************************************************
992 * InternetGetLastResponseInfoW (WININET.@)
994 * Return last wininet error description on the calling thread
997 * TRUE on success of writing to buffer
1001 BOOL WINAPI
InternetGetLastResponseInfoW(LPDWORD lpdwError
,
1002 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
1004 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
1010 *lpdwError
= lpwite
->dwError
;
1011 if (lpwite
->dwError
)
1013 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
1014 *lpdwBufferLength
= lstrlenW(lpszBuffer
);
1017 *lpdwBufferLength
= 0;
1022 *lpdwBufferLength
= 0;
1028 /***********************************************************************
1029 * InternetGetConnectedState (WININET.@)
1031 * Return connected state
1035 * if lpdwStatus is not null, return the status (off line,
1036 * modem, lan...) in it.
1037 * FALSE if not connected
1039 BOOL WINAPI
InternetGetConnectedState(LPDWORD lpdwStatus
, DWORD dwReserved
)
1041 TRACE("(%p, 0x%08x)\n", lpdwStatus
, dwReserved
);
1044 WARN("always returning LAN connection.\n");
1045 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
1051 /***********************************************************************
1052 * InternetGetConnectedStateExW (WININET.@)
1054 * Return connected state
1058 * lpdwStatus [O] Flags specifying the status of the internet connection.
1059 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
1060 * dwNameLen [I] Size of the buffer, in characters.
1061 * dwReserved [I] Reserved. Must be set to 0.
1065 * if lpdwStatus is not null, return the status (off line,
1066 * modem, lan...) in it.
1067 * FALSE if not connected
1070 * If the system has no available network connections, an empty string is
1071 * stored in lpszConnectionName. If there is a LAN connection, a localized
1072 * "LAN Connection" string is stored. Presumably, if only a dial-up
1073 * connection is available then the name of the dial-up connection is
1074 * returned. Why any application, other than the "Internet Settings" CPL,
1075 * would want to use this function instead of the simpler InternetGetConnectedStateW
1076 * function is beyond me.
1078 BOOL WINAPI
InternetGetConnectedStateExW(LPDWORD lpdwStatus
, LPWSTR lpszConnectionName
,
1079 DWORD dwNameLen
, DWORD dwReserved
)
1081 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
1088 WARN("always returning LAN connection.\n");
1089 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
1091 return LoadStringW(WININET_hModule
, IDS_LANCONNECTION
, lpszConnectionName
, dwNameLen
);
1095 /***********************************************************************
1096 * InternetGetConnectedStateExA (WININET.@)
1098 BOOL WINAPI
InternetGetConnectedStateExA(LPDWORD lpdwStatus
, LPSTR lpszConnectionName
,
1099 DWORD dwNameLen
, DWORD dwReserved
)
1101 LPWSTR lpwszConnectionName
= NULL
;
1104 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
1106 if (lpszConnectionName
&& dwNameLen
> 0)
1107 lpwszConnectionName
= heap_alloc(dwNameLen
* sizeof(WCHAR
));
1109 rc
= InternetGetConnectedStateExW(lpdwStatus
,lpwszConnectionName
, dwNameLen
,
1111 if (rc
&& lpwszConnectionName
)
1113 WideCharToMultiByte(CP_ACP
,0,lpwszConnectionName
,-1,lpszConnectionName
,
1114 dwNameLen
, NULL
, NULL
);
1115 heap_free(lpwszConnectionName
);
1121 /***********************************************************************
1122 * InternetConnectW (WININET.@)
1124 * Open a ftp, gopher or http session
1127 * HINTERNET a session handle on success
1131 HINTERNET WINAPI
InternetConnectW(HINTERNET hInternet
,
1132 LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
1133 LPCWSTR lpszUserName
, LPCWSTR lpszPassword
,
1134 DWORD dwService
, DWORD dwFlags
, DWORD_PTR dwContext
)
1137 HINTERNET rc
= NULL
;
1138 DWORD res
= ERROR_SUCCESS
;
1140 TRACE("(%p, %s, %i, %s, %s, %i, %i, %lx)\n", hInternet
, debugstr_w(lpszServerName
),
1141 nServerPort
, debugstr_w(lpszUserName
), debugstr_w(lpszPassword
),
1142 dwService
, dwFlags
, dwContext
);
1144 if (!lpszServerName
)
1146 SetLastError(ERROR_INVALID_PARAMETER
);
1150 hIC
= (appinfo_t
*)get_handle_object( hInternet
);
1151 if ( (hIC
== NULL
) || (hIC
->hdr
.htype
!= WH_HINIT
) )
1153 res
= ERROR_INVALID_HANDLE
;
1159 case INTERNET_SERVICE_FTP
:
1160 rc
= FTP_Connect(hIC
, lpszServerName
, nServerPort
,
1161 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0);
1163 res
= INTERNET_GetLastError();
1166 case INTERNET_SERVICE_HTTP
:
1167 res
= HTTP_Connect(hIC
, lpszServerName
, nServerPort
,
1168 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0, &rc
);
1171 case INTERNET_SERVICE_GOPHER
:
1177 WININET_Release( &hIC
->hdr
);
1179 TRACE("returning %p\n", rc
);
1185 /***********************************************************************
1186 * InternetConnectA (WININET.@)
1188 * Open a ftp, gopher or http session
1191 * HINTERNET a session handle on success
1195 HINTERNET WINAPI
InternetConnectA(HINTERNET hInternet
,
1196 LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
1197 LPCSTR lpszUserName
, LPCSTR lpszPassword
,
1198 DWORD dwService
, DWORD dwFlags
, DWORD_PTR dwContext
)
1200 HINTERNET rc
= NULL
;
1201 LPWSTR szServerName
;
1205 szServerName
= heap_strdupAtoW(lpszServerName
);
1206 szUserName
= heap_strdupAtoW(lpszUserName
);
1207 szPassword
= heap_strdupAtoW(lpszPassword
);
1209 rc
= InternetConnectW(hInternet
, szServerName
, nServerPort
,
1210 szUserName
, szPassword
, dwService
, dwFlags
, dwContext
);
1212 heap_free(szServerName
);
1213 heap_free(szUserName
);
1214 heap_free(szPassword
);
1219 /***********************************************************************
1220 * InternetFindNextFileA (WININET.@)
1222 * Continues a file search from a previous call to FindFirstFile
1229 BOOL WINAPI
InternetFindNextFileA(HINTERNET hFind
, LPVOID lpvFindData
)
1232 WIN32_FIND_DATAW fd
;
1234 ret
= InternetFindNextFileW(hFind
, lpvFindData
?&fd
:NULL
);
1236 WININET_find_data_WtoA(&fd
, (LPWIN32_FIND_DATAA
)lpvFindData
);
1240 /***********************************************************************
1241 * InternetFindNextFileW (WININET.@)
1243 * Continues a file search from a previous call to FindFirstFile
1250 BOOL WINAPI
InternetFindNextFileW(HINTERNET hFind
, LPVOID lpvFindData
)
1252 object_header_t
*hdr
;
1257 hdr
= get_handle_object(hFind
);
1259 WARN("Invalid handle\n");
1260 SetLastError(ERROR_INVALID_HANDLE
);
1264 if(hdr
->vtbl
->FindNextFileW
) {
1265 res
= hdr
->vtbl
->FindNextFileW(hdr
, lpvFindData
);
1267 WARN("Handle doesn't support NextFile\n");
1268 res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
1271 WININET_Release(hdr
);
1273 if(res
!= ERROR_SUCCESS
)
1275 return res
== ERROR_SUCCESS
;
1278 /***********************************************************************
1279 * InternetCloseHandle (WININET.@)
1281 * Generic close handle function
1288 BOOL WINAPI
InternetCloseHandle(HINTERNET hInternet
)
1290 object_header_t
*obj
;
1292 TRACE("%p\n", hInternet
);
1294 obj
= get_handle_object( hInternet
);
1296 SetLastError(ERROR_INVALID_HANDLE
);
1300 invalidate_handle(obj
);
1301 WININET_Release(obj
);
1307 /***********************************************************************
1308 * ConvertUrlComponentValue (Internal)
1310 * Helper function for InternetCrackUrlA
1313 static void ConvertUrlComponentValue(LPSTR
* lppszComponent
, LPDWORD dwComponentLen
,
1314 LPWSTR lpwszComponent
, DWORD dwwComponentLen
,
1315 LPCSTR lpszStart
, LPCWSTR lpwszStart
)
1317 TRACE("%p %d %p %d %p %p\n", *lppszComponent
, *dwComponentLen
, lpwszComponent
, dwwComponentLen
, lpszStart
, lpwszStart
);
1318 if (*dwComponentLen
!= 0)
1320 DWORD nASCIILength
=WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,NULL
,0,NULL
,NULL
);
1321 if (*lppszComponent
== NULL
)
1325 int offset
= WideCharToMultiByte(CP_ACP
, 0, lpwszStart
, lpwszComponent
-lpwszStart
, NULL
, 0, NULL
, NULL
);
1326 *lppszComponent
= (LPSTR
)lpszStart
+ offset
;
1329 *lppszComponent
= NULL
;
1331 *dwComponentLen
= nASCIILength
;
1335 DWORD ncpylen
= min((*dwComponentLen
)-1, nASCIILength
);
1336 WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,*lppszComponent
,ncpylen
+1,NULL
,NULL
);
1337 (*lppszComponent
)[ncpylen
]=0;
1338 *dwComponentLen
= ncpylen
;
1344 /***********************************************************************
1345 * InternetCrackUrlA (WININET.@)
1347 * See InternetCrackUrlW.
1349 BOOL WINAPI
InternetCrackUrlA(LPCSTR lpszUrl
, DWORD dwUrlLength
, DWORD dwFlags
,
1350 LPURL_COMPONENTSA lpUrlComponents
)
1353 URL_COMPONENTSW UCW
;
1355 WCHAR
*lpwszUrl
, *hostname
= NULL
, *username
= NULL
, *password
= NULL
, *path
= NULL
,
1356 *scheme
= NULL
, *extra
= NULL
;
1358 TRACE("(%s %u %x %p)\n",
1359 lpszUrl
? debugstr_an(lpszUrl
, dwUrlLength
? dwUrlLength
: strlen(lpszUrl
)) : "(null)",
1360 dwUrlLength
, dwFlags
, lpUrlComponents
);
1362 if (!lpszUrl
|| !*lpszUrl
|| !lpUrlComponents
||
1363 lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSA
))
1365 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1371 nLength
=MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,NULL
,0);
1373 /* if dwUrlLength=-1 then nLength includes null but length to
1374 InternetCrackUrlW should not include it */
1375 if (dwUrlLength
== -1) nLength
--;
1377 lpwszUrl
= heap_alloc((nLength
+ 1) * sizeof(WCHAR
));
1378 MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,lpwszUrl
,nLength
+ 1);
1379 lpwszUrl
[nLength
] = '\0';
1381 memset(&UCW
,0,sizeof(UCW
));
1382 UCW
.dwStructSize
= sizeof(URL_COMPONENTSW
);
1383 if (lpUrlComponents
->dwHostNameLength
)
1385 UCW
.dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
1386 if (lpUrlComponents
->lpszHostName
)
1388 hostname
= heap_alloc(UCW
.dwHostNameLength
* sizeof(WCHAR
));
1389 UCW
.lpszHostName
= hostname
;
1392 if (lpUrlComponents
->dwUserNameLength
)
1394 UCW
.dwUserNameLength
= lpUrlComponents
->dwUserNameLength
;
1395 if (lpUrlComponents
->lpszUserName
)
1397 username
= heap_alloc(UCW
.dwUserNameLength
* sizeof(WCHAR
));
1398 UCW
.lpszUserName
= username
;
1401 if (lpUrlComponents
->dwPasswordLength
)
1403 UCW
.dwPasswordLength
= lpUrlComponents
->dwPasswordLength
;
1404 if (lpUrlComponents
->lpszPassword
)
1406 password
= heap_alloc(UCW
.dwPasswordLength
* sizeof(WCHAR
));
1407 UCW
.lpszPassword
= password
;
1410 if (lpUrlComponents
->dwUrlPathLength
)
1412 UCW
.dwUrlPathLength
= lpUrlComponents
->dwUrlPathLength
;
1413 if (lpUrlComponents
->lpszUrlPath
)
1415 path
= heap_alloc(UCW
.dwUrlPathLength
* sizeof(WCHAR
));
1416 UCW
.lpszUrlPath
= path
;
1419 if (lpUrlComponents
->dwSchemeLength
)
1421 UCW
.dwSchemeLength
= lpUrlComponents
->dwSchemeLength
;
1422 if (lpUrlComponents
->lpszScheme
)
1424 scheme
= heap_alloc(UCW
.dwSchemeLength
* sizeof(WCHAR
));
1425 UCW
.lpszScheme
= scheme
;
1428 if (lpUrlComponents
->dwExtraInfoLength
)
1430 UCW
.dwExtraInfoLength
= lpUrlComponents
->dwExtraInfoLength
;
1431 if (lpUrlComponents
->lpszExtraInfo
)
1433 extra
= heap_alloc(UCW
.dwExtraInfoLength
* sizeof(WCHAR
));
1434 UCW
.lpszExtraInfo
= extra
;
1437 if ((ret
= InternetCrackUrlW(lpwszUrl
, nLength
, dwFlags
, &UCW
)))
1439 ConvertUrlComponentValue(&lpUrlComponents
->lpszHostName
, &lpUrlComponents
->dwHostNameLength
,
1440 UCW
.lpszHostName
, UCW
.dwHostNameLength
, lpszUrl
, lpwszUrl
);
1441 ConvertUrlComponentValue(&lpUrlComponents
->lpszUserName
, &lpUrlComponents
->dwUserNameLength
,
1442 UCW
.lpszUserName
, UCW
.dwUserNameLength
, lpszUrl
, lpwszUrl
);
1443 ConvertUrlComponentValue(&lpUrlComponents
->lpszPassword
, &lpUrlComponents
->dwPasswordLength
,
1444 UCW
.lpszPassword
, UCW
.dwPasswordLength
, lpszUrl
, lpwszUrl
);
1445 ConvertUrlComponentValue(&lpUrlComponents
->lpszUrlPath
, &lpUrlComponents
->dwUrlPathLength
,
1446 UCW
.lpszUrlPath
, UCW
.dwUrlPathLength
, lpszUrl
, lpwszUrl
);
1447 ConvertUrlComponentValue(&lpUrlComponents
->lpszScheme
, &lpUrlComponents
->dwSchemeLength
,
1448 UCW
.lpszScheme
, UCW
.dwSchemeLength
, lpszUrl
, lpwszUrl
);
1449 ConvertUrlComponentValue(&lpUrlComponents
->lpszExtraInfo
, &lpUrlComponents
->dwExtraInfoLength
,
1450 UCW
.lpszExtraInfo
, UCW
.dwExtraInfoLength
, lpszUrl
, lpwszUrl
);
1452 lpUrlComponents
->nScheme
= UCW
.nScheme
;
1453 lpUrlComponents
->nPort
= UCW
.nPort
;
1455 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_a(lpszUrl
),
1456 debugstr_an(lpUrlComponents
->lpszScheme
, lpUrlComponents
->dwSchemeLength
),
1457 debugstr_an(lpUrlComponents
->lpszHostName
, lpUrlComponents
->dwHostNameLength
),
1458 debugstr_an(lpUrlComponents
->lpszUrlPath
, lpUrlComponents
->dwUrlPathLength
),
1459 debugstr_an(lpUrlComponents
->lpszExtraInfo
, lpUrlComponents
->dwExtraInfoLength
));
1461 heap_free(lpwszUrl
);
1462 heap_free(hostname
);
1463 heap_free(username
);
1464 heap_free(password
);
1471 static const WCHAR url_schemes
[][7] =
1474 {'g','o','p','h','e','r',0},
1475 {'h','t','t','p',0},
1476 {'h','t','t','p','s',0},
1477 {'f','i','l','e',0},
1478 {'n','e','w','s',0},
1479 {'m','a','i','l','t','o',0},
1483 /***********************************************************************
1484 * GetInternetSchemeW (internal)
1490 * INTERNET_SCHEME_UNKNOWN on failure
1493 static INTERNET_SCHEME
GetInternetSchemeW(LPCWSTR lpszScheme
, DWORD nMaxCmp
)
1497 TRACE("%s %d\n",debugstr_wn(lpszScheme
, nMaxCmp
), nMaxCmp
);
1499 if(lpszScheme
==NULL
)
1500 return INTERNET_SCHEME_UNKNOWN
;
1502 for (i
= 0; i
< sizeof(url_schemes
)/sizeof(url_schemes
[0]); i
++)
1503 if (!strncmpW(lpszScheme
, url_schemes
[i
], nMaxCmp
))
1504 return INTERNET_SCHEME_FIRST
+ i
;
1506 return INTERNET_SCHEME_UNKNOWN
;
1509 /***********************************************************************
1510 * SetUrlComponentValueW (Internal)
1512 * Helper function for InternetCrackUrlW
1515 * lppszComponent [O] Holds the returned string
1516 * dwComponentLen [I] Holds the size of lppszComponent
1517 * [O] Holds the length of the string in lppszComponent without '\0'
1518 * lpszStart [I] Holds the string to copy from
1519 * len [I] Holds the length of lpszStart without '\0'
1526 static BOOL
SetUrlComponentValueW(LPWSTR
* lppszComponent
, LPDWORD dwComponentLen
, LPCWSTR lpszStart
, DWORD len
)
1528 TRACE("%s (%d)\n", debugstr_wn(lpszStart
,len
), len
);
1530 if ( (*dwComponentLen
== 0) && (*lppszComponent
== NULL
) )
1533 if (*dwComponentLen
!= 0 || *lppszComponent
== NULL
)
1535 if (*lppszComponent
== NULL
)
1537 *lppszComponent
= (LPWSTR
)lpszStart
;
1538 *dwComponentLen
= len
;
1542 DWORD ncpylen
= min((*dwComponentLen
)-1, len
);
1543 memcpy(*lppszComponent
, lpszStart
, ncpylen
*sizeof(WCHAR
));
1544 (*lppszComponent
)[ncpylen
] = '\0';
1545 *dwComponentLen
= ncpylen
;
1552 /***********************************************************************
1553 * InternetCrackUrlW (WININET.@)
1555 * Break up URL into its components
1561 BOOL WINAPI
InternetCrackUrlW(LPCWSTR lpszUrl_orig
, DWORD dwUrlLength_orig
, DWORD dwFlags
,
1562 LPURL_COMPONENTSW lpUC
)
1566 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1569 LPCWSTR lpszParam
= NULL
;
1570 BOOL bIsAbsolute
= FALSE
;
1571 LPCWSTR lpszap
, lpszUrl
= lpszUrl_orig
;
1572 LPCWSTR lpszcp
= NULL
;
1573 LPWSTR lpszUrl_decode
= NULL
;
1574 DWORD dwUrlLength
= dwUrlLength_orig
;
1576 TRACE("(%s %u %x %p)\n",
1577 lpszUrl
? debugstr_wn(lpszUrl
, dwUrlLength
? dwUrlLength
: strlenW(lpszUrl
)) : "(null)",
1578 dwUrlLength
, dwFlags
, lpUC
);
1580 if (!lpszUrl_orig
|| !*lpszUrl_orig
|| !lpUC
)
1582 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1585 if (!dwUrlLength
) dwUrlLength
= strlenW(lpszUrl
);
1587 if (dwFlags
& ICU_DECODE
)
1590 DWORD len
= dwUrlLength
+ 1;
1592 if (!(url_tmp
= heap_alloc(len
* sizeof(WCHAR
))))
1594 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
1597 memcpy(url_tmp
, lpszUrl_orig
, dwUrlLength
* sizeof(WCHAR
));
1598 url_tmp
[dwUrlLength
] = 0;
1599 if (!(lpszUrl_decode
= heap_alloc(len
* sizeof(WCHAR
))))
1602 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
1605 if (InternetCanonicalizeUrlW(url_tmp
, lpszUrl_decode
, &len
, ICU_DECODE
| ICU_NO_ENCODE
))
1608 lpszUrl
= lpszUrl_decode
;
1614 /* Determine if the URI is absolute. */
1615 while (lpszap
- lpszUrl
< dwUrlLength
)
1617 if (isalnumW(*lpszap
) || *lpszap
== '+' || *lpszap
== '.' || *lpszap
== '-')
1622 if ((*lpszap
== ':') && (lpszap
- lpszUrl
>= 2))
1629 lpszcp
= lpszUrl
; /* Relative url */
1635 lpUC
->nScheme
= INTERNET_SCHEME_UNKNOWN
;
1636 lpUC
->nPort
= INTERNET_INVALID_PORT_NUMBER
;
1638 /* Parse <params> */
1639 lpszParam
= memchrW(lpszap
, ';', dwUrlLength
- (lpszap
- lpszUrl
));
1641 lpszParam
= memchrW(lpszap
, '?', dwUrlLength
- (lpszap
- lpszUrl
));
1643 lpszParam
= memchrW(lpszap
, '#', dwUrlLength
- (lpszap
- lpszUrl
));
1645 SetUrlComponentValueW(&lpUC
->lpszExtraInfo
, &lpUC
->dwExtraInfoLength
,
1646 lpszParam
, lpszParam
? dwUrlLength
-(lpszParam
-lpszUrl
) : 0);
1648 if (bIsAbsolute
) /* Parse <protocol>:[//<net_loc>] */
1652 /* Get scheme first. */
1653 lpUC
->nScheme
= GetInternetSchemeW(lpszUrl
, lpszcp
- lpszUrl
);
1654 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
,
1655 lpszUrl
, lpszcp
- lpszUrl
);
1657 /* Eat ':' in protocol. */
1660 /* double slash indicates the net_loc portion is present */
1661 if ((lpszcp
[0] == '/') && (lpszcp
[1] == '/'))
1665 lpszNetLoc
= memchrW(lpszcp
, '/', dwUrlLength
- (lpszcp
- lpszUrl
));
1669 lpszNetLoc
= min(lpszNetLoc
, lpszParam
);
1671 lpszNetLoc
= lpszParam
;
1673 else if (!lpszNetLoc
)
1674 lpszNetLoc
= lpszcp
+ dwUrlLength
-(lpszcp
-lpszUrl
);
1682 /* [<user>[<:password>]@]<host>[:<port>] */
1683 /* First find the user and password if they exist */
1685 lpszHost
= memchrW(lpszcp
, '@', dwUrlLength
- (lpszcp
- lpszUrl
));
1686 if (lpszHost
== NULL
|| lpszHost
> lpszNetLoc
)
1688 /* username and password not specified. */
1689 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1690 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1692 else /* Parse out username and password */
1694 LPCWSTR lpszUser
= lpszcp
;
1695 LPCWSTR lpszPasswd
= lpszHost
;
1697 while (lpszcp
< lpszHost
)
1700 lpszPasswd
= lpszcp
;
1705 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
,
1706 lpszUser
, lpszPasswd
- lpszUser
);
1708 if (lpszPasswd
!= lpszHost
)
1710 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
,
1711 lpszPasswd
== lpszHost
? NULL
: lpszPasswd
,
1712 lpszHost
- lpszPasswd
);
1714 lpszcp
++; /* Advance to beginning of host */
1717 /* Parse <host><:port> */
1720 lpszPort
= lpszNetLoc
;
1722 /* special case for res:// URLs: there is no port here, so the host is the
1723 entire string up to the first '/' */
1724 if(lpUC
->nScheme
==INTERNET_SCHEME_RES
)
1726 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1727 lpszHost
, lpszPort
- lpszHost
);
1732 while (lpszcp
< lpszNetLoc
)
1740 /* If the scheme is "file" and the host is just one letter, it's not a host */
1741 if(lpUC
->nScheme
==INTERNET_SCHEME_FILE
&& lpszPort
<= lpszHost
+1)
1744 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1749 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1750 lpszHost
, lpszPort
- lpszHost
);
1751 if (lpszPort
!= lpszNetLoc
)
1752 lpUC
->nPort
= atoiW(++lpszPort
);
1753 else switch (lpUC
->nScheme
)
1755 case INTERNET_SCHEME_HTTP
:
1756 lpUC
->nPort
= INTERNET_DEFAULT_HTTP_PORT
;
1758 case INTERNET_SCHEME_HTTPS
:
1759 lpUC
->nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
1761 case INTERNET_SCHEME_FTP
:
1762 lpUC
->nPort
= INTERNET_DEFAULT_FTP_PORT
;
1764 case INTERNET_SCHEME_GOPHER
:
1765 lpUC
->nPort
= INTERNET_DEFAULT_GOPHER_PORT
;
1776 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1777 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1778 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1783 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
, NULL
, 0);
1784 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1785 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1786 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1789 /* Here lpszcp points to:
1791 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1792 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1794 if (lpszcp
!= 0 && lpszcp
- lpszUrl
< dwUrlLength
&& (!lpszParam
|| lpszcp
<= lpszParam
))
1798 /* Only truncate the parameter list if it's already been saved
1799 * in lpUC->lpszExtraInfo.
1801 if (lpszParam
&& lpUC
->dwExtraInfoLength
&& lpUC
->lpszExtraInfo
)
1802 len
= lpszParam
- lpszcp
;
1805 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1806 * newlines if necessary.
1808 LPWSTR lpsznewline
= memchrW(lpszcp
, '\n', dwUrlLength
- (lpszcp
- lpszUrl
));
1809 if (lpsznewline
!= NULL
)
1810 len
= lpsznewline
- lpszcp
;
1812 len
= dwUrlLength
-(lpszcp
-lpszUrl
);
1814 if (lpUC
->dwUrlPathLength
&& lpUC
->lpszUrlPath
&&
1815 lpUC
->nScheme
== INTERNET_SCHEME_FILE
)
1817 WCHAR tmppath
[MAX_PATH
];
1821 PathCreateFromUrlW(lpszUrl_orig
, tmppath
, &len
, 0);
1826 memcpy(tmppath
, lpszcp
, len
* sizeof(WCHAR
));
1827 tmppath
[len
] = '\0';
1836 /* if ends in \. or \.. append a backslash */
1837 if (tmppath
[len
- 1] == '.' &&
1838 (tmppath
[len
- 2] == '\\' ||
1839 (tmppath
[len
- 2] == '.' && tmppath
[len
- 3] == '\\')))
1841 if (len
< MAX_PATH
- 1)
1843 tmppath
[len
] = '\\';
1844 tmppath
[len
+1] = '\0';
1848 SetUrlComponentValueW(&lpUC
->lpszUrlPath
, &lpUC
->dwUrlPathLength
,
1852 SetUrlComponentValueW(&lpUC
->lpszUrlPath
, &lpUC
->dwUrlPathLength
,
1857 if (lpUC
->lpszUrlPath
&& (lpUC
->dwUrlPathLength
> 0))
1858 lpUC
->lpszUrlPath
[0] = 0;
1859 lpUC
->dwUrlPathLength
= 0;
1862 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl
,dwUrlLength
),
1863 debugstr_wn(lpUC
->lpszScheme
,lpUC
->dwSchemeLength
),
1864 debugstr_wn(lpUC
->lpszHostName
,lpUC
->dwHostNameLength
),
1865 debugstr_wn(lpUC
->lpszUrlPath
,lpUC
->dwUrlPathLength
),
1866 debugstr_wn(lpUC
->lpszExtraInfo
,lpUC
->dwExtraInfoLength
));
1868 heap_free( lpszUrl_decode
);
1872 /***********************************************************************
1873 * InternetAttemptConnect (WININET.@)
1875 * Attempt to make a connection to the internet
1878 * ERROR_SUCCESS on success
1879 * Error value on failure
1882 DWORD WINAPI
InternetAttemptConnect(DWORD dwReserved
)
1885 return ERROR_SUCCESS
;
1889 /***********************************************************************
1890 * InternetCanonicalizeUrlA (WININET.@)
1892 * Escape unsafe characters and spaces
1899 BOOL WINAPI
InternetCanonicalizeUrlA(LPCSTR lpszUrl
, LPSTR lpszBuffer
,
1900 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1903 DWORD dwURLFlags
= URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
;
1905 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl
), lpszBuffer
,
1906 lpdwBufferLength
, dwFlags
, lpdwBufferLength
? *lpdwBufferLength
: -1);
1908 if(dwFlags
& ICU_DECODE
)
1910 dwURLFlags
|= URL_UNESCAPE
;
1911 dwFlags
&= ~ICU_DECODE
;
1914 if(dwFlags
& ICU_ESCAPE
)
1916 dwURLFlags
|= URL_UNESCAPE
;
1917 dwFlags
&= ~ICU_ESCAPE
;
1920 if(dwFlags
& ICU_BROWSER_MODE
)
1922 dwURLFlags
|= URL_BROWSER_MODE
;
1923 dwFlags
&= ~ICU_BROWSER_MODE
;
1926 if(dwFlags
& ICU_NO_ENCODE
)
1928 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1929 dwURLFlags
^= URL_ESCAPE_UNSAFE
;
1930 dwFlags
&= ~ICU_NO_ENCODE
;
1933 if (dwFlags
) FIXME("Unhandled flags 0x%08x\n", dwFlags
);
1935 hr
= UrlCanonicalizeA(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1936 if (hr
== E_POINTER
) SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1937 if (hr
== E_INVALIDARG
) SetLastError(ERROR_INVALID_PARAMETER
);
1939 return (hr
== S_OK
) ? TRUE
: FALSE
;
1942 /***********************************************************************
1943 * InternetCanonicalizeUrlW (WININET.@)
1945 * Escape unsafe characters and spaces
1952 BOOL WINAPI
InternetCanonicalizeUrlW(LPCWSTR lpszUrl
, LPWSTR lpszBuffer
,
1953 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1956 DWORD dwURLFlags
= URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
;
1958 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl
), lpszBuffer
,
1959 lpdwBufferLength
, dwFlags
, lpdwBufferLength
? *lpdwBufferLength
: -1);
1961 if(dwFlags
& ICU_DECODE
)
1963 dwURLFlags
|= URL_UNESCAPE
;
1964 dwFlags
&= ~ICU_DECODE
;
1967 if(dwFlags
& ICU_ESCAPE
)
1969 dwURLFlags
|= URL_UNESCAPE
;
1970 dwFlags
&= ~ICU_ESCAPE
;
1973 if(dwFlags
& ICU_BROWSER_MODE
)
1975 dwURLFlags
|= URL_BROWSER_MODE
;
1976 dwFlags
&= ~ICU_BROWSER_MODE
;
1979 if(dwFlags
& ICU_NO_ENCODE
)
1981 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1982 dwURLFlags
^= URL_ESCAPE_UNSAFE
;
1983 dwFlags
&= ~ICU_NO_ENCODE
;
1986 if (dwFlags
) FIXME("Unhandled flags 0x%08x\n", dwFlags
);
1988 hr
= UrlCanonicalizeW(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1989 if (hr
== E_POINTER
) SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1990 if (hr
== E_INVALIDARG
) SetLastError(ERROR_INVALID_PARAMETER
);
1992 return (hr
== S_OK
) ? TRUE
: FALSE
;
1995 /* #################################################### */
1997 static INTERNET_STATUS_CALLBACK
set_status_callback(
1998 object_header_t
*lpwh
, INTERNET_STATUS_CALLBACK callback
, BOOL unicode
)
2000 INTERNET_STATUS_CALLBACK ret
;
2002 if (unicode
) lpwh
->dwInternalFlags
|= INET_CALLBACKW
;
2003 else lpwh
->dwInternalFlags
&= ~INET_CALLBACKW
;
2005 ret
= lpwh
->lpfnStatusCB
;
2006 lpwh
->lpfnStatusCB
= callback
;
2011 /***********************************************************************
2012 * InternetSetStatusCallbackA (WININET.@)
2014 * Sets up a callback function which is called as progress is made
2015 * during an operation.
2018 * Previous callback or NULL on success
2019 * INTERNET_INVALID_STATUS_CALLBACK on failure
2022 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackA(
2023 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
2025 INTERNET_STATUS_CALLBACK retVal
;
2026 object_header_t
*lpwh
;
2028 TRACE("%p\n", hInternet
);
2030 if (!(lpwh
= get_handle_object(hInternet
)))
2031 return INTERNET_INVALID_STATUS_CALLBACK
;
2033 retVal
= set_status_callback(lpwh
, lpfnIntCB
, FALSE
);
2035 WININET_Release( lpwh
);
2039 /***********************************************************************
2040 * InternetSetStatusCallbackW (WININET.@)
2042 * Sets up a callback function which is called as progress is made
2043 * during an operation.
2046 * Previous callback or NULL on success
2047 * INTERNET_INVALID_STATUS_CALLBACK on failure
2050 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackW(
2051 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
2053 INTERNET_STATUS_CALLBACK retVal
;
2054 object_header_t
*lpwh
;
2056 TRACE("%p\n", hInternet
);
2058 if (!(lpwh
= get_handle_object(hInternet
)))
2059 return INTERNET_INVALID_STATUS_CALLBACK
;
2061 retVal
= set_status_callback(lpwh
, lpfnIntCB
, TRUE
);
2063 WININET_Release( lpwh
);
2067 /***********************************************************************
2068 * InternetSetFilePointer (WININET.@)
2070 DWORD WINAPI
InternetSetFilePointer(HINTERNET hFile
, LONG lDistanceToMove
,
2071 PVOID pReserved
, DWORD dwMoveContext
, DWORD_PTR dwContext
)
2077 /***********************************************************************
2078 * InternetWriteFile (WININET.@)
2080 * Write data to an open internet file
2087 BOOL WINAPI
InternetWriteFile(HINTERNET hFile
, LPCVOID lpBuffer
,
2088 DWORD dwNumOfBytesToWrite
, LPDWORD lpdwNumOfBytesWritten
)
2090 object_header_t
*lpwh
;
2093 TRACE("(%p %p %d %p)\n", hFile
, lpBuffer
, dwNumOfBytesToWrite
, lpdwNumOfBytesWritten
);
2095 lpwh
= get_handle_object( hFile
);
2097 WARN("Invalid handle\n");
2098 SetLastError(ERROR_INVALID_HANDLE
);
2102 if(lpwh
->vtbl
->WriteFile
) {
2103 res
= lpwh
->vtbl
->WriteFile(lpwh
, lpBuffer
, dwNumOfBytesToWrite
, lpdwNumOfBytesWritten
);
2105 WARN("No Writefile method.\n");
2106 res
= ERROR_INVALID_HANDLE
;
2109 WININET_Release( lpwh
);
2111 if(res
!= ERROR_SUCCESS
)
2113 return res
== ERROR_SUCCESS
;
2117 /***********************************************************************
2118 * InternetReadFile (WININET.@)
2120 * Read data from an open internet file
2127 BOOL WINAPI
InternetReadFile(HINTERNET hFile
, LPVOID lpBuffer
,
2128 DWORD dwNumOfBytesToRead
, LPDWORD pdwNumOfBytesRead
)
2130 object_header_t
*hdr
;
2131 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2133 TRACE("%p %p %d %p\n", hFile
, lpBuffer
, dwNumOfBytesToRead
, pdwNumOfBytesRead
);
2135 hdr
= get_handle_object(hFile
);
2137 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2141 if(hdr
->vtbl
->ReadFile
)
2142 res
= hdr
->vtbl
->ReadFile(hdr
, lpBuffer
, dwNumOfBytesToRead
, pdwNumOfBytesRead
);
2144 WININET_Release(hdr
);
2146 TRACE("-- %s (%u) (bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE", res
,
2147 pdwNumOfBytesRead
? *pdwNumOfBytesRead
: -1);
2149 if(res
!= ERROR_SUCCESS
)
2151 return res
== ERROR_SUCCESS
;
2154 /***********************************************************************
2155 * InternetReadFileExA (WININET.@)
2157 * Read data from an open internet file
2160 * hFile [I] Handle returned by InternetOpenUrl or HttpOpenRequest.
2161 * lpBuffersOut [I/O] Buffer.
2162 * dwFlags [I] Flags. See notes.
2163 * dwContext [I] Context for callbacks.
2170 * The parameter dwFlags include zero or more of the following flags:
2171 *|IRF_ASYNC - Makes the call asynchronous.
2172 *|IRF_SYNC - Makes the call synchronous.
2173 *|IRF_USE_CONTEXT - Forces dwContext to be used.
2174 *|IRF_NO_WAIT - Don't block if the data is not available, just return what is available.
2176 * However, in testing IRF_USE_CONTEXT seems to have no effect - dwContext isn't used.
2179 * InternetOpenUrlA(), HttpOpenRequestA()
2181 BOOL WINAPI
InternetReadFileExA(HINTERNET hFile
, LPINTERNET_BUFFERSA lpBuffersOut
,
2182 DWORD dwFlags
, DWORD_PTR dwContext
)
2184 object_header_t
*hdr
;
2185 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2187 TRACE("(%p %p 0x%x 0x%lx)\n", hFile
, lpBuffersOut
, dwFlags
, dwContext
);
2189 hdr
= get_handle_object(hFile
);
2191 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2195 if(hdr
->vtbl
->ReadFileExA
)
2196 res
= hdr
->vtbl
->ReadFileExA(hdr
, lpBuffersOut
, dwFlags
, dwContext
);
2198 WININET_Release(hdr
);
2200 TRACE("-- %s (%u, bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE",
2201 res
, lpBuffersOut
->dwBufferLength
);
2203 if(res
!= ERROR_SUCCESS
)
2205 return res
== ERROR_SUCCESS
;
2208 /***********************************************************************
2209 * InternetReadFileExW (WININET.@)
2211 * InternetReadFileExA()
2213 BOOL WINAPI
InternetReadFileExW(HINTERNET hFile
, LPINTERNET_BUFFERSW lpBuffer
,
2214 DWORD dwFlags
, DWORD_PTR dwContext
)
2216 object_header_t
*hdr
;
2217 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2219 TRACE("(%p %p 0x%x 0x%lx)\n", hFile
, lpBuffer
, dwFlags
, dwContext
);
2221 hdr
= get_handle_object(hFile
);
2223 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2227 if(hdr
->vtbl
->ReadFileExW
)
2228 res
= hdr
->vtbl
->ReadFileExW(hdr
, lpBuffer
, dwFlags
, dwContext
);
2230 WININET_Release(hdr
);
2232 TRACE("-- %s (%u, bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE",
2233 res
, lpBuffer
->dwBufferLength
);
2235 if(res
!= ERROR_SUCCESS
)
2237 return res
== ERROR_SUCCESS
;
2240 DWORD
INET_QueryOption(object_header_t
*hdr
, DWORD option
, void *buffer
, DWORD
*size
, BOOL unicode
)
2242 static BOOL warn
= TRUE
;
2245 case INTERNET_OPTION_REQUEST_FLAGS
:
2246 TRACE("INTERNET_OPTION_REQUEST_FLAGS\n");
2248 if (*size
< sizeof(ULONG
))
2249 return ERROR_INSUFFICIENT_BUFFER
;
2251 *(ULONG
*)buffer
= 4;
2252 *size
= sizeof(ULONG
);
2254 return ERROR_SUCCESS
;
2256 case INTERNET_OPTION_HTTP_VERSION
:
2257 if (*size
< sizeof(HTTP_VERSION_INFO
))
2258 return ERROR_INSUFFICIENT_BUFFER
;
2261 * Presently hardcoded to 1.1
2263 ((HTTP_VERSION_INFO
*)buffer
)->dwMajorVersion
= 1;
2264 ((HTTP_VERSION_INFO
*)buffer
)->dwMinorVersion
= 1;
2265 *size
= sizeof(HTTP_VERSION_INFO
);
2267 return ERROR_SUCCESS
;
2269 case INTERNET_OPTION_CONNECTED_STATE
:
2271 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
2274 if (*size
< sizeof(ULONG
))
2275 return ERROR_INSUFFICIENT_BUFFER
;
2277 *(ULONG
*)buffer
= INTERNET_STATE_CONNECTED
;
2278 *size
= sizeof(ULONG
);
2280 return ERROR_SUCCESS
;
2282 case INTERNET_OPTION_PROXY
: {
2286 TRACE("Getting global proxy info\n");
2287 memset(&ai
, 0, sizeof(appinfo_t
));
2288 INTERNET_ConfigureProxy(&ai
);
2290 ret
= APPINFO_QueryOption(&ai
.hdr
, INTERNET_OPTION_PROXY
, buffer
, size
, unicode
); /* FIXME */
2291 APPINFO_Destroy(&ai
.hdr
);
2295 case INTERNET_OPTION_MAX_CONNS_PER_SERVER
:
2296 TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER\n");
2298 if (*size
< sizeof(ULONG
))
2299 return ERROR_INSUFFICIENT_BUFFER
;
2301 *(ULONG
*)buffer
= 2;
2302 *size
= sizeof(ULONG
);
2304 return ERROR_SUCCESS
;
2306 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
:
2307 TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER\n");
2309 if (*size
< sizeof(ULONG
))
2310 return ERROR_INSUFFICIENT_BUFFER
;
2312 *(ULONG
*)buffer
= 4;
2313 *size
= sizeof(ULONG
);
2315 return ERROR_SUCCESS
;
2317 case INTERNET_OPTION_SECURITY_FLAGS
:
2318 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2319 return ERROR_SUCCESS
;
2321 case INTERNET_OPTION_VERSION
: {
2322 static const INTERNET_VERSION_INFO info
= { 1, 2 };
2324 TRACE("INTERNET_OPTION_VERSION\n");
2326 if (*size
< sizeof(INTERNET_VERSION_INFO
))
2327 return ERROR_INSUFFICIENT_BUFFER
;
2329 memcpy(buffer
, &info
, sizeof(info
));
2330 *size
= sizeof(info
);
2332 return ERROR_SUCCESS
;
2335 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2336 INTERNET_PER_CONN_OPTION_LISTW
*con
= buffer
;
2337 INTERNET_PER_CONN_OPTION_LISTA
*conA
= buffer
;
2338 DWORD res
= ERROR_SUCCESS
, i
;
2342 TRACE("Getting global proxy info\n");
2343 if((ret
= INTERNET_LoadProxySettings(&pi
)))
2346 FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
2348 if (*size
< sizeof(INTERNET_PER_CONN_OPTION_LISTW
)) {
2350 return ERROR_INSUFFICIENT_BUFFER
;
2353 for (i
= 0; i
< con
->dwOptionCount
; i
++) {
2354 INTERNET_PER_CONN_OPTIONW
*optionW
= con
->pOptions
+ i
;
2355 INTERNET_PER_CONN_OPTIONA
*optionA
= conA
->pOptions
+ i
;
2357 switch (optionW
->dwOption
) {
2358 case INTERNET_PER_CONN_FLAGS
:
2360 optionW
->Value
.dwValue
= PROXY_TYPE_PROXY
;
2362 optionW
->Value
.dwValue
= PROXY_TYPE_DIRECT
;
2365 case INTERNET_PER_CONN_PROXY_SERVER
:
2367 optionW
->Value
.pszValue
= heap_strdupW(pi
.proxy
);
2369 optionA
->Value
.pszValue
= heap_strdupWtoA(pi
.proxy
);
2372 case INTERNET_PER_CONN_PROXY_BYPASS
:
2374 optionW
->Value
.pszValue
= heap_strdupW(pi
.proxyBypass
);
2376 optionA
->Value
.pszValue
= heap_strdupWtoA(pi
.proxyBypass
);
2379 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2380 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2381 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2382 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2383 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2384 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2385 FIXME("Unhandled dwOption %d\n", optionW
->dwOption
);
2386 memset(&optionW
->Value
, 0, sizeof(optionW
->Value
));
2390 FIXME("Unknown dwOption %d\n", optionW
->dwOption
);
2391 res
= ERROR_INVALID_PARAMETER
;
2399 case INTERNET_OPTION_USER_AGENT
:
2400 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2401 case INTERNET_OPTION_POLICY
:
2402 return ERROR_INVALID_PARAMETER
;
2403 case INTERNET_OPTION_CONTEXT_VALUE
:
2406 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2408 return ERROR_INVALID_PARAMETER
;
2410 if (*size
< sizeof(DWORD_PTR
))
2412 *size
= sizeof(DWORD_PTR
);
2413 return ERROR_INSUFFICIENT_BUFFER
;
2416 return ERROR_INVALID_PARAMETER
;
2418 *(DWORD_PTR
*)buffer
= hdr
->dwContext
;
2419 *size
= sizeof(DWORD_PTR
);
2420 return ERROR_SUCCESS
;
2424 FIXME("Stub for %d\n", option
);
2425 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2428 /***********************************************************************
2429 * InternetQueryOptionW (WININET.@)
2431 * Queries an options on the specified handle
2438 BOOL WINAPI
InternetQueryOptionW(HINTERNET hInternet
, DWORD dwOption
,
2439 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2441 object_header_t
*hdr
;
2442 DWORD res
= ERROR_INVALID_HANDLE
;
2444 TRACE("%p %d %p %p\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2447 hdr
= get_handle_object(hInternet
);
2449 res
= hdr
->vtbl
->QueryOption(hdr
, dwOption
, lpBuffer
, lpdwBufferLength
, TRUE
);
2450 WININET_Release(hdr
);
2453 res
= INET_QueryOption(NULL
, dwOption
, lpBuffer
, lpdwBufferLength
, TRUE
);
2456 if(res
!= ERROR_SUCCESS
)
2458 return res
== ERROR_SUCCESS
;
2461 /***********************************************************************
2462 * InternetQueryOptionA (WININET.@)
2464 * Queries an options on the specified handle
2471 BOOL WINAPI
InternetQueryOptionA(HINTERNET hInternet
, DWORD dwOption
,
2472 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2474 object_header_t
*hdr
;
2475 DWORD res
= ERROR_INVALID_HANDLE
;
2477 TRACE("%p %d %p %p\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2480 hdr
= get_handle_object(hInternet
);
2482 res
= hdr
->vtbl
->QueryOption(hdr
, dwOption
, lpBuffer
, lpdwBufferLength
, FALSE
);
2483 WININET_Release(hdr
);
2486 res
= INET_QueryOption(NULL
, dwOption
, lpBuffer
, lpdwBufferLength
, FALSE
);
2489 if(res
!= ERROR_SUCCESS
)
2491 return res
== ERROR_SUCCESS
;
2495 /***********************************************************************
2496 * InternetSetOptionW (WININET.@)
2498 * Sets an options on the specified handle
2505 BOOL WINAPI
InternetSetOptionW(HINTERNET hInternet
, DWORD dwOption
,
2506 LPVOID lpBuffer
, DWORD dwBufferLength
)
2508 object_header_t
*lpwhh
;
2511 TRACE("(%p %d %p %d)\n", hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2513 lpwhh
= (object_header_t
*) get_handle_object( hInternet
);
2514 if(lpwhh
&& lpwhh
->vtbl
->SetOption
) {
2517 res
= lpwhh
->vtbl
->SetOption(lpwhh
, dwOption
, lpBuffer
, dwBufferLength
);
2518 if(res
!= ERROR_INTERNET_INVALID_OPTION
) {
2519 WININET_Release( lpwhh
);
2521 if(res
!= ERROR_SUCCESS
)
2524 return res
== ERROR_SUCCESS
;
2530 case INTERNET_OPTION_CALLBACK
:
2534 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2537 WININET_Release(lpwhh
);
2538 SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE
);
2541 case INTERNET_OPTION_HTTP_VERSION
:
2543 HTTP_VERSION_INFO
* pVersion
=(HTTP_VERSION_INFO
*)lpBuffer
;
2544 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%d,%d): STUB\n",pVersion
->dwMajorVersion
,pVersion
->dwMinorVersion
);
2547 case INTERNET_OPTION_ERROR_MASK
:
2550 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2552 } else if(*(ULONG
*)lpBuffer
& (~(INTERNET_ERROR_MASK_INSERT_CDROM
|
2553 INTERNET_ERROR_MASK_COMBINED_SEC_CERT
|
2554 INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY
))) {
2555 SetLastError(ERROR_INVALID_PARAMETER
);
2557 } else if(dwBufferLength
!= sizeof(ULONG
)) {
2558 SetLastError(ERROR_INTERNET_BAD_OPTION_LENGTH
);
2561 lpwhh
->ErrorMask
= *(ULONG
*)lpBuffer
;
2564 case INTERNET_OPTION_PROXY
:
2566 INTERNET_PROXY_INFOW
*info
= lpBuffer
;
2568 if (!lpBuffer
|| dwBufferLength
< sizeof(INTERNET_PROXY_INFOW
))
2570 SetLastError(ERROR_INVALID_PARAMETER
);
2575 EnterCriticalSection( &WININET_cs
);
2576 free_global_proxy();
2577 global_proxy
= heap_alloc( sizeof(proxyinfo_t
) );
2580 if (info
->dwAccessType
== INTERNET_OPEN_TYPE_PROXY
)
2582 global_proxy
->proxyEnabled
= 1;
2583 global_proxy
->proxy
= heap_strdupW( info
->lpszProxy
);
2584 global_proxy
->proxyBypass
= heap_strdupW( info
->lpszProxyBypass
);
2588 global_proxy
->proxyEnabled
= 0;
2589 global_proxy
->proxy
= global_proxy
->proxyBypass
= NULL
;
2592 LeaveCriticalSection( &WININET_cs
);
2596 /* In general, each type of object should handle
2597 * INTERNET_OPTION_PROXY directly. This FIXME ensures it doesn't
2598 * get silently dropped.
2600 FIXME("INTERNET_OPTION_PROXY unimplemented\n");
2601 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2606 case INTERNET_OPTION_CODEPAGE
:
2608 ULONG codepage
= *(ULONG
*)lpBuffer
;
2609 FIXME("Option INTERNET_OPTION_CODEPAGE (%d): STUB\n", codepage
);
2612 case INTERNET_OPTION_REQUEST_PRIORITY
:
2614 ULONG priority
= *(ULONG
*)lpBuffer
;
2615 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%d): STUB\n", priority
);
2618 case INTERNET_OPTION_CONNECT_TIMEOUT
:
2620 ULONG connecttimeout
= *(ULONG
*)lpBuffer
;
2621 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%d): STUB\n", connecttimeout
);
2624 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
:
2626 ULONG receivetimeout
= *(ULONG
*)lpBuffer
;
2627 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%d): STUB\n", receivetimeout
);
2630 case INTERNET_OPTION_MAX_CONNS_PER_SERVER
:
2632 ULONG conns
= *(ULONG
*)lpBuffer
;
2633 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%d): STUB\n", conns
);
2636 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
:
2638 ULONG conns
= *(ULONG
*)lpBuffer
;
2639 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%d): STUB\n", conns
);
2642 case INTERNET_OPTION_RESET_URLCACHE_SESSION
:
2643 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2645 case INTERNET_OPTION_END_BROWSER_SESSION
:
2646 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2648 case INTERNET_OPTION_CONNECTED_STATE
:
2649 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2651 case INTERNET_OPTION_DISABLE_PASSPORT_AUTH
:
2652 TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
2654 case INTERNET_OPTION_SEND_TIMEOUT
:
2655 case INTERNET_OPTION_RECEIVE_TIMEOUT
:
2656 case INTERNET_OPTION_DATA_SEND_TIMEOUT
:
2658 ULONG timeout
= *(ULONG
*)lpBuffer
;
2659 FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT/DATA_SEND_TIMEOUT %d\n", timeout
);
2662 case INTERNET_OPTION_CONNECT_RETRIES
:
2664 ULONG retries
= *(ULONG
*)lpBuffer
;
2665 FIXME("INTERNET_OPTION_CONNECT_RETRIES %d\n", retries
);
2668 case INTERNET_OPTION_CONTEXT_VALUE
:
2672 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2675 if (!lpBuffer
|| dwBufferLength
!= sizeof(DWORD_PTR
))
2677 SetLastError(ERROR_INVALID_PARAMETER
);
2681 lpwhh
->dwContext
= *(DWORD_PTR
*)lpBuffer
;
2684 case INTERNET_OPTION_SECURITY_FLAGS
:
2685 FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n");
2687 case INTERNET_OPTION_DISABLE_AUTODIAL
:
2688 FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n");
2690 case INTERNET_OPTION_HTTP_DECODING
:
2691 FIXME("INTERNET_OPTION_HTTP_DECODING; STUB\n");
2692 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2695 case INTERNET_OPTION_COOKIES_3RD_PARTY
:
2696 FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n");
2697 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2700 case INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY
:
2701 FIXME("INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY; STUB\n");
2702 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2705 case INTERNET_OPTION_CODEPAGE_PATH
:
2706 FIXME("INTERNET_OPTION_CODEPAGE_PATH; STUB\n");
2707 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2710 case INTERNET_OPTION_CODEPAGE_EXTRA
:
2711 FIXME("INTERNET_OPTION_CODEPAGE_EXTRA; STUB\n");
2712 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2715 case INTERNET_OPTION_IDN
:
2716 FIXME("INTERNET_OPTION_IDN; STUB\n");
2717 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2720 case INTERNET_OPTION_POLICY
:
2721 SetLastError(ERROR_INVALID_PARAMETER
);
2724 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2725 INTERNET_PER_CONN_OPTION_LISTW
*con
= lpBuffer
;
2730 INTERNET_LoadProxySettings(&pi
);
2732 for (i
= 0; i
< con
->dwOptionCount
; i
++) {
2733 INTERNET_PER_CONN_OPTIONW
*option
= con
->pOptions
+ i
;
2735 switch (option
->dwOption
) {
2736 case INTERNET_PER_CONN_PROXY_SERVER
:
2737 heap_free(pi
.proxy
);
2738 pi
.proxy
= heap_strdupW(option
->Value
.pszValue
);
2741 case INTERNET_PER_CONN_FLAGS
:
2742 if(option
->Value
.dwValue
& PROXY_TYPE_PROXY
)
2743 pi
.proxyEnabled
= 1;
2746 if(option
->Value
.dwValue
!= PROXY_TYPE_DIRECT
)
2747 FIXME("Unhandled flags: 0x%x\n", option
->Value
.dwValue
);
2748 pi
.proxyEnabled
= 0;
2752 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2753 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2754 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2755 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2756 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2757 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2758 case INTERNET_PER_CONN_PROXY_BYPASS
:
2759 FIXME("Unhandled dwOption %d\n", option
->dwOption
);
2763 FIXME("Unknown dwOption %d\n", option
->dwOption
);
2764 SetLastError(ERROR_INVALID_PARAMETER
);
2769 if ((res
= INTERNET_SaveProxySettings(&pi
)))
2774 ret
= (res
== ERROR_SUCCESS
);
2778 FIXME("Option %d STUB\n",dwOption
);
2779 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2785 WININET_Release( lpwhh
);
2791 /***********************************************************************
2792 * InternetSetOptionA (WININET.@)
2794 * Sets an options on the specified handle.
2801 BOOL WINAPI
InternetSetOptionA(HINTERNET hInternet
, DWORD dwOption
,
2802 LPVOID lpBuffer
, DWORD dwBufferLength
)
2810 case INTERNET_OPTION_CALLBACK
:
2812 object_header_t
*lpwh
;
2814 if (!(lpwh
= get_handle_object(hInternet
)))
2816 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2819 WININET_Release(lpwh
);
2820 INTERNET_SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE
);
2823 case INTERNET_OPTION_PROXY
:
2825 LPINTERNET_PROXY_INFOA pi
= (LPINTERNET_PROXY_INFOA
) lpBuffer
;
2826 LPINTERNET_PROXY_INFOW piw
;
2827 DWORD proxlen
, prbylen
;
2830 proxlen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, NULL
, 0);
2831 prbylen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, NULL
, 0);
2832 wlen
= sizeof(*piw
) + proxlen
+ prbylen
;
2833 wbuffer
= heap_alloc(wlen
*sizeof(WCHAR
) );
2834 piw
= (LPINTERNET_PROXY_INFOW
) wbuffer
;
2835 piw
->dwAccessType
= pi
->dwAccessType
;
2836 prox
= (LPWSTR
) &piw
[1];
2837 prby
= &prox
[proxlen
+1];
2838 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, prox
, proxlen
);
2839 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, prby
, prbylen
);
2840 piw
->lpszProxy
= prox
;
2841 piw
->lpszProxyBypass
= prby
;
2844 case INTERNET_OPTION_USER_AGENT
:
2845 case INTERNET_OPTION_USERNAME
:
2846 case INTERNET_OPTION_PASSWORD
:
2847 wlen
= MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2849 wbuffer
= heap_alloc(wlen
*sizeof(WCHAR
) );
2850 MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2853 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2855 INTERNET_PER_CONN_OPTION_LISTW
*listW
;
2856 INTERNET_PER_CONN_OPTION_LISTA
*listA
= lpBuffer
;
2857 wlen
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
2858 wbuffer
= heap_alloc(wlen
);
2861 listW
->dwSize
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
2862 if (listA
->pszConnection
)
2864 wlen
= MultiByteToWideChar( CP_ACP
, 0, listA
->pszConnection
, -1, NULL
, 0 );
2865 listW
->pszConnection
= heap_alloc(wlen
*sizeof(WCHAR
));
2866 MultiByteToWideChar( CP_ACP
, 0, listA
->pszConnection
, -1, listW
->pszConnection
, wlen
);
2869 listW
->pszConnection
= NULL
;
2870 listW
->dwOptionCount
= listA
->dwOptionCount
;
2871 listW
->dwOptionError
= listA
->dwOptionError
;
2872 listW
->pOptions
= heap_alloc(sizeof(INTERNET_PER_CONN_OPTIONW
) * listA
->dwOptionCount
);
2874 for (i
= 0; i
< listA
->dwOptionCount
; ++i
) {
2875 INTERNET_PER_CONN_OPTIONA
*optA
= listA
->pOptions
+ i
;
2876 INTERNET_PER_CONN_OPTIONW
*optW
= listW
->pOptions
+ i
;
2878 optW
->dwOption
= optA
->dwOption
;
2880 switch (optA
->dwOption
) {
2881 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2882 case INTERNET_PER_CONN_PROXY_BYPASS
:
2883 case INTERNET_PER_CONN_PROXY_SERVER
:
2884 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2885 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2886 if (optA
->Value
.pszValue
)
2888 wlen
= MultiByteToWideChar( CP_ACP
, 0, optA
->Value
.pszValue
, -1, NULL
, 0 );
2889 optW
->Value
.pszValue
= heap_alloc(wlen
*sizeof(WCHAR
));
2890 MultiByteToWideChar( CP_ACP
, 0, optA
->Value
.pszValue
, -1, optW
->Value
.pszValue
, wlen
);
2893 optW
->Value
.pszValue
= NULL
;
2895 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2896 case INTERNET_PER_CONN_FLAGS
:
2897 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2898 optW
->Value
.dwValue
= optA
->Value
.dwValue
;
2900 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2901 optW
->Value
.ftValue
= optA
->Value
.ftValue
;
2904 WARN("Unknown PER_CONN dwOption: %d, guessing at conversion to Wide\n", optA
->dwOption
);
2905 optW
->Value
.dwValue
= optA
->Value
.dwValue
;
2913 wlen
= dwBufferLength
;
2916 r
= InternetSetOptionW(hInternet
,dwOption
, wbuffer
, wlen
);
2918 if( lpBuffer
!= wbuffer
)
2920 if (dwOption
== INTERNET_OPTION_PER_CONNECTION_OPTION
)
2922 INTERNET_PER_CONN_OPTION_LISTW
*list
= wbuffer
;
2924 for (i
= 0; i
< list
->dwOptionCount
; ++i
) {
2925 INTERNET_PER_CONN_OPTIONW
*opt
= list
->pOptions
+ i
;
2926 switch (opt
->dwOption
) {
2927 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2928 case INTERNET_PER_CONN_PROXY_BYPASS
:
2929 case INTERNET_PER_CONN_PROXY_SERVER
:
2930 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2931 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2932 heap_free( opt
->Value
.pszValue
);
2938 heap_free( list
->pOptions
);
2940 heap_free( wbuffer
);
2947 /***********************************************************************
2948 * InternetSetOptionExA (WININET.@)
2950 BOOL WINAPI
InternetSetOptionExA(HINTERNET hInternet
, DWORD dwOption
,
2951 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2953 FIXME("Flags %08x ignored\n", dwFlags
);
2954 return InternetSetOptionA( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2957 /***********************************************************************
2958 * InternetSetOptionExW (WININET.@)
2960 BOOL WINAPI
InternetSetOptionExW(HINTERNET hInternet
, DWORD dwOption
,
2961 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2963 FIXME("Flags %08x ignored\n", dwFlags
);
2964 if( dwFlags
& ~ISO_VALID_FLAGS
)
2966 SetLastError( ERROR_INVALID_PARAMETER
);
2969 return InternetSetOptionW( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2972 static const WCHAR WININET_wkday
[7][4] =
2973 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2974 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2975 static const WCHAR WININET_month
[12][4] =
2976 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2977 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2978 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2980 /***********************************************************************
2981 * InternetTimeFromSystemTimeA (WININET.@)
2983 BOOL WINAPI
InternetTimeFromSystemTimeA( const SYSTEMTIME
* time
, DWORD format
, LPSTR string
, DWORD size
)
2986 WCHAR stringW
[INTERNET_RFC1123_BUFSIZE
];
2988 TRACE( "%p 0x%08x %p 0x%08x\n", time
, format
, string
, size
);
2990 if (!time
|| !string
|| format
!= INTERNET_RFC1123_FORMAT
)
2992 SetLastError(ERROR_INVALID_PARAMETER
);
2996 if (size
< INTERNET_RFC1123_BUFSIZE
* sizeof(*string
))
2998 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
3002 ret
= InternetTimeFromSystemTimeW( time
, format
, stringW
, sizeof(stringW
) );
3003 if (ret
) WideCharToMultiByte( CP_ACP
, 0, stringW
, -1, string
, size
, NULL
, NULL
);
3008 /***********************************************************************
3009 * InternetTimeFromSystemTimeW (WININET.@)
3011 BOOL WINAPI
InternetTimeFromSystemTimeW( const SYSTEMTIME
* time
, DWORD format
, LPWSTR string
, DWORD size
)
3013 static const WCHAR date
[] =
3014 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
3015 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
3017 TRACE( "%p 0x%08x %p 0x%08x\n", time
, format
, string
, size
);
3019 if (!time
|| !string
|| format
!= INTERNET_RFC1123_FORMAT
)
3021 SetLastError(ERROR_INVALID_PARAMETER
);
3025 if (size
< INTERNET_RFC1123_BUFSIZE
* sizeof(*string
))
3027 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
3031 sprintfW( string
, date
,
3032 WININET_wkday
[time
->wDayOfWeek
],
3034 WININET_month
[time
->wMonth
- 1],
3043 /***********************************************************************
3044 * InternetTimeToSystemTimeA (WININET.@)
3046 BOOL WINAPI
InternetTimeToSystemTimeA( LPCSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
3051 TRACE( "%s %p 0x%08x\n", debugstr_a(string
), time
, reserved
);
3053 stringW
= heap_strdupAtoW(string
);
3056 ret
= InternetTimeToSystemTimeW( stringW
, time
, reserved
);
3057 heap_free( stringW
);
3062 /***********************************************************************
3063 * InternetTimeToSystemTimeW (WININET.@)
3065 BOOL WINAPI
InternetTimeToSystemTimeW( LPCWSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
3068 const WCHAR
*s
= string
;
3071 TRACE( "%s %p 0x%08x\n", debugstr_w(string
), time
, reserved
);
3073 if (!string
|| !time
) return FALSE
;
3075 /* Windows does this too */
3076 GetSystemTime( time
);
3078 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
3079 * a SYSTEMTIME structure.
3082 while (*s
&& !isalphaW( *s
)) s
++;
3083 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
3084 time
->wDayOfWeek
= 7;
3086 for (i
= 0; i
< 7; i
++)
3088 if (toupperW( WININET_wkday
[i
][0] ) == toupperW( s
[0] ) &&
3089 toupperW( WININET_wkday
[i
][1] ) == toupperW( s
[1] ) &&
3090 toupperW( WININET_wkday
[i
][2] ) == toupperW( s
[2] ) )
3092 time
->wDayOfWeek
= i
;
3097 if (time
->wDayOfWeek
> 6) return TRUE
;
3098 while (*s
&& !isdigitW( *s
)) s
++;
3099 time
->wDay
= strtolW( s
, &end
, 10 );
3102 while (*s
&& !isalphaW( *s
)) s
++;
3103 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
3106 for (i
= 0; i
< 12; i
++)
3108 if (toupperW( WININET_month
[i
][0]) == toupperW( s
[0] ) &&
3109 toupperW( WININET_month
[i
][1]) == toupperW( s
[1] ) &&
3110 toupperW( WININET_month
[i
][2]) == toupperW( s
[2] ) )
3112 time
->wMonth
= i
+ 1;
3116 if (time
->wMonth
== 0) return TRUE
;
3118 while (*s
&& !isdigitW( *s
)) s
++;
3119 if (*s
== '\0') return TRUE
;
3120 time
->wYear
= strtolW( s
, &end
, 10 );
3123 while (*s
&& !isdigitW( *s
)) s
++;
3124 if (*s
== '\0') return TRUE
;
3125 time
->wHour
= strtolW( s
, &end
, 10 );
3128 while (*s
&& !isdigitW( *s
)) s
++;
3129 if (*s
== '\0') return TRUE
;
3130 time
->wMinute
= strtolW( s
, &end
, 10 );
3133 while (*s
&& !isdigitW( *s
)) s
++;
3134 if (*s
== '\0') return TRUE
;
3135 time
->wSecond
= strtolW( s
, &end
, 10 );
3138 time
->wMilliseconds
= 0;
3142 /***********************************************************************
3143 * InternetCheckConnectionW (WININET.@)
3145 * Pings a requested host to check internet connection
3148 * TRUE on success and FALSE on failure. If a failure then
3149 * ERROR_NOT_CONNECTED is placed into GetLastError
3152 BOOL WINAPI
InternetCheckConnectionW( LPCWSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
3155 * this is a kludge which runs the resident ping program and reads the output.
3157 * Anyone have a better idea?
3161 static const CHAR ping
[] = "ping -c 1 ";
3162 static const CHAR redirect
[] = " >/dev/null 2>/dev/null";
3163 CHAR
*command
= NULL
;
3172 * Crack or set the Address
3174 if (lpszUrl
== NULL
)
3177 * According to the doc we are supposed to use the ip for the next
3178 * server in the WnInet internal server database. I have
3179 * no idea what that is or how to get it.
3181 * So someone needs to implement this.
3183 FIXME("Unimplemented with URL of NULL\n");
3188 URL_COMPONENTSW components
;
3190 ZeroMemory(&components
,sizeof(URL_COMPONENTSW
));
3191 components
.lpszHostName
= (LPWSTR
)hostW
;
3192 components
.dwHostNameLength
= 1024;
3194 if (!InternetCrackUrlW(lpszUrl
,0,0,&components
))
3197 TRACE("host name : %s\n",debugstr_w(components
.lpszHostName
));
3198 port
= components
.nPort
;
3199 TRACE("port: %d\n", port
);
3202 if (dwFlags
& FLAG_ICC_FORCE_CONNECTION
)
3204 struct sockaddr_storage saddr
;
3205 socklen_t sa_len
= sizeof(saddr
);
3208 if (!GetAddress(hostW
, port
, (struct sockaddr
*)&saddr
, &sa_len
))
3210 fd
= socket(saddr
.ss_family
, SOCK_STREAM
, 0);
3213 if (connect(fd
, (struct sockaddr
*)&saddr
, sa_len
) == 0)
3221 * Build our ping command
3223 len
= WideCharToMultiByte(CP_UNIXCP
, 0, hostW
, -1, NULL
, 0, NULL
, NULL
);
3224 command
= heap_alloc(strlen(ping
)+len
+strlen(redirect
));
3225 strcpy(command
,ping
);
3226 WideCharToMultiByte(CP_UNIXCP
, 0, hostW
, -1, command
+strlen(ping
), len
, NULL
, NULL
);
3227 strcat(command
,redirect
);
3229 TRACE("Ping command is : %s\n",command
);
3231 status
= system(command
);
3233 TRACE("Ping returned a code of %i\n",status
);
3235 /* Ping return code of 0 indicates success */
3241 heap_free( command
);
3243 INTERNET_SetLastError(ERROR_NOT_CONNECTED
);
3249 /***********************************************************************
3250 * InternetCheckConnectionA (WININET.@)
3252 * Pings a requested host to check internet connection
3255 * TRUE on success and FALSE on failure. If a failure then
3256 * ERROR_NOT_CONNECTED is placed into GetLastError
3259 BOOL WINAPI
InternetCheckConnectionA(LPCSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
3265 url
= heap_strdupAtoW(lpszUrl
);
3270 rc
= InternetCheckConnectionW(url
, dwFlags
, dwReserved
);
3277 /**********************************************************
3278 * INTERNET_InternetOpenUrlW (internal)
3283 * handle of connection or NULL on failure
3285 static HINTERNET
INTERNET_InternetOpenUrlW(appinfo_t
*hIC
, LPCWSTR lpszUrl
,
3286 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3288 URL_COMPONENTSW urlComponents
;
3289 WCHAR protocol
[32], hostName
[MAXHOSTNAME
], userName
[1024];
3290 WCHAR password
[1024], path
[2048], extra
[1024];
3291 HINTERNET client
= NULL
, client1
= NULL
;
3294 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hIC
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
3295 dwHeadersLength
, dwFlags
, dwContext
);
3297 urlComponents
.dwStructSize
= sizeof(URL_COMPONENTSW
);
3298 urlComponents
.lpszScheme
= protocol
;
3299 urlComponents
.dwSchemeLength
= 32;
3300 urlComponents
.lpszHostName
= hostName
;
3301 urlComponents
.dwHostNameLength
= MAXHOSTNAME
;
3302 urlComponents
.lpszUserName
= userName
;
3303 urlComponents
.dwUserNameLength
= 1024;
3304 urlComponents
.lpszPassword
= password
;
3305 urlComponents
.dwPasswordLength
= 1024;
3306 urlComponents
.lpszUrlPath
= path
;
3307 urlComponents
.dwUrlPathLength
= 2048;
3308 urlComponents
.lpszExtraInfo
= extra
;
3309 urlComponents
.dwExtraInfoLength
= 1024;
3310 if(!InternetCrackUrlW(lpszUrl
, strlenW(lpszUrl
), 0, &urlComponents
))
3312 switch(urlComponents
.nScheme
) {
3313 case INTERNET_SCHEME_FTP
:
3314 if(urlComponents
.nPort
== 0)
3315 urlComponents
.nPort
= INTERNET_DEFAULT_FTP_PORT
;
3316 client
= FTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
3317 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
);
3320 client1
= FtpOpenFileW(client
, path
, GENERIC_READ
, dwFlags
, dwContext
);
3321 if(client1
== NULL
) {
3322 InternetCloseHandle(client
);
3327 case INTERNET_SCHEME_HTTP
:
3328 case INTERNET_SCHEME_HTTPS
: {
3329 static const WCHAR szStars
[] = { '*','/','*', 0 };
3330 LPCWSTR accept
[2] = { szStars
, NULL
};
3331 if(urlComponents
.nPort
== 0) {
3332 if(urlComponents
.nScheme
== INTERNET_SCHEME_HTTP
)
3333 urlComponents
.nPort
= INTERNET_DEFAULT_HTTP_PORT
;
3335 urlComponents
.nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
3337 if (urlComponents
.nScheme
== INTERNET_SCHEME_HTTPS
) dwFlags
|= INTERNET_FLAG_SECURE
;
3339 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
3340 res
= HTTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
3341 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
, &client
);
3342 if(res
!= ERROR_SUCCESS
) {
3343 INTERNET_SetLastError(res
);
3347 if (urlComponents
.dwExtraInfoLength
) {
3349 DWORD len
= urlComponents
.dwUrlPathLength
+ urlComponents
.dwExtraInfoLength
+ 1;
3351 if (!(path_extra
= heap_alloc(len
* sizeof(WCHAR
))))
3353 InternetCloseHandle(client
);
3356 strcpyW(path_extra
, urlComponents
.lpszUrlPath
);
3357 strcatW(path_extra
, urlComponents
.lpszExtraInfo
);
3358 client1
= HttpOpenRequestW(client
, NULL
, path_extra
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
3359 heap_free(path_extra
);
3362 client1
= HttpOpenRequestW(client
, NULL
, path
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
3364 if(client1
== NULL
) {
3365 InternetCloseHandle(client
);
3368 HttpAddRequestHeadersW(client1
, lpszHeaders
, dwHeadersLength
, HTTP_ADDREQ_FLAG_ADD
);
3369 if (!HttpSendRequestW(client1
, NULL
, 0, NULL
, 0) &&
3370 GetLastError() != ERROR_IO_PENDING
) {
3371 InternetCloseHandle(client1
);
3376 case INTERNET_SCHEME_GOPHER
:
3377 /* gopher doesn't seem to be implemented in wine, but it's supposed
3378 * to be supported by InternetOpenUrlA. */
3380 SetLastError(ERROR_INTERNET_UNRECOGNIZED_SCHEME
);
3384 TRACE(" %p <--\n", client1
);
3389 /**********************************************************
3390 * InternetOpenUrlW (WININET.@)
3395 * handle of connection or NULL on failure
3397 static void AsyncInternetOpenUrlProc(WORKREQUEST
*workRequest
)
3399 struct WORKREQ_INTERNETOPENURLW
const *req
= &workRequest
->u
.InternetOpenUrlW
;
3400 appinfo_t
*hIC
= (appinfo_t
*) workRequest
->hdr
;
3404 INTERNET_InternetOpenUrlW(hIC
, req
->lpszUrl
,
3405 req
->lpszHeaders
, req
->dwHeadersLength
, req
->dwFlags
, req
->dwContext
);
3406 heap_free(req
->lpszUrl
);
3407 heap_free(req
->lpszHeaders
);
3410 HINTERNET WINAPI
InternetOpenUrlW(HINTERNET hInternet
, LPCWSTR lpszUrl
,
3411 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3413 HINTERNET ret
= NULL
;
3414 appinfo_t
*hIC
= NULL
;
3416 if (TRACE_ON(wininet
)) {
3417 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hInternet
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
3418 dwHeadersLength
, dwFlags
, dwContext
);
3420 dump_INTERNET_FLAGS(dwFlags
);
3425 SetLastError(ERROR_INVALID_PARAMETER
);
3429 hIC
= (appinfo_t
*)get_handle_object( hInternet
);
3430 if (NULL
== hIC
|| hIC
->hdr
.htype
!= WH_HINIT
) {
3431 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
3435 if (hIC
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
) {
3436 WORKREQUEST workRequest
;
3437 struct WORKREQ_INTERNETOPENURLW
*req
;
3439 workRequest
.asyncproc
= AsyncInternetOpenUrlProc
;
3440 workRequest
.hdr
= WININET_AddRef( &hIC
->hdr
);
3441 req
= &workRequest
.u
.InternetOpenUrlW
;
3442 req
->lpszUrl
= heap_strdupW(lpszUrl
);
3443 req
->lpszHeaders
= heap_strdupW(lpszHeaders
);
3444 req
->dwHeadersLength
= dwHeadersLength
;
3445 req
->dwFlags
= dwFlags
;
3446 req
->dwContext
= dwContext
;
3448 INTERNET_AsyncCall(&workRequest
);
3450 * This is from windows.
3452 SetLastError(ERROR_IO_PENDING
);
3454 ret
= INTERNET_InternetOpenUrlW(hIC
, lpszUrl
, lpszHeaders
, dwHeadersLength
, dwFlags
, dwContext
);
3459 WININET_Release( &hIC
->hdr
);
3460 TRACE(" %p <--\n", ret
);
3465 /**********************************************************
3466 * InternetOpenUrlA (WININET.@)
3471 * handle of connection or NULL on failure
3473 HINTERNET WINAPI
InternetOpenUrlA(HINTERNET hInternet
, LPCSTR lpszUrl
,
3474 LPCSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3476 HINTERNET rc
= NULL
;
3477 DWORD lenHeaders
= 0;
3478 LPWSTR szUrl
= NULL
;
3479 LPWSTR szHeaders
= NULL
;
3484 szUrl
= heap_strdupAtoW(lpszUrl
);
3490 lenHeaders
= MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, NULL
, 0 );
3491 szHeaders
= heap_alloc(lenHeaders
*sizeof(WCHAR
));
3496 MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, szHeaders
, lenHeaders
);
3499 rc
= InternetOpenUrlW(hInternet
, szUrl
, szHeaders
,
3500 lenHeaders
, dwFlags
, dwContext
);
3503 heap_free(szHeaders
);
3508 static LPWITHREADERROR
INTERNET_AllocThreadError(void)
3510 LPWITHREADERROR lpwite
= heap_alloc(sizeof(*lpwite
));
3514 lpwite
->dwError
= 0;
3515 lpwite
->response
[0] = '\0';
3518 if (!TlsSetValue(g_dwTlsErrIndex
, lpwite
))
3527 /***********************************************************************
3528 * INTERNET_SetLastError (internal)
3530 * Set last thread specific error
3535 void INTERNET_SetLastError(DWORD dwError
)
3537 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3540 lpwite
= INTERNET_AllocThreadError();
3542 SetLastError(dwError
);
3544 lpwite
->dwError
= dwError
;
3548 /***********************************************************************
3549 * INTERNET_GetLastError (internal)
3551 * Get last thread specific error
3556 DWORD
INTERNET_GetLastError(void)
3558 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3559 if (!lpwite
) return 0;
3560 /* TlsGetValue clears last error, so set it again here */
3561 SetLastError(lpwite
->dwError
);
3562 return lpwite
->dwError
;
3566 /***********************************************************************
3567 * INTERNET_WorkerThreadFunc (internal)
3569 * Worker thread execution function
3574 static DWORD CALLBACK
INTERNET_WorkerThreadFunc(LPVOID lpvParam
)
3576 LPWORKREQUEST lpRequest
= lpvParam
;
3577 WORKREQUEST workRequest
;
3581 workRequest
= *lpRequest
;
3582 heap_free(lpRequest
);
3584 workRequest
.asyncproc(&workRequest
);
3585 WININET_Release( workRequest
.hdr
);
3587 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
3589 heap_free(TlsGetValue(g_dwTlsErrIndex
));
3590 TlsSetValue(g_dwTlsErrIndex
, NULL
);
3596 /***********************************************************************
3597 * INTERNET_AsyncCall (internal)
3599 * Retrieves work request from queue
3604 DWORD
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
)
3607 LPWORKREQUEST lpNewRequest
;
3611 lpNewRequest
= heap_alloc(sizeof(WORKREQUEST
));
3613 return ERROR_OUTOFMEMORY
;
3615 *lpNewRequest
= *lpWorkRequest
;
3617 bSuccess
= QueueUserWorkItem(INTERNET_WorkerThreadFunc
, lpNewRequest
, WT_EXECUTELONGFUNCTION
);
3620 heap_free(lpNewRequest
);
3621 return ERROR_INTERNET_ASYNC_THREAD_FAILED
;
3623 return ERROR_SUCCESS
;
3627 /***********************************************************************
3628 * INTERNET_GetResponseBuffer (internal)
3633 LPSTR
INTERNET_GetResponseBuffer(void)
3635 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3637 lpwite
= INTERNET_AllocThreadError();
3639 return lpwite
->response
;
3642 /***********************************************************************
3643 * INTERNET_GetNextLine (internal)
3645 * Parse next line in directory string listing
3648 * Pointer to beginning of next line
3653 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
)
3656 BOOL bSuccess
= FALSE
;
3658 LPSTR lpszBuffer
= INTERNET_GetResponseBuffer();
3663 pfd
.events
= POLLIN
;
3665 while (nRecv
< MAX_REPLY_LEN
)
3667 if (poll(&pfd
,1, RESPONSE_TIMEOUT
* 1000) > 0)
3669 if (recv(nSocket
, &lpszBuffer
[nRecv
], 1, 0) <= 0)
3671 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS
);
3675 if (lpszBuffer
[nRecv
] == '\n')
3680 if (lpszBuffer
[nRecv
] != '\r')
3685 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT
);
3693 lpszBuffer
[nRecv
] = '\0';
3695 TRACE(":%d %s\n", nRecv
, lpszBuffer
);
3704 /**********************************************************
3705 * InternetQueryDataAvailable (WININET.@)
3707 * Determines how much data is available to be read.
3710 * TRUE on success, FALSE if an error occurred. If
3711 * INTERNET_FLAG_ASYNC was specified in InternetOpen, and
3712 * no data is presently available, FALSE is returned with
3713 * the last error ERROR_IO_PENDING; a callback with status
3714 * INTERNET_STATUS_REQUEST_COMPLETE will be sent when more
3715 * data is available.
3717 BOOL WINAPI
InternetQueryDataAvailable( HINTERNET hFile
,
3718 LPDWORD lpdwNumberOfBytesAvailble
,
3719 DWORD dwFlags
, DWORD_PTR dwContext
)
3721 object_header_t
*hdr
;
3724 TRACE("(%p %p %x %lx)\n", hFile
, lpdwNumberOfBytesAvailble
, dwFlags
, dwContext
);
3726 hdr
= get_handle_object( hFile
);
3728 SetLastError(ERROR_INVALID_HANDLE
);
3732 if(hdr
->vtbl
->QueryDataAvailable
) {
3733 res
= hdr
->vtbl
->QueryDataAvailable(hdr
, lpdwNumberOfBytesAvailble
, dwFlags
, dwContext
);
3735 WARN("wrong handle\n");
3736 res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
3739 WININET_Release(hdr
);
3741 if(res
!= ERROR_SUCCESS
)
3743 return res
== ERROR_SUCCESS
;
3747 /***********************************************************************
3748 * InternetLockRequestFile (WININET.@)
3750 BOOL WINAPI
InternetLockRequestFile( HINTERNET hInternet
, HANDLE
3757 BOOL WINAPI
InternetUnlockRequestFile( HANDLE hLockHandle
)
3764 /***********************************************************************
3765 * InternetAutodial (WININET.@)
3767 * On windows this function is supposed to dial the default internet
3768 * connection. We don't want to have Wine dial out to the internet so
3769 * we return TRUE by default. It might be nice to check if we are connected.
3776 BOOL WINAPI
InternetAutodial(DWORD dwFlags
, HWND hwndParent
)
3780 /* Tell that we are connected to the internet. */
3784 /***********************************************************************
3785 * InternetAutodialHangup (WININET.@)
3787 * Hangs up a connection made with InternetAutodial
3796 BOOL WINAPI
InternetAutodialHangup(DWORD dwReserved
)
3800 /* we didn't dial, we don't disconnect */
3804 /***********************************************************************
3805 * InternetCombineUrlA (WININET.@)
3807 * Combine a base URL with a relative URL
3815 BOOL WINAPI
InternetCombineUrlA(LPCSTR lpszBaseUrl
, LPCSTR lpszRelativeUrl
,
3816 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3821 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_a(lpszBaseUrl
), debugstr_a(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3823 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3824 dwFlags
^= ICU_NO_ENCODE
;
3825 hr
=UrlCombineA(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3830 /***********************************************************************
3831 * InternetCombineUrlW (WININET.@)
3833 * Combine a base URL with a relative URL
3841 BOOL WINAPI
InternetCombineUrlW(LPCWSTR lpszBaseUrl
, LPCWSTR lpszRelativeUrl
,
3842 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3847 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(lpszBaseUrl
), debugstr_w(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3849 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3850 dwFlags
^= ICU_NO_ENCODE
;
3851 hr
=UrlCombineW(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3856 /* max port num is 65535 => 5 digits */
3857 #define MAX_WORD_DIGITS 5
3859 #define URL_GET_COMP_LENGTH(url, component) ((url)->dw##component##Length ? \
3860 (url)->dw##component##Length : strlenW((url)->lpsz##component))
3861 #define URL_GET_COMP_LENGTHA(url, component) ((url)->dw##component##Length ? \
3862 (url)->dw##component##Length : strlen((url)->lpsz##component))
3864 static BOOL
url_uses_default_port(INTERNET_SCHEME nScheme
, INTERNET_PORT nPort
)
3866 if ((nScheme
== INTERNET_SCHEME_HTTP
) &&
3867 (nPort
== INTERNET_DEFAULT_HTTP_PORT
))
3869 if ((nScheme
== INTERNET_SCHEME_HTTPS
) &&
3870 (nPort
== INTERNET_DEFAULT_HTTPS_PORT
))
3872 if ((nScheme
== INTERNET_SCHEME_FTP
) &&
3873 (nPort
== INTERNET_DEFAULT_FTP_PORT
))
3875 if ((nScheme
== INTERNET_SCHEME_GOPHER
) &&
3876 (nPort
== INTERNET_DEFAULT_GOPHER_PORT
))
3879 if (nPort
== INTERNET_INVALID_PORT_NUMBER
)
3885 /* opaque urls do not fit into the standard url hierarchy and don't have
3886 * two following slashes */
3887 static inline BOOL
scheme_is_opaque(INTERNET_SCHEME nScheme
)
3889 return (nScheme
!= INTERNET_SCHEME_FTP
) &&
3890 (nScheme
!= INTERNET_SCHEME_GOPHER
) &&
3891 (nScheme
!= INTERNET_SCHEME_HTTP
) &&
3892 (nScheme
!= INTERNET_SCHEME_HTTPS
) &&
3893 (nScheme
!= INTERNET_SCHEME_FILE
);
3896 static LPCWSTR
INTERNET_GetSchemeString(INTERNET_SCHEME scheme
)
3899 if (scheme
< INTERNET_SCHEME_FIRST
)
3901 index
= scheme
- INTERNET_SCHEME_FIRST
;
3902 if (index
>= sizeof(url_schemes
)/sizeof(url_schemes
[0]))
3904 return (LPCWSTR
)url_schemes
[index
];
3907 /* we can calculate using ansi strings because we're just
3908 * calculating string length, not size
3910 static BOOL
calc_url_length(LPURL_COMPONENTSW lpUrlComponents
,
3911 LPDWORD lpdwUrlLength
)
3913 INTERNET_SCHEME nScheme
;
3917 if (lpUrlComponents
->lpszScheme
)
3919 DWORD dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Scheme
);
3920 *lpdwUrlLength
+= dwLen
;
3921 nScheme
= GetInternetSchemeW(lpUrlComponents
->lpszScheme
, dwLen
);
3927 nScheme
= lpUrlComponents
->nScheme
;
3929 if (nScheme
== INTERNET_SCHEME_DEFAULT
)
3930 nScheme
= INTERNET_SCHEME_HTTP
;
3931 scheme
= INTERNET_GetSchemeString(nScheme
);
3932 *lpdwUrlLength
+= strlenW(scheme
);
3935 (*lpdwUrlLength
)++; /* ':' */
3936 if (!scheme_is_opaque(nScheme
) || lpUrlComponents
->lpszHostName
)
3937 *lpdwUrlLength
+= strlen("//");
3939 if (lpUrlComponents
->lpszUserName
)
3941 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, UserName
);
3942 *lpdwUrlLength
+= strlen("@");
3946 if (lpUrlComponents
->lpszPassword
)
3948 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
3953 if (lpUrlComponents
->lpszPassword
)
3955 *lpdwUrlLength
+= strlen(":");
3956 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, Password
);
3959 if (lpUrlComponents
->lpszHostName
)
3961 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, HostName
);
3963 if (!url_uses_default_port(nScheme
, lpUrlComponents
->nPort
))
3965 char szPort
[MAX_WORD_DIGITS
+1];
3967 sprintf(szPort
, "%d", lpUrlComponents
->nPort
);
3968 *lpdwUrlLength
+= strlen(szPort
);
3969 *lpdwUrlLength
+= strlen(":");
3972 if (lpUrlComponents
->lpszUrlPath
&& *lpUrlComponents
->lpszUrlPath
!= '/')
3973 (*lpdwUrlLength
)++; /* '/' */
3976 if (lpUrlComponents
->lpszUrlPath
)
3977 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, UrlPath
);
3979 if (lpUrlComponents
->lpszExtraInfo
)
3980 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, ExtraInfo
);
3985 static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents
, LPURL_COMPONENTSW urlCompW
)
3989 ZeroMemory(urlCompW
, sizeof(URL_COMPONENTSW
));
3991 urlCompW
->dwStructSize
= sizeof(URL_COMPONENTSW
);
3992 urlCompW
->dwSchemeLength
= lpUrlComponents
->dwSchemeLength
;
3993 urlCompW
->nScheme
= lpUrlComponents
->nScheme
;
3994 urlCompW
->dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
3995 urlCompW
->nPort
= lpUrlComponents
->nPort
;
3996 urlCompW
->dwUserNameLength
= lpUrlComponents
->dwUserNameLength
;
3997 urlCompW
->dwPasswordLength
= lpUrlComponents
->dwPasswordLength
;
3998 urlCompW
->dwUrlPathLength
= lpUrlComponents
->dwUrlPathLength
;
3999 urlCompW
->dwExtraInfoLength
= lpUrlComponents
->dwExtraInfoLength
;
4001 if (lpUrlComponents
->lpszScheme
)
4003 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, Scheme
) + 1;
4004 urlCompW
->lpszScheme
= heap_alloc(len
* sizeof(WCHAR
));
4005 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszScheme
,
4006 -1, urlCompW
->lpszScheme
, len
);
4009 if (lpUrlComponents
->lpszHostName
)
4011 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, HostName
) + 1;
4012 urlCompW
->lpszHostName
= heap_alloc(len
* sizeof(WCHAR
));
4013 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszHostName
,
4014 -1, urlCompW
->lpszHostName
, len
);
4017 if (lpUrlComponents
->lpszUserName
)
4019 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, UserName
) + 1;
4020 urlCompW
->lpszUserName
= heap_alloc(len
* sizeof(WCHAR
));
4021 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszUserName
,
4022 -1, urlCompW
->lpszUserName
, len
);
4025 if (lpUrlComponents
->lpszPassword
)
4027 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, Password
) + 1;
4028 urlCompW
->lpszPassword
= heap_alloc(len
* sizeof(WCHAR
));
4029 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszPassword
,
4030 -1, urlCompW
->lpszPassword
, len
);
4033 if (lpUrlComponents
->lpszUrlPath
)
4035 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, UrlPath
) + 1;
4036 urlCompW
->lpszUrlPath
= heap_alloc(len
* sizeof(WCHAR
));
4037 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszUrlPath
,
4038 -1, urlCompW
->lpszUrlPath
, len
);
4041 if (lpUrlComponents
->lpszExtraInfo
)
4043 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, ExtraInfo
) + 1;
4044 urlCompW
->lpszExtraInfo
= heap_alloc(len
* sizeof(WCHAR
));
4045 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszExtraInfo
,
4046 -1, urlCompW
->lpszExtraInfo
, len
);
4050 /***********************************************************************
4051 * InternetCreateUrlA (WININET.@)
4053 * See InternetCreateUrlW.
4055 BOOL WINAPI
InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents
, DWORD dwFlags
,
4056 LPSTR lpszUrl
, LPDWORD lpdwUrlLength
)
4060 URL_COMPONENTSW urlCompW
;
4062 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents
, dwFlags
, lpszUrl
, lpdwUrlLength
);
4064 if (!lpUrlComponents
|| lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSW
) || !lpdwUrlLength
)
4066 SetLastError(ERROR_INVALID_PARAMETER
);
4070 convert_urlcomp_atow(lpUrlComponents
, &urlCompW
);
4073 urlW
= heap_alloc(*lpdwUrlLength
* sizeof(WCHAR
));
4075 ret
= InternetCreateUrlW(&urlCompW
, dwFlags
, urlW
, lpdwUrlLength
);
4077 if (!ret
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
))
4078 *lpdwUrlLength
/= sizeof(WCHAR
);
4080 /* on success, lpdwUrlLength points to the size of urlW in WCHARS
4081 * minus one, so add one to leave room for NULL terminator
4084 WideCharToMultiByte(CP_ACP
, 0, urlW
, -1, lpszUrl
, *lpdwUrlLength
+ 1, NULL
, NULL
);
4086 heap_free(urlCompW
.lpszScheme
);
4087 heap_free(urlCompW
.lpszHostName
);
4088 heap_free(urlCompW
.lpszUserName
);
4089 heap_free(urlCompW
.lpszPassword
);
4090 heap_free(urlCompW
.lpszUrlPath
);
4091 heap_free(urlCompW
.lpszExtraInfo
);
4096 /***********************************************************************
4097 * InternetCreateUrlW (WININET.@)
4099 * Creates a URL from its component parts.
4102 * lpUrlComponents [I] URL Components.
4103 * dwFlags [I] Flags. See notes.
4104 * lpszUrl [I] Buffer in which to store the created URL.
4105 * lpdwUrlLength [I/O] On input, the length of the buffer pointed to by
4106 * lpszUrl in characters. On output, the number of bytes
4107 * required to store the URL including terminator.
4111 * The dwFlags parameter can be zero or more of the following:
4112 *|ICU_ESCAPE - Generates escape sequences for unsafe characters in the path and extra info of the URL.
4119 BOOL WINAPI
InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents
, DWORD dwFlags
,
4120 LPWSTR lpszUrl
, LPDWORD lpdwUrlLength
)
4123 INTERNET_SCHEME nScheme
;
4125 static const WCHAR slashSlashW
[] = {'/','/'};
4126 static const WCHAR fmtW
[] = {'%','u',0};
4128 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents
, dwFlags
, lpszUrl
, lpdwUrlLength
);
4130 if (!lpUrlComponents
|| lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSW
) || !lpdwUrlLength
)
4132 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
4136 if (!calc_url_length(lpUrlComponents
, &dwLen
))
4139 if (!lpszUrl
|| *lpdwUrlLength
< dwLen
)
4141 *lpdwUrlLength
= (dwLen
+ 1) * sizeof(WCHAR
);
4142 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
4146 *lpdwUrlLength
= dwLen
;
4151 if (lpUrlComponents
->lpszScheme
)
4153 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Scheme
);
4154 memcpy(lpszUrl
, lpUrlComponents
->lpszScheme
, dwLen
* sizeof(WCHAR
));
4157 nScheme
= GetInternetSchemeW(lpUrlComponents
->lpszScheme
, dwLen
);
4162 nScheme
= lpUrlComponents
->nScheme
;
4164 if (nScheme
== INTERNET_SCHEME_DEFAULT
)
4165 nScheme
= INTERNET_SCHEME_HTTP
;
4167 scheme
= INTERNET_GetSchemeString(nScheme
);
4168 dwLen
= strlenW(scheme
);
4169 memcpy(lpszUrl
, scheme
, dwLen
* sizeof(WCHAR
));
4173 /* all schemes are followed by at least a colon */
4177 if (!scheme_is_opaque(nScheme
) || lpUrlComponents
->lpszHostName
)
4179 memcpy(lpszUrl
, slashSlashW
, sizeof(slashSlashW
));
4180 lpszUrl
+= sizeof(slashSlashW
)/sizeof(slashSlashW
[0]);
4183 if (lpUrlComponents
->lpszUserName
)
4185 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, UserName
);
4186 memcpy(lpszUrl
, lpUrlComponents
->lpszUserName
, dwLen
* sizeof(WCHAR
));
4189 if (lpUrlComponents
->lpszPassword
)
4194 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Password
);
4195 memcpy(lpszUrl
, lpUrlComponents
->lpszPassword
, dwLen
* sizeof(WCHAR
));
4203 if (lpUrlComponents
->lpszHostName
)
4205 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, HostName
);
4206 memcpy(lpszUrl
, lpUrlComponents
->lpszHostName
, dwLen
* sizeof(WCHAR
));
4209 if (!url_uses_default_port(nScheme
, lpUrlComponents
->nPort
))
4211 WCHAR szPort
[MAX_WORD_DIGITS
+1];
4213 sprintfW(szPort
, fmtW
, lpUrlComponents
->nPort
);
4216 dwLen
= strlenW(szPort
);
4217 memcpy(lpszUrl
, szPort
, dwLen
* sizeof(WCHAR
));
4221 /* add slash between hostname and path if necessary */
4222 if (lpUrlComponents
->lpszUrlPath
&& *lpUrlComponents
->lpszUrlPath
!= '/')
4229 if (lpUrlComponents
->lpszUrlPath
)
4231 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, UrlPath
);
4232 memcpy(lpszUrl
, lpUrlComponents
->lpszUrlPath
, dwLen
* sizeof(WCHAR
));
4236 if (lpUrlComponents
->lpszExtraInfo
)
4238 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, ExtraInfo
);
4239 memcpy(lpszUrl
, lpUrlComponents
->lpszExtraInfo
, dwLen
* sizeof(WCHAR
));
4248 /***********************************************************************
4249 * InternetConfirmZoneCrossingA (WININET.@)
4252 DWORD WINAPI
InternetConfirmZoneCrossingA( HWND hWnd
, LPSTR szUrlPrev
, LPSTR szUrlNew
, BOOL bPost
)
4254 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_a(szUrlPrev
), debugstr_a(szUrlNew
), bPost
);
4255 return ERROR_SUCCESS
;
4258 /***********************************************************************
4259 * InternetConfirmZoneCrossingW (WININET.@)
4262 DWORD WINAPI
InternetConfirmZoneCrossingW( HWND hWnd
, LPWSTR szUrlPrev
, LPWSTR szUrlNew
, BOOL bPost
)
4264 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_w(szUrlPrev
), debugstr_w(szUrlNew
), bPost
);
4265 return ERROR_SUCCESS
;
4268 static DWORD zone_preference
= 3;
4270 /***********************************************************************
4271 * PrivacySetZonePreferenceW (WININET.@)
4273 DWORD WINAPI
PrivacySetZonePreferenceW( DWORD zone
, DWORD type
, DWORD
template, LPCWSTR preference
)
4275 FIXME( "%x %x %x %s: stub\n", zone
, type
, template, debugstr_w(preference
) );
4277 zone_preference
= template;
4281 /***********************************************************************
4282 * PrivacyGetZonePreferenceW (WININET.@)
4284 DWORD WINAPI
PrivacyGetZonePreferenceW( DWORD zone
, DWORD type
, LPDWORD
template,
4285 LPWSTR preference
, LPDWORD length
)
4287 FIXME( "%x %x %p %p %p: stub\n", zone
, type
, template, preference
, length
);
4289 if (template) *template = zone_preference
;
4293 DWORD WINAPI
InternetDialA( HWND hwndParent
, LPSTR lpszConnectoid
, DWORD dwFlags
,
4294 DWORD_PTR
* lpdwConnection
, DWORD dwReserved
)
4296 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
4297 lpdwConnection
, dwReserved
);
4298 return ERROR_SUCCESS
;
4301 DWORD WINAPI
InternetDialW( HWND hwndParent
, LPWSTR lpszConnectoid
, DWORD dwFlags
,
4302 DWORD_PTR
* lpdwConnection
, DWORD dwReserved
)
4304 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
4305 lpdwConnection
, dwReserved
);
4306 return ERROR_SUCCESS
;
4309 BOOL WINAPI
InternetGoOnlineA( LPSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
4311 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_a(lpszURL
), hwndParent
, dwReserved
);
4315 BOOL WINAPI
InternetGoOnlineW( LPWSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
4317 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_w(lpszURL
), hwndParent
, dwReserved
);
4321 DWORD WINAPI
InternetHangUp( DWORD_PTR dwConnection
, DWORD dwReserved
)
4323 FIXME("(0x%08lx, 0x%08x) stub\n", dwConnection
, dwReserved
);
4324 return ERROR_SUCCESS
;
4327 BOOL WINAPI
CreateMD5SSOHash( PWSTR pszChallengeInfo
, PWSTR pwszRealm
, PWSTR pwszTarget
,
4330 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo
), debugstr_w(pwszRealm
),
4331 debugstr_w(pwszTarget
), pbHexHash
);
4335 BOOL WINAPI
ResumeSuspendedDownload( HINTERNET hInternet
, DWORD dwError
)
4337 FIXME("(%p, 0x%08x) stub\n", hInternet
, dwError
);
4341 BOOL WINAPI
InternetQueryFortezzaStatus(DWORD
*a
, DWORD_PTR b
)
4343 FIXME("(%p, %08lx) stub\n", a
, b
);