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
;
108 DWORD dwProxyEnabled
;
109 LPWSTR lpszProxyServer
;
110 LPWSTR lpszProxyBypass
;
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 WININET_hModule
= hinstDLL
;
297 case DLL_THREAD_ATTACH
:
300 case DLL_THREAD_DETACH
:
301 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
303 LPVOID lpwite
= TlsGetValue(g_dwTlsErrIndex
);
304 HeapFree(GetProcessHeap(), 0, lpwite
);
308 case DLL_PROCESS_DETACH
:
309 collect_connections(TRUE
);
312 URLCacheContainers_DeleteAll();
314 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
316 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex
));
317 TlsFree(g_dwTlsErrIndex
);
325 /***********************************************************************
326 * INTERNET_SaveProxySettings
328 * Stores the proxy settings given by lpwai into the registry
331 * ERROR_SUCCESS if no error, or error code on fail
333 static LONG
INTERNET_SaveProxySettings( proxyinfo_t
*lpwpi
)
338 if ((ret
= RegOpenKeyW( HKEY_CURRENT_USER
, szInternetSettings
, &key
)))
341 if ((ret
= RegSetValueExW( key
, szProxyEnable
, 0, REG_DWORD
, (BYTE
*)&lpwpi
->dwProxyEnabled
, sizeof(DWORD
))))
347 if (lpwpi
->lpszProxyServer
)
349 if ((ret
= RegSetValueExW( key
, szProxyServer
, 0, REG_SZ
, (BYTE
*)lpwpi
->lpszProxyServer
, sizeof(WCHAR
) * (lstrlenW(lpwpi
->lpszProxyServer
) + 1))))
357 if ((ret
= RegDeleteValueW( key
, szProxyServer
)))
365 return ERROR_SUCCESS
;
368 /***********************************************************************
369 * INTERNET_FindProxyForProtocol
371 * Searches the proxy string for a proxy of the given protocol.
372 * Returns the found proxy, or the default proxy if none of the given
376 * szProxy [In] proxy string to search
377 * proto [In] protocol to search for, e.g. "http"
378 * foundProxy [Out] found proxy
379 * foundProxyLen [In/Out] length of foundProxy buffer, in WCHARs
382 * TRUE if a proxy is found, FALSE if not. If foundProxy is too short,
383 * *foundProxyLen is set to the required size in WCHARs, including the
384 * NULL terminator, and the last error is set to ERROR_INSUFFICIENT_BUFFER.
386 BOOL
INTERNET_FindProxyForProtocol(LPCWSTR szProxy
, LPCWSTR proto
, WCHAR
*foundProxy
, DWORD
*foundProxyLen
)
391 TRACE("(%s, %s)\n", debugstr_w(szProxy
), debugstr_w(proto
));
393 /* First, look for the specified protocol (proto=scheme://host:port) */
394 for (ptr
= szProxy
; !ret
&& ptr
&& *ptr
; )
398 if (!(end
= strchrW(ptr
, ' ')))
399 end
= ptr
+ strlenW(ptr
);
400 if ((equal
= strchrW(ptr
, '=')) && equal
< end
&&
401 equal
- ptr
== strlenW(proto
) &&
402 !strncmpiW(proto
, ptr
, strlenW(proto
)))
404 if (end
- equal
> *foundProxyLen
)
406 WARN("buffer too short for %s\n",
407 debugstr_wn(equal
+ 1, end
- equal
- 1));
408 *foundProxyLen
= end
- equal
;
409 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
413 memcpy(foundProxy
, equal
+ 1, (end
- equal
) * sizeof(WCHAR
));
414 foundProxy
[end
- equal
] = 0;
425 /* It wasn't found: look for no protocol */
426 for (ptr
= szProxy
; !ret
&& ptr
&& *ptr
; )
430 if (!(end
= strchrW(ptr
, ' ')))
431 end
= ptr
+ strlenW(ptr
);
432 if (!(equal
= strchrW(ptr
, '=')))
434 if (end
- ptr
+ 1 > *foundProxyLen
)
436 WARN("buffer too short for %s\n",
437 debugstr_wn(ptr
, end
- ptr
));
438 *foundProxyLen
= end
- ptr
+ 1;
439 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
443 memcpy(foundProxy
, ptr
, (end
- ptr
) * sizeof(WCHAR
));
444 foundProxy
[end
- ptr
] = 0;
455 TRACE("found proxy for %s: %s\n", debugstr_w(proto
),
456 debugstr_w(foundProxy
));
460 /***********************************************************************
461 * InternetInitializeAutoProxyDll (WININET.@)
463 * Setup the internal proxy
472 BOOL WINAPI
InternetInitializeAutoProxyDll(DWORD dwReserved
)
475 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
479 /***********************************************************************
480 * DetectAutoProxyUrl (WININET.@)
482 * Auto detect the proxy url
488 BOOL WINAPI
DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl
,
489 DWORD dwAutoProxyUrlLength
, DWORD dwDetectFlags
)
492 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
496 static void FreeProxyInfo( proxyinfo_t
*lpwpi
)
498 HeapFree(GetProcessHeap(), 0, lpwpi
->lpszProxyServer
);
499 HeapFree(GetProcessHeap(), 0, lpwpi
->lpszProxyBypass
);
502 /***********************************************************************
503 * INTERNET_LoadProxySettings
505 * Loads proxy information from the registry or environment into lpwpi.
507 * The caller should call FreeProxyInfo when done with lpwpi.
510 * The proxy may be specified in the form 'http=proxy.my.org'
511 * Presumably that means there can be ftp=ftpproxy.my.org too.
513 static LONG
INTERNET_LoadProxySettings( proxyinfo_t
*lpwpi
)
520 if ((ret
= RegOpenKeyW( HKEY_CURRENT_USER
, szInternetSettings
, &key
)))
524 if (RegQueryValueExW( key
, szProxyEnable
, NULL
, &type
, (BYTE
*)&lpwpi
->dwProxyEnabled
, &len
) || type
!= REG_DWORD
)
526 lpwpi
->dwProxyEnabled
= 0;
527 if((ret
= RegSetValueExW( key
, szProxyEnable
, 0, REG_DWORD
, (BYTE
*)&lpwpi
->dwProxyEnabled
, sizeof(DWORD
) )))
534 if (!(envproxy
= getenv( "http_proxy" )) || lpwpi
->dwProxyEnabled
)
536 TRACE("Proxy is enabled.\n");
538 /* figure out how much memory the proxy setting takes */
539 if (!RegQueryValueExW( key
, szProxyServer
, NULL
, &type
, NULL
, &len
) && len
&& (type
== REG_SZ
))
542 static const WCHAR szHttp
[] = {'h','t','t','p','=',0};
544 if (!(szProxy
= heap_alloc(len
)))
547 return ERROR_OUTOFMEMORY
;
549 RegQueryValueExW( key
, szProxyServer
, NULL
, &type
, (BYTE
*)szProxy
, &len
);
551 /* find the http proxy, and strip away everything else */
552 p
= strstrW( szProxy
, szHttp
);
555 p
+= lstrlenW( szHttp
);
556 lstrcpyW( szProxy
, p
);
558 p
= strchrW( szProxy
, ' ' );
561 lpwpi
->lpszProxyServer
= szProxy
;
563 TRACE("http proxy = %s\n", debugstr_w(lpwpi
->lpszProxyServer
));
567 TRACE("No proxy server settings in registry.\n");
568 lpwpi
->lpszProxyServer
= NULL
;
575 len
= MultiByteToWideChar( CP_UNIXCP
, 0, envproxy
, -1, NULL
, 0 );
576 if (!(envproxyW
= heap_alloc(len
* sizeof(WCHAR
))))
577 return ERROR_OUTOFMEMORY
;
578 MultiByteToWideChar( CP_UNIXCP
, 0, envproxy
, -1, envproxyW
, len
);
580 lpwpi
->dwProxyEnabled
= 1;
581 lpwpi
->lpszProxyServer
= envproxyW
;
583 TRACE("http proxy (from environment) = %s\n", debugstr_w(lpwpi
->lpszProxyServer
));
587 lpwpi
->lpszProxyBypass
= NULL
;
589 return ERROR_SUCCESS
;
592 /***********************************************************************
593 * INTERNET_ConfigureProxy
595 static BOOL
INTERNET_ConfigureProxy( appinfo_t
*lpwai
)
599 if (INTERNET_LoadProxySettings( &wpi
))
602 if (wpi
.dwProxyEnabled
)
604 lpwai
->accessType
= INTERNET_OPEN_TYPE_PROXY
;
605 lpwai
->proxy
= wpi
.lpszProxyServer
;
609 lpwai
->accessType
= INTERNET_OPEN_TYPE_DIRECT
;
613 /***********************************************************************
614 * dump_INTERNET_FLAGS
616 * Helper function to TRACE the internet flags.
622 static void dump_INTERNET_FLAGS(DWORD dwFlags
)
624 #define FE(x) { x, #x }
625 static const wininet_flag_info flag
[] = {
626 FE(INTERNET_FLAG_RELOAD
),
627 FE(INTERNET_FLAG_RAW_DATA
),
628 FE(INTERNET_FLAG_EXISTING_CONNECT
),
629 FE(INTERNET_FLAG_ASYNC
),
630 FE(INTERNET_FLAG_PASSIVE
),
631 FE(INTERNET_FLAG_NO_CACHE_WRITE
),
632 FE(INTERNET_FLAG_MAKE_PERSISTENT
),
633 FE(INTERNET_FLAG_FROM_CACHE
),
634 FE(INTERNET_FLAG_SECURE
),
635 FE(INTERNET_FLAG_KEEP_CONNECTION
),
636 FE(INTERNET_FLAG_NO_AUTO_REDIRECT
),
637 FE(INTERNET_FLAG_READ_PREFETCH
),
638 FE(INTERNET_FLAG_NO_COOKIES
),
639 FE(INTERNET_FLAG_NO_AUTH
),
640 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL
),
641 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
),
642 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
),
643 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
),
644 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID
),
645 FE(INTERNET_FLAG_RESYNCHRONIZE
),
646 FE(INTERNET_FLAG_HYPERLINK
),
647 FE(INTERNET_FLAG_NO_UI
),
648 FE(INTERNET_FLAG_PRAGMA_NOCACHE
),
649 FE(INTERNET_FLAG_CACHE_ASYNC
),
650 FE(INTERNET_FLAG_FORMS_SUBMIT
),
651 FE(INTERNET_FLAG_NEED_FILE
),
652 FE(INTERNET_FLAG_TRANSFER_ASCII
),
653 FE(INTERNET_FLAG_TRANSFER_BINARY
)
658 for (i
= 0; i
< (sizeof(flag
) / sizeof(flag
[0])); i
++) {
659 if (flag
[i
].val
& dwFlags
) {
660 TRACE(" %s", flag
[i
].name
);
661 dwFlags
&= ~flag
[i
].val
;
665 TRACE(" Unknown flags (%08x)\n", dwFlags
);
670 /***********************************************************************
671 * INTERNET_CloseHandle (internal)
673 * Close internet handle
676 static VOID
APPINFO_Destroy(object_header_t
*hdr
)
678 appinfo_t
*lpwai
= (appinfo_t
*)hdr
;
682 HeapFree(GetProcessHeap(), 0, lpwai
->agent
);
683 HeapFree(GetProcessHeap(), 0, lpwai
->proxy
);
684 HeapFree(GetProcessHeap(), 0, lpwai
->proxyBypass
);
685 HeapFree(GetProcessHeap(), 0, lpwai
->proxyUsername
);
686 HeapFree(GetProcessHeap(), 0, lpwai
->proxyPassword
);
689 static DWORD
APPINFO_QueryOption(object_header_t
*hdr
, DWORD option
, void *buffer
, DWORD
*size
, BOOL unicode
)
691 appinfo_t
*ai
= (appinfo_t
*)hdr
;
694 case INTERNET_OPTION_HANDLE_TYPE
:
695 TRACE("INTERNET_OPTION_HANDLE_TYPE\n");
697 if (*size
< sizeof(ULONG
))
698 return ERROR_INSUFFICIENT_BUFFER
;
700 *size
= sizeof(DWORD
);
701 *(DWORD
*)buffer
= INTERNET_HANDLE_TYPE_INTERNET
;
702 return ERROR_SUCCESS
;
704 case INTERNET_OPTION_USER_AGENT
: {
707 TRACE("INTERNET_OPTION_USER_AGENT\n");
712 DWORD len
= ai
->agent
? strlenW(ai
->agent
) : 0;
714 *size
= (len
+ 1) * sizeof(WCHAR
);
715 if(!buffer
|| bufsize
< *size
)
716 return ERROR_INSUFFICIENT_BUFFER
;
719 strcpyW(buffer
, ai
->agent
);
721 *(WCHAR
*)buffer
= 0;
722 /* If the buffer is copied, the returned length doesn't include
723 * the NULL terminator.
725 *size
= len
* sizeof(WCHAR
);
728 *size
= WideCharToMultiByte(CP_ACP
, 0, ai
->agent
, -1, NULL
, 0, NULL
, NULL
);
731 if(!buffer
|| bufsize
< *size
)
732 return ERROR_INSUFFICIENT_BUFFER
;
735 WideCharToMultiByte(CP_ACP
, 0, ai
->agent
, -1, buffer
, *size
, NULL
, NULL
);
738 /* If the buffer is copied, the returned length doesn't include
739 * the NULL terminator.
744 return ERROR_SUCCESS
;
747 case INTERNET_OPTION_PROXY
:
749 INTERNET_PROXY_INFOW
*pi
= (INTERNET_PROXY_INFOW
*)buffer
;
750 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
751 LPWSTR proxy
, proxy_bypass
;
754 proxyBytesRequired
= (lstrlenW(ai
->proxy
) + 1) * sizeof(WCHAR
);
756 proxyBypassBytesRequired
= (lstrlenW(ai
->proxyBypass
) + 1) * sizeof(WCHAR
);
757 if (*size
< sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
)
759 *size
= sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
760 return ERROR_INSUFFICIENT_BUFFER
;
762 proxy
= (LPWSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOW
));
763 proxy_bypass
= (LPWSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
);
765 pi
->dwAccessType
= ai
->accessType
;
766 pi
->lpszProxy
= NULL
;
767 pi
->lpszProxyBypass
= NULL
;
769 lstrcpyW(proxy
, ai
->proxy
);
770 pi
->lpszProxy
= proxy
;
773 if (ai
->proxyBypass
) {
774 lstrcpyW(proxy_bypass
, ai
->proxyBypass
);
775 pi
->lpszProxyBypass
= proxy_bypass
;
778 *size
= sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
779 return ERROR_SUCCESS
;
781 INTERNET_PROXY_INFOA
*pi
= (INTERNET_PROXY_INFOA
*)buffer
;
782 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
783 LPSTR proxy
, proxy_bypass
;
786 proxyBytesRequired
= WideCharToMultiByte(CP_ACP
, 0, ai
->proxy
, -1, NULL
, 0, NULL
, NULL
);
788 proxyBypassBytesRequired
= WideCharToMultiByte(CP_ACP
, 0, ai
->proxyBypass
, -1,
789 NULL
, 0, NULL
, NULL
);
790 if (*size
< sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
)
792 *size
= sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
793 return ERROR_INSUFFICIENT_BUFFER
;
795 proxy
= (LPSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOA
));
796 proxy_bypass
= (LPSTR
)((LPBYTE
)buffer
+ sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
);
798 pi
->dwAccessType
= ai
->accessType
;
799 pi
->lpszProxy
= NULL
;
800 pi
->lpszProxyBypass
= NULL
;
802 WideCharToMultiByte(CP_ACP
, 0, ai
->proxy
, -1, proxy
, proxyBytesRequired
, NULL
, NULL
);
803 pi
->lpszProxy
= proxy
;
806 if (ai
->proxyBypass
) {
807 WideCharToMultiByte(CP_ACP
, 0, ai
->proxyBypass
, -1, proxy_bypass
,
808 proxyBypassBytesRequired
, NULL
, NULL
);
809 pi
->lpszProxyBypass
= proxy_bypass
;
812 *size
= sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
+ proxyBypassBytesRequired
;
813 return ERROR_SUCCESS
;
817 return INET_QueryOption(hdr
, option
, buffer
, size
, unicode
);
820 static const object_vtbl_t APPINFOVtbl
= {
833 /***********************************************************************
834 * InternetOpenW (WININET.@)
836 * Per-application initialization of wininet
839 * HINTERNET on success
843 HINTERNET WINAPI
InternetOpenW(LPCWSTR lpszAgent
, DWORD dwAccessType
,
844 LPCWSTR lpszProxy
, LPCWSTR lpszProxyBypass
, DWORD dwFlags
)
846 appinfo_t
*lpwai
= NULL
;
848 if (TRACE_ON(wininet
)) {
849 #define FE(x) { x, #x }
850 static const wininet_flag_info access_type
[] = {
851 FE(INTERNET_OPEN_TYPE_PRECONFIG
),
852 FE(INTERNET_OPEN_TYPE_DIRECT
),
853 FE(INTERNET_OPEN_TYPE_PROXY
),
854 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY
)
858 const char *access_type_str
= "Unknown";
860 TRACE("(%s, %i, %s, %s, %i)\n", debugstr_w(lpszAgent
), dwAccessType
,
861 debugstr_w(lpszProxy
), debugstr_w(lpszProxyBypass
), dwFlags
);
862 for (i
= 0; i
< (sizeof(access_type
) / sizeof(access_type
[0])); i
++) {
863 if (access_type
[i
].val
== dwAccessType
) {
864 access_type_str
= access_type
[i
].name
;
868 TRACE(" access type : %s\n", access_type_str
);
870 dump_INTERNET_FLAGS(dwFlags
);
873 /* Clear any error information */
874 INTERNET_SetLastError(0);
876 lpwai
= alloc_object(NULL
, &APPINFOVtbl
, sizeof(appinfo_t
));
878 SetLastError(ERROR_OUTOFMEMORY
);
882 lpwai
->hdr
.htype
= WH_HINIT
;
883 lpwai
->hdr
.dwFlags
= dwFlags
;
884 lpwai
->accessType
= dwAccessType
;
885 lpwai
->proxyUsername
= NULL
;
886 lpwai
->proxyPassword
= NULL
;
888 lpwai
->agent
= heap_strdupW(lpszAgent
);
889 if(dwAccessType
== INTERNET_OPEN_TYPE_PRECONFIG
)
890 INTERNET_ConfigureProxy( lpwai
);
892 lpwai
->proxy
= heap_strdupW(lpszProxy
);
893 lpwai
->proxyBypass
= heap_strdupW(lpszProxyBypass
);
895 TRACE("returning %p\n", lpwai
);
897 return lpwai
->hdr
.hInternet
;
901 /***********************************************************************
902 * InternetOpenA (WININET.@)
904 * Per-application initialization of wininet
907 * HINTERNET on success
911 HINTERNET WINAPI
InternetOpenA(LPCSTR lpszAgent
, DWORD dwAccessType
,
912 LPCSTR lpszProxy
, LPCSTR lpszProxyBypass
, DWORD dwFlags
)
914 WCHAR
*szAgent
, *szProxy
, *szBypass
;
917 TRACE("(%s, 0x%08x, %s, %s, 0x%08x)\n", debugstr_a(lpszAgent
),
918 dwAccessType
, debugstr_a(lpszProxy
), debugstr_a(lpszProxyBypass
), dwFlags
);
920 szAgent
= heap_strdupAtoW(lpszAgent
);
921 szProxy
= heap_strdupAtoW(lpszProxy
);
922 szBypass
= heap_strdupAtoW(lpszProxyBypass
);
924 rc
= InternetOpenW(szAgent
, dwAccessType
, szProxy
, szBypass
, dwFlags
);
926 HeapFree(GetProcessHeap(), 0, szAgent
);
927 HeapFree(GetProcessHeap(), 0, szProxy
);
928 HeapFree(GetProcessHeap(), 0, szBypass
);
933 /***********************************************************************
934 * InternetGetLastResponseInfoA (WININET.@)
936 * Return last wininet error description on the calling thread
939 * TRUE on success of writing to buffer
943 BOOL WINAPI
InternetGetLastResponseInfoA(LPDWORD lpdwError
,
944 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
946 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
952 *lpdwError
= lpwite
->dwError
;
955 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
956 *lpdwBufferLength
= strlen(lpszBuffer
);
959 *lpdwBufferLength
= 0;
964 *lpdwBufferLength
= 0;
970 /***********************************************************************
971 * InternetGetLastResponseInfoW (WININET.@)
973 * Return last wininet error description on the calling thread
976 * TRUE on success of writing to buffer
980 BOOL WINAPI
InternetGetLastResponseInfoW(LPDWORD lpdwError
,
981 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
983 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
989 *lpdwError
= lpwite
->dwError
;
992 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
993 *lpdwBufferLength
= lstrlenW(lpszBuffer
);
996 *lpdwBufferLength
= 0;
1001 *lpdwBufferLength
= 0;
1007 /***********************************************************************
1008 * InternetGetConnectedState (WININET.@)
1010 * Return connected state
1014 * if lpdwStatus is not null, return the status (off line,
1015 * modem, lan...) in it.
1016 * FALSE if not connected
1018 BOOL WINAPI
InternetGetConnectedState(LPDWORD lpdwStatus
, DWORD dwReserved
)
1020 TRACE("(%p, 0x%08x)\n", lpdwStatus
, dwReserved
);
1023 WARN("always returning LAN connection.\n");
1024 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
1030 /***********************************************************************
1031 * InternetGetConnectedStateExW (WININET.@)
1033 * Return connected state
1037 * lpdwStatus [O] Flags specifying the status of the internet connection.
1038 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
1039 * dwNameLen [I] Size of the buffer, in characters.
1040 * dwReserved [I] Reserved. Must be set to 0.
1044 * if lpdwStatus is not null, return the status (off line,
1045 * modem, lan...) in it.
1046 * FALSE if not connected
1049 * If the system has no available network connections, an empty string is
1050 * stored in lpszConnectionName. If there is a LAN connection, a localized
1051 * "LAN Connection" string is stored. Presumably, if only a dial-up
1052 * connection is available then the name of the dial-up connection is
1053 * returned. Why any application, other than the "Internet Settings" CPL,
1054 * would want to use this function instead of the simpler InternetGetConnectedStateW
1055 * function is beyond me.
1057 BOOL WINAPI
InternetGetConnectedStateExW(LPDWORD lpdwStatus
, LPWSTR lpszConnectionName
,
1058 DWORD dwNameLen
, DWORD dwReserved
)
1060 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
1067 WARN("always returning LAN connection.\n");
1068 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
1070 return LoadStringW(WININET_hModule
, IDS_LANCONNECTION
, lpszConnectionName
, dwNameLen
);
1074 /***********************************************************************
1075 * InternetGetConnectedStateExA (WININET.@)
1077 BOOL WINAPI
InternetGetConnectedStateExA(LPDWORD lpdwStatus
, LPSTR lpszConnectionName
,
1078 DWORD dwNameLen
, DWORD dwReserved
)
1080 LPWSTR lpwszConnectionName
= NULL
;
1083 TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
1085 if (lpszConnectionName
&& dwNameLen
> 0)
1086 lpwszConnectionName
= heap_alloc(dwNameLen
* sizeof(WCHAR
));
1088 rc
= InternetGetConnectedStateExW(lpdwStatus
,lpwszConnectionName
, dwNameLen
,
1090 if (rc
&& lpwszConnectionName
)
1092 WideCharToMultiByte(CP_ACP
,0,lpwszConnectionName
,-1,lpszConnectionName
,
1093 dwNameLen
, NULL
, NULL
);
1095 HeapFree(GetProcessHeap(),0,lpwszConnectionName
);
1102 /***********************************************************************
1103 * InternetConnectW (WININET.@)
1105 * Open a ftp, gopher or http session
1108 * HINTERNET a session handle on success
1112 HINTERNET WINAPI
InternetConnectW(HINTERNET hInternet
,
1113 LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
1114 LPCWSTR lpszUserName
, LPCWSTR lpszPassword
,
1115 DWORD dwService
, DWORD dwFlags
, DWORD_PTR dwContext
)
1118 HINTERNET rc
= NULL
;
1119 DWORD res
= ERROR_SUCCESS
;
1121 TRACE("(%p, %s, %i, %s, %s, %i, %i, %lx)\n", hInternet
, debugstr_w(lpszServerName
),
1122 nServerPort
, debugstr_w(lpszUserName
), debugstr_w(lpszPassword
),
1123 dwService
, dwFlags
, dwContext
);
1125 if (!lpszServerName
)
1127 SetLastError(ERROR_INVALID_PARAMETER
);
1131 hIC
= (appinfo_t
*)get_handle_object( hInternet
);
1132 if ( (hIC
== NULL
) || (hIC
->hdr
.htype
!= WH_HINIT
) )
1134 res
= ERROR_INVALID_HANDLE
;
1140 case INTERNET_SERVICE_FTP
:
1141 rc
= FTP_Connect(hIC
, lpszServerName
, nServerPort
,
1142 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0);
1144 res
= INTERNET_GetLastError();
1147 case INTERNET_SERVICE_HTTP
:
1148 res
= HTTP_Connect(hIC
, lpszServerName
, nServerPort
,
1149 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0, &rc
);
1152 case INTERNET_SERVICE_GOPHER
:
1158 WININET_Release( &hIC
->hdr
);
1160 TRACE("returning %p\n", rc
);
1166 /***********************************************************************
1167 * InternetConnectA (WININET.@)
1169 * Open a ftp, gopher or http session
1172 * HINTERNET a session handle on success
1176 HINTERNET WINAPI
InternetConnectA(HINTERNET hInternet
,
1177 LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
1178 LPCSTR lpszUserName
, LPCSTR lpszPassword
,
1179 DWORD dwService
, DWORD dwFlags
, DWORD_PTR dwContext
)
1181 HINTERNET rc
= NULL
;
1182 LPWSTR szServerName
;
1186 szServerName
= heap_strdupAtoW(lpszServerName
);
1187 szUserName
= heap_strdupAtoW(lpszUserName
);
1188 szPassword
= heap_strdupAtoW(lpszPassword
);
1190 rc
= InternetConnectW(hInternet
, szServerName
, nServerPort
,
1191 szUserName
, szPassword
, dwService
, dwFlags
, dwContext
);
1193 HeapFree(GetProcessHeap(), 0, szServerName
);
1194 HeapFree(GetProcessHeap(), 0, szUserName
);
1195 HeapFree(GetProcessHeap(), 0, szPassword
);
1200 /***********************************************************************
1201 * InternetFindNextFileA (WININET.@)
1203 * Continues a file search from a previous call to FindFirstFile
1210 BOOL WINAPI
InternetFindNextFileA(HINTERNET hFind
, LPVOID lpvFindData
)
1213 WIN32_FIND_DATAW fd
;
1215 ret
= InternetFindNextFileW(hFind
, lpvFindData
?&fd
:NULL
);
1217 WININET_find_data_WtoA(&fd
, (LPWIN32_FIND_DATAA
)lpvFindData
);
1221 /***********************************************************************
1222 * InternetFindNextFileW (WININET.@)
1224 * Continues a file search from a previous call to FindFirstFile
1231 BOOL WINAPI
InternetFindNextFileW(HINTERNET hFind
, LPVOID lpvFindData
)
1233 object_header_t
*hdr
;
1238 hdr
= get_handle_object(hFind
);
1240 WARN("Invalid handle\n");
1241 SetLastError(ERROR_INVALID_HANDLE
);
1245 if(hdr
->vtbl
->FindNextFileW
) {
1246 res
= hdr
->vtbl
->FindNextFileW(hdr
, lpvFindData
);
1248 WARN("Handle doesn't support NextFile\n");
1249 res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
1252 WININET_Release(hdr
);
1254 if(res
!= ERROR_SUCCESS
)
1256 return res
== ERROR_SUCCESS
;
1259 /***********************************************************************
1260 * InternetCloseHandle (WININET.@)
1262 * Generic close handle function
1269 BOOL WINAPI
InternetCloseHandle(HINTERNET hInternet
)
1271 object_header_t
*obj
;
1273 TRACE("%p\n", hInternet
);
1275 obj
= get_handle_object( hInternet
);
1277 SetLastError(ERROR_INVALID_HANDLE
);
1281 invalidate_handle(obj
);
1282 WININET_Release(obj
);
1288 /***********************************************************************
1289 * ConvertUrlComponentValue (Internal)
1291 * Helper function for InternetCrackUrlA
1294 static void ConvertUrlComponentValue(LPSTR
* lppszComponent
, LPDWORD dwComponentLen
,
1295 LPWSTR lpwszComponent
, DWORD dwwComponentLen
,
1296 LPCSTR lpszStart
, LPCWSTR lpwszStart
)
1298 TRACE("%p %d %p %d %p %p\n", *lppszComponent
, *dwComponentLen
, lpwszComponent
, dwwComponentLen
, lpszStart
, lpwszStart
);
1299 if (*dwComponentLen
!= 0)
1301 DWORD nASCIILength
=WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,NULL
,0,NULL
,NULL
);
1302 if (*lppszComponent
== NULL
)
1306 int offset
= WideCharToMultiByte(CP_ACP
, 0, lpwszStart
, lpwszComponent
-lpwszStart
, NULL
, 0, NULL
, NULL
);
1307 *lppszComponent
= (LPSTR
)lpszStart
+ offset
;
1310 *lppszComponent
= NULL
;
1312 *dwComponentLen
= nASCIILength
;
1316 DWORD ncpylen
= min((*dwComponentLen
)-1, nASCIILength
);
1317 WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,*lppszComponent
,ncpylen
+1,NULL
,NULL
);
1318 (*lppszComponent
)[ncpylen
]=0;
1319 *dwComponentLen
= ncpylen
;
1325 /***********************************************************************
1326 * InternetCrackUrlA (WININET.@)
1328 * See InternetCrackUrlW.
1330 BOOL WINAPI
InternetCrackUrlA(LPCSTR lpszUrl
, DWORD dwUrlLength
, DWORD dwFlags
,
1331 LPURL_COMPONENTSA lpUrlComponents
)
1334 URL_COMPONENTSW UCW
;
1336 WCHAR
*lpwszUrl
, *hostname
= NULL
, *username
= NULL
, *password
= NULL
, *path
= NULL
,
1337 *scheme
= NULL
, *extra
= NULL
;
1339 TRACE("(%s %u %x %p)\n",
1340 lpszUrl
? debugstr_an(lpszUrl
, dwUrlLength
? dwUrlLength
: strlen(lpszUrl
)) : "(null)",
1341 dwUrlLength
, dwFlags
, lpUrlComponents
);
1343 if (!lpszUrl
|| !*lpszUrl
|| !lpUrlComponents
||
1344 lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSA
))
1346 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1352 nLength
=MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,NULL
,0);
1354 /* if dwUrlLength=-1 then nLength includes null but length to
1355 InternetCrackUrlW should not include it */
1356 if (dwUrlLength
== -1) nLength
--;
1358 lpwszUrl
= heap_alloc((nLength
+ 1) * sizeof(WCHAR
));
1359 MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,lpwszUrl
,nLength
+ 1);
1360 lpwszUrl
[nLength
] = '\0';
1362 memset(&UCW
,0,sizeof(UCW
));
1363 UCW
.dwStructSize
= sizeof(URL_COMPONENTSW
);
1364 if (lpUrlComponents
->dwHostNameLength
)
1366 UCW
.dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
1367 if (lpUrlComponents
->lpszHostName
)
1369 hostname
= heap_alloc(UCW
.dwHostNameLength
* sizeof(WCHAR
));
1370 UCW
.lpszHostName
= hostname
;
1373 if (lpUrlComponents
->dwUserNameLength
)
1375 UCW
.dwUserNameLength
= lpUrlComponents
->dwUserNameLength
;
1376 if (lpUrlComponents
->lpszUserName
)
1378 username
= heap_alloc(UCW
.dwUserNameLength
* sizeof(WCHAR
));
1379 UCW
.lpszUserName
= username
;
1382 if (lpUrlComponents
->dwPasswordLength
)
1384 UCW
.dwPasswordLength
= lpUrlComponents
->dwPasswordLength
;
1385 if (lpUrlComponents
->lpszPassword
)
1387 password
= heap_alloc(UCW
.dwPasswordLength
* sizeof(WCHAR
));
1388 UCW
.lpszPassword
= password
;
1391 if (lpUrlComponents
->dwUrlPathLength
)
1393 UCW
.dwUrlPathLength
= lpUrlComponents
->dwUrlPathLength
;
1394 if (lpUrlComponents
->lpszUrlPath
)
1396 path
= heap_alloc(UCW
.dwUrlPathLength
* sizeof(WCHAR
));
1397 UCW
.lpszUrlPath
= path
;
1400 if (lpUrlComponents
->dwSchemeLength
)
1402 UCW
.dwSchemeLength
= lpUrlComponents
->dwSchemeLength
;
1403 if (lpUrlComponents
->lpszScheme
)
1405 scheme
= heap_alloc(UCW
.dwSchemeLength
* sizeof(WCHAR
));
1406 UCW
.lpszScheme
= scheme
;
1409 if (lpUrlComponents
->dwExtraInfoLength
)
1411 UCW
.dwExtraInfoLength
= lpUrlComponents
->dwExtraInfoLength
;
1412 if (lpUrlComponents
->lpszExtraInfo
)
1414 extra
= heap_alloc(UCW
.dwExtraInfoLength
* sizeof(WCHAR
));
1415 UCW
.lpszExtraInfo
= extra
;
1418 if ((ret
= InternetCrackUrlW(lpwszUrl
, nLength
, dwFlags
, &UCW
)))
1420 ConvertUrlComponentValue(&lpUrlComponents
->lpszHostName
, &lpUrlComponents
->dwHostNameLength
,
1421 UCW
.lpszHostName
, UCW
.dwHostNameLength
, lpszUrl
, lpwszUrl
);
1422 ConvertUrlComponentValue(&lpUrlComponents
->lpszUserName
, &lpUrlComponents
->dwUserNameLength
,
1423 UCW
.lpszUserName
, UCW
.dwUserNameLength
, lpszUrl
, lpwszUrl
);
1424 ConvertUrlComponentValue(&lpUrlComponents
->lpszPassword
, &lpUrlComponents
->dwPasswordLength
,
1425 UCW
.lpszPassword
, UCW
.dwPasswordLength
, lpszUrl
, lpwszUrl
);
1426 ConvertUrlComponentValue(&lpUrlComponents
->lpszUrlPath
, &lpUrlComponents
->dwUrlPathLength
,
1427 UCW
.lpszUrlPath
, UCW
.dwUrlPathLength
, lpszUrl
, lpwszUrl
);
1428 ConvertUrlComponentValue(&lpUrlComponents
->lpszScheme
, &lpUrlComponents
->dwSchemeLength
,
1429 UCW
.lpszScheme
, UCW
.dwSchemeLength
, lpszUrl
, lpwszUrl
);
1430 ConvertUrlComponentValue(&lpUrlComponents
->lpszExtraInfo
, &lpUrlComponents
->dwExtraInfoLength
,
1431 UCW
.lpszExtraInfo
, UCW
.dwExtraInfoLength
, lpszUrl
, lpwszUrl
);
1433 lpUrlComponents
->nScheme
= UCW
.nScheme
;
1434 lpUrlComponents
->nPort
= UCW
.nPort
;
1436 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_a(lpszUrl
),
1437 debugstr_an(lpUrlComponents
->lpszScheme
, lpUrlComponents
->dwSchemeLength
),
1438 debugstr_an(lpUrlComponents
->lpszHostName
, lpUrlComponents
->dwHostNameLength
),
1439 debugstr_an(lpUrlComponents
->lpszUrlPath
, lpUrlComponents
->dwUrlPathLength
),
1440 debugstr_an(lpUrlComponents
->lpszExtraInfo
, lpUrlComponents
->dwExtraInfoLength
));
1442 HeapFree(GetProcessHeap(), 0, lpwszUrl
);
1443 HeapFree(GetProcessHeap(), 0, hostname
);
1444 HeapFree(GetProcessHeap(), 0, username
);
1445 HeapFree(GetProcessHeap(), 0, password
);
1446 HeapFree(GetProcessHeap(), 0, path
);
1447 HeapFree(GetProcessHeap(), 0, scheme
);
1448 HeapFree(GetProcessHeap(), 0, extra
);
1452 static const WCHAR url_schemes
[][7] =
1455 {'g','o','p','h','e','r',0},
1456 {'h','t','t','p',0},
1457 {'h','t','t','p','s',0},
1458 {'f','i','l','e',0},
1459 {'n','e','w','s',0},
1460 {'m','a','i','l','t','o',0},
1464 /***********************************************************************
1465 * GetInternetSchemeW (internal)
1471 * INTERNET_SCHEME_UNKNOWN on failure
1474 static INTERNET_SCHEME
GetInternetSchemeW(LPCWSTR lpszScheme
, DWORD nMaxCmp
)
1478 TRACE("%s %d\n",debugstr_wn(lpszScheme
, nMaxCmp
), nMaxCmp
);
1480 if(lpszScheme
==NULL
)
1481 return INTERNET_SCHEME_UNKNOWN
;
1483 for (i
= 0; i
< sizeof(url_schemes
)/sizeof(url_schemes
[0]); i
++)
1484 if (!strncmpW(lpszScheme
, url_schemes
[i
], nMaxCmp
))
1485 return INTERNET_SCHEME_FIRST
+ i
;
1487 return INTERNET_SCHEME_UNKNOWN
;
1490 /***********************************************************************
1491 * SetUrlComponentValueW (Internal)
1493 * Helper function for InternetCrackUrlW
1496 * lppszComponent [O] Holds the returned string
1497 * dwComponentLen [I] Holds the size of lppszComponent
1498 * [O] Holds the length of the string in lppszComponent without '\0'
1499 * lpszStart [I] Holds the string to copy from
1500 * len [I] Holds the length of lpszStart without '\0'
1507 static BOOL
SetUrlComponentValueW(LPWSTR
* lppszComponent
, LPDWORD dwComponentLen
, LPCWSTR lpszStart
, DWORD len
)
1509 TRACE("%s (%d)\n", debugstr_wn(lpszStart
,len
), len
);
1511 if ( (*dwComponentLen
== 0) && (*lppszComponent
== NULL
) )
1514 if (*dwComponentLen
!= 0 || *lppszComponent
== NULL
)
1516 if (*lppszComponent
== NULL
)
1518 *lppszComponent
= (LPWSTR
)lpszStart
;
1519 *dwComponentLen
= len
;
1523 DWORD ncpylen
= min((*dwComponentLen
)-1, len
);
1524 memcpy(*lppszComponent
, lpszStart
, ncpylen
*sizeof(WCHAR
));
1525 (*lppszComponent
)[ncpylen
] = '\0';
1526 *dwComponentLen
= ncpylen
;
1533 /***********************************************************************
1534 * InternetCrackUrlW (WININET.@)
1536 * Break up URL into its components
1542 BOOL WINAPI
InternetCrackUrlW(LPCWSTR lpszUrl_orig
, DWORD dwUrlLength_orig
, DWORD dwFlags
,
1543 LPURL_COMPONENTSW lpUC
)
1547 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1550 LPCWSTR lpszParam
= NULL
;
1551 BOOL bIsAbsolute
= FALSE
;
1552 LPCWSTR lpszap
, lpszUrl
= lpszUrl_orig
;
1553 LPCWSTR lpszcp
= NULL
;
1554 LPWSTR lpszUrl_decode
= NULL
;
1555 DWORD dwUrlLength
= dwUrlLength_orig
;
1557 TRACE("(%s %u %x %p)\n",
1558 lpszUrl
? debugstr_wn(lpszUrl
, dwUrlLength
? dwUrlLength
: strlenW(lpszUrl
)) : "(null)",
1559 dwUrlLength
, dwFlags
, lpUC
);
1561 if (!lpszUrl_orig
|| !*lpszUrl_orig
|| !lpUC
)
1563 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1566 if (!dwUrlLength
) dwUrlLength
= strlenW(lpszUrl
);
1568 if (dwFlags
& ICU_DECODE
)
1571 DWORD len
= dwUrlLength
+ 1;
1573 if (!(url_tmp
= heap_alloc(len
* sizeof(WCHAR
))))
1575 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
1578 memcpy(url_tmp
, lpszUrl_orig
, dwUrlLength
* sizeof(WCHAR
));
1579 url_tmp
[dwUrlLength
] = 0;
1580 if (!(lpszUrl_decode
= heap_alloc(len
* sizeof(WCHAR
))))
1582 HeapFree(GetProcessHeap(), 0, url_tmp
);
1583 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
1586 if (InternetCanonicalizeUrlW(url_tmp
, lpszUrl_decode
, &len
, ICU_DECODE
| ICU_NO_ENCODE
))
1589 lpszUrl
= lpszUrl_decode
;
1591 HeapFree(GetProcessHeap(), 0, url_tmp
);
1595 /* Determine if the URI is absolute. */
1596 while (lpszap
- lpszUrl
< dwUrlLength
)
1598 if (isalnumW(*lpszap
) || *lpszap
== '+' || *lpszap
== '.' || *lpszap
== '-')
1603 if ((*lpszap
== ':') && (lpszap
- lpszUrl
>= 2))
1610 lpszcp
= lpszUrl
; /* Relative url */
1616 lpUC
->nScheme
= INTERNET_SCHEME_UNKNOWN
;
1617 lpUC
->nPort
= INTERNET_INVALID_PORT_NUMBER
;
1619 /* Parse <params> */
1620 lpszParam
= memchrW(lpszap
, ';', dwUrlLength
- (lpszap
- lpszUrl
));
1622 lpszParam
= memchrW(lpszap
, '?', dwUrlLength
- (lpszap
- lpszUrl
));
1624 lpszParam
= memchrW(lpszap
, '#', dwUrlLength
- (lpszap
- lpszUrl
));
1626 SetUrlComponentValueW(&lpUC
->lpszExtraInfo
, &lpUC
->dwExtraInfoLength
,
1627 lpszParam
, lpszParam
? dwUrlLength
-(lpszParam
-lpszUrl
) : 0);
1629 if (bIsAbsolute
) /* Parse <protocol>:[//<net_loc>] */
1633 /* Get scheme first. */
1634 lpUC
->nScheme
= GetInternetSchemeW(lpszUrl
, lpszcp
- lpszUrl
);
1635 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
,
1636 lpszUrl
, lpszcp
- lpszUrl
);
1638 /* Eat ':' in protocol. */
1641 /* double slash indicates the net_loc portion is present */
1642 if ((lpszcp
[0] == '/') && (lpszcp
[1] == '/'))
1646 lpszNetLoc
= memchrW(lpszcp
, '/', dwUrlLength
- (lpszcp
- lpszUrl
));
1650 lpszNetLoc
= min(lpszNetLoc
, lpszParam
);
1652 lpszNetLoc
= lpszParam
;
1654 else if (!lpszNetLoc
)
1655 lpszNetLoc
= lpszcp
+ dwUrlLength
-(lpszcp
-lpszUrl
);
1663 /* [<user>[<:password>]@]<host>[:<port>] */
1664 /* First find the user and password if they exist */
1666 lpszHost
= memchrW(lpszcp
, '@', dwUrlLength
- (lpszcp
- lpszUrl
));
1667 if (lpszHost
== NULL
|| lpszHost
> lpszNetLoc
)
1669 /* username and password not specified. */
1670 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1671 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1673 else /* Parse out username and password */
1675 LPCWSTR lpszUser
= lpszcp
;
1676 LPCWSTR lpszPasswd
= lpszHost
;
1678 while (lpszcp
< lpszHost
)
1681 lpszPasswd
= lpszcp
;
1686 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
,
1687 lpszUser
, lpszPasswd
- lpszUser
);
1689 if (lpszPasswd
!= lpszHost
)
1691 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
,
1692 lpszPasswd
== lpszHost
? NULL
: lpszPasswd
,
1693 lpszHost
- lpszPasswd
);
1695 lpszcp
++; /* Advance to beginning of host */
1698 /* Parse <host><:port> */
1701 lpszPort
= lpszNetLoc
;
1703 /* special case for res:// URLs: there is no port here, so the host is the
1704 entire string up to the first '/' */
1705 if(lpUC
->nScheme
==INTERNET_SCHEME_RES
)
1707 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1708 lpszHost
, lpszPort
- lpszHost
);
1713 while (lpszcp
< lpszNetLoc
)
1721 /* If the scheme is "file" and the host is just one letter, it's not a host */
1722 if(lpUC
->nScheme
==INTERNET_SCHEME_FILE
&& lpszPort
<= lpszHost
+1)
1725 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1730 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1731 lpszHost
, lpszPort
- lpszHost
);
1732 if (lpszPort
!= lpszNetLoc
)
1733 lpUC
->nPort
= atoiW(++lpszPort
);
1734 else switch (lpUC
->nScheme
)
1736 case INTERNET_SCHEME_HTTP
:
1737 lpUC
->nPort
= INTERNET_DEFAULT_HTTP_PORT
;
1739 case INTERNET_SCHEME_HTTPS
:
1740 lpUC
->nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
1742 case INTERNET_SCHEME_FTP
:
1743 lpUC
->nPort
= INTERNET_DEFAULT_FTP_PORT
;
1745 case INTERNET_SCHEME_GOPHER
:
1746 lpUC
->nPort
= INTERNET_DEFAULT_GOPHER_PORT
;
1757 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1758 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1759 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1764 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
, NULL
, 0);
1765 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1766 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1767 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1770 /* Here lpszcp points to:
1772 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1773 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1775 if (lpszcp
!= 0 && lpszcp
- lpszUrl
< dwUrlLength
&& (!lpszParam
|| lpszcp
<= lpszParam
))
1779 /* Only truncate the parameter list if it's already been saved
1780 * in lpUC->lpszExtraInfo.
1782 if (lpszParam
&& lpUC
->dwExtraInfoLength
&& lpUC
->lpszExtraInfo
)
1783 len
= lpszParam
- lpszcp
;
1786 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1787 * newlines if necessary.
1789 LPWSTR lpsznewline
= memchrW(lpszcp
, '\n', dwUrlLength
- (lpszcp
- lpszUrl
));
1790 if (lpsznewline
!= NULL
)
1791 len
= lpsznewline
- lpszcp
;
1793 len
= dwUrlLength
-(lpszcp
-lpszUrl
);
1795 if (lpUC
->dwUrlPathLength
&& lpUC
->lpszUrlPath
&&
1796 lpUC
->nScheme
== INTERNET_SCHEME_FILE
)
1798 WCHAR tmppath
[MAX_PATH
];
1802 PathCreateFromUrlW(lpszUrl_orig
, tmppath
, &len
, 0);
1807 memcpy(tmppath
, lpszcp
, len
* sizeof(WCHAR
));
1808 tmppath
[len
] = '\0';
1817 /* if ends in \. or \.. append a backslash */
1818 if (tmppath
[len
- 1] == '.' &&
1819 (tmppath
[len
- 2] == '\\' ||
1820 (tmppath
[len
- 2] == '.' && tmppath
[len
- 3] == '\\')))
1822 if (len
< MAX_PATH
- 1)
1824 tmppath
[len
] = '\\';
1825 tmppath
[len
+1] = '\0';
1829 SetUrlComponentValueW(&lpUC
->lpszUrlPath
, &lpUC
->dwUrlPathLength
,
1833 SetUrlComponentValueW(&lpUC
->lpszUrlPath
, &lpUC
->dwUrlPathLength
,
1838 if (lpUC
->lpszUrlPath
&& (lpUC
->dwUrlPathLength
> 0))
1839 lpUC
->lpszUrlPath
[0] = 0;
1840 lpUC
->dwUrlPathLength
= 0;
1843 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl
,dwUrlLength
),
1844 debugstr_wn(lpUC
->lpszScheme
,lpUC
->dwSchemeLength
),
1845 debugstr_wn(lpUC
->lpszHostName
,lpUC
->dwHostNameLength
),
1846 debugstr_wn(lpUC
->lpszUrlPath
,lpUC
->dwUrlPathLength
),
1847 debugstr_wn(lpUC
->lpszExtraInfo
,lpUC
->dwExtraInfoLength
));
1849 HeapFree(GetProcessHeap(), 0, lpszUrl_decode
);
1853 /***********************************************************************
1854 * InternetAttemptConnect (WININET.@)
1856 * Attempt to make a connection to the internet
1859 * ERROR_SUCCESS on success
1860 * Error value on failure
1863 DWORD WINAPI
InternetAttemptConnect(DWORD dwReserved
)
1866 return ERROR_SUCCESS
;
1870 /***********************************************************************
1871 * InternetCanonicalizeUrlA (WININET.@)
1873 * Escape unsafe characters and spaces
1880 BOOL WINAPI
InternetCanonicalizeUrlA(LPCSTR lpszUrl
, LPSTR lpszBuffer
,
1881 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1884 DWORD dwURLFlags
= URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
;
1886 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_a(lpszUrl
), lpszBuffer
,
1887 lpdwBufferLength
, dwFlags
, lpdwBufferLength
? *lpdwBufferLength
: -1);
1889 if(dwFlags
& ICU_DECODE
)
1891 dwURLFlags
|= URL_UNESCAPE
;
1892 dwFlags
&= ~ICU_DECODE
;
1895 if(dwFlags
& ICU_ESCAPE
)
1897 dwURLFlags
|= URL_UNESCAPE
;
1898 dwFlags
&= ~ICU_ESCAPE
;
1901 if(dwFlags
& ICU_BROWSER_MODE
)
1903 dwURLFlags
|= URL_BROWSER_MODE
;
1904 dwFlags
&= ~ICU_BROWSER_MODE
;
1907 if(dwFlags
& ICU_NO_ENCODE
)
1909 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1910 dwURLFlags
^= URL_ESCAPE_UNSAFE
;
1911 dwFlags
&= ~ICU_NO_ENCODE
;
1914 if (dwFlags
) FIXME("Unhandled flags 0x%08x\n", dwFlags
);
1916 hr
= UrlCanonicalizeA(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1917 if (hr
== E_POINTER
) SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1918 if (hr
== E_INVALIDARG
) SetLastError(ERROR_INVALID_PARAMETER
);
1920 return (hr
== S_OK
) ? TRUE
: FALSE
;
1923 /***********************************************************************
1924 * InternetCanonicalizeUrlW (WININET.@)
1926 * Escape unsafe characters and spaces
1933 BOOL WINAPI
InternetCanonicalizeUrlW(LPCWSTR lpszUrl
, LPWSTR lpszBuffer
,
1934 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1937 DWORD dwURLFlags
= URL_WININET_COMPATIBILITY
| URL_ESCAPE_UNSAFE
;
1939 TRACE("(%s, %p, %p, 0x%08x) bufferlength: %d\n", debugstr_w(lpszUrl
), lpszBuffer
,
1940 lpdwBufferLength
, dwFlags
, lpdwBufferLength
? *lpdwBufferLength
: -1);
1942 if(dwFlags
& ICU_DECODE
)
1944 dwURLFlags
|= URL_UNESCAPE
;
1945 dwFlags
&= ~ICU_DECODE
;
1948 if(dwFlags
& ICU_ESCAPE
)
1950 dwURLFlags
|= URL_UNESCAPE
;
1951 dwFlags
&= ~ICU_ESCAPE
;
1954 if(dwFlags
& ICU_BROWSER_MODE
)
1956 dwURLFlags
|= URL_BROWSER_MODE
;
1957 dwFlags
&= ~ICU_BROWSER_MODE
;
1960 if(dwFlags
& ICU_NO_ENCODE
)
1962 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1963 dwURLFlags
^= URL_ESCAPE_UNSAFE
;
1964 dwFlags
&= ~ICU_NO_ENCODE
;
1967 if (dwFlags
) FIXME("Unhandled flags 0x%08x\n", dwFlags
);
1969 hr
= UrlCanonicalizeW(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1970 if (hr
== E_POINTER
) SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1971 if (hr
== E_INVALIDARG
) SetLastError(ERROR_INVALID_PARAMETER
);
1973 return (hr
== S_OK
) ? TRUE
: FALSE
;
1976 /* #################################################### */
1978 static INTERNET_STATUS_CALLBACK
set_status_callback(
1979 object_header_t
*lpwh
, INTERNET_STATUS_CALLBACK callback
, BOOL unicode
)
1981 INTERNET_STATUS_CALLBACK ret
;
1983 if (unicode
) lpwh
->dwInternalFlags
|= INET_CALLBACKW
;
1984 else lpwh
->dwInternalFlags
&= ~INET_CALLBACKW
;
1986 ret
= lpwh
->lpfnStatusCB
;
1987 lpwh
->lpfnStatusCB
= callback
;
1992 /***********************************************************************
1993 * InternetSetStatusCallbackA (WININET.@)
1995 * Sets up a callback function which is called as progress is made
1996 * during an operation.
1999 * Previous callback or NULL on success
2000 * INTERNET_INVALID_STATUS_CALLBACK on failure
2003 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackA(
2004 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
2006 INTERNET_STATUS_CALLBACK retVal
;
2007 object_header_t
*lpwh
;
2009 TRACE("%p\n", hInternet
);
2011 if (!(lpwh
= get_handle_object(hInternet
)))
2012 return INTERNET_INVALID_STATUS_CALLBACK
;
2014 retVal
= set_status_callback(lpwh
, lpfnIntCB
, FALSE
);
2016 WININET_Release( lpwh
);
2020 /***********************************************************************
2021 * InternetSetStatusCallbackW (WININET.@)
2023 * Sets up a callback function which is called as progress is made
2024 * during an operation.
2027 * Previous callback or NULL on success
2028 * INTERNET_INVALID_STATUS_CALLBACK on failure
2031 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackW(
2032 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
2034 INTERNET_STATUS_CALLBACK retVal
;
2035 object_header_t
*lpwh
;
2037 TRACE("%p\n", hInternet
);
2039 if (!(lpwh
= get_handle_object(hInternet
)))
2040 return INTERNET_INVALID_STATUS_CALLBACK
;
2042 retVal
= set_status_callback(lpwh
, lpfnIntCB
, TRUE
);
2044 WININET_Release( lpwh
);
2048 /***********************************************************************
2049 * InternetSetFilePointer (WININET.@)
2051 DWORD WINAPI
InternetSetFilePointer(HINTERNET hFile
, LONG lDistanceToMove
,
2052 PVOID pReserved
, DWORD dwMoveContext
, DWORD_PTR dwContext
)
2058 /***********************************************************************
2059 * InternetWriteFile (WININET.@)
2061 * Write data to an open internet file
2068 BOOL WINAPI
InternetWriteFile(HINTERNET hFile
, LPCVOID lpBuffer
,
2069 DWORD dwNumOfBytesToWrite
, LPDWORD lpdwNumOfBytesWritten
)
2071 object_header_t
*lpwh
;
2074 TRACE("(%p %p %d %p)\n", hFile
, lpBuffer
, dwNumOfBytesToWrite
, lpdwNumOfBytesWritten
);
2076 lpwh
= get_handle_object( hFile
);
2078 WARN("Invalid handle\n");
2079 SetLastError(ERROR_INVALID_HANDLE
);
2083 if(lpwh
->vtbl
->WriteFile
) {
2084 res
= lpwh
->vtbl
->WriteFile(lpwh
, lpBuffer
, dwNumOfBytesToWrite
, lpdwNumOfBytesWritten
);
2086 WARN("No Writefile method.\n");
2087 res
= ERROR_INVALID_HANDLE
;
2090 WININET_Release( lpwh
);
2092 if(res
!= ERROR_SUCCESS
)
2094 return res
== ERROR_SUCCESS
;
2098 /***********************************************************************
2099 * InternetReadFile (WININET.@)
2101 * Read data from an open internet file
2108 BOOL WINAPI
InternetReadFile(HINTERNET hFile
, LPVOID lpBuffer
,
2109 DWORD dwNumOfBytesToRead
, LPDWORD pdwNumOfBytesRead
)
2111 object_header_t
*hdr
;
2112 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2114 TRACE("%p %p %d %p\n", hFile
, lpBuffer
, dwNumOfBytesToRead
, pdwNumOfBytesRead
);
2116 hdr
= get_handle_object(hFile
);
2118 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2122 if(hdr
->vtbl
->ReadFile
)
2123 res
= hdr
->vtbl
->ReadFile(hdr
, lpBuffer
, dwNumOfBytesToRead
, pdwNumOfBytesRead
);
2125 WININET_Release(hdr
);
2127 TRACE("-- %s (%u) (bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE", res
,
2128 pdwNumOfBytesRead
? *pdwNumOfBytesRead
: -1);
2130 if(res
!= ERROR_SUCCESS
)
2132 return res
== ERROR_SUCCESS
;
2135 /***********************************************************************
2136 * InternetReadFileExA (WININET.@)
2138 * Read data from an open internet file
2141 * hFile [I] Handle returned by InternetOpenUrl or HttpOpenRequest.
2142 * lpBuffersOut [I/O] Buffer.
2143 * dwFlags [I] Flags. See notes.
2144 * dwContext [I] Context for callbacks.
2151 * The parameter dwFlags include zero or more of the following flags:
2152 *|IRF_ASYNC - Makes the call asynchronous.
2153 *|IRF_SYNC - Makes the call synchronous.
2154 *|IRF_USE_CONTEXT - Forces dwContext to be used.
2155 *|IRF_NO_WAIT - Don't block if the data is not available, just return what is available.
2157 * However, in testing IRF_USE_CONTEXT seems to have no effect - dwContext isn't used.
2160 * InternetOpenUrlA(), HttpOpenRequestA()
2162 BOOL WINAPI
InternetReadFileExA(HINTERNET hFile
, LPINTERNET_BUFFERSA lpBuffersOut
,
2163 DWORD dwFlags
, DWORD_PTR dwContext
)
2165 object_header_t
*hdr
;
2166 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2168 TRACE("(%p %p 0x%x 0x%lx)\n", hFile
, lpBuffersOut
, dwFlags
, dwContext
);
2170 hdr
= get_handle_object(hFile
);
2172 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2176 if(hdr
->vtbl
->ReadFileExA
)
2177 res
= hdr
->vtbl
->ReadFileExA(hdr
, lpBuffersOut
, dwFlags
, dwContext
);
2179 WININET_Release(hdr
);
2181 TRACE("-- %s (%u, bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE",
2182 res
, lpBuffersOut
->dwBufferLength
);
2184 if(res
!= ERROR_SUCCESS
)
2186 return res
== ERROR_SUCCESS
;
2189 /***********************************************************************
2190 * InternetReadFileExW (WININET.@)
2192 * InternetReadFileExA()
2194 BOOL WINAPI
InternetReadFileExW(HINTERNET hFile
, LPINTERNET_BUFFERSW lpBuffer
,
2195 DWORD dwFlags
, DWORD_PTR dwContext
)
2197 object_header_t
*hdr
;
2198 DWORD res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2200 TRACE("(%p %p 0x%x 0x%lx)\n", hFile
, lpBuffer
, dwFlags
, dwContext
);
2202 hdr
= get_handle_object(hFile
);
2204 INTERNET_SetLastError(ERROR_INVALID_HANDLE
);
2208 if(hdr
->vtbl
->ReadFileExW
)
2209 res
= hdr
->vtbl
->ReadFileExW(hdr
, lpBuffer
, dwFlags
, dwContext
);
2211 WININET_Release(hdr
);
2213 TRACE("-- %s (%u, bytes read: %d)\n", res
== ERROR_SUCCESS
? "TRUE": "FALSE",
2214 res
, lpBuffer
->dwBufferLength
);
2216 if(res
!= ERROR_SUCCESS
)
2218 return res
== ERROR_SUCCESS
;
2221 DWORD
INET_QueryOption(object_header_t
*hdr
, DWORD option
, void *buffer
, DWORD
*size
, BOOL unicode
)
2223 static BOOL warn
= TRUE
;
2226 case INTERNET_OPTION_REQUEST_FLAGS
:
2227 TRACE("INTERNET_OPTION_REQUEST_FLAGS\n");
2229 if (*size
< sizeof(ULONG
))
2230 return ERROR_INSUFFICIENT_BUFFER
;
2232 *(ULONG
*)buffer
= 4;
2233 *size
= sizeof(ULONG
);
2235 return ERROR_SUCCESS
;
2237 case INTERNET_OPTION_HTTP_VERSION
:
2238 if (*size
< sizeof(HTTP_VERSION_INFO
))
2239 return ERROR_INSUFFICIENT_BUFFER
;
2242 * Presently hardcoded to 1.1
2244 ((HTTP_VERSION_INFO
*)buffer
)->dwMajorVersion
= 1;
2245 ((HTTP_VERSION_INFO
*)buffer
)->dwMinorVersion
= 1;
2246 *size
= sizeof(HTTP_VERSION_INFO
);
2248 return ERROR_SUCCESS
;
2250 case INTERNET_OPTION_CONNECTED_STATE
:
2252 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
2255 if (*size
< sizeof(ULONG
))
2256 return ERROR_INSUFFICIENT_BUFFER
;
2258 *(ULONG
*)buffer
= INTERNET_STATE_CONNECTED
;
2259 *size
= sizeof(ULONG
);
2261 return ERROR_SUCCESS
;
2263 case INTERNET_OPTION_PROXY
: {
2267 TRACE("Getting global proxy info\n");
2268 memset(&ai
, 0, sizeof(appinfo_t
));
2269 INTERNET_ConfigureProxy(&ai
);
2271 ret
= APPINFO_QueryOption(&ai
.hdr
, INTERNET_OPTION_PROXY
, buffer
, size
, unicode
); /* FIXME */
2272 APPINFO_Destroy(&ai
.hdr
);
2276 case INTERNET_OPTION_MAX_CONNS_PER_SERVER
:
2277 TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER\n");
2279 if (*size
< sizeof(ULONG
))
2280 return ERROR_INSUFFICIENT_BUFFER
;
2282 *(ULONG
*)buffer
= 2;
2283 *size
= sizeof(ULONG
);
2285 return ERROR_SUCCESS
;
2287 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
:
2288 TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER\n");
2290 if (*size
< sizeof(ULONG
))
2291 return ERROR_INSUFFICIENT_BUFFER
;
2293 *(ULONG
*)buffer
= 4;
2294 *size
= sizeof(ULONG
);
2296 return ERROR_SUCCESS
;
2298 case INTERNET_OPTION_SECURITY_FLAGS
:
2299 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2300 return ERROR_SUCCESS
;
2302 case INTERNET_OPTION_VERSION
: {
2303 static const INTERNET_VERSION_INFO info
= { 1, 2 };
2305 TRACE("INTERNET_OPTION_VERSION\n");
2307 if (*size
< sizeof(INTERNET_VERSION_INFO
))
2308 return ERROR_INSUFFICIENT_BUFFER
;
2310 memcpy(buffer
, &info
, sizeof(info
));
2311 *size
= sizeof(info
);
2313 return ERROR_SUCCESS
;
2316 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2317 INTERNET_PER_CONN_OPTION_LISTW
*con
= buffer
;
2318 INTERNET_PER_CONN_OPTION_LISTA
*conA
= buffer
;
2319 DWORD res
= ERROR_SUCCESS
, i
;
2323 TRACE("Getting global proxy info\n");
2324 if((ret
= INTERNET_LoadProxySettings(&pi
)))
2327 FIXME("INTERNET_OPTION_PER_CONNECTION_OPTION stub\n");
2329 if (*size
< sizeof(INTERNET_PER_CONN_OPTION_LISTW
)) {
2331 return ERROR_INSUFFICIENT_BUFFER
;
2334 for (i
= 0; i
< con
->dwOptionCount
; i
++) {
2335 INTERNET_PER_CONN_OPTIONW
*optionW
= con
->pOptions
+ i
;
2336 INTERNET_PER_CONN_OPTIONA
*optionA
= conA
->pOptions
+ i
;
2338 switch (optionW
->dwOption
) {
2339 case INTERNET_PER_CONN_FLAGS
:
2340 if(pi
.dwProxyEnabled
)
2341 optionW
->Value
.dwValue
= PROXY_TYPE_PROXY
;
2343 optionW
->Value
.dwValue
= PROXY_TYPE_DIRECT
;
2346 case INTERNET_PER_CONN_PROXY_SERVER
:
2348 optionW
->Value
.pszValue
= heap_strdupW(pi
.lpszProxyServer
);
2350 optionA
->Value
.pszValue
= heap_strdupWtoA(pi
.lpszProxyServer
);
2353 case INTERNET_PER_CONN_PROXY_BYPASS
:
2355 optionW
->Value
.pszValue
= heap_strdupW(pi
.lpszProxyBypass
);
2357 optionA
->Value
.pszValue
= heap_strdupWtoA(pi
.lpszProxyBypass
);
2360 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2361 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2362 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2363 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2364 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2365 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2366 FIXME("Unhandled dwOption %d\n", optionW
->dwOption
);
2367 memset(&optionW
->Value
, 0, sizeof(optionW
->Value
));
2371 FIXME("Unknown dwOption %d\n", optionW
->dwOption
);
2372 res
= ERROR_INVALID_PARAMETER
;
2380 case INTERNET_OPTION_USER_AGENT
:
2381 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2382 case INTERNET_OPTION_POLICY
:
2383 return ERROR_INVALID_PARAMETER
;
2384 case INTERNET_OPTION_CONTEXT_VALUE
:
2387 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2389 return ERROR_INVALID_PARAMETER
;
2391 if (*size
< sizeof(DWORD_PTR
))
2393 *size
= sizeof(DWORD_PTR
);
2394 return ERROR_INSUFFICIENT_BUFFER
;
2397 return ERROR_INVALID_PARAMETER
;
2399 *(DWORD_PTR
*)buffer
= hdr
->dwContext
;
2400 *size
= sizeof(DWORD_PTR
);
2401 return ERROR_SUCCESS
;
2405 FIXME("Stub for %d\n", option
);
2406 return ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
2409 /***********************************************************************
2410 * InternetQueryOptionW (WININET.@)
2412 * Queries an options on the specified handle
2419 BOOL WINAPI
InternetQueryOptionW(HINTERNET hInternet
, DWORD dwOption
,
2420 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2422 object_header_t
*hdr
;
2423 DWORD res
= ERROR_INVALID_HANDLE
;
2425 TRACE("%p %d %p %p\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2428 hdr
= get_handle_object(hInternet
);
2430 res
= hdr
->vtbl
->QueryOption(hdr
, dwOption
, lpBuffer
, lpdwBufferLength
, TRUE
);
2431 WININET_Release(hdr
);
2434 res
= INET_QueryOption(NULL
, dwOption
, lpBuffer
, lpdwBufferLength
, TRUE
);
2437 if(res
!= ERROR_SUCCESS
)
2439 return res
== ERROR_SUCCESS
;
2442 /***********************************************************************
2443 * InternetQueryOptionA (WININET.@)
2445 * Queries an options on the specified handle
2452 BOOL WINAPI
InternetQueryOptionA(HINTERNET hInternet
, DWORD dwOption
,
2453 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2455 object_header_t
*hdr
;
2456 DWORD res
= ERROR_INVALID_HANDLE
;
2458 TRACE("%p %d %p %p\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2461 hdr
= get_handle_object(hInternet
);
2463 res
= hdr
->vtbl
->QueryOption(hdr
, dwOption
, lpBuffer
, lpdwBufferLength
, FALSE
);
2464 WININET_Release(hdr
);
2467 res
= INET_QueryOption(NULL
, dwOption
, lpBuffer
, lpdwBufferLength
, FALSE
);
2470 if(res
!= ERROR_SUCCESS
)
2472 return res
== ERROR_SUCCESS
;
2476 /***********************************************************************
2477 * InternetSetOptionW (WININET.@)
2479 * Sets an options on the specified handle
2486 BOOL WINAPI
InternetSetOptionW(HINTERNET hInternet
, DWORD dwOption
,
2487 LPVOID lpBuffer
, DWORD dwBufferLength
)
2489 object_header_t
*lpwhh
;
2492 TRACE("(%p %d %p %d)\n", hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2494 lpwhh
= (object_header_t
*) get_handle_object( hInternet
);
2495 if(lpwhh
&& lpwhh
->vtbl
->SetOption
) {
2498 res
= lpwhh
->vtbl
->SetOption(lpwhh
, dwOption
, lpBuffer
, dwBufferLength
);
2499 if(res
!= ERROR_INTERNET_INVALID_OPTION
) {
2500 WININET_Release( lpwhh
);
2502 if(res
!= ERROR_SUCCESS
)
2505 return res
== ERROR_SUCCESS
;
2511 case INTERNET_OPTION_CALLBACK
:
2515 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2518 WININET_Release(lpwhh
);
2519 SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE
);
2522 case INTERNET_OPTION_HTTP_VERSION
:
2524 HTTP_VERSION_INFO
* pVersion
=(HTTP_VERSION_INFO
*)lpBuffer
;
2525 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%d,%d): STUB\n",pVersion
->dwMajorVersion
,pVersion
->dwMinorVersion
);
2528 case INTERNET_OPTION_ERROR_MASK
:
2531 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2533 } else if(*(ULONG
*)lpBuffer
& (~(INTERNET_ERROR_MASK_INSERT_CDROM
|
2534 INTERNET_ERROR_MASK_COMBINED_SEC_CERT
|
2535 INTERNET_ERROR_MASK_LOGIN_FAILURE_DISPLAY_ENTITY_BODY
))) {
2536 SetLastError(ERROR_INVALID_PARAMETER
);
2538 } else if(dwBufferLength
!= sizeof(ULONG
)) {
2539 SetLastError(ERROR_INTERNET_BAD_OPTION_LENGTH
);
2542 lpwhh
->ErrorMask
= *(ULONG
*)lpBuffer
;
2545 case INTERNET_OPTION_CODEPAGE
:
2547 ULONG codepage
= *(ULONG
*)lpBuffer
;
2548 FIXME("Option INTERNET_OPTION_CODEPAGE (%d): STUB\n", codepage
);
2551 case INTERNET_OPTION_REQUEST_PRIORITY
:
2553 ULONG priority
= *(ULONG
*)lpBuffer
;
2554 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%d): STUB\n", priority
);
2557 case INTERNET_OPTION_CONNECT_TIMEOUT
:
2559 ULONG connecttimeout
= *(ULONG
*)lpBuffer
;
2560 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%d): STUB\n", connecttimeout
);
2563 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
:
2565 ULONG receivetimeout
= *(ULONG
*)lpBuffer
;
2566 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%d): STUB\n", receivetimeout
);
2569 case INTERNET_OPTION_MAX_CONNS_PER_SERVER
:
2571 ULONG conns
= *(ULONG
*)lpBuffer
;
2572 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%d): STUB\n", conns
);
2575 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER
:
2577 ULONG conns
= *(ULONG
*)lpBuffer
;
2578 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%d): STUB\n", conns
);
2581 case INTERNET_OPTION_RESET_URLCACHE_SESSION
:
2582 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2584 case INTERNET_OPTION_END_BROWSER_SESSION
:
2585 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2587 case INTERNET_OPTION_CONNECTED_STATE
:
2588 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2590 case INTERNET_OPTION_DISABLE_PASSPORT_AUTH
:
2591 TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
2593 case INTERNET_OPTION_SEND_TIMEOUT
:
2594 case INTERNET_OPTION_RECEIVE_TIMEOUT
:
2595 case INTERNET_OPTION_DATA_SEND_TIMEOUT
:
2597 ULONG timeout
= *(ULONG
*)lpBuffer
;
2598 FIXME("INTERNET_OPTION_SEND/RECEIVE_TIMEOUT/DATA_SEND_TIMEOUT %d\n", timeout
);
2601 case INTERNET_OPTION_CONNECT_RETRIES
:
2603 ULONG retries
= *(ULONG
*)lpBuffer
;
2604 FIXME("INTERNET_OPTION_CONNECT_RETRIES %d\n", retries
);
2607 case INTERNET_OPTION_CONTEXT_VALUE
:
2611 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2614 if (!lpBuffer
|| dwBufferLength
!= sizeof(DWORD_PTR
))
2616 SetLastError(ERROR_INVALID_PARAMETER
);
2620 lpwhh
->dwContext
= *(DWORD_PTR
*)lpBuffer
;
2623 case INTERNET_OPTION_SECURITY_FLAGS
:
2624 FIXME("Option INTERNET_OPTION_SECURITY_FLAGS; STUB\n");
2626 case INTERNET_OPTION_DISABLE_AUTODIAL
:
2627 FIXME("Option INTERNET_OPTION_DISABLE_AUTODIAL; STUB\n");
2629 case INTERNET_OPTION_HTTP_DECODING
:
2630 FIXME("INTERNET_OPTION_HTTP_DECODING; STUB\n");
2631 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2634 case INTERNET_OPTION_COOKIES_3RD_PARTY
:
2635 FIXME("INTERNET_OPTION_COOKIES_3RD_PARTY; STUB\n");
2636 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2639 case INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY
:
2640 FIXME("INTERNET_OPTION_SEND_UTF8_SERVERNAME_TO_PROXY; STUB\n");
2641 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2644 case INTERNET_OPTION_CODEPAGE_PATH
:
2645 FIXME("INTERNET_OPTION_CODEPAGE_PATH; STUB\n");
2646 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2649 case INTERNET_OPTION_CODEPAGE_EXTRA
:
2650 FIXME("INTERNET_OPTION_CODEPAGE_EXTRA; STUB\n");
2651 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2654 case INTERNET_OPTION_IDN
:
2655 FIXME("INTERNET_OPTION_IDN; STUB\n");
2656 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2659 case INTERNET_OPTION_POLICY
:
2660 SetLastError(ERROR_INVALID_PARAMETER
);
2663 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2664 INTERNET_PER_CONN_OPTION_LISTW
*con
= lpBuffer
;
2669 INTERNET_LoadProxySettings(&pi
);
2671 for (i
= 0; i
< con
->dwOptionCount
; i
++) {
2672 INTERNET_PER_CONN_OPTIONW
*option
= con
->pOptions
+ i
;
2674 switch (option
->dwOption
) {
2675 case INTERNET_PER_CONN_PROXY_SERVER
:
2676 HeapFree(GetProcessHeap(), 0, pi
.lpszProxyServer
);
2677 pi
.lpszProxyServer
= heap_strdupW(option
->Value
.pszValue
);
2680 case INTERNET_PER_CONN_FLAGS
:
2681 if(option
->Value
.dwValue
& PROXY_TYPE_PROXY
)
2682 pi
.dwProxyEnabled
= 1;
2685 if(option
->Value
.dwValue
!= PROXY_TYPE_DIRECT
)
2686 FIXME("Unhandled flags: 0x%x\n", option
->Value
.dwValue
);
2687 pi
.dwProxyEnabled
= 0;
2691 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2692 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2693 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2694 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2695 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2696 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2697 case INTERNET_PER_CONN_PROXY_BYPASS
:
2698 FIXME("Unhandled dwOption %d\n", option
->dwOption
);
2702 FIXME("Unknown dwOption %d\n", option
->dwOption
);
2703 SetLastError(ERROR_INVALID_PARAMETER
);
2708 if ((res
= INTERNET_SaveProxySettings(&pi
)))
2713 ret
= (res
== ERROR_SUCCESS
);
2717 FIXME("Option %d STUB\n",dwOption
);
2718 SetLastError(ERROR_INTERNET_INVALID_OPTION
);
2724 WININET_Release( lpwhh
);
2730 /***********************************************************************
2731 * InternetSetOptionA (WININET.@)
2733 * Sets an options on the specified handle.
2740 BOOL WINAPI
InternetSetOptionA(HINTERNET hInternet
, DWORD dwOption
,
2741 LPVOID lpBuffer
, DWORD dwBufferLength
)
2749 case INTERNET_OPTION_CALLBACK
:
2751 object_header_t
*lpwh
;
2753 if (!(lpwh
= get_handle_object(hInternet
)))
2755 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2758 WININET_Release(lpwh
);
2759 INTERNET_SetLastError(ERROR_INTERNET_OPTION_NOT_SETTABLE
);
2762 case INTERNET_OPTION_PROXY
:
2764 LPINTERNET_PROXY_INFOA pi
= (LPINTERNET_PROXY_INFOA
) lpBuffer
;
2765 LPINTERNET_PROXY_INFOW piw
;
2766 DWORD proxlen
, prbylen
;
2769 proxlen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, NULL
, 0);
2770 prbylen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, NULL
, 0);
2771 wlen
= sizeof(*piw
) + proxlen
+ prbylen
;
2772 wbuffer
= heap_alloc(wlen
*sizeof(WCHAR
) );
2773 piw
= (LPINTERNET_PROXY_INFOW
) wbuffer
;
2774 piw
->dwAccessType
= pi
->dwAccessType
;
2775 prox
= (LPWSTR
) &piw
[1];
2776 prby
= &prox
[proxlen
+1];
2777 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, prox
, proxlen
);
2778 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, prby
, prbylen
);
2779 piw
->lpszProxy
= prox
;
2780 piw
->lpszProxyBypass
= prby
;
2783 case INTERNET_OPTION_USER_AGENT
:
2784 case INTERNET_OPTION_USERNAME
:
2785 case INTERNET_OPTION_PASSWORD
:
2786 wlen
= MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2788 wbuffer
= heap_alloc(wlen
*sizeof(WCHAR
) );
2789 MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2792 case INTERNET_OPTION_PER_CONNECTION_OPTION
: {
2794 INTERNET_PER_CONN_OPTION_LISTW
*listW
;
2795 INTERNET_PER_CONN_OPTION_LISTA
*listA
= lpBuffer
;
2796 wlen
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
2797 wbuffer
= heap_alloc(wlen
);
2800 listW
->dwSize
= sizeof(INTERNET_PER_CONN_OPTION_LISTW
);
2801 if (listA
->pszConnection
)
2803 wlen
= MultiByteToWideChar( CP_ACP
, 0, listA
->pszConnection
, -1, NULL
, 0 );
2804 listW
->pszConnection
= heap_alloc(wlen
*sizeof(WCHAR
));
2805 MultiByteToWideChar( CP_ACP
, 0, listA
->pszConnection
, -1, listW
->pszConnection
, wlen
);
2808 listW
->pszConnection
= NULL
;
2809 listW
->dwOptionCount
= listA
->dwOptionCount
;
2810 listW
->dwOptionError
= listA
->dwOptionError
;
2811 listW
->pOptions
= heap_alloc(sizeof(INTERNET_PER_CONN_OPTIONW
) * listA
->dwOptionCount
);
2813 for (i
= 0; i
< listA
->dwOptionCount
; ++i
) {
2814 INTERNET_PER_CONN_OPTIONA
*optA
= listA
->pOptions
+ i
;
2815 INTERNET_PER_CONN_OPTIONW
*optW
= listW
->pOptions
+ i
;
2817 optW
->dwOption
= optA
->dwOption
;
2819 switch (optA
->dwOption
) {
2820 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2821 case INTERNET_PER_CONN_PROXY_BYPASS
:
2822 case INTERNET_PER_CONN_PROXY_SERVER
:
2823 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2824 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2825 if (optA
->Value
.pszValue
)
2827 wlen
= MultiByteToWideChar( CP_ACP
, 0, optA
->Value
.pszValue
, -1, NULL
, 0 );
2828 optW
->Value
.pszValue
= heap_alloc(wlen
*sizeof(WCHAR
));
2829 MultiByteToWideChar( CP_ACP
, 0, optA
->Value
.pszValue
, -1, optW
->Value
.pszValue
, wlen
);
2832 optW
->Value
.pszValue
= NULL
;
2834 case INTERNET_PER_CONN_AUTODISCOVERY_FLAGS
:
2835 case INTERNET_PER_CONN_FLAGS
:
2836 case INTERNET_PER_CONN_AUTOCONFIG_RELOAD_DELAY_MINS
:
2837 optW
->Value
.dwValue
= optA
->Value
.dwValue
;
2839 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_TIME
:
2840 optW
->Value
.ftValue
= optA
->Value
.ftValue
;
2843 WARN("Unknown PER_CONN dwOption: %d, guessing at conversion to Wide\n", optA
->dwOption
);
2844 optW
->Value
.dwValue
= optA
->Value
.dwValue
;
2852 wlen
= dwBufferLength
;
2855 r
= InternetSetOptionW(hInternet
,dwOption
, wbuffer
, wlen
);
2857 if( lpBuffer
!= wbuffer
)
2859 if (dwOption
== INTERNET_OPTION_PER_CONNECTION_OPTION
)
2861 INTERNET_PER_CONN_OPTION_LISTW
*list
= wbuffer
;
2863 for (i
= 0; i
< list
->dwOptionCount
; ++i
) {
2864 INTERNET_PER_CONN_OPTIONW
*opt
= list
->pOptions
+ i
;
2865 switch (opt
->dwOption
) {
2866 case INTERNET_PER_CONN_AUTOCONFIG_URL
:
2867 case INTERNET_PER_CONN_PROXY_BYPASS
:
2868 case INTERNET_PER_CONN_PROXY_SERVER
:
2869 case INTERNET_PER_CONN_AUTOCONFIG_SECONDARY_URL
:
2870 case INTERNET_PER_CONN_AUTOCONFIG_LAST_DETECT_URL
:
2871 HeapFree( GetProcessHeap(), 0, opt
->Value
.pszValue
);
2877 HeapFree( GetProcessHeap(), 0, list
->pOptions
);
2879 HeapFree( GetProcessHeap(), 0, wbuffer
);
2886 /***********************************************************************
2887 * InternetSetOptionExA (WININET.@)
2889 BOOL WINAPI
InternetSetOptionExA(HINTERNET hInternet
, DWORD dwOption
,
2890 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2892 FIXME("Flags %08x ignored\n", dwFlags
);
2893 return InternetSetOptionA( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2896 /***********************************************************************
2897 * InternetSetOptionExW (WININET.@)
2899 BOOL WINAPI
InternetSetOptionExW(HINTERNET hInternet
, DWORD dwOption
,
2900 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2902 FIXME("Flags %08x ignored\n", dwFlags
);
2903 if( dwFlags
& ~ISO_VALID_FLAGS
)
2905 SetLastError( ERROR_INVALID_PARAMETER
);
2908 return InternetSetOptionW( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2911 static const WCHAR WININET_wkday
[7][4] =
2912 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2913 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2914 static const WCHAR WININET_month
[12][4] =
2915 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2916 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2917 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2919 /***********************************************************************
2920 * InternetTimeFromSystemTimeA (WININET.@)
2922 BOOL WINAPI
InternetTimeFromSystemTimeA( const SYSTEMTIME
* time
, DWORD format
, LPSTR string
, DWORD size
)
2925 WCHAR stringW
[INTERNET_RFC1123_BUFSIZE
];
2927 TRACE( "%p 0x%08x %p 0x%08x\n", time
, format
, string
, size
);
2929 if (!time
|| !string
|| format
!= INTERNET_RFC1123_FORMAT
)
2931 SetLastError(ERROR_INVALID_PARAMETER
);
2935 if (size
< INTERNET_RFC1123_BUFSIZE
* sizeof(*string
))
2937 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2941 ret
= InternetTimeFromSystemTimeW( time
, format
, stringW
, sizeof(stringW
) );
2942 if (ret
) WideCharToMultiByte( CP_ACP
, 0, stringW
, -1, string
, size
, NULL
, NULL
);
2947 /***********************************************************************
2948 * InternetTimeFromSystemTimeW (WININET.@)
2950 BOOL WINAPI
InternetTimeFromSystemTimeW( const SYSTEMTIME
* time
, DWORD format
, LPWSTR string
, DWORD size
)
2952 static const WCHAR date
[] =
2953 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2954 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
2956 TRACE( "%p 0x%08x %p 0x%08x\n", time
, format
, string
, size
);
2958 if (!time
|| !string
|| format
!= INTERNET_RFC1123_FORMAT
)
2960 SetLastError(ERROR_INVALID_PARAMETER
);
2964 if (size
< INTERNET_RFC1123_BUFSIZE
* sizeof(*string
))
2966 SetLastError(ERROR_INSUFFICIENT_BUFFER
);
2970 sprintfW( string
, date
,
2971 WININET_wkday
[time
->wDayOfWeek
],
2973 WININET_month
[time
->wMonth
- 1],
2982 /***********************************************************************
2983 * InternetTimeToSystemTimeA (WININET.@)
2985 BOOL WINAPI
InternetTimeToSystemTimeA( LPCSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
2990 TRACE( "%s %p 0x%08x\n", debugstr_a(string
), time
, reserved
);
2992 stringW
= heap_strdupAtoW(string
);
2995 ret
= InternetTimeToSystemTimeW( stringW
, time
, reserved
);
2996 HeapFree( GetProcessHeap(), 0, stringW
);
3001 /***********************************************************************
3002 * InternetTimeToSystemTimeW (WININET.@)
3004 BOOL WINAPI
InternetTimeToSystemTimeW( LPCWSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
3007 const WCHAR
*s
= string
;
3010 TRACE( "%s %p 0x%08x\n", debugstr_w(string
), time
, reserved
);
3012 if (!string
|| !time
) return FALSE
;
3014 /* Windows does this too */
3015 GetSystemTime( time
);
3017 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
3018 * a SYSTEMTIME structure.
3021 while (*s
&& !isalphaW( *s
)) s
++;
3022 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
3023 time
->wDayOfWeek
= 7;
3025 for (i
= 0; i
< 7; i
++)
3027 if (toupperW( WININET_wkday
[i
][0] ) == toupperW( s
[0] ) &&
3028 toupperW( WININET_wkday
[i
][1] ) == toupperW( s
[1] ) &&
3029 toupperW( WININET_wkday
[i
][2] ) == toupperW( s
[2] ) )
3031 time
->wDayOfWeek
= i
;
3036 if (time
->wDayOfWeek
> 6) return TRUE
;
3037 while (*s
&& !isdigitW( *s
)) s
++;
3038 time
->wDay
= strtolW( s
, &end
, 10 );
3041 while (*s
&& !isalphaW( *s
)) s
++;
3042 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
3045 for (i
= 0; i
< 12; i
++)
3047 if (toupperW( WININET_month
[i
][0]) == toupperW( s
[0] ) &&
3048 toupperW( WININET_month
[i
][1]) == toupperW( s
[1] ) &&
3049 toupperW( WININET_month
[i
][2]) == toupperW( s
[2] ) )
3051 time
->wMonth
= i
+ 1;
3055 if (time
->wMonth
== 0) return TRUE
;
3057 while (*s
&& !isdigitW( *s
)) s
++;
3058 if (*s
== '\0') return TRUE
;
3059 time
->wYear
= strtolW( s
, &end
, 10 );
3062 while (*s
&& !isdigitW( *s
)) s
++;
3063 if (*s
== '\0') return TRUE
;
3064 time
->wHour
= strtolW( s
, &end
, 10 );
3067 while (*s
&& !isdigitW( *s
)) s
++;
3068 if (*s
== '\0') return TRUE
;
3069 time
->wMinute
= strtolW( s
, &end
, 10 );
3072 while (*s
&& !isdigitW( *s
)) s
++;
3073 if (*s
== '\0') return TRUE
;
3074 time
->wSecond
= strtolW( s
, &end
, 10 );
3077 time
->wMilliseconds
= 0;
3081 /***********************************************************************
3082 * InternetCheckConnectionW (WININET.@)
3084 * Pings a requested host to check internet connection
3087 * TRUE on success and FALSE on failure. If a failure then
3088 * ERROR_NOT_CONNECTED is placed into GetLastError
3091 BOOL WINAPI
InternetCheckConnectionW( LPCWSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
3094 * this is a kludge which runs the resident ping program and reads the output.
3096 * Anyone have a better idea?
3100 static const CHAR ping
[] = "ping -c 1 ";
3101 static const CHAR redirect
[] = " >/dev/null 2>/dev/null";
3102 CHAR
*command
= NULL
;
3111 * Crack or set the Address
3113 if (lpszUrl
== NULL
)
3116 * According to the doc we are supposed to use the ip for the next
3117 * server in the WnInet internal server database. I have
3118 * no idea what that is or how to get it.
3120 * So someone needs to implement this.
3122 FIXME("Unimplemented with URL of NULL\n");
3127 URL_COMPONENTSW components
;
3129 ZeroMemory(&components
,sizeof(URL_COMPONENTSW
));
3130 components
.lpszHostName
= (LPWSTR
)hostW
;
3131 components
.dwHostNameLength
= 1024;
3133 if (!InternetCrackUrlW(lpszUrl
,0,0,&components
))
3136 TRACE("host name : %s\n",debugstr_w(components
.lpszHostName
));
3137 port
= components
.nPort
;
3138 TRACE("port: %d\n", port
);
3141 if (dwFlags
& FLAG_ICC_FORCE_CONNECTION
)
3143 struct sockaddr_storage saddr
;
3144 socklen_t sa_len
= sizeof(saddr
);
3147 if (!GetAddress(hostW
, port
, (struct sockaddr
*)&saddr
, &sa_len
))
3149 fd
= socket(saddr
.ss_family
, SOCK_STREAM
, 0);
3152 if (connect(fd
, (struct sockaddr
*)&saddr
, sa_len
) == 0)
3160 * Build our ping command
3162 len
= WideCharToMultiByte(CP_UNIXCP
, 0, hostW
, -1, NULL
, 0, NULL
, NULL
);
3163 command
= heap_alloc(strlen(ping
)+len
+strlen(redirect
));
3164 strcpy(command
,ping
);
3165 WideCharToMultiByte(CP_UNIXCP
, 0, hostW
, -1, command
+strlen(ping
), len
, NULL
, NULL
);
3166 strcat(command
,redirect
);
3168 TRACE("Ping command is : %s\n",command
);
3170 status
= system(command
);
3172 TRACE("Ping returned a code of %i\n",status
);
3174 /* Ping return code of 0 indicates success */
3181 HeapFree( GetProcessHeap(), 0, command
);
3183 INTERNET_SetLastError(ERROR_NOT_CONNECTED
);
3189 /***********************************************************************
3190 * InternetCheckConnectionA (WININET.@)
3192 * Pings a requested host to check internet connection
3195 * TRUE on success and FALSE on failure. If a failure then
3196 * ERROR_NOT_CONNECTED is placed into GetLastError
3199 BOOL WINAPI
InternetCheckConnectionA(LPCSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
3205 url
= heap_strdupAtoW(lpszUrl
);
3210 rc
= InternetCheckConnectionW(url
, dwFlags
, dwReserved
);
3212 HeapFree(GetProcessHeap(), 0, url
);
3217 /**********************************************************
3218 * INTERNET_InternetOpenUrlW (internal)
3223 * handle of connection or NULL on failure
3225 static HINTERNET
INTERNET_InternetOpenUrlW(appinfo_t
*hIC
, LPCWSTR lpszUrl
,
3226 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3228 URL_COMPONENTSW urlComponents
;
3229 WCHAR protocol
[32], hostName
[MAXHOSTNAME
], userName
[1024];
3230 WCHAR password
[1024], path
[2048], extra
[1024];
3231 HINTERNET client
= NULL
, client1
= NULL
;
3234 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hIC
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
3235 dwHeadersLength
, dwFlags
, dwContext
);
3237 urlComponents
.dwStructSize
= sizeof(URL_COMPONENTSW
);
3238 urlComponents
.lpszScheme
= protocol
;
3239 urlComponents
.dwSchemeLength
= 32;
3240 urlComponents
.lpszHostName
= hostName
;
3241 urlComponents
.dwHostNameLength
= MAXHOSTNAME
;
3242 urlComponents
.lpszUserName
= userName
;
3243 urlComponents
.dwUserNameLength
= 1024;
3244 urlComponents
.lpszPassword
= password
;
3245 urlComponents
.dwPasswordLength
= 1024;
3246 urlComponents
.lpszUrlPath
= path
;
3247 urlComponents
.dwUrlPathLength
= 2048;
3248 urlComponents
.lpszExtraInfo
= extra
;
3249 urlComponents
.dwExtraInfoLength
= 1024;
3250 if(!InternetCrackUrlW(lpszUrl
, strlenW(lpszUrl
), 0, &urlComponents
))
3252 switch(urlComponents
.nScheme
) {
3253 case INTERNET_SCHEME_FTP
:
3254 if(urlComponents
.nPort
== 0)
3255 urlComponents
.nPort
= INTERNET_DEFAULT_FTP_PORT
;
3256 client
= FTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
3257 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
);
3260 client1
= FtpOpenFileW(client
, path
, GENERIC_READ
, dwFlags
, dwContext
);
3261 if(client1
== NULL
) {
3262 InternetCloseHandle(client
);
3267 case INTERNET_SCHEME_HTTP
:
3268 case INTERNET_SCHEME_HTTPS
: {
3269 static const WCHAR szStars
[] = { '*','/','*', 0 };
3270 LPCWSTR accept
[2] = { szStars
, NULL
};
3271 if(urlComponents
.nPort
== 0) {
3272 if(urlComponents
.nScheme
== INTERNET_SCHEME_HTTP
)
3273 urlComponents
.nPort
= INTERNET_DEFAULT_HTTP_PORT
;
3275 urlComponents
.nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
3277 if (urlComponents
.nScheme
== INTERNET_SCHEME_HTTPS
) dwFlags
|= INTERNET_FLAG_SECURE
;
3279 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
3280 res
= HTTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
3281 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
, &client
);
3282 if(res
!= ERROR_SUCCESS
) {
3283 INTERNET_SetLastError(res
);
3287 if (urlComponents
.dwExtraInfoLength
) {
3289 DWORD len
= urlComponents
.dwUrlPathLength
+ urlComponents
.dwExtraInfoLength
+ 1;
3291 if (!(path_extra
= heap_alloc(len
* sizeof(WCHAR
))))
3293 InternetCloseHandle(client
);
3296 strcpyW(path_extra
, urlComponents
.lpszUrlPath
);
3297 strcatW(path_extra
, urlComponents
.lpszExtraInfo
);
3298 client1
= HttpOpenRequestW(client
, NULL
, path_extra
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
3299 HeapFree(GetProcessHeap(), 0, path_extra
);
3302 client1
= HttpOpenRequestW(client
, NULL
, path
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
3304 if(client1
== NULL
) {
3305 InternetCloseHandle(client
);
3308 HttpAddRequestHeadersW(client1
, lpszHeaders
, dwHeadersLength
, HTTP_ADDREQ_FLAG_ADD
);
3309 if (!HttpSendRequestW(client1
, NULL
, 0, NULL
, 0) &&
3310 GetLastError() != ERROR_IO_PENDING
) {
3311 InternetCloseHandle(client1
);
3316 case INTERNET_SCHEME_GOPHER
:
3317 /* gopher doesn't seem to be implemented in wine, but it's supposed
3318 * to be supported by InternetOpenUrlA. */
3320 SetLastError(ERROR_INTERNET_UNRECOGNIZED_SCHEME
);
3324 TRACE(" %p <--\n", client1
);
3329 /**********************************************************
3330 * InternetOpenUrlW (WININET.@)
3335 * handle of connection or NULL on failure
3337 static void AsyncInternetOpenUrlProc(WORKREQUEST
*workRequest
)
3339 struct WORKREQ_INTERNETOPENURLW
const *req
= &workRequest
->u
.InternetOpenUrlW
;
3340 appinfo_t
*hIC
= (appinfo_t
*) workRequest
->hdr
;
3344 INTERNET_InternetOpenUrlW(hIC
, req
->lpszUrl
,
3345 req
->lpszHeaders
, req
->dwHeadersLength
, req
->dwFlags
, req
->dwContext
);
3346 HeapFree(GetProcessHeap(), 0, req
->lpszUrl
);
3347 HeapFree(GetProcessHeap(), 0, req
->lpszHeaders
);
3350 HINTERNET WINAPI
InternetOpenUrlW(HINTERNET hInternet
, LPCWSTR lpszUrl
,
3351 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3353 HINTERNET ret
= NULL
;
3354 appinfo_t
*hIC
= NULL
;
3356 if (TRACE_ON(wininet
)) {
3357 TRACE("(%p, %s, %s, %08x, %08x, %08lx)\n", hInternet
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
3358 dwHeadersLength
, dwFlags
, dwContext
);
3360 dump_INTERNET_FLAGS(dwFlags
);
3365 SetLastError(ERROR_INVALID_PARAMETER
);
3369 hIC
= (appinfo_t
*)get_handle_object( hInternet
);
3370 if (NULL
== hIC
|| hIC
->hdr
.htype
!= WH_HINIT
) {
3371 SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
3375 if (hIC
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
) {
3376 WORKREQUEST workRequest
;
3377 struct WORKREQ_INTERNETOPENURLW
*req
;
3379 workRequest
.asyncproc
= AsyncInternetOpenUrlProc
;
3380 workRequest
.hdr
= WININET_AddRef( &hIC
->hdr
);
3381 req
= &workRequest
.u
.InternetOpenUrlW
;
3382 req
->lpszUrl
= heap_strdupW(lpszUrl
);
3383 req
->lpszHeaders
= heap_strdupW(lpszHeaders
);
3384 req
->dwHeadersLength
= dwHeadersLength
;
3385 req
->dwFlags
= dwFlags
;
3386 req
->dwContext
= dwContext
;
3388 INTERNET_AsyncCall(&workRequest
);
3390 * This is from windows.
3392 SetLastError(ERROR_IO_PENDING
);
3394 ret
= INTERNET_InternetOpenUrlW(hIC
, lpszUrl
, lpszHeaders
, dwHeadersLength
, dwFlags
, dwContext
);
3399 WININET_Release( &hIC
->hdr
);
3400 TRACE(" %p <--\n", ret
);
3405 /**********************************************************
3406 * InternetOpenUrlA (WININET.@)
3411 * handle of connection or NULL on failure
3413 HINTERNET WINAPI
InternetOpenUrlA(HINTERNET hInternet
, LPCSTR lpszUrl
,
3414 LPCSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD_PTR dwContext
)
3416 HINTERNET rc
= NULL
;
3417 DWORD lenHeaders
= 0;
3418 LPWSTR szUrl
= NULL
;
3419 LPWSTR szHeaders
= NULL
;
3424 szUrl
= heap_strdupAtoW(lpszUrl
);
3430 lenHeaders
= MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, NULL
, 0 );
3431 szHeaders
= heap_alloc(lenHeaders
*sizeof(WCHAR
));
3433 HeapFree(GetProcessHeap(), 0, szUrl
);
3436 MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, szHeaders
, lenHeaders
);
3439 rc
= InternetOpenUrlW(hInternet
, szUrl
, szHeaders
,
3440 lenHeaders
, dwFlags
, dwContext
);
3442 HeapFree(GetProcessHeap(), 0, szUrl
);
3443 HeapFree(GetProcessHeap(), 0, szHeaders
);
3449 static LPWITHREADERROR
INTERNET_AllocThreadError(void)
3451 LPWITHREADERROR lpwite
= heap_alloc(sizeof(*lpwite
));
3455 lpwite
->dwError
= 0;
3456 lpwite
->response
[0] = '\0';
3459 if (!TlsSetValue(g_dwTlsErrIndex
, lpwite
))
3461 HeapFree(GetProcessHeap(), 0, lpwite
);
3469 /***********************************************************************
3470 * INTERNET_SetLastError (internal)
3472 * Set last thread specific error
3477 void INTERNET_SetLastError(DWORD dwError
)
3479 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3482 lpwite
= INTERNET_AllocThreadError();
3484 SetLastError(dwError
);
3486 lpwite
->dwError
= dwError
;
3490 /***********************************************************************
3491 * INTERNET_GetLastError (internal)
3493 * Get last thread specific error
3498 DWORD
INTERNET_GetLastError(void)
3500 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3501 if (!lpwite
) return 0;
3502 /* TlsGetValue clears last error, so set it again here */
3503 SetLastError(lpwite
->dwError
);
3504 return lpwite
->dwError
;
3508 /***********************************************************************
3509 * INTERNET_WorkerThreadFunc (internal)
3511 * Worker thread execution function
3516 static DWORD CALLBACK
INTERNET_WorkerThreadFunc(LPVOID lpvParam
)
3518 LPWORKREQUEST lpRequest
= lpvParam
;
3519 WORKREQUEST workRequest
;
3523 workRequest
= *lpRequest
;
3524 HeapFree(GetProcessHeap(), 0, lpRequest
);
3526 workRequest
.asyncproc(&workRequest
);
3527 WININET_Release( workRequest
.hdr
);
3529 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
3531 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex
));
3532 TlsSetValue(g_dwTlsErrIndex
, NULL
);
3538 /***********************************************************************
3539 * INTERNET_AsyncCall (internal)
3541 * Retrieves work request from queue
3546 DWORD
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
)
3549 LPWORKREQUEST lpNewRequest
;
3553 lpNewRequest
= heap_alloc(sizeof(WORKREQUEST
));
3555 return ERROR_OUTOFMEMORY
;
3557 *lpNewRequest
= *lpWorkRequest
;
3559 bSuccess
= QueueUserWorkItem(INTERNET_WorkerThreadFunc
, lpNewRequest
, WT_EXECUTELONGFUNCTION
);
3562 HeapFree(GetProcessHeap(), 0, lpNewRequest
);
3563 return ERROR_INTERNET_ASYNC_THREAD_FAILED
;
3566 return ERROR_SUCCESS
;
3570 /***********************************************************************
3571 * INTERNET_GetResponseBuffer (internal)
3576 LPSTR
INTERNET_GetResponseBuffer(void)
3578 LPWITHREADERROR lpwite
= TlsGetValue(g_dwTlsErrIndex
);
3580 lpwite
= INTERNET_AllocThreadError();
3582 return lpwite
->response
;
3585 /***********************************************************************
3586 * INTERNET_GetNextLine (internal)
3588 * Parse next line in directory string listing
3591 * Pointer to beginning of next line
3596 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
)
3600 BOOL bSuccess
= FALSE
;
3602 LPSTR lpszBuffer
= INTERNET_GetResponseBuffer();
3607 FD_SET(nSocket
,&infd
);
3608 tv
.tv_sec
= RESPONSE_TIMEOUT
;
3611 while (nRecv
< MAX_REPLY_LEN
)
3613 if (select(0, &infd
, NULL
, NULL
, &tv
) > 0)
3615 if (recv(nSocket
, &lpszBuffer
[nRecv
], 1, 0) <= 0)
3617 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS
);
3621 if (lpszBuffer
[nRecv
] == '\n')
3626 if (lpszBuffer
[nRecv
] != '\r')
3631 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT
);
3639 lpszBuffer
[nRecv
] = '\0';
3641 TRACE(":%d %s\n", nRecv
, lpszBuffer
);
3650 /**********************************************************
3651 * InternetQueryDataAvailable (WININET.@)
3653 * Determines how much data is available to be read.
3656 * TRUE on success, FALSE if an error occurred. If
3657 * INTERNET_FLAG_ASYNC was specified in InternetOpen, and
3658 * no data is presently available, FALSE is returned with
3659 * the last error ERROR_IO_PENDING; a callback with status
3660 * INTERNET_STATUS_REQUEST_COMPLETE will be sent when more
3661 * data is available.
3663 BOOL WINAPI
InternetQueryDataAvailable( HINTERNET hFile
,
3664 LPDWORD lpdwNumberOfBytesAvailble
,
3665 DWORD dwFlags
, DWORD_PTR dwContext
)
3667 object_header_t
*hdr
;
3670 TRACE("(%p %p %x %lx)\n", hFile
, lpdwNumberOfBytesAvailble
, dwFlags
, dwContext
);
3672 hdr
= get_handle_object( hFile
);
3674 SetLastError(ERROR_INVALID_HANDLE
);
3678 if(hdr
->vtbl
->QueryDataAvailable
) {
3679 res
= hdr
->vtbl
->QueryDataAvailable(hdr
, lpdwNumberOfBytesAvailble
, dwFlags
, dwContext
);
3681 WARN("wrong handle\n");
3682 res
= ERROR_INTERNET_INCORRECT_HANDLE_TYPE
;
3685 WININET_Release(hdr
);
3687 if(res
!= ERROR_SUCCESS
)
3689 return res
== ERROR_SUCCESS
;
3693 /***********************************************************************
3694 * InternetLockRequestFile (WININET.@)
3696 BOOL WINAPI
InternetLockRequestFile( HINTERNET hInternet
, HANDLE
3703 BOOL WINAPI
InternetUnlockRequestFile( HANDLE hLockHandle
)
3710 /***********************************************************************
3711 * InternetAutodial (WININET.@)
3713 * On windows this function is supposed to dial the default internet
3714 * connection. We don't want to have Wine dial out to the internet so
3715 * we return TRUE by default. It might be nice to check if we are connected.
3722 BOOL WINAPI
InternetAutodial(DWORD dwFlags
, HWND hwndParent
)
3726 /* Tell that we are connected to the internet. */
3730 /***********************************************************************
3731 * InternetAutodialHangup (WININET.@)
3733 * Hangs up a connection made with InternetAutodial
3742 BOOL WINAPI
InternetAutodialHangup(DWORD dwReserved
)
3746 /* we didn't dial, we don't disconnect */
3750 /***********************************************************************
3751 * InternetCombineUrlA (WININET.@)
3753 * Combine a base URL with a relative URL
3761 BOOL WINAPI
InternetCombineUrlA(LPCSTR lpszBaseUrl
, LPCSTR lpszRelativeUrl
,
3762 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3767 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_a(lpszBaseUrl
), debugstr_a(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3769 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3770 dwFlags
^= ICU_NO_ENCODE
;
3771 hr
=UrlCombineA(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3776 /***********************************************************************
3777 * InternetCombineUrlW (WININET.@)
3779 * Combine a base URL with a relative URL
3787 BOOL WINAPI
InternetCombineUrlW(LPCWSTR lpszBaseUrl
, LPCWSTR lpszRelativeUrl
,
3788 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3793 TRACE("(%s, %s, %p, %p, 0x%08x)\n", debugstr_w(lpszBaseUrl
), debugstr_w(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3795 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3796 dwFlags
^= ICU_NO_ENCODE
;
3797 hr
=UrlCombineW(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3802 /* max port num is 65535 => 5 digits */
3803 #define MAX_WORD_DIGITS 5
3805 #define URL_GET_COMP_LENGTH(url, component) ((url)->dw##component##Length ? \
3806 (url)->dw##component##Length : strlenW((url)->lpsz##component))
3807 #define URL_GET_COMP_LENGTHA(url, component) ((url)->dw##component##Length ? \
3808 (url)->dw##component##Length : strlen((url)->lpsz##component))
3810 static BOOL
url_uses_default_port(INTERNET_SCHEME nScheme
, INTERNET_PORT nPort
)
3812 if ((nScheme
== INTERNET_SCHEME_HTTP
) &&
3813 (nPort
== INTERNET_DEFAULT_HTTP_PORT
))
3815 if ((nScheme
== INTERNET_SCHEME_HTTPS
) &&
3816 (nPort
== INTERNET_DEFAULT_HTTPS_PORT
))
3818 if ((nScheme
== INTERNET_SCHEME_FTP
) &&
3819 (nPort
== INTERNET_DEFAULT_FTP_PORT
))
3821 if ((nScheme
== INTERNET_SCHEME_GOPHER
) &&
3822 (nPort
== INTERNET_DEFAULT_GOPHER_PORT
))
3825 if (nPort
== INTERNET_INVALID_PORT_NUMBER
)
3831 /* opaque urls do not fit into the standard url hierarchy and don't have
3832 * two following slashes */
3833 static inline BOOL
scheme_is_opaque(INTERNET_SCHEME nScheme
)
3835 return (nScheme
!= INTERNET_SCHEME_FTP
) &&
3836 (nScheme
!= INTERNET_SCHEME_GOPHER
) &&
3837 (nScheme
!= INTERNET_SCHEME_HTTP
) &&
3838 (nScheme
!= INTERNET_SCHEME_HTTPS
) &&
3839 (nScheme
!= INTERNET_SCHEME_FILE
);
3842 static LPCWSTR
INTERNET_GetSchemeString(INTERNET_SCHEME scheme
)
3845 if (scheme
< INTERNET_SCHEME_FIRST
)
3847 index
= scheme
- INTERNET_SCHEME_FIRST
;
3848 if (index
>= sizeof(url_schemes
)/sizeof(url_schemes
[0]))
3850 return (LPCWSTR
)url_schemes
[index
];
3853 /* we can calculate using ansi strings because we're just
3854 * calculating string length, not size
3856 static BOOL
calc_url_length(LPURL_COMPONENTSW lpUrlComponents
,
3857 LPDWORD lpdwUrlLength
)
3859 INTERNET_SCHEME nScheme
;
3863 if (lpUrlComponents
->lpszScheme
)
3865 DWORD dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Scheme
);
3866 *lpdwUrlLength
+= dwLen
;
3867 nScheme
= GetInternetSchemeW(lpUrlComponents
->lpszScheme
, dwLen
);
3873 nScheme
= lpUrlComponents
->nScheme
;
3875 if (nScheme
== INTERNET_SCHEME_DEFAULT
)
3876 nScheme
= INTERNET_SCHEME_HTTP
;
3877 scheme
= INTERNET_GetSchemeString(nScheme
);
3878 *lpdwUrlLength
+= strlenW(scheme
);
3881 (*lpdwUrlLength
)++; /* ':' */
3882 if (!scheme_is_opaque(nScheme
) || lpUrlComponents
->lpszHostName
)
3883 *lpdwUrlLength
+= strlen("//");
3885 if (lpUrlComponents
->lpszUserName
)
3887 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, UserName
);
3888 *lpdwUrlLength
+= strlen("@");
3892 if (lpUrlComponents
->lpszPassword
)
3894 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
3899 if (lpUrlComponents
->lpszPassword
)
3901 *lpdwUrlLength
+= strlen(":");
3902 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, Password
);
3905 if (lpUrlComponents
->lpszHostName
)
3907 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, HostName
);
3909 if (!url_uses_default_port(nScheme
, lpUrlComponents
->nPort
))
3911 char szPort
[MAX_WORD_DIGITS
+1];
3913 sprintf(szPort
, "%d", lpUrlComponents
->nPort
);
3914 *lpdwUrlLength
+= strlen(szPort
);
3915 *lpdwUrlLength
+= strlen(":");
3918 if (lpUrlComponents
->lpszUrlPath
&& *lpUrlComponents
->lpszUrlPath
!= '/')
3919 (*lpdwUrlLength
)++; /* '/' */
3922 if (lpUrlComponents
->lpszUrlPath
)
3923 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, UrlPath
);
3925 if (lpUrlComponents
->lpszExtraInfo
)
3926 *lpdwUrlLength
+= URL_GET_COMP_LENGTH(lpUrlComponents
, ExtraInfo
);
3931 static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents
, LPURL_COMPONENTSW urlCompW
)
3935 ZeroMemory(urlCompW
, sizeof(URL_COMPONENTSW
));
3937 urlCompW
->dwStructSize
= sizeof(URL_COMPONENTSW
);
3938 urlCompW
->dwSchemeLength
= lpUrlComponents
->dwSchemeLength
;
3939 urlCompW
->nScheme
= lpUrlComponents
->nScheme
;
3940 urlCompW
->dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
3941 urlCompW
->nPort
= lpUrlComponents
->nPort
;
3942 urlCompW
->dwUserNameLength
= lpUrlComponents
->dwUserNameLength
;
3943 urlCompW
->dwPasswordLength
= lpUrlComponents
->dwPasswordLength
;
3944 urlCompW
->dwUrlPathLength
= lpUrlComponents
->dwUrlPathLength
;
3945 urlCompW
->dwExtraInfoLength
= lpUrlComponents
->dwExtraInfoLength
;
3947 if (lpUrlComponents
->lpszScheme
)
3949 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, Scheme
) + 1;
3950 urlCompW
->lpszScheme
= heap_alloc(len
* sizeof(WCHAR
));
3951 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszScheme
,
3952 -1, urlCompW
->lpszScheme
, len
);
3955 if (lpUrlComponents
->lpszHostName
)
3957 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, HostName
) + 1;
3958 urlCompW
->lpszHostName
= heap_alloc(len
* sizeof(WCHAR
));
3959 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszHostName
,
3960 -1, urlCompW
->lpszHostName
, len
);
3963 if (lpUrlComponents
->lpszUserName
)
3965 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, UserName
) + 1;
3966 urlCompW
->lpszUserName
= heap_alloc(len
* sizeof(WCHAR
));
3967 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszUserName
,
3968 -1, urlCompW
->lpszUserName
, len
);
3971 if (lpUrlComponents
->lpszPassword
)
3973 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, Password
) + 1;
3974 urlCompW
->lpszPassword
= heap_alloc(len
* sizeof(WCHAR
));
3975 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszPassword
,
3976 -1, urlCompW
->lpszPassword
, len
);
3979 if (lpUrlComponents
->lpszUrlPath
)
3981 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, UrlPath
) + 1;
3982 urlCompW
->lpszUrlPath
= heap_alloc(len
* sizeof(WCHAR
));
3983 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszUrlPath
,
3984 -1, urlCompW
->lpszUrlPath
, len
);
3987 if (lpUrlComponents
->lpszExtraInfo
)
3989 len
= URL_GET_COMP_LENGTHA(lpUrlComponents
, ExtraInfo
) + 1;
3990 urlCompW
->lpszExtraInfo
= heap_alloc(len
* sizeof(WCHAR
));
3991 MultiByteToWideChar(CP_ACP
, 0, lpUrlComponents
->lpszExtraInfo
,
3992 -1, urlCompW
->lpszExtraInfo
, len
);
3996 /***********************************************************************
3997 * InternetCreateUrlA (WININET.@)
3999 * See InternetCreateUrlW.
4001 BOOL WINAPI
InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents
, DWORD dwFlags
,
4002 LPSTR lpszUrl
, LPDWORD lpdwUrlLength
)
4006 URL_COMPONENTSW urlCompW
;
4008 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents
, dwFlags
, lpszUrl
, lpdwUrlLength
);
4010 if (!lpUrlComponents
|| lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSW
) || !lpdwUrlLength
)
4012 SetLastError(ERROR_INVALID_PARAMETER
);
4016 convert_urlcomp_atow(lpUrlComponents
, &urlCompW
);
4019 urlW
= heap_alloc(*lpdwUrlLength
* sizeof(WCHAR
));
4021 ret
= InternetCreateUrlW(&urlCompW
, dwFlags
, urlW
, lpdwUrlLength
);
4023 if (!ret
&& (GetLastError() == ERROR_INSUFFICIENT_BUFFER
))
4024 *lpdwUrlLength
/= sizeof(WCHAR
);
4026 /* on success, lpdwUrlLength points to the size of urlW in WCHARS
4027 * minus one, so add one to leave room for NULL terminator
4030 WideCharToMultiByte(CP_ACP
, 0, urlW
, -1, lpszUrl
, *lpdwUrlLength
+ 1, NULL
, NULL
);
4032 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszScheme
);
4033 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszHostName
);
4034 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszUserName
);
4035 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszPassword
);
4036 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszUrlPath
);
4037 HeapFree(GetProcessHeap(), 0, urlCompW
.lpszExtraInfo
);
4038 HeapFree(GetProcessHeap(), 0, urlW
);
4043 /***********************************************************************
4044 * InternetCreateUrlW (WININET.@)
4046 * Creates a URL from its component parts.
4049 * lpUrlComponents [I] URL Components.
4050 * dwFlags [I] Flags. See notes.
4051 * lpszUrl [I] Buffer in which to store the created URL.
4052 * lpdwUrlLength [I/O] On input, the length of the buffer pointed to by
4053 * lpszUrl in characters. On output, the number of bytes
4054 * required to store the URL including terminator.
4058 * The dwFlags parameter can be zero or more of the following:
4059 *|ICU_ESCAPE - Generates escape sequences for unsafe characters in the path and extra info of the URL.
4066 BOOL WINAPI
InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents
, DWORD dwFlags
,
4067 LPWSTR lpszUrl
, LPDWORD lpdwUrlLength
)
4070 INTERNET_SCHEME nScheme
;
4072 static const WCHAR slashSlashW
[] = {'/','/'};
4073 static const WCHAR fmtW
[] = {'%','u',0};
4075 TRACE("(%p,%d,%p,%p)\n", lpUrlComponents
, dwFlags
, lpszUrl
, lpdwUrlLength
);
4077 if (!lpUrlComponents
|| lpUrlComponents
->dwStructSize
!= sizeof(URL_COMPONENTSW
) || !lpdwUrlLength
)
4079 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
4083 if (!calc_url_length(lpUrlComponents
, &dwLen
))
4086 if (!lpszUrl
|| *lpdwUrlLength
< dwLen
)
4088 *lpdwUrlLength
= (dwLen
+ 1) * sizeof(WCHAR
);
4089 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
4093 *lpdwUrlLength
= dwLen
;
4098 if (lpUrlComponents
->lpszScheme
)
4100 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Scheme
);
4101 memcpy(lpszUrl
, lpUrlComponents
->lpszScheme
, dwLen
* sizeof(WCHAR
));
4104 nScheme
= GetInternetSchemeW(lpUrlComponents
->lpszScheme
, dwLen
);
4109 nScheme
= lpUrlComponents
->nScheme
;
4111 if (nScheme
== INTERNET_SCHEME_DEFAULT
)
4112 nScheme
= INTERNET_SCHEME_HTTP
;
4114 scheme
= INTERNET_GetSchemeString(nScheme
);
4115 dwLen
= strlenW(scheme
);
4116 memcpy(lpszUrl
, scheme
, dwLen
* sizeof(WCHAR
));
4120 /* all schemes are followed by at least a colon */
4124 if (!scheme_is_opaque(nScheme
) || lpUrlComponents
->lpszHostName
)
4126 memcpy(lpszUrl
, slashSlashW
, sizeof(slashSlashW
));
4127 lpszUrl
+= sizeof(slashSlashW
)/sizeof(slashSlashW
[0]);
4130 if (lpUrlComponents
->lpszUserName
)
4132 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, UserName
);
4133 memcpy(lpszUrl
, lpUrlComponents
->lpszUserName
, dwLen
* sizeof(WCHAR
));
4136 if (lpUrlComponents
->lpszPassword
)
4141 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, Password
);
4142 memcpy(lpszUrl
, lpUrlComponents
->lpszPassword
, dwLen
* sizeof(WCHAR
));
4150 if (lpUrlComponents
->lpszHostName
)
4152 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, HostName
);
4153 memcpy(lpszUrl
, lpUrlComponents
->lpszHostName
, dwLen
* sizeof(WCHAR
));
4156 if (!url_uses_default_port(nScheme
, lpUrlComponents
->nPort
))
4158 WCHAR szPort
[MAX_WORD_DIGITS
+1];
4160 sprintfW(szPort
, fmtW
, lpUrlComponents
->nPort
);
4163 dwLen
= strlenW(szPort
);
4164 memcpy(lpszUrl
, szPort
, dwLen
* sizeof(WCHAR
));
4168 /* add slash between hostname and path if necessary */
4169 if (lpUrlComponents
->lpszUrlPath
&& *lpUrlComponents
->lpszUrlPath
!= '/')
4176 if (lpUrlComponents
->lpszUrlPath
)
4178 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, UrlPath
);
4179 memcpy(lpszUrl
, lpUrlComponents
->lpszUrlPath
, dwLen
* sizeof(WCHAR
));
4183 if (lpUrlComponents
->lpszExtraInfo
)
4185 dwLen
= URL_GET_COMP_LENGTH(lpUrlComponents
, ExtraInfo
);
4186 memcpy(lpszUrl
, lpUrlComponents
->lpszExtraInfo
, dwLen
* sizeof(WCHAR
));
4195 /***********************************************************************
4196 * InternetConfirmZoneCrossingA (WININET.@)
4199 DWORD WINAPI
InternetConfirmZoneCrossingA( HWND hWnd
, LPSTR szUrlPrev
, LPSTR szUrlNew
, BOOL bPost
)
4201 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_a(szUrlPrev
), debugstr_a(szUrlNew
), bPost
);
4202 return ERROR_SUCCESS
;
4205 /***********************************************************************
4206 * InternetConfirmZoneCrossingW (WININET.@)
4209 DWORD WINAPI
InternetConfirmZoneCrossingW( HWND hWnd
, LPWSTR szUrlPrev
, LPWSTR szUrlNew
, BOOL bPost
)
4211 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_w(szUrlPrev
), debugstr_w(szUrlNew
), bPost
);
4212 return ERROR_SUCCESS
;
4215 static DWORD zone_preference
= 3;
4217 /***********************************************************************
4218 * PrivacySetZonePreferenceW (WININET.@)
4220 DWORD WINAPI
PrivacySetZonePreferenceW( DWORD zone
, DWORD type
, DWORD
template, LPCWSTR preference
)
4222 FIXME( "%x %x %x %s: stub\n", zone
, type
, template, debugstr_w(preference
) );
4224 zone_preference
= template;
4228 /***********************************************************************
4229 * PrivacyGetZonePreferenceW (WININET.@)
4231 DWORD WINAPI
PrivacyGetZonePreferenceW( DWORD zone
, DWORD type
, LPDWORD
template,
4232 LPWSTR preference
, LPDWORD length
)
4234 FIXME( "%x %x %p %p %p: stub\n", zone
, type
, template, preference
, length
);
4236 if (template) *template = zone_preference
;
4240 DWORD WINAPI
InternetDialA( HWND hwndParent
, LPSTR lpszConnectoid
, DWORD dwFlags
,
4241 DWORD_PTR
* lpdwConnection
, DWORD dwReserved
)
4243 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
4244 lpdwConnection
, dwReserved
);
4245 return ERROR_SUCCESS
;
4248 DWORD WINAPI
InternetDialW( HWND hwndParent
, LPWSTR lpszConnectoid
, DWORD dwFlags
,
4249 DWORD_PTR
* lpdwConnection
, DWORD dwReserved
)
4251 FIXME("(%p, %p, 0x%08x, %p, 0x%08x) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
4252 lpdwConnection
, dwReserved
);
4253 return ERROR_SUCCESS
;
4256 BOOL WINAPI
InternetGoOnlineA( LPSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
4258 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_a(lpszURL
), hwndParent
, dwReserved
);
4262 BOOL WINAPI
InternetGoOnlineW( LPWSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
4264 FIXME("(%s, %p, 0x%08x) stub\n", debugstr_w(lpszURL
), hwndParent
, dwReserved
);
4268 DWORD WINAPI
InternetHangUp( DWORD_PTR dwConnection
, DWORD dwReserved
)
4270 FIXME("(0x%08lx, 0x%08x) stub\n", dwConnection
, dwReserved
);
4271 return ERROR_SUCCESS
;
4274 BOOL WINAPI
CreateMD5SSOHash( PWSTR pszChallengeInfo
, PWSTR pwszRealm
, PWSTR pwszTarget
,
4277 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo
), debugstr_w(pwszRealm
),
4278 debugstr_w(pwszTarget
), pbHexHash
);
4282 BOOL WINAPI
ResumeSuspendedDownload( HINTERNET hInternet
, DWORD dwError
)
4284 FIXME("(%p, 0x%08x) stub\n", hInternet
, dwError
);
4288 BOOL WINAPI
InternetQueryFortezzaStatus(DWORD
*a
, DWORD_PTR b
)
4290 FIXME("(%p, %08lx) stub\n", a
, b
);