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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include "wine/port.h"
32 #define MAXHOSTNAME 100 /* from http.c */
37 #include <sys/types.h>
38 #ifdef HAVE_SYS_SOCKET_H
39 # include <sys/socket.h>
41 #ifdef HAVE_SYS_TIME_H
42 # include <sys/time.h>
58 #include "wine/debug.h"
60 #define NO_SHLWAPI_STREAM
63 #include "wine/exception.h"
69 #include "wine/unicode.h"
71 WINE_DEFAULT_DEBUG_CHANNEL(wininet
);
73 #define MAX_IDLE_WORKER 1000*60*1
74 #define MAX_WORKER_THREADS 10
75 #define RESPONSE_TIMEOUT 30
77 #define GET_HWININET_FROM_LPWININETFINDNEXT(lpwh) \
78 (LPWININETAPPINFOW)(((LPWININETFTPSESSIONW)(lpwh->hdr.lpwhparent))->hdr.lpwhparent)
84 CHAR response
[MAX_REPLY_LEN
];
85 } WITHREADERROR
, *LPWITHREADERROR
;
87 static VOID
INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr
);
88 BOOL WINAPI
INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh
, LPVOID lpvFindData
);
89 HINTERNET WINAPI
INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC
, LPCWSTR lpszUrl
,
90 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD dwContext
);
91 static VOID
INTERNET_ExecuteWork(void);
93 static DWORD g_dwTlsErrIndex
= TLS_OUT_OF_INDEXES
;
94 static DWORD dwNumThreads
;
95 static DWORD dwNumIdleThreads
;
96 static DWORD dwNumJobs
;
97 static HANDLE hEventArray
[2];
98 #define hQuitEvent hEventArray[0]
99 #define hWorkEvent hEventArray[1]
100 static CRITICAL_SECTION csQueue
;
101 static LPWORKREQUEST lpHeadWorkQueue
;
102 static LPWORKREQUEST lpWorkQueueTail
;
103 static HMODULE WININET_hModule
;
105 extern void URLCacheContainers_CreateDefaults(void);
106 extern void URLCacheContainers_DeleteAll(void);
108 #define HANDLE_CHUNK_SIZE 0x10
110 static CRITICAL_SECTION WININET_cs
;
111 static CRITICAL_SECTION_DEBUG WININET_cs_debug
=
114 { &WININET_cs_debug
.ProcessLocksList
, &WININET_cs_debug
.ProcessLocksList
},
115 0, 0, { 0, (DWORD
)(__FILE__
": WININET_cs") }
117 static CRITICAL_SECTION WININET_cs
= { &WININET_cs_debug
, -1, 0, 0, 0, 0 };
119 static LPWININETHANDLEHEADER
*WININET_Handles
;
120 static UINT WININET_dwNextHandle
;
121 static UINT WININET_dwMaxHandles
;
123 HINTERNET
WININET_AllocHandle( LPWININETHANDLEHEADER info
)
125 LPWININETHANDLEHEADER
*p
;
126 UINT handle
= 0, num
;
128 EnterCriticalSection( &WININET_cs
);
129 if( !WININET_dwMaxHandles
)
131 num
= HANDLE_CHUNK_SIZE
;
132 p
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
137 WININET_dwMaxHandles
= num
;
139 if( WININET_dwMaxHandles
== WININET_dwNextHandle
)
141 num
= WININET_dwMaxHandles
+ HANDLE_CHUNK_SIZE
;
142 p
= HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
143 WININET_Handles
, sizeof (UINT
)* num
);
147 WININET_dwMaxHandles
= num
;
150 handle
= WININET_dwNextHandle
;
151 if( WININET_Handles
[handle
] )
152 ERR("handle isn't free but should be\n");
153 WININET_Handles
[handle
] = WININET_AddRef( info
);
155 while( WININET_Handles
[WININET_dwNextHandle
] &&
156 (WININET_dwNextHandle
< WININET_dwMaxHandles
) )
157 WININET_dwNextHandle
++;
160 LeaveCriticalSection( &WININET_cs
);
162 return (HINTERNET
) (handle
+1);
165 HINTERNET
WININET_FindHandle( LPWININETHANDLEHEADER info
)
169 EnterCriticalSection( &WININET_cs
);
170 for( i
=0; i
<WININET_dwMaxHandles
; i
++ )
172 if( info
== WININET_Handles
[i
] )
174 WININET_AddRef( info
);
179 LeaveCriticalSection( &WININET_cs
);
181 return (HINTERNET
) handle
;
184 LPWININETHANDLEHEADER
WININET_AddRef( LPWININETHANDLEHEADER info
)
187 TRACE("%p -> refcount = %ld\n", info
, info
->dwRefCount
);
191 LPWININETHANDLEHEADER
WININET_GetObject( HINTERNET hinternet
)
193 LPWININETHANDLEHEADER info
= NULL
;
194 UINT handle
= (UINT
) hinternet
;
196 EnterCriticalSection( &WININET_cs
);
198 if( (handle
> 0) && ( handle
<= WININET_dwMaxHandles
) &&
199 WININET_Handles
[handle
-1] )
200 info
= WININET_AddRef( WININET_Handles
[handle
-1] );
202 LeaveCriticalSection( &WININET_cs
);
204 TRACE("handle %d -> %p\n", handle
, info
);
209 BOOL
WININET_Release( LPWININETHANDLEHEADER info
)
212 TRACE( "object %p refcount = %ld\n", info
, info
->dwRefCount
);
213 if( !info
->dwRefCount
)
215 TRACE( "destroying object %p\n", info
);
216 info
->destroy( info
);
221 BOOL
WININET_FreeHandle( HINTERNET hinternet
)
224 UINT handle
= (UINT
) hinternet
;
225 LPWININETHANDLEHEADER info
= NULL
;
227 EnterCriticalSection( &WININET_cs
);
229 if( (handle
> 0) && ( handle
<= WININET_dwMaxHandles
) )
232 if( WININET_Handles
[handle
] )
234 info
= WININET_Handles
[handle
];
235 TRACE( "destroying handle %d for object %p\n", handle
+1, info
);
236 WININET_Handles
[handle
] = NULL
;
238 if( WININET_dwNextHandle
> handle
)
239 WININET_dwNextHandle
= handle
;
243 LeaveCriticalSection( &WININET_cs
);
246 WININET_Release( info
);
251 /***********************************************************************
252 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
255 * hinstDLL [I] handle to the DLL's instance
257 * lpvReserved [I] reserved, must be NULL
264 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
266 TRACE("%p,%lx,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
269 case DLL_PROCESS_ATTACH
:
271 g_dwTlsErrIndex
= TlsAlloc();
273 if (g_dwTlsErrIndex
== TLS_OUT_OF_INDEXES
)
276 hQuitEvent
= CreateEventW(0, TRUE
, FALSE
, NULL
);
277 hWorkEvent
= CreateEventW(0, FALSE
, FALSE
, NULL
);
278 InitializeCriticalSection(&csQueue
);
280 URLCacheContainers_CreateDefaults();
283 dwNumIdleThreads
= 0;
286 WININET_hModule
= (HMODULE
)hinstDLL
;
288 case DLL_THREAD_ATTACH
:
290 LPWITHREADERROR lpwite
= HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR
));
294 TlsSetValue(g_dwTlsErrIndex
, (LPVOID
)lpwite
);
298 case DLL_THREAD_DETACH
:
299 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
301 LPVOID lpwite
= TlsGetValue(g_dwTlsErrIndex
);
302 HeapFree(GetProcessHeap(), 0, lpwite
);
306 case DLL_PROCESS_DETACH
:
308 URLCacheContainers_DeleteAll();
310 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
312 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex
));
313 TlsFree(g_dwTlsErrIndex
);
316 SetEvent(hQuitEvent
);
318 CloseHandle(hQuitEvent
);
319 CloseHandle(hWorkEvent
);
320 DeleteCriticalSection(&csQueue
);
328 /***********************************************************************
329 * InternetInitializeAutoProxyDll (WININET.@)
331 * Setup the internal proxy
340 BOOL WINAPI
InternetInitializeAutoProxyDll(DWORD dwReserved
)
343 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
347 /***********************************************************************
348 * DetectAutoProxyUrl (WININET.@)
350 * Auto detect the proxy url
356 BOOL WINAPI
DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl
,
357 DWORD dwAutoProxyUrlLength
, DWORD dwDetectFlags
)
360 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
365 /***********************************************************************
366 * INTERNET_ConfigureProxyFromReg
369 * The proxy may be specified in the form 'http=proxy.my.org'
370 * Presumably that means there can be ftp=ftpproxy.my.org too.
372 static BOOL
INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOW lpwai
)
375 DWORD r
, keytype
, len
, enabled
;
376 LPSTR lpszInternetSettings
=
377 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
378 static const WCHAR szProxyServer
[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
380 r
= RegOpenKeyA(HKEY_CURRENT_USER
, lpszInternetSettings
, &key
);
381 if ( r
!= ERROR_SUCCESS
)
384 len
= sizeof enabled
;
385 r
= RegQueryValueExA( key
, "ProxyEnable", NULL
, &keytype
,
386 (BYTE
*)&enabled
, &len
);
387 if( (r
== ERROR_SUCCESS
) && enabled
)
389 TRACE("Proxy is enabled.\n");
391 /* figure out how much memory the proxy setting takes */
392 r
= RegQueryValueExW( key
, szProxyServer
, NULL
, &keytype
,
394 if( (r
== ERROR_SUCCESS
) && len
&& (keytype
== REG_SZ
) )
397 static const WCHAR szHttp
[] = {'h','t','t','p','=',0};
399 szProxy
=HeapAlloc( GetProcessHeap(), 0, len
);
400 RegQueryValueExW( key
, szProxyServer
, NULL
, &keytype
,
401 (BYTE
*)szProxy
, &len
);
403 /* find the http proxy, and strip away everything else */
404 p
= strstrW( szProxy
, szHttp
);
407 p
+= lstrlenW(szHttp
);
408 lstrcpyW( szProxy
, p
);
410 p
= strchrW( szProxy
, ' ' );
414 lpwai
->dwAccessType
= INTERNET_OPEN_TYPE_PROXY
;
415 lpwai
->lpszProxy
= szProxy
;
417 TRACE("http proxy = %s\n", debugstr_w(lpwai
->lpszProxy
));
420 ERR("Couldn't read proxy server settings.\n");
423 TRACE("Proxy is not enabled.\n");
429 /***********************************************************************
430 * InternetOpenW (WININET.@)
432 * Per-application initialization of wininet
435 * HINTERNET on success
439 HINTERNET WINAPI
InternetOpenW(LPCWSTR lpszAgent
, DWORD dwAccessType
,
440 LPCWSTR lpszProxy
, LPCWSTR lpszProxyBypass
, DWORD dwFlags
)
442 LPWININETAPPINFOW lpwai
= NULL
;
443 HINTERNET handle
= NULL
;
445 if (TRACE_ON(wininet
)) {
446 #define FE(x) { x, #x }
447 static const wininet_flag_info access_type
[] = {
448 FE(INTERNET_OPEN_TYPE_PRECONFIG
),
449 FE(INTERNET_OPEN_TYPE_DIRECT
),
450 FE(INTERNET_OPEN_TYPE_PROXY
),
451 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY
)
455 const char *access_type_str
= "Unknown";
457 TRACE("(%s, %li, %s, %s, %li)\n", debugstr_w(lpszAgent
), dwAccessType
,
458 debugstr_w(lpszProxy
), debugstr_w(lpszProxyBypass
), dwFlags
);
459 for (i
= 0; i
< (sizeof(access_type
) / sizeof(access_type
[0])); i
++) {
460 if (access_type
[i
].val
== dwAccessType
) {
461 access_type_str
= access_type
[i
].name
;
465 TRACE(" access type : %s\n", access_type_str
);
467 dump_INTERNET_FLAGS(dwFlags
);
470 /* Clear any error information */
471 INTERNET_SetLastError(0);
473 lpwai
= HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOW
));
476 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
480 memset(lpwai
, 0, sizeof(WININETAPPINFOW
));
481 lpwai
->hdr
.htype
= WH_HINIT
;
482 lpwai
->hdr
.lpwhparent
= NULL
;
483 lpwai
->hdr
.dwFlags
= dwFlags
;
484 lpwai
->hdr
.dwRefCount
= 1;
485 lpwai
->hdr
.destroy
= INTERNET_CloseHandle
;
486 lpwai
->dwAccessType
= dwAccessType
;
487 lpwai
->lpszProxyUsername
= NULL
;
488 lpwai
->lpszProxyPassword
= NULL
;
490 handle
= WININET_AllocHandle( &lpwai
->hdr
);
493 HeapFree( GetProcessHeap(), 0, lpwai
);
494 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
498 if (NULL
!= lpszAgent
)
500 lpwai
->lpszAgent
= HeapAlloc( GetProcessHeap(),0,
501 (strlenW(lpszAgent
)+1)*sizeof(WCHAR
));
502 if (lpwai
->lpszAgent
)
503 lstrcpyW( lpwai
->lpszAgent
, lpszAgent
);
505 if(dwAccessType
== INTERNET_OPEN_TYPE_PRECONFIG
)
506 INTERNET_ConfigureProxyFromReg( lpwai
);
507 else if (NULL
!= lpszProxy
)
509 lpwai
->lpszProxy
= HeapAlloc( GetProcessHeap(), 0,
510 (strlenW(lpszProxy
)+1)*sizeof(WCHAR
));
511 if (lpwai
->lpszProxy
)
512 lstrcpyW( lpwai
->lpszProxy
, lpszProxy
);
515 if (NULL
!= lpszProxyBypass
)
517 lpwai
->lpszProxyBypass
= HeapAlloc( GetProcessHeap(), 0,
518 (strlenW(lpszProxyBypass
)+1)*sizeof(WCHAR
));
519 if (lpwai
->lpszProxyBypass
)
520 lstrcpyW( lpwai
->lpszProxyBypass
, lpszProxyBypass
);
525 WININET_Release( &lpwai
->hdr
);
527 TRACE("returning %p\n", lpwai
);
533 /***********************************************************************
534 * InternetOpenA (WININET.@)
536 * Per-application initialization of wininet
539 * HINTERNET on success
543 HINTERNET WINAPI
InternetOpenA(LPCSTR lpszAgent
, DWORD dwAccessType
,
544 LPCSTR lpszProxy
, LPCSTR lpszProxyBypass
, DWORD dwFlags
)
546 HINTERNET rc
= (HINTERNET
)NULL
;
548 WCHAR
*szAgent
= NULL
, *szProxy
= NULL
, *szBypass
= NULL
;
550 TRACE("(%s, 0x%08lx, %s, %s, 0x%08lx)\n", debugstr_a(lpszAgent
),
551 dwAccessType
, debugstr_a(lpszProxy
), debugstr_a(lpszProxyBypass
), dwFlags
);
555 len
= MultiByteToWideChar(CP_ACP
, 0, lpszAgent
, -1, NULL
, 0);
556 szAgent
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
557 MultiByteToWideChar(CP_ACP
, 0, lpszAgent
, -1, szAgent
, len
);
562 len
= MultiByteToWideChar(CP_ACP
, 0, lpszProxy
, -1, NULL
, 0);
563 szProxy
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
564 MultiByteToWideChar(CP_ACP
, 0, lpszProxy
, -1, szProxy
, len
);
567 if( lpszProxyBypass
)
569 len
= MultiByteToWideChar(CP_ACP
, 0, lpszProxyBypass
, -1, NULL
, 0);
570 szBypass
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
571 MultiByteToWideChar(CP_ACP
, 0, lpszProxyBypass
, -1, szBypass
, len
);
574 rc
= InternetOpenW(szAgent
, dwAccessType
, szProxy
, szBypass
, dwFlags
);
576 HeapFree(GetProcessHeap(), 0, szAgent
);
577 HeapFree(GetProcessHeap(), 0, szProxy
);
578 HeapFree(GetProcessHeap(), 0, szBypass
);
583 /***********************************************************************
584 * InternetGetLastResponseInfoA (WININET.@)
586 * Return last wininet error description on the calling thread
589 * TRUE on success of writing to buffer
593 BOOL WINAPI
InternetGetLastResponseInfoA(LPDWORD lpdwError
,
594 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
596 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
600 *lpdwError
= lpwite
->dwError
;
603 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
604 *lpdwBufferLength
= strlen(lpszBuffer
);
607 *lpdwBufferLength
= 0;
612 /***********************************************************************
613 * InternetGetLastResponseInfoW (WININET.@)
615 * Return last wininet error description on the calling thread
618 * TRUE on success of writing to buffer
622 BOOL WINAPI
InternetGetLastResponseInfoW(LPDWORD lpdwError
,
623 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
625 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
629 *lpdwError
= lpwite
->dwError
;
632 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
633 *lpdwBufferLength
= lstrlenW(lpszBuffer
);
636 *lpdwBufferLength
= 0;
641 /***********************************************************************
642 * InternetGetConnectedState (WININET.@)
644 * Return connected state
648 * if lpdwStatus is not null, return the status (off line,
649 * modem, lan...) in it.
650 * FALSE if not connected
652 BOOL WINAPI
InternetGetConnectedState(LPDWORD lpdwStatus
, DWORD dwReserved
)
654 TRACE("(%p, 0x%08lx)\n", lpdwStatus
, dwReserved
);
657 FIXME("always returning LAN connection.\n");
658 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
664 /***********************************************************************
665 * InternetGetConnectedStateExW (WININET.@)
667 * Return connected state
671 * lpdwStatus [O] Flags specifying the status of the internet connection.
672 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
673 * dwNameLen [I] Size of the buffer, in characters.
674 * dwReserved [I] Reserved. Must be set to 0.
678 * if lpdwStatus is not null, return the status (off line,
679 * modem, lan...) in it.
680 * FALSE if not connected
683 * If the system has no available network connections, an empty string is
684 * stored in lpszConnectionName. If there is a LAN connection, a localized
685 * "LAN Connection" string is stored. Presumably, if only a dial-up
686 * connection is available then the name of the dial-up connection is
687 * returned. Why any application, other than the "Internet Settings" CPL,
688 * would want to use this function instead of the simpler InternetGetConnectedStateW
689 * function is beyond me.
691 BOOL WINAPI
InternetGetConnectedStateExW(LPDWORD lpdwStatus
, LPWSTR lpszConnectionName
,
692 DWORD dwNameLen
, DWORD dwReserved
)
694 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
701 FIXME("always returning LAN connection.\n");
702 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
704 return LoadStringW(WININET_hModule
, IDS_LANCONNECTION
, lpszConnectionName
, dwNameLen
);
708 /***********************************************************************
709 * InternetGetConnectedStateExA (WININET.@)
711 BOOL WINAPI
InternetGetConnectedStateExA(LPDWORD lpdwStatus
, LPSTR lpszConnectionName
,
712 DWORD dwNameLen
, DWORD dwReserved
)
714 LPWSTR lpwszConnectionName
= NULL
;
717 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
719 if (lpszConnectionName
&& dwNameLen
> 0)
720 lpwszConnectionName
= HeapAlloc(GetProcessHeap(), 0, dwNameLen
* sizeof(WCHAR
));
722 rc
= InternetGetConnectedStateExW(lpdwStatus
,lpwszConnectionName
, dwNameLen
,
724 if (rc
&& lpwszConnectionName
)
726 WideCharToMultiByte(CP_ACP
,0,lpwszConnectionName
,-1,lpszConnectionName
,
727 dwNameLen
, NULL
, NULL
);
729 HeapFree(GetProcessHeap(),0,lpwszConnectionName
);
736 /***********************************************************************
737 * InternetConnectW (WININET.@)
739 * Open a ftp, gopher or http session
742 * HINTERNET a session handle on success
746 HINTERNET WINAPI
InternetConnectW(HINTERNET hInternet
,
747 LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
748 LPCWSTR lpszUserName
, LPCWSTR lpszPassword
,
749 DWORD dwService
, DWORD dwFlags
, DWORD dwContext
)
751 LPWININETAPPINFOW hIC
;
752 HINTERNET rc
= (HINTERNET
) NULL
;
754 TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet
, debugstr_w(lpszServerName
),
755 nServerPort
, debugstr_w(lpszUserName
), debugstr_w(lpszPassword
),
756 dwService
, dwFlags
, dwContext
);
758 /* Clear any error information */
759 INTERNET_SetLastError(0);
760 hIC
= (LPWININETAPPINFOW
) WININET_GetObject( hInternet
);
761 if ( (hIC
== NULL
) || (hIC
->hdr
.htype
!= WH_HINIT
) )
766 case INTERNET_SERVICE_FTP
:
767 rc
= FTP_Connect(hIC
, lpszServerName
, nServerPort
,
768 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0);
771 case INTERNET_SERVICE_HTTP
:
772 rc
= HTTP_Connect(hIC
, lpszServerName
, nServerPort
,
773 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0);
776 case INTERNET_SERVICE_GOPHER
:
782 WININET_Release( &hIC
->hdr
);
784 TRACE("returning %p\n", rc
);
789 /***********************************************************************
790 * InternetConnectA (WININET.@)
792 * Open a ftp, gopher or http session
795 * HINTERNET a session handle on success
799 HINTERNET WINAPI
InternetConnectA(HINTERNET hInternet
,
800 LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
801 LPCSTR lpszUserName
, LPCSTR lpszPassword
,
802 DWORD dwService
, DWORD dwFlags
, DWORD dwContext
)
804 HINTERNET rc
= (HINTERNET
)NULL
;
806 LPWSTR szServerName
= NULL
;
807 LPWSTR szUserName
= NULL
;
808 LPWSTR szPassword
= NULL
;
812 len
= MultiByteToWideChar(CP_ACP
, 0, lpszServerName
, -1, NULL
, 0);
813 szServerName
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
814 MultiByteToWideChar(CP_ACP
, 0, lpszServerName
, -1, szServerName
, len
);
818 len
= MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, NULL
, 0);
819 szUserName
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
820 MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, szUserName
, len
);
824 len
= MultiByteToWideChar(CP_ACP
, 0, lpszPassword
, -1, NULL
, 0);
825 szPassword
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
826 MultiByteToWideChar(CP_ACP
, 0, lpszPassword
, -1, szPassword
, len
);
830 rc
= InternetConnectW(hInternet
, szServerName
, nServerPort
,
831 szUserName
, szPassword
, dwService
, dwFlags
, dwContext
);
833 HeapFree(GetProcessHeap(), 0, szServerName
);
834 HeapFree(GetProcessHeap(), 0, szUserName
);
835 HeapFree(GetProcessHeap(), 0, szPassword
);
840 /***********************************************************************
841 * InternetFindNextFileA (WININET.@)
843 * Continues a file search from a previous call to FindFirstFile
850 BOOL WINAPI
InternetFindNextFileA(HINTERNET hFind
, LPVOID lpvFindData
)
855 ret
= InternetFindNextFileW(hFind
, lpvFindData
?&fd
:NULL
);
857 WININET_find_data_WtoA(&fd
, (LPWIN32_FIND_DATAA
)lpvFindData
);
861 /***********************************************************************
862 * InternetFindNextFileW (WININET.@)
864 * Continues a file search from a previous call to FindFirstFile
871 BOOL WINAPI
InternetFindNextFileW(HINTERNET hFind
, LPVOID lpvFindData
)
873 LPWININETAPPINFOW hIC
= NULL
;
874 LPWININETFINDNEXTW lpwh
;
875 BOOL bSuccess
= FALSE
;
879 lpwh
= (LPWININETFINDNEXTW
) WININET_GetObject( hFind
);
880 if (NULL
== lpwh
|| lpwh
->hdr
.htype
!= WH_HFINDNEXT
)
882 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
886 hIC
= GET_HWININET_FROM_LPWININETFINDNEXT(lpwh
);
887 if (hIC
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
)
889 WORKREQUEST workRequest
;
890 struct WORKREQ_INTERNETFINDNEXTW
*req
;
892 workRequest
.asyncall
= INTERNETFINDNEXTW
;
893 workRequest
.hdr
= WININET_AddRef( &lpwh
->hdr
);
894 req
= &workRequest
.u
.InternetFindNextW
;
895 req
->lpFindFileData
= lpvFindData
;
897 bSuccess
= INTERNET_AsyncCall(&workRequest
);
901 bSuccess
= INTERNET_FindNextFileW(lpwh
, lpvFindData
);
905 WININET_Release( &lpwh
->hdr
);
909 /***********************************************************************
910 * INTERNET_FindNextFileW (Internal)
912 * Continues a file search from a previous call to FindFirstFile
919 BOOL WINAPI
INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh
, LPVOID lpvFindData
)
921 BOOL bSuccess
= TRUE
;
922 LPWIN32_FIND_DATAW lpFindFileData
;
926 assert (lpwh
->hdr
.htype
== WH_HFINDNEXT
);
928 /* Clear any error information */
929 INTERNET_SetLastError(0);
931 if (lpwh
->hdr
.lpwhparent
->htype
!= WH_HFTPSESSION
)
933 FIXME("Only FTP find next supported\n");
934 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
938 TRACE("index(%ld) size(%ld)\n", lpwh
->index
, lpwh
->size
);
940 lpFindFileData
= (LPWIN32_FIND_DATAW
) lpvFindData
;
941 ZeroMemory(lpFindFileData
, sizeof(WIN32_FIND_DATAA
));
943 if (lpwh
->index
>= lpwh
->size
)
945 INTERNET_SetLastError(ERROR_NO_MORE_FILES
);
950 FTP_ConvertFileProp(&lpwh
->lpafp
[lpwh
->index
], lpFindFileData
);
953 TRACE("\nName: %s\nSize: %ld\n", debugstr_w(lpFindFileData
->cFileName
), lpFindFileData
->nFileSizeLow
);
957 if (lpwh
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
&& lpwh
->hdr
.lpfnStatusCB
)
959 INTERNET_ASYNC_RESULT iar
;
961 iar
.dwResult
= (DWORD
)bSuccess
;
962 iar
.dwError
= iar
.dwError
= bSuccess
? ERROR_SUCCESS
:
963 INTERNET_GetLastError();
965 SendAsyncCallback(&lpwh
->hdr
, lpwh
->hdr
.dwContext
,
966 INTERNET_STATUS_REQUEST_COMPLETE
, &iar
,
967 sizeof(INTERNET_ASYNC_RESULT
));
974 /***********************************************************************
975 * INTERNET_CloseHandle (internal)
977 * Close internet handle
983 static VOID
INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr
)
985 LPWININETAPPINFOW lpwai
= (LPWININETAPPINFOW
) hdr
;
989 HeapFree(GetProcessHeap(), 0, lpwai
->lpszAgent
);
990 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxy
);
991 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyBypass
);
992 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyUsername
);
993 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyPassword
);
994 HeapFree(GetProcessHeap(), 0, lpwai
);
998 /***********************************************************************
999 * InternetCloseHandle (WININET.@)
1001 * Generic close handle function
1008 BOOL WINAPI
InternetCloseHandle(HINTERNET hInternet
)
1010 LPWININETHANDLEHEADER lpwh
;
1012 TRACE("%p\n",hInternet
);
1014 lpwh
= WININET_GetObject( hInternet
);
1017 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1021 SendAsyncCallback(lpwh
, lpwh
->dwContext
,
1022 INTERNET_STATUS_HANDLE_CLOSING
, &hInternet
,
1023 sizeof(HINTERNET
*));
1025 if( lpwh
->lpwhparent
)
1026 WININET_Release( lpwh
->lpwhparent
);
1027 WININET_FreeHandle( hInternet
);
1028 WININET_Release( lpwh
);
1034 /***********************************************************************
1035 * ConvertUrlComponentValue (Internal)
1037 * Helper function for InternetCrackUrlW
1040 static void ConvertUrlComponentValue(LPSTR
* lppszComponent
, LPDWORD dwComponentLen
,
1041 LPWSTR lpwszComponent
, DWORD dwwComponentLen
,
1042 LPCSTR lpszStart
, LPCWSTR lpwszStart
)
1044 TRACE("%p %p %p %ld %p %p\n", lppszComponent
, dwComponentLen
, lpwszComponent
, dwwComponentLen
, lpszStart
, lpwszStart
);
1045 if (*dwComponentLen
!= 0)
1047 DWORD nASCIILength
=WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,NULL
,0,NULL
,NULL
);
1048 if (*lppszComponent
== NULL
)
1050 int nASCIIOffset
=WideCharToMultiByte(CP_ACP
,0,lpwszStart
,lpwszComponent
-lpwszStart
,NULL
,0,NULL
,NULL
);
1051 *lppszComponent
= (LPSTR
)lpszStart
+nASCIIOffset
;
1052 *dwComponentLen
= nASCIILength
;
1056 DWORD ncpylen
= min((*dwComponentLen
)-1, nASCIILength
);
1057 WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,*lppszComponent
,ncpylen
+1,NULL
,NULL
);
1058 (*lppszComponent
)[ncpylen
]=0;
1059 *dwComponentLen
= ncpylen
;
1065 /***********************************************************************
1066 * InternetCrackUrlA (WININET.@)
1068 * Break up URL into its components
1070 * TODO: Handle dwFlags
1077 BOOL WINAPI
InternetCrackUrlA(LPCSTR lpszUrl
, DWORD dwUrlLength
, DWORD dwFlags
,
1078 LPURL_COMPONENTSA lpUrlComponents
)
1081 URL_COMPONENTSW UCW
;
1084 TRACE("(%s %lu %lx %p)\n", debugstr_a(lpszUrl
), dwUrlLength
, dwFlags
, lpUrlComponents
);
1087 nLength
=MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,NULL
,0);
1089 /* if dwUrlLength=-1 then nLength includes null but length to
1090 InternetCrackUrlW should not include it */
1091 if (dwUrlLength
== -1) nLength
--;
1093 lpwszUrl
=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WCHAR
)*nLength
);
1094 MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,lpwszUrl
,nLength
);
1096 memset(&UCW
,0,sizeof(UCW
));
1097 if(lpUrlComponents
->dwHostNameLength
!=0)
1098 UCW
.dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
1099 if(lpUrlComponents
->dwUserNameLength
!=0)
1100 UCW
.dwUserNameLength
=lpUrlComponents
->dwUserNameLength
;
1101 if(lpUrlComponents
->dwPasswordLength
!=0)
1102 UCW
.dwPasswordLength
=lpUrlComponents
->dwPasswordLength
;
1103 if(lpUrlComponents
->dwUrlPathLength
!=0)
1104 UCW
.dwUrlPathLength
=lpUrlComponents
->dwUrlPathLength
;
1105 if(lpUrlComponents
->dwSchemeLength
!=0)
1106 UCW
.dwSchemeLength
=lpUrlComponents
->dwSchemeLength
;
1107 if(lpUrlComponents
->dwExtraInfoLength
!=0)
1108 UCW
.dwExtraInfoLength
=lpUrlComponents
->dwExtraInfoLength
;
1109 if(!InternetCrackUrlW(lpwszUrl
,nLength
,dwFlags
,&UCW
))
1111 HeapFree(GetProcessHeap(), 0, lpwszUrl
);
1115 ConvertUrlComponentValue(&lpUrlComponents
->lpszHostName
, &lpUrlComponents
->dwHostNameLength
,
1116 UCW
.lpszHostName
, UCW
.dwHostNameLength
,
1118 ConvertUrlComponentValue(&lpUrlComponents
->lpszUserName
, &lpUrlComponents
->dwUserNameLength
,
1119 UCW
.lpszUserName
, UCW
.dwUserNameLength
,
1121 ConvertUrlComponentValue(&lpUrlComponents
->lpszPassword
, &lpUrlComponents
->dwPasswordLength
,
1122 UCW
.lpszPassword
, UCW
.dwPasswordLength
,
1124 ConvertUrlComponentValue(&lpUrlComponents
->lpszUrlPath
, &lpUrlComponents
->dwUrlPathLength
,
1125 UCW
.lpszUrlPath
, UCW
.dwUrlPathLength
,
1127 ConvertUrlComponentValue(&lpUrlComponents
->lpszScheme
, &lpUrlComponents
->dwSchemeLength
,
1128 UCW
.lpszScheme
, UCW
.dwSchemeLength
,
1130 ConvertUrlComponentValue(&lpUrlComponents
->lpszExtraInfo
, &lpUrlComponents
->dwExtraInfoLength
,
1131 UCW
.lpszExtraInfo
, UCW
.dwExtraInfoLength
,
1133 lpUrlComponents
->nScheme
=UCW
.nScheme
;
1134 lpUrlComponents
->nPort
=UCW
.nPort
;
1135 HeapFree(GetProcessHeap(), 0, lpwszUrl
);
1137 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl
,
1138 debugstr_an(lpUrlComponents
->lpszScheme
,lpUrlComponents
->dwSchemeLength
),
1139 debugstr_an(lpUrlComponents
->lpszHostName
,lpUrlComponents
->dwHostNameLength
),
1140 debugstr_an(lpUrlComponents
->lpszUrlPath
,lpUrlComponents
->dwUrlPathLength
),
1141 debugstr_an(lpUrlComponents
->lpszExtraInfo
,lpUrlComponents
->dwExtraInfoLength
));
1146 /***********************************************************************
1147 * GetInternetSchemeW (internal)
1153 * INTERNET_SCHEME_UNKNOWN on failure
1156 static INTERNET_SCHEME
GetInternetSchemeW(LPCWSTR lpszScheme
, DWORD nMaxCmp
)
1158 INTERNET_SCHEME iScheme
=INTERNET_SCHEME_UNKNOWN
;
1159 static const WCHAR lpszFtp
[]={'f','t','p',0};
1160 static const WCHAR lpszGopher
[]={'g','o','p','h','e','r',0};
1161 static const WCHAR lpszHttp
[]={'h','t','t','p',0};
1162 static const WCHAR lpszHttps
[]={'h','t','t','p','s',0};
1163 static const WCHAR lpszFile
[]={'f','i','l','e',0};
1164 static const WCHAR lpszNews
[]={'n','e','w','s',0};
1165 static const WCHAR lpszMailto
[]={'m','a','i','l','t','o',0};
1166 static const WCHAR lpszRes
[]={'r','e','s',0};
1167 WCHAR
* tempBuffer
=NULL
;
1168 TRACE("%s %ld\n",debugstr_wn(lpszScheme
, nMaxCmp
), nMaxCmp
);
1169 if(lpszScheme
==NULL
)
1170 return INTERNET_SCHEME_UNKNOWN
;
1172 tempBuffer
=HeapAlloc(GetProcessHeap(),0,(nMaxCmp
+1)*sizeof(WCHAR
));
1173 lstrcpynW(tempBuffer
,lpszScheme
,nMaxCmp
+1);
1174 strlwrW(tempBuffer
);
1175 if (nMaxCmp
==strlenW(lpszFtp
) && !strncmpW(lpszFtp
, tempBuffer
, nMaxCmp
))
1176 iScheme
=INTERNET_SCHEME_FTP
;
1177 else if (nMaxCmp
==strlenW(lpszGopher
) && !strncmpW(lpszGopher
, tempBuffer
, nMaxCmp
))
1178 iScheme
=INTERNET_SCHEME_GOPHER
;
1179 else if (nMaxCmp
==strlenW(lpszHttp
) && !strncmpW(lpszHttp
, tempBuffer
, nMaxCmp
))
1180 iScheme
=INTERNET_SCHEME_HTTP
;
1181 else if (nMaxCmp
==strlenW(lpszHttps
) && !strncmpW(lpszHttps
, tempBuffer
, nMaxCmp
))
1182 iScheme
=INTERNET_SCHEME_HTTPS
;
1183 else if (nMaxCmp
==strlenW(lpszFile
) && !strncmpW(lpszFile
, tempBuffer
, nMaxCmp
))
1184 iScheme
=INTERNET_SCHEME_FILE
;
1185 else if (nMaxCmp
==strlenW(lpszNews
) && !strncmpW(lpszNews
, tempBuffer
, nMaxCmp
))
1186 iScheme
=INTERNET_SCHEME_NEWS
;
1187 else if (nMaxCmp
==strlenW(lpszMailto
) && !strncmpW(lpszMailto
, tempBuffer
, nMaxCmp
))
1188 iScheme
=INTERNET_SCHEME_MAILTO
;
1189 else if (nMaxCmp
==strlenW(lpszRes
) && !strncmpW(lpszRes
, tempBuffer
, nMaxCmp
))
1190 iScheme
=INTERNET_SCHEME_RES
;
1191 HeapFree(GetProcessHeap(),0,tempBuffer
);
1195 /***********************************************************************
1196 * SetUrlComponentValueW (Internal)
1198 * Helper function for InternetCrackUrlW
1201 * lppszComponent [O] Holds the returned string
1202 * dwComponentLen [I] Holds the size of lppszComponent
1203 * [O] Holds the length of the string in lppszComponent without '\0'
1204 * lpszStart [I] Holds the string to copy from
1205 * len [I] Holds the length of lpszStart without '\0'
1212 static BOOL
SetUrlComponentValueW(LPWSTR
* lppszComponent
, LPDWORD dwComponentLen
, LPCWSTR lpszStart
, DWORD len
)
1214 TRACE("%s (%ld)\n", debugstr_wn(lpszStart
,len
), len
);
1216 if ( (*dwComponentLen
== 0) && (*lppszComponent
== NULL
) )
1219 if (*dwComponentLen
!= 0 || *lppszComponent
== NULL
)
1221 if (*lppszComponent
== NULL
)
1223 *lppszComponent
= (LPWSTR
)lpszStart
;
1224 *dwComponentLen
= len
;
1228 DWORD ncpylen
= min((*dwComponentLen
)-1, len
);
1229 memcpy(*lppszComponent
, lpszStart
, ncpylen
*sizeof(WCHAR
));
1230 (*lppszComponent
)[ncpylen
] = '\0';
1231 *dwComponentLen
= ncpylen
;
1238 /***********************************************************************
1239 * InternetCrackUrlW (WININET.@)
1241 BOOL WINAPI
InternetCrackUrlW(LPCWSTR lpszUrl_orig
, DWORD dwUrlLength_orig
, DWORD dwFlags
,
1242 LPURL_COMPONENTSW lpUC
)
1246 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1249 LPCWSTR lpszParam
= NULL
;
1250 BOOL bIsAbsolute
= FALSE
;
1251 LPCWSTR lpszap
, lpszUrl
= lpszUrl_orig
;
1252 LPCWSTR lpszcp
= NULL
;
1253 LPWSTR lpszUrl_decode
= NULL
;
1254 DWORD dwUrlLength
= dwUrlLength_orig
;
1255 const WCHAR lpszSeparators
[3]={';','?',0};
1256 const WCHAR lpszSlash
[2]={'/',0};
1258 dwUrlLength
=strlenW(lpszUrl
);
1260 TRACE("(%s %lu %lx %p)\n", debugstr_w(lpszUrl
), dwUrlLength
, dwFlags
, lpUC
);
1261 if (dwFlags
& ICU_DECODE
)
1263 lpszUrl_decode
=HeapAlloc( GetProcessHeap(), 0, dwUrlLength
* sizeof (WCHAR
) );
1264 if( InternetCanonicalizeUrlW(lpszUrl_orig
, lpszUrl_decode
, &dwUrlLength
, dwFlags
))
1266 lpszUrl
= lpszUrl_decode
;
1271 /* Determine if the URI is absolute. */
1272 while (*lpszap
!= '\0')
1274 if (isalnumW(*lpszap
))
1279 if ((*lpszap
== ':') && (lpszap
- lpszUrl
>= 2))
1286 lpszcp
= lpszUrl
; /* Relative url */
1292 /* Parse <params> */
1293 lpszParam
= strpbrkW(lpszap
, lpszSeparators
);
1294 if (lpszParam
!= NULL
)
1296 SetUrlComponentValueW(&lpUC
->lpszExtraInfo
, &lpUC
->dwExtraInfoLength
,
1297 lpszParam
, dwUrlLength
-(lpszParam
-lpszUrl
));
1300 if (bIsAbsolute
) /* Parse <protocol>:[//<net_loc>] */
1303 static const WCHAR wszAbout
[]={'a','b','o','u','t',':',0};
1305 /* Get scheme first. */
1306 lpUC
->nScheme
= GetInternetSchemeW(lpszUrl
, lpszcp
- lpszUrl
);
1307 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
,
1308 lpszUrl
, lpszcp
- lpszUrl
);
1310 /* Eat ':' in protocol. */
1313 /* if the scheme is "about", there is no host */
1314 if(strncmpW(wszAbout
,lpszUrl
, lpszcp
- lpszUrl
)==0)
1316 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1317 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1318 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1323 /* Skip over slashes. */
1335 lpszNetLoc
= strpbrkW(lpszcp
, lpszSlash
);
1339 lpszNetLoc
= min(lpszNetLoc
, lpszParam
);
1341 lpszNetLoc
= lpszParam
;
1343 else if (!lpszNetLoc
)
1344 lpszNetLoc
= lpszcp
+ dwUrlLength
-(lpszcp
-lpszUrl
);
1352 /* [<user>[<:password>]@]<host>[:<port>] */
1353 /* First find the user and password if they exist */
1355 lpszHost
= strchrW(lpszcp
, '@');
1356 if (lpszHost
== NULL
|| lpszHost
> lpszNetLoc
)
1358 /* username and password not specified. */
1359 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1360 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1362 else /* Parse out username and password */
1364 LPCWSTR lpszUser
= lpszcp
;
1365 LPCWSTR lpszPasswd
= lpszHost
;
1367 while (lpszcp
< lpszHost
)
1370 lpszPasswd
= lpszcp
;
1375 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
,
1376 lpszUser
, lpszPasswd
- lpszUser
);
1378 if (lpszPasswd
!= lpszHost
)
1380 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
,
1381 lpszPasswd
== lpszHost
? NULL
: lpszPasswd
,
1382 lpszHost
- lpszPasswd
);
1384 lpszcp
++; /* Advance to beginning of host */
1387 /* Parse <host><:port> */
1390 lpszPort
= lpszNetLoc
;
1392 /* special case for res:// URLs: there is no port here, so the host is the
1393 entire string up to the first '/' */
1394 if(lpUC
->nScheme
==INTERNET_SCHEME_RES
)
1396 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1397 lpszHost
, lpszPort
- lpszHost
);
1403 while (lpszcp
< lpszNetLoc
)
1411 /* If the scheme is "file" and the host is just one letter, it's not a host */
1412 if(lpUC
->nScheme
==INTERNET_SCHEME_FILE
&& (lpszPort
-lpszHost
)==1)
1415 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1421 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1422 lpszHost
, lpszPort
- lpszHost
);
1423 if (lpszPort
!= lpszNetLoc
)
1424 lpUC
->nPort
= atoiW(++lpszPort
);
1433 /* Here lpszcp points to:
1435 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1436 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1438 if (lpszcp
!= 0 && *lpszcp
!= '\0' && (!lpszParam
|| lpszcp
< lpszParam
))
1442 /* Only truncate the parameter list if it's already been saved
1443 * in lpUC->lpszExtraInfo.
1445 if (lpszParam
&& lpUC
->dwExtraInfoLength
&& lpUC
->lpszExtraInfo
)
1446 len
= lpszParam
- lpszcp
;
1449 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1450 * newlines if necessary.
1452 LPWSTR lpsznewline
= strchrW(lpszcp
, '\n');
1453 if (lpsznewline
!= NULL
)
1454 len
= lpsznewline
- lpszcp
;
1456 len
= dwUrlLength
-(lpszcp
-lpszUrl
);
1458 SetUrlComponentValueW(&lpUC
->lpszUrlPath
, &lpUC
->dwUrlPathLength
,
1463 lpUC
->dwUrlPathLength
= 0;
1466 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl
,dwUrlLength
),
1467 debugstr_wn(lpUC
->lpszScheme
,lpUC
->dwSchemeLength
),
1468 debugstr_wn(lpUC
->lpszHostName
,lpUC
->dwHostNameLength
),
1469 debugstr_wn(lpUC
->lpszUrlPath
,lpUC
->dwUrlPathLength
),
1470 debugstr_wn(lpUC
->lpszExtraInfo
,lpUC
->dwExtraInfoLength
));
1473 HeapFree(GetProcessHeap(), 0, lpszUrl_decode
);
1477 /***********************************************************************
1478 * InternetAttemptConnect (WININET.@)
1480 * Attempt to make a connection to the internet
1483 * ERROR_SUCCESS on success
1484 * Error value on failure
1487 DWORD WINAPI
InternetAttemptConnect(DWORD dwReserved
)
1490 return ERROR_SUCCESS
;
1494 /***********************************************************************
1495 * InternetCanonicalizeUrlA (WININET.@)
1497 * Escape unsafe characters and spaces
1504 BOOL WINAPI
InternetCanonicalizeUrlA(LPCSTR lpszUrl
, LPSTR lpszBuffer
,
1505 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1508 DWORD dwURLFlags
= 0x80000000; /* Don't know what this means */
1509 if(dwFlags
& ICU_DECODE
)
1511 dwURLFlags
|= URL_UNESCAPE
;
1512 dwFlags
&= ~ICU_DECODE
;
1515 if(dwFlags
& ICU_ESCAPE
)
1517 dwURLFlags
|= URL_UNESCAPE
;
1518 dwFlags
&= ~ICU_ESCAPE
;
1521 FIXME("Unhandled flags 0x%08lx\n", dwFlags
);
1522 TRACE("%s %p %p %08lx\n", debugstr_a(lpszUrl
), lpszBuffer
,
1523 lpdwBufferLength
, dwURLFlags
);
1525 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1526 dwFlags
^= ICU_NO_ENCODE
;
1528 hr
= UrlCanonicalizeA(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1530 return (hr
== S_OK
) ? TRUE
: FALSE
;
1533 /***********************************************************************
1534 * InternetCanonicalizeUrlW (WININET.@)
1536 * Escape unsafe characters and spaces
1543 BOOL WINAPI
InternetCanonicalizeUrlW(LPCWSTR lpszUrl
, LPWSTR lpszBuffer
,
1544 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1547 DWORD dwURLFlags
= 0x80000000; /* Don't know what this means */
1548 if(dwFlags
& ICU_DECODE
)
1550 dwURLFlags
|= URL_UNESCAPE
;
1551 dwFlags
&= ~ICU_DECODE
;
1554 if(dwFlags
& ICU_ESCAPE
)
1556 dwURLFlags
|= URL_UNESCAPE
;
1557 dwFlags
&= ~ICU_ESCAPE
;
1560 FIXME("Unhandled flags 0x%08lx\n", dwFlags
);
1561 TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl
), lpszBuffer
,
1562 lpdwBufferLength
, dwURLFlags
);
1564 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1565 dwFlags
^= ICU_NO_ENCODE
;
1567 hr
= UrlCanonicalizeW(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1569 return (hr
== S_OK
) ? TRUE
: FALSE
;
1573 /***********************************************************************
1574 * InternetSetStatusCallbackA (WININET.@)
1576 * Sets up a callback function which is called as progress is made
1577 * during an operation.
1580 * Previous callback or NULL on success
1581 * INTERNET_INVALID_STATUS_CALLBACK on failure
1584 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackA(
1585 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
1587 INTERNET_STATUS_CALLBACK retVal
;
1588 LPWININETHANDLEHEADER lpwh
;
1590 TRACE("0x%08lx\n", (ULONG
)hInternet
);
1592 lpwh
= WININET_GetObject(hInternet
);
1594 return INTERNET_INVALID_STATUS_CALLBACK
;
1596 lpwh
->dwInternalFlags
&= ~INET_CALLBACKW
;
1597 retVal
= lpwh
->lpfnStatusCB
;
1598 lpwh
->lpfnStatusCB
= lpfnIntCB
;
1600 WININET_Release( lpwh
);
1605 /***********************************************************************
1606 * InternetSetStatusCallbackW (WININET.@)
1608 * Sets up a callback function which is called as progress is made
1609 * during an operation.
1612 * Previous callback or NULL on success
1613 * INTERNET_INVALID_STATUS_CALLBACK on failure
1616 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackW(
1617 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
1619 INTERNET_STATUS_CALLBACK retVal
;
1620 LPWININETHANDLEHEADER lpwh
;
1622 TRACE("0x%08lx\n", (ULONG
)hInternet
);
1624 lpwh
= WININET_GetObject(hInternet
);
1626 return INTERNET_INVALID_STATUS_CALLBACK
;
1628 lpwh
->dwInternalFlags
|= INET_CALLBACKW
;
1629 retVal
= lpwh
->lpfnStatusCB
;
1630 lpwh
->lpfnStatusCB
= lpfnIntCB
;
1632 WININET_Release( lpwh
);
1637 /***********************************************************************
1638 * InternetSetFilePointer (WININET.@)
1640 DWORD WINAPI
InternetSetFilePointer(HINTERNET f1
, LONG f2
, PVOID f3
, DWORD f4
, DWORD f5
)
1646 /***********************************************************************
1647 * InternetWriteFile (WININET.@)
1649 * Write data to an open internet file
1656 BOOL WINAPI
InternetWriteFile(HINTERNET hFile
, LPCVOID lpBuffer
,
1657 DWORD dwNumOfBytesToWrite
, LPDWORD lpdwNumOfBytesWritten
)
1659 BOOL retval
= FALSE
;
1661 LPWININETHANDLEHEADER lpwh
;
1664 lpwh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hFile
);
1668 switch (lpwh
->htype
)
1671 FIXME("This shouldn't be here! We don't support this kind"
1672 " of connection anymore. Must use NETCON functions,"
1673 " especially if using SSL\n");
1674 nSocket
= ((LPWININETHTTPREQW
)lpwh
)->netConnection
.socketFD
;
1678 nSocket
= ((LPWININETFILE
)lpwh
)->nDataSocket
;
1687 int res
= send(nSocket
, lpBuffer
, dwNumOfBytesToWrite
, 0);
1688 retval
= (res
>= 0);
1689 *lpdwNumOfBytesWritten
= retval
? res
: 0;
1691 WININET_Release( lpwh
);
1697 /***********************************************************************
1698 * InternetReadFile (WININET.@)
1700 * Read data from an open internet file
1707 BOOL WINAPI
InternetReadFile(HINTERNET hFile
, LPVOID lpBuffer
,
1708 DWORD dwNumOfBytesToRead
, LPDWORD dwNumOfBytesRead
)
1710 BOOL retval
= FALSE
;
1712 LPWININETHANDLEHEADER lpwh
;
1714 TRACE("%p %p %ld %p\n", hFile
, lpBuffer
, dwNumOfBytesToRead
, dwNumOfBytesRead
);
1716 lpwh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hFile
);
1720 /* FIXME: this should use NETCON functions! */
1721 switch (lpwh
->htype
)
1724 if (!NETCON_recv(&((LPWININETHTTPREQW
)lpwh
)->netConnection
, lpBuffer
,
1725 dwNumOfBytesToRead
, MSG_WAITALL
, (int *)dwNumOfBytesRead
))
1727 *dwNumOfBytesRead
= 0;
1728 retval
= TRUE
; /* Under windows, it seems to return 0 even if nothing was read... */
1735 /* FIXME: FTP should use NETCON_ stuff */
1736 nSocket
= ((LPWININETFILE
)lpwh
)->nDataSocket
;
1739 int res
= recv(nSocket
, lpBuffer
, dwNumOfBytesToRead
, MSG_WAITALL
);
1740 retval
= (res
>= 0);
1741 *dwNumOfBytesRead
= retval
? res
: 0;
1748 WININET_Release( lpwh
);
1750 TRACE("-- %s (bytes read: %ld)\n", retval
? "TRUE": "FALSE", dwNumOfBytesRead
? *dwNumOfBytesRead
: -1);
1754 /***********************************************************************
1755 * InternetReadFileExA (WININET.@)
1757 * Read data from an open internet file
1764 BOOL WINAPI
InternetReadFileExA(HINTERNET hFile
, LPINTERNET_BUFFERSA lpBuffer
,
1765 DWORD dwFlags
, DWORD dwContext
)
1771 /***********************************************************************
1772 * InternetReadFileExW (WININET.@)
1774 * Read data from an open internet file
1781 BOOL WINAPI
InternetReadFileExW(HINTERNET hFile
, LPINTERNET_BUFFERSW lpBuffer
,
1782 DWORD dwFlags
, DWORD dwContext
)
1786 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1790 /***********************************************************************
1791 * INET_QueryOptionHelper (internal)
1793 static BOOL
INET_QueryOptionHelper(BOOL bIsUnicode
, HINTERNET hInternet
, DWORD dwOption
,
1794 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
1796 LPWININETHANDLEHEADER lpwhh
;
1797 BOOL bSuccess
= FALSE
;
1799 TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
1801 lpwhh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hInternet
);
1805 case INTERNET_OPTION_HANDLE_TYPE
:
1811 WARN("Invalid hInternet handle\n");
1812 SetLastError(ERROR_INVALID_HANDLE
);
1816 type
= lpwhh
->htype
;
1818 TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type
);
1820 if (*lpdwBufferLength
< sizeof(ULONG
))
1821 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1824 memcpy(lpBuffer
, &type
, sizeof(ULONG
));
1827 *lpdwBufferLength
= sizeof(ULONG
);
1831 case INTERNET_OPTION_REQUEST_FLAGS
:
1834 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags
);
1835 if (*lpdwBufferLength
< sizeof(ULONG
))
1836 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1839 memcpy(lpBuffer
, &flags
, sizeof(ULONG
));
1842 *lpdwBufferLength
= sizeof(ULONG
);
1846 case INTERNET_OPTION_URL
:
1847 case INTERNET_OPTION_DATAFILE_NAME
:
1851 WARN("Invalid hInternet handle\n");
1852 SetLastError(ERROR_INVALID_HANDLE
);
1855 if (lpwhh
->htype
== WH_HHTTPREQ
)
1857 LPWININETHTTPREQW lpreq
= (LPWININETHTTPREQW
) lpwhh
;
1859 static const WCHAR szFmt
[] = {'h','t','t','p',':','/','/','%','s','%','s',0};
1862 sprintfW(url
,szFmt
,lpreq
->StdHeaders
[HTTP_QUERY_HOST
].lpszValue
,lpreq
->lpszPath
);
1863 TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url
));
1866 sizeRequired
= WideCharToMultiByte(CP_ACP
,0,url
,-1,
1867 lpBuffer
,*lpdwBufferLength
,NULL
,NULL
);
1868 if (sizeRequired
> *lpdwBufferLength
)
1869 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1872 *lpdwBufferLength
= sizeRequired
;
1876 sizeRequired
= (lstrlenW(url
)+1) * sizeof(WCHAR
);
1877 if (*lpdwBufferLength
< sizeRequired
)
1878 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1881 strcpyW(lpBuffer
, url
);
1884 *lpdwBufferLength
= sizeRequired
;
1889 case INTERNET_OPTION_HTTP_VERSION
:
1891 if (*lpdwBufferLength
< sizeof(HTTP_VERSION_INFO
))
1892 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1896 * Presently hardcoded to 1.1
1898 ((HTTP_VERSION_INFO
*)lpBuffer
)->dwMajorVersion
= 1;
1899 ((HTTP_VERSION_INFO
*)lpBuffer
)->dwMinorVersion
= 1;
1902 *lpdwBufferLength
= sizeof(HTTP_VERSION_INFO
);
1905 case INTERNET_OPTION_CONNECTED_STATE
:
1907 INTERNET_CONNECTED_INFO
* pCi
= (INTERNET_CONNECTED_INFO
*)lpBuffer
;
1908 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
1910 if (*lpdwBufferLength
< sizeof(INTERNET_CONNECTED_INFO
))
1911 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1914 pCi
->dwConnectedState
= INTERNET_STATE_CONNECTED
;
1918 *lpdwBufferLength
= sizeof(INTERNET_CONNECTED_INFO
);
1921 case INTERNET_OPTION_PROXY
:
1923 LPWININETAPPINFOW lpwai
= (LPWININETAPPINFOW
)lpwhh
;
1924 WININETAPPINFOW wai
;
1928 TRACE("Getting global proxy info\n");
1929 memset(&wai
, 0, sizeof(WININETAPPINFOW
));
1930 INTERNET_ConfigureProxyFromReg( &wai
);
1936 INTERNET_PROXY_INFOW
*pPI
= (INTERNET_PROXY_INFOW
*)lpBuffer
;
1937 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
1939 if (lpwai
->lpszProxy
)
1940 proxyBytesRequired
= (lstrlenW(lpwai
->lpszProxy
) + 1) *
1942 if (lpwai
->lpszProxyBypass
)
1943 proxyBypassBytesRequired
=
1944 (lstrlenW(lpwai
->lpszProxyBypass
) + 1) * sizeof(WCHAR
);
1945 if (*lpdwBufferLength
< sizeof(INTERNET_PROXY_INFOW
) +
1946 proxyBytesRequired
+ proxyBypassBytesRequired
)
1947 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1950 pPI
->dwAccessType
= lpwai
->dwAccessType
;
1951 if (lpwai
->lpszProxy
)
1953 pPI
->lpszProxy
= (LPWSTR
)((LPBYTE
)lpBuffer
+
1954 sizeof(INTERNET_PROXY_INFOW
));
1955 lstrcpyW((LPWSTR
)pPI
->lpszProxy
, lpwai
->lpszProxy
);
1958 pPI
->lpszProxy
= NULL
;
1959 if (lpwai
->lpszProxyBypass
)
1961 pPI
->lpszProxyBypass
= (LPWSTR
)((LPBYTE
)lpBuffer
+
1962 sizeof(INTERNET_PROXY_INFOW
) + proxyBytesRequired
);
1963 lstrcpyW((LPWSTR
)pPI
->lpszProxyBypass
,
1964 lpwai
->lpszProxyBypass
);
1967 pPI
->lpszProxyBypass
= NULL
;
1970 *lpdwBufferLength
= sizeof(INTERNET_PROXY_INFOW
) +
1971 proxyBytesRequired
+ proxyBypassBytesRequired
;
1975 INTERNET_PROXY_INFOA
*pPI
= (INTERNET_PROXY_INFOA
*)lpBuffer
;
1976 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
1978 if (lpwai
->lpszProxy
)
1979 proxyBytesRequired
= WideCharToMultiByte(CP_ACP
, 0,
1980 lpwai
->lpszProxy
, -1, NULL
, 0, NULL
, NULL
);
1981 if (lpwai
->lpszProxyBypass
)
1982 proxyBypassBytesRequired
= WideCharToMultiByte(CP_ACP
, 0,
1983 lpwai
->lpszProxyBypass
, -1, NULL
, 0, NULL
, NULL
);
1984 if (*lpdwBufferLength
< sizeof(INTERNET_PROXY_INFOA
) +
1985 proxyBytesRequired
+ proxyBypassBytesRequired
)
1986 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1989 pPI
->dwAccessType
= lpwai
->dwAccessType
;
1990 FIXME("INTERNET_OPTION_PROXY: Stub\n");
1991 if (lpwai
->lpszProxy
)
1993 pPI
->lpszProxy
= (LPSTR
)((LPBYTE
)lpBuffer
+
1994 sizeof(INTERNET_PROXY_INFOA
));
1995 WideCharToMultiByte(CP_ACP
, 0, lpwai
->lpszProxy
, -1,
1996 (LPSTR
)pPI
->lpszProxy
, proxyBytesRequired
, NULL
, NULL
);
1999 pPI
->lpszProxy
= NULL
;
2000 if (lpwai
->lpszProxyBypass
)
2002 pPI
->lpszProxyBypass
= (LPSTR
)((LPBYTE
)lpBuffer
+
2003 sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
);
2004 WideCharToMultiByte(CP_ACP
, 0, lpwai
->lpszProxyBypass
,
2005 -1, (LPSTR
)pPI
->lpszProxyBypass
,
2006 proxyBypassBytesRequired
,
2010 pPI
->lpszProxyBypass
= NULL
;
2013 *lpdwBufferLength
= sizeof(INTERNET_PROXY_INFOA
) +
2014 proxyBytesRequired
+ proxyBypassBytesRequired
;
2018 case INTERNET_OPTION_SECURITY_FLAGS
:
2019 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2023 FIXME("Stub! %ld \n",dwOption
);
2027 WININET_Release( lpwhh
);
2032 /***********************************************************************
2033 * InternetQueryOptionW (WININET.@)
2035 * Queries an options on the specified handle
2042 BOOL WINAPI
InternetQueryOptionW(HINTERNET hInternet
, DWORD dwOption
,
2043 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2045 return INET_QueryOptionHelper(TRUE
, hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2048 /***********************************************************************
2049 * InternetQueryOptionA (WININET.@)
2051 * Queries an options on the specified handle
2058 BOOL WINAPI
InternetQueryOptionA(HINTERNET hInternet
, DWORD dwOption
,
2059 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2061 return INET_QueryOptionHelper(FALSE
, hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2065 /***********************************************************************
2066 * InternetSetOptionW (WININET.@)
2068 * Sets an options on the specified handle
2075 BOOL WINAPI
InternetSetOptionW(HINTERNET hInternet
, DWORD dwOption
,
2076 LPVOID lpBuffer
, DWORD dwBufferLength
)
2078 LPWININETHANDLEHEADER lpwhh
;
2081 TRACE("0x%08lx\n", dwOption
);
2083 lpwhh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hInternet
);
2089 case INTERNET_OPTION_HTTP_VERSION
:
2091 HTTP_VERSION_INFO
* pVersion
=(HTTP_VERSION_INFO
*)lpBuffer
;
2092 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion
->dwMajorVersion
,pVersion
->dwMinorVersion
);
2095 case INTERNET_OPTION_ERROR_MASK
:
2097 unsigned long flags
=*(unsigned long*)lpBuffer
;
2098 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags
);
2101 case INTERNET_OPTION_CODEPAGE
:
2103 unsigned long codepage
=*(unsigned long*)lpBuffer
;
2104 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage
);
2107 case INTERNET_OPTION_REQUEST_PRIORITY
:
2109 unsigned long priority
=*(unsigned long*)lpBuffer
;
2110 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority
);
2113 case INTERNET_OPTION_CONNECT_TIMEOUT
:
2115 unsigned long connecttimeout
=*(unsigned long*)lpBuffer
;
2116 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%ld): STUB\n",connecttimeout
);
2119 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
:
2121 unsigned long receivetimeout
=*(unsigned long*)lpBuffer
;
2122 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%ld): STUB\n",receivetimeout
);
2125 case INTERNET_OPTION_RESET_URLCACHE_SESSION
:
2126 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2128 case INTERNET_OPTION_END_BROWSER_SESSION
:
2129 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2131 case INTERNET_OPTION_CONNECTED_STATE
:
2132 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2135 FIXME("Option %ld STUB\n",dwOption
);
2136 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
2140 WININET_Release( lpwhh
);
2146 /***********************************************************************
2147 * InternetSetOptionA (WININET.@)
2149 * Sets an options on the specified handle.
2156 BOOL WINAPI
InternetSetOptionA(HINTERNET hInternet
, DWORD dwOption
,
2157 LPVOID lpBuffer
, DWORD dwBufferLength
)
2165 case INTERNET_OPTION_PROXY
:
2167 LPINTERNET_PROXY_INFOA pi
= (LPINTERNET_PROXY_INFOA
) lpBuffer
;
2168 LPINTERNET_PROXY_INFOW piw
;
2169 DWORD proxlen
, prbylen
;
2172 proxlen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, NULL
, 0);
2173 prbylen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, NULL
, 0);
2174 wlen
= sizeof(*piw
) + proxlen
+ prbylen
;
2175 wbuffer
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2176 piw
= (LPINTERNET_PROXY_INFOW
) wbuffer
;
2177 piw
->dwAccessType
= pi
->dwAccessType
;
2178 prox
= (LPWSTR
) &piw
[1];
2179 prby
= &prox
[proxlen
+1];
2180 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, prox
, proxlen
);
2181 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, prby
, prbylen
);
2182 piw
->lpszProxy
= prox
;
2183 piw
->lpszProxyBypass
= prby
;
2186 case INTERNET_OPTION_USER_AGENT
:
2187 case INTERNET_OPTION_USERNAME
:
2188 case INTERNET_OPTION_PASSWORD
:
2189 wlen
= MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2191 wbuffer
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2192 MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2197 wlen
= dwBufferLength
;
2200 r
= InternetSetOptionW(hInternet
,dwOption
, wbuffer
, wlen
);
2202 if( lpBuffer
!= wbuffer
)
2203 HeapFree( GetProcessHeap(), 0, wbuffer
);
2209 /***********************************************************************
2210 * InternetSetOptionExA (WININET.@)
2212 BOOL WINAPI
InternetSetOptionExA(HINTERNET hInternet
, DWORD dwOption
,
2213 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2215 FIXME("Flags %08lx ignored\n", dwFlags
);
2216 return InternetSetOptionA( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2219 /***********************************************************************
2220 * InternetSetOptionExW (WININET.@)
2222 BOOL WINAPI
InternetSetOptionExW(HINTERNET hInternet
, DWORD dwOption
,
2223 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2225 FIXME("Flags %08lx ignored\n", dwFlags
);
2226 if( dwFlags
& ~ISO_VALID_FLAGS
)
2228 SetLastError( ERROR_INVALID_PARAMETER
);
2231 return InternetSetOptionW( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2234 static const WCHAR WININET_wkday
[7][4] =
2235 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2236 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2237 static const WCHAR WININET_month
[12][4] =
2238 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2239 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2240 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2242 /***********************************************************************
2243 * InternetTimeFromSystemTimeA (WININET.@)
2245 BOOL WINAPI
InternetTimeFromSystemTimeA( const SYSTEMTIME
* time
, DWORD format
, LPSTR string
, DWORD size
)
2248 WCHAR stringW
[INTERNET_RFC1123_BUFSIZE
];
2250 TRACE( "%p 0x%08lx %p 0x%08lx\n", time
, format
, string
, size
);
2252 ret
= InternetTimeFromSystemTimeW( time
, format
, stringW
, sizeof(stringW
) );
2253 if (ret
) WideCharToMultiByte( CP_ACP
, 0, stringW
, -1, string
, size
, NULL
, NULL
);
2258 /***********************************************************************
2259 * InternetTimeFromSystemTimeW (WININET.@)
2261 BOOL WINAPI
InternetTimeFromSystemTimeW( const SYSTEMTIME
* time
, DWORD format
, LPWSTR string
, DWORD size
)
2263 static const WCHAR date
[] =
2264 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2265 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
2267 TRACE( "%p 0x%08lx %p 0x%08lx\n", time
, format
, string
, size
);
2269 if (!time
|| !string
) return FALSE
;
2271 if (format
!= INTERNET_RFC1123_FORMAT
|| size
< INTERNET_RFC1123_BUFSIZE
* sizeof(WCHAR
))
2274 sprintfW( string
, date
,
2275 WININET_wkday
[time
->wDayOfWeek
],
2277 WININET_month
[time
->wMonth
- 1],
2286 /***********************************************************************
2287 * InternetTimeToSystemTimeA (WININET.@)
2289 BOOL WINAPI
InternetTimeToSystemTimeA( LPCSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
2295 TRACE( "%s %p 0x%08lx\n", debugstr_a(string
), time
, reserved
);
2297 len
= MultiByteToWideChar( CP_ACP
, 0, string
, -1, NULL
, 0 );
2298 stringW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
2302 MultiByteToWideChar( CP_ACP
, 0, string
, -1, stringW
, len
);
2303 ret
= InternetTimeToSystemTimeW( stringW
, time
, reserved
);
2304 HeapFree( GetProcessHeap(), 0, stringW
);
2309 /***********************************************************************
2310 * InternetTimeToSystemTimeW (WININET.@)
2312 BOOL WINAPI
InternetTimeToSystemTimeW( LPCWSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
2315 WCHAR
*s
= (LPWSTR
)string
;
2317 TRACE( "%s %p 0x%08lx\n", debugstr_w(string
), time
, reserved
);
2319 if (!string
|| !time
) return FALSE
;
2321 /* Windows does this too */
2322 GetSystemTime( time
);
2324 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2325 * a SYSTEMTIME structure.
2328 while (*s
&& !isalphaW( *s
)) s
++;
2329 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
2330 time
->wDayOfWeek
= 7;
2332 for (i
= 0; i
< 7; i
++)
2334 if (toupperW( WININET_wkday
[i
][0] ) == toupperW( s
[0] ) &&
2335 toupperW( WININET_wkday
[i
][1] ) == toupperW( s
[1] ) &&
2336 toupperW( WININET_wkday
[i
][2] ) == toupperW( s
[2] ) )
2338 time
->wDayOfWeek
= i
;
2343 if (time
->wDayOfWeek
> 6) return TRUE
;
2344 while (*s
&& !isdigitW( *s
)) s
++;
2345 time
->wDay
= strtolW( s
, &s
, 10 );
2347 while (*s
&& !isalphaW( *s
)) s
++;
2348 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
2351 for (i
= 0; i
< 12; i
++)
2353 if (toupperW( WININET_month
[i
][0]) == toupperW( s
[0] ) &&
2354 toupperW( WININET_month
[i
][1]) == toupperW( s
[1] ) &&
2355 toupperW( WININET_month
[i
][2]) == toupperW( s
[2] ) )
2357 time
->wMonth
= i
+ 1;
2361 if (time
->wMonth
== 0) return TRUE
;
2363 while (*s
&& !isdigitW( *s
)) s
++;
2364 if (*s
== '\0') return TRUE
;
2365 time
->wYear
= strtolW( s
, &s
, 10 );
2367 while (*s
&& !isdigitW( *s
)) s
++;
2368 if (*s
== '\0') return TRUE
;
2369 time
->wHour
= strtolW( s
, &s
, 10 );
2371 while (*s
&& !isdigitW( *s
)) s
++;
2372 if (*s
== '\0') return TRUE
;
2373 time
->wMinute
= strtolW( s
, &s
, 10 );
2375 while (*s
&& !isdigitW( *s
)) s
++;
2376 if (*s
== '\0') return TRUE
;
2377 time
->wSecond
= strtolW( s
, &s
, 10 );
2379 time
->wMilliseconds
= 0;
2383 /***********************************************************************
2384 * InternetCheckConnectionA (WININET.@)
2386 * Pings a requested host to check internet connection
2389 * TRUE on success and FALSE on failure. If a failure then
2390 * ERROR_NOT_CONNECTED is placesd into GetLastError
2393 BOOL WINAPI
InternetCheckConnectionA( LPCSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
2396 * this is a kludge which runs the resident ping program and reads the output.
2398 * Anyone have a better idea?
2409 * Crack or set the Address
2411 if (lpszUrl
== NULL
)
2414 * According to the doc we are supost to use the ip for the next
2415 * server in the WnInet internal server database. I have
2416 * no idea what that is or how to get it.
2418 * So someone needs to implement this.
2420 FIXME("Unimplemented with URL of NULL\n");
2425 URL_COMPONENTSA components
;
2427 ZeroMemory(&components
,sizeof(URL_COMPONENTSA
));
2428 components
.lpszHostName
= (LPSTR
)&host
;
2429 components
.dwHostNameLength
= 1024;
2431 if (!InternetCrackUrlA(lpszUrl
,0,0,&components
))
2434 TRACE("host name : %s\n",components
.lpszHostName
);
2438 * Build our ping command
2440 strcpy(command
,"ping -w 1 ");
2441 strcat(command
,host
);
2442 strcat(command
," >/dev/null 2>/dev/null");
2444 TRACE("Ping command is : %s\n",command
);
2446 status
= system(command
);
2448 TRACE("Ping returned a code of %i \n",status
);
2450 /* Ping return code of 0 indicates success */
2457 SetLastError(ERROR_NOT_CONNECTED
);
2463 /***********************************************************************
2464 * InternetCheckConnectionW (WININET.@)
2466 * Pings a requested host to check internet connection
2469 * TRUE on success and FALSE on failure. If a failure then
2470 * ERROR_NOT_CONNECTED is placed into GetLastError
2473 BOOL WINAPI
InternetCheckConnectionW(LPCWSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
2479 len
= WideCharToMultiByte(CP_ACP
, 0, lpszUrl
, -1, NULL
, 0, NULL
, NULL
);
2480 if (!(szUrl
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(CHAR
))))
2482 WideCharToMultiByte(CP_ACP
, 0, lpszUrl
, -1, szUrl
, len
, NULL
, NULL
);
2483 rc
= InternetCheckConnectionA((LPCSTR
)szUrl
, dwFlags
, dwReserved
);
2484 HeapFree(GetProcessHeap(), 0, szUrl
);
2490 /**********************************************************
2491 * INTERNET_InternetOpenUrlW (internal)
2496 * handle of connection or NULL on failure
2498 HINTERNET WINAPI
INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC
, LPCWSTR lpszUrl
,
2499 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD dwContext
)
2501 URL_COMPONENTSW urlComponents
;
2502 WCHAR protocol
[32], hostName
[MAXHOSTNAME
], userName
[1024];
2503 WCHAR password
[1024], path
[2048], extra
[1024];
2504 HINTERNET client
= NULL
, client1
= NULL
;
2506 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hIC
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
2507 dwHeadersLength
, dwFlags
, dwContext
);
2509 urlComponents
.dwStructSize
= sizeof(URL_COMPONENTSW
);
2510 urlComponents
.lpszScheme
= protocol
;
2511 urlComponents
.dwSchemeLength
= 32;
2512 urlComponents
.lpszHostName
= hostName
;
2513 urlComponents
.dwHostNameLength
= MAXHOSTNAME
;
2514 urlComponents
.lpszUserName
= userName
;
2515 urlComponents
.dwUserNameLength
= 1024;
2516 urlComponents
.lpszPassword
= password
;
2517 urlComponents
.dwPasswordLength
= 1024;
2518 urlComponents
.lpszUrlPath
= path
;
2519 urlComponents
.dwUrlPathLength
= 2048;
2520 urlComponents
.lpszExtraInfo
= extra
;
2521 urlComponents
.dwExtraInfoLength
= 1024;
2522 if(!InternetCrackUrlW(lpszUrl
, strlenW(lpszUrl
), 0, &urlComponents
))
2524 switch(urlComponents
.nScheme
) {
2525 case INTERNET_SCHEME_FTP
:
2526 if(urlComponents
.nPort
== 0)
2527 urlComponents
.nPort
= INTERNET_DEFAULT_FTP_PORT
;
2528 client
= FTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
2529 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
);
2532 client1
= FtpOpenFileW(client
, path
, GENERIC_READ
, dwFlags
, dwContext
);
2533 if(client1
== NULL
) {
2534 InternetCloseHandle(client
);
2539 case INTERNET_SCHEME_HTTP
:
2540 case INTERNET_SCHEME_HTTPS
: {
2541 static const WCHAR szStars
[] = { '*','/','*', 0 };
2542 LPCWSTR accept
[2] = { szStars
, NULL
};
2543 if(urlComponents
.nPort
== 0) {
2544 if(urlComponents
.nScheme
== INTERNET_SCHEME_HTTP
)
2545 urlComponents
.nPort
= INTERNET_DEFAULT_HTTP_PORT
;
2547 urlComponents
.nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
2549 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
2550 client
= HTTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
2551 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
);
2554 client1
= HttpOpenRequestW(client
, NULL
, path
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
2555 if(client1
== NULL
) {
2556 InternetCloseHandle(client
);
2559 HttpAddRequestHeadersW(client1
, lpszHeaders
, dwHeadersLength
, HTTP_ADDREQ_FLAG_ADD
);
2560 if (!HttpSendRequestW(client1
, NULL
, 0, NULL
, 0)) {
2561 InternetCloseHandle(client1
);
2566 case INTERNET_SCHEME_GOPHER
:
2567 /* gopher doesn't seem to be implemented in wine, but it's supposed
2568 * to be supported by InternetOpenUrlA. */
2573 TRACE(" %p <--\n", client1
);
2578 /**********************************************************
2579 * InternetOpenUrlW (WININET.@)
2584 * handle of connection or NULL on failure
2586 HINTERNET WINAPI
InternetOpenUrlW(HINTERNET hInternet
, LPCWSTR lpszUrl
,
2587 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD dwContext
)
2589 HINTERNET ret
= NULL
;
2590 LPWININETAPPINFOW hIC
= NULL
;
2592 if (TRACE_ON(wininet
)) {
2593 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hInternet
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
2594 dwHeadersLength
, dwFlags
, dwContext
);
2596 dump_INTERNET_FLAGS(dwFlags
);
2599 hIC
= (LPWININETAPPINFOW
) WININET_GetObject( hInternet
);
2600 if (NULL
== hIC
|| hIC
->hdr
.htype
!= WH_HINIT
) {
2601 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2605 if (hIC
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
) {
2606 WORKREQUEST workRequest
;
2607 struct WORKREQ_INTERNETOPENURLW
*req
;
2609 workRequest
.asyncall
= INTERNETOPENURLW
;
2610 workRequest
.hdr
= WININET_AddRef( &hIC
->hdr
);
2611 req
= &workRequest
.u
.InternetOpenUrlW
;
2613 req
->lpszUrl
= WININET_strdupW(lpszUrl
);
2617 req
->lpszHeaders
= WININET_strdupW(lpszHeaders
);
2619 req
->lpszHeaders
= 0;
2620 req
->dwHeadersLength
= dwHeadersLength
;
2621 req
->dwFlags
= dwFlags
;
2622 req
->dwContext
= dwContext
;
2624 INTERNET_AsyncCall(&workRequest
);
2626 * This is from windows.
2628 SetLastError(ERROR_IO_PENDING
);
2630 ret
= INTERNET_InternetOpenUrlW(hIC
, lpszUrl
, lpszHeaders
, dwHeadersLength
, dwFlags
, dwContext
);
2635 WININET_Release( &hIC
->hdr
);
2636 TRACE(" %p <--\n", ret
);
2641 /**********************************************************
2642 * InternetOpenUrlA (WININET.@)
2647 * handle of connection or NULL on failure
2649 HINTERNET WINAPI
InternetOpenUrlA(HINTERNET hInternet
, LPCSTR lpszUrl
,
2650 LPCSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD dwContext
)
2652 HINTERNET rc
= (HINTERNET
)NULL
;
2656 LPWSTR szUrl
= NULL
;
2657 LPWSTR szHeaders
= NULL
;
2662 lenUrl
= MultiByteToWideChar(CP_ACP
, 0, lpszUrl
, -1, NULL
, 0 );
2663 szUrl
= HeapAlloc(GetProcessHeap(), 0, lenUrl
*sizeof(WCHAR
));
2665 return (HINTERNET
)NULL
;
2666 MultiByteToWideChar(CP_ACP
, 0, lpszUrl
, -1, szUrl
, lenUrl
);
2670 lenHeaders
= MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, NULL
, 0 );
2671 szHeaders
= HeapAlloc(GetProcessHeap(), 0, lenHeaders
*sizeof(WCHAR
));
2673 HeapFree(GetProcessHeap(), 0, szUrl
);
2674 return (HINTERNET
)NULL
;
2676 MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, szHeaders
, lenHeaders
);
2679 rc
= InternetOpenUrlW(hInternet
, szUrl
, szHeaders
,
2680 lenHeaders
, dwFlags
, dwContext
);
2682 HeapFree(GetProcessHeap(), 0, szUrl
);
2683 HeapFree(GetProcessHeap(), 0, szHeaders
);
2689 /***********************************************************************
2690 * INTERNET_SetLastError (internal)
2692 * Set last thread specific error
2697 void INTERNET_SetLastError(DWORD dwError
)
2699 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
2701 SetLastError(dwError
);
2703 lpwite
->dwError
= dwError
;
2707 /***********************************************************************
2708 * INTERNET_GetLastError (internal)
2710 * Get last thread specific error
2715 DWORD
INTERNET_GetLastError(void)
2717 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
2718 return lpwite
->dwError
;
2722 /***********************************************************************
2723 * INTERNET_WorkerThreadFunc (internal)
2725 * Worker thread execution function
2730 static DWORD
INTERNET_WorkerThreadFunc(LPVOID
*lpvParam
)
2737 INTERNET_ExecuteWork();
2740 dwWaitRes
= WaitForMultipleObjects(2, hEventArray
, FALSE
, MAX_IDLE_WORKER
);
2742 if (dwWaitRes
== WAIT_OBJECT_0
+ 1)
2743 INTERNET_ExecuteWork();
2747 InterlockedIncrement(&dwNumIdleThreads
);
2750 InterlockedDecrement(&dwNumIdleThreads
);
2751 InterlockedDecrement(&dwNumThreads
);
2752 TRACE("Worker thread exiting\n");
2757 /***********************************************************************
2758 * INTERNET_InsertWorkRequest (internal)
2760 * Insert work request into queue
2765 static BOOL
INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest
)
2767 BOOL bSuccess
= FALSE
;
2768 LPWORKREQUEST lpNewRequest
;
2772 lpNewRequest
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST
));
2775 memcpy(lpNewRequest
, lpWorkRequest
, sizeof(WORKREQUEST
));
2776 lpNewRequest
->prev
= NULL
;
2778 EnterCriticalSection(&csQueue
);
2780 lpNewRequest
->next
= lpWorkQueueTail
;
2781 if (lpWorkQueueTail
)
2782 lpWorkQueueTail
->prev
= lpNewRequest
;
2783 lpWorkQueueTail
= lpNewRequest
;
2784 if (!lpHeadWorkQueue
)
2785 lpHeadWorkQueue
= lpWorkQueueTail
;
2787 LeaveCriticalSection(&csQueue
);
2790 InterlockedIncrement(&dwNumJobs
);
2797 /***********************************************************************
2798 * INTERNET_GetWorkRequest (internal)
2800 * Retrieves work request from queue
2805 static BOOL
INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest
)
2807 BOOL bSuccess
= FALSE
;
2808 LPWORKREQUEST lpRequest
= NULL
;
2812 EnterCriticalSection(&csQueue
);
2814 if (lpHeadWorkQueue
)
2816 lpRequest
= lpHeadWorkQueue
;
2817 lpHeadWorkQueue
= lpHeadWorkQueue
->prev
;
2818 if (lpRequest
== lpWorkQueueTail
)
2819 lpWorkQueueTail
= lpHeadWorkQueue
;
2822 LeaveCriticalSection(&csQueue
);
2826 memcpy(lpWorkRequest
, lpRequest
, sizeof(WORKREQUEST
));
2827 HeapFree(GetProcessHeap(), 0, lpRequest
);
2829 InterlockedDecrement(&dwNumJobs
);
2836 /***********************************************************************
2837 * INTERNET_AsyncCall (internal)
2839 * Retrieves work request from queue
2844 BOOL
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
)
2848 BOOL bSuccess
= FALSE
;
2852 if (InterlockedDecrement(&dwNumIdleThreads
) < 0)
2854 InterlockedIncrement(&dwNumIdleThreads
);
2856 if (InterlockedIncrement(&dwNumThreads
) > MAX_WORKER_THREADS
||
2857 !(hThread
= CreateThread(NULL
, 0,
2858 (LPTHREAD_START_ROUTINE
)INTERNET_WorkerThreadFunc
, NULL
, 0, &dwTID
)))
2860 InterlockedDecrement(&dwNumThreads
);
2861 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED
);
2865 TRACE("Created new thread\n");
2869 INTERNET_InsertWorkRequest(lpWorkRequest
);
2870 SetEvent(hWorkEvent
);
2878 /***********************************************************************
2879 * INTERNET_ExecuteWork (internal)
2884 static VOID
INTERNET_ExecuteWork(void)
2886 WORKREQUEST workRequest
;
2890 if (!INTERNET_GetWorkRequest(&workRequest
))
2893 switch (workRequest
.asyncall
)
2897 struct WORKREQ_FTPPUTFILEW
*req
= &workRequest
.u
.FtpPutFileW
;
2898 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2900 TRACE("FTPPUTFILEW %p\n", lpwfs
);
2902 FTP_FtpPutFileW(lpwfs
, req
->lpszLocalFile
,
2903 req
->lpszNewRemoteFile
, req
->dwFlags
, req
->dwContext
);
2905 HeapFree(GetProcessHeap(), 0, req
->lpszLocalFile
);
2906 HeapFree(GetProcessHeap(), 0, req
->lpszNewRemoteFile
);
2910 case FTPSETCURRENTDIRECTORYW
:
2912 struct WORKREQ_FTPSETCURRENTDIRECTORYW
*req
;
2913 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2915 TRACE("FTPSETCURRENTDIRECTORYW %p\n", lpwfs
);
2917 req
= &workRequest
.u
.FtpSetCurrentDirectoryW
;
2918 FTP_FtpSetCurrentDirectoryW(lpwfs
, req
->lpszDirectory
);
2919 HeapFree(GetProcessHeap(), 0, req
->lpszDirectory
);
2923 case FTPCREATEDIRECTORYW
:
2925 struct WORKREQ_FTPCREATEDIRECTORYW
*req
;
2926 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2928 TRACE("FTPCREATEDIRECTORYW %p\n", lpwfs
);
2930 req
= &workRequest
.u
.FtpCreateDirectoryW
;
2931 FTP_FtpCreateDirectoryW(lpwfs
, req
->lpszDirectory
);
2932 HeapFree(GetProcessHeap(), 0, req
->lpszDirectory
);
2936 case FTPFINDFIRSTFILEW
:
2938 struct WORKREQ_FTPFINDFIRSTFILEW
*req
;
2939 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2941 TRACE("FTPFINDFIRSTFILEW %p\n", lpwfs
);
2943 req
= &workRequest
.u
.FtpFindFirstFileW
;
2944 FTP_FtpFindFirstFileW(lpwfs
, req
->lpszSearchFile
,
2945 req
->lpFindFileData
, req
->dwFlags
, req
->dwContext
);
2946 HeapFree(GetProcessHeap(), 0, req
->lpszSearchFile
);
2950 case FTPGETCURRENTDIRECTORYW
:
2952 struct WORKREQ_FTPGETCURRENTDIRECTORYW
*req
;
2953 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2955 TRACE("FTPGETCURRENTDIRECTORYW %p\n", lpwfs
);
2957 req
= &workRequest
.u
.FtpGetCurrentDirectoryW
;
2958 FTP_FtpGetCurrentDirectoryW(lpwfs
,
2959 req
->lpszDirectory
, req
->lpdwDirectory
);
2965 struct WORKREQ_FTPOPENFILEW
*req
= &workRequest
.u
.FtpOpenFileW
;
2966 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2968 TRACE("FTPOPENFILEW %p\n", lpwfs
);
2970 FTP_FtpOpenFileW(lpwfs
, req
->lpszFilename
,
2971 req
->dwAccess
, req
->dwFlags
, req
->dwContext
);
2972 HeapFree(GetProcessHeap(), 0, req
->lpszFilename
);
2978 struct WORKREQ_FTPGETFILEW
*req
= &workRequest
.u
.FtpGetFileW
;
2979 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2981 TRACE("FTPGETFILEW %p\n", lpwfs
);
2983 FTP_FtpGetFileW(lpwfs
, req
->lpszRemoteFile
,
2984 req
->lpszNewFile
, req
->fFailIfExists
,
2985 req
->dwLocalFlagsAttribute
, req
->dwFlags
, req
->dwContext
);
2986 HeapFree(GetProcessHeap(), 0, req
->lpszRemoteFile
);
2987 HeapFree(GetProcessHeap(), 0, req
->lpszNewFile
);
2991 case FTPDELETEFILEW
:
2993 struct WORKREQ_FTPDELETEFILEW
*req
= &workRequest
.u
.FtpDeleteFileW
;
2994 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2996 TRACE("FTPDELETEFILEW %p\n", lpwfs
);
2998 FTP_FtpDeleteFileW(lpwfs
, req
->lpszFilename
);
2999 HeapFree(GetProcessHeap(), 0, req
->lpszFilename
);
3003 case FTPREMOVEDIRECTORYW
:
3005 struct WORKREQ_FTPREMOVEDIRECTORYW
*req
;
3006 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
3008 TRACE("FTPREMOVEDIRECTORYW %p\n", lpwfs
);
3010 req
= &workRequest
.u
.FtpRemoveDirectoryW
;
3011 FTP_FtpRemoveDirectoryW(lpwfs
, req
->lpszDirectory
);
3012 HeapFree(GetProcessHeap(), 0, req
->lpszDirectory
);
3016 case FTPRENAMEFILEW
:
3018 struct WORKREQ_FTPRENAMEFILEW
*req
= &workRequest
.u
.FtpRenameFileW
;
3019 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
3021 TRACE("FTPRENAMEFILEW %p\n", lpwfs
);
3023 FTP_FtpRenameFileW(lpwfs
, req
->lpszSrcFile
, req
->lpszDestFile
);
3024 HeapFree(GetProcessHeap(), 0, req
->lpszSrcFile
);
3025 HeapFree(GetProcessHeap(), 0, req
->lpszDestFile
);
3029 case INTERNETFINDNEXTW
:
3031 struct WORKREQ_INTERNETFINDNEXTW
*req
;
3032 LPWININETFINDNEXTW lpwh
= (LPWININETFINDNEXTW
) workRequest
.hdr
;
3034 TRACE("INTERNETFINDNEXTW %p\n", lpwh
);
3036 req
= &workRequest
.u
.InternetFindNextW
;
3037 INTERNET_FindNextFileW(lpwh
, req
->lpFindFileData
);
3041 case HTTPSENDREQUESTW
:
3043 struct WORKREQ_HTTPSENDREQUESTW
*req
= &workRequest
.u
.HttpSendRequestW
;
3044 LPWININETHTTPREQW lpwhr
= (LPWININETHTTPREQW
) workRequest
.hdr
;
3046 TRACE("HTTPSENDREQUESTW %p\n", lpwhr
);
3048 HTTP_HttpSendRequestW(lpwhr
, req
->lpszHeader
,
3049 req
->dwHeaderLength
, req
->lpOptional
, req
->dwOptionalLength
);
3051 HeapFree(GetProcessHeap(), 0, req
->lpszHeader
);
3055 case HTTPOPENREQUESTW
:
3057 struct WORKREQ_HTTPOPENREQUESTW
*req
= &workRequest
.u
.HttpOpenRequestW
;
3058 LPWININETHTTPSESSIONW lpwhs
= (LPWININETHTTPSESSIONW
) workRequest
.hdr
;
3060 TRACE("HTTPOPENREQUESTW %p\n", lpwhs
);
3062 HTTP_HttpOpenRequestW(lpwhs
, req
->lpszVerb
,
3063 req
->lpszObjectName
, req
->lpszVersion
, req
->lpszReferrer
,
3064 req
->lpszAcceptTypes
, req
->dwFlags
, req
->dwContext
);
3066 HeapFree(GetProcessHeap(), 0, req
->lpszVerb
);
3067 HeapFree(GetProcessHeap(), 0, req
->lpszObjectName
);
3068 HeapFree(GetProcessHeap(), 0, req
->lpszVersion
);
3069 HeapFree(GetProcessHeap(), 0, req
->lpszReferrer
);
3075 struct WORKREQ_SENDCALLBACK
*req
= &workRequest
.u
.SendCallback
;
3077 TRACE("SENDCALLBACK %p\n", workRequest
.hdr
);
3079 SendSyncCallback(workRequest
.hdr
,
3080 req
->dwContext
, req
->dwInternetStatus
, req
->lpvStatusInfo
,
3081 req
->dwStatusInfoLength
);
3083 /* And frees the copy of the status info */
3084 HeapFree(GetProcessHeap(), 0, req
->lpvStatusInfo
);
3088 case INTERNETOPENURLW
:
3090 struct WORKREQ_INTERNETOPENURLW
*req
= &workRequest
.u
.InternetOpenUrlW
;
3091 LPWININETAPPINFOW hIC
= (LPWININETAPPINFOW
) workRequest
.hdr
;
3093 TRACE("INTERNETOPENURLW %p\n", hIC
);
3095 INTERNET_InternetOpenUrlW(hIC
, req
->lpszUrl
,
3096 req
->lpszHeaders
, req
->dwHeadersLength
, req
->dwFlags
, req
->dwContext
);
3097 HeapFree(GetProcessHeap(), 0, req
->lpszUrl
);
3098 HeapFree(GetProcessHeap(), 0, req
->lpszHeaders
);
3102 WININET_Release( workRequest
.hdr
);
3106 /***********************************************************************
3107 * INTERNET_GetResponseBuffer
3112 LPSTR
INTERNET_GetResponseBuffer(void)
3114 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
3116 return lpwite
->response
;
3119 /***********************************************************************
3120 * INTERNET_GetNextLine (internal)
3122 * Parse next line in directory string listing
3125 * Pointer to beginning of next line
3130 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
)
3134 BOOL bSuccess
= FALSE
;
3136 LPSTR lpszBuffer
= INTERNET_GetResponseBuffer();
3141 FD_SET(nSocket
, &infd
);
3142 tv
.tv_sec
=RESPONSE_TIMEOUT
;
3145 while (nRecv
< MAX_REPLY_LEN
)
3147 if (select(nSocket
+1,&infd
,NULL
,NULL
,&tv
) > 0)
3149 if (recv(nSocket
, &lpszBuffer
[nRecv
], 1, 0) <= 0)
3151 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS
);
3155 if (lpszBuffer
[nRecv
] == '\n')
3160 if (lpszBuffer
[nRecv
] != '\r')
3165 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT
);
3173 lpszBuffer
[nRecv
] = '\0';
3175 TRACE(":%d %s\n", nRecv
, lpszBuffer
);
3184 /***********************************************************************
3187 BOOL WINAPI
InternetQueryDataAvailable( HINTERNET hFile
,
3188 LPDWORD lpdwNumberOfBytesAvailble
,
3189 DWORD dwFlags
, DWORD dwConext
)
3191 LPWININETHTTPREQW lpwhr
;
3195 lpwhr
= (LPWININETHTTPREQW
) WININET_GetObject( hFile
);
3198 SetLastError(ERROR_NO_MORE_FILES
);
3202 TRACE("--> %p %i\n",lpwhr
,lpwhr
->hdr
.htype
);
3204 switch (lpwhr
->hdr
.htype
)
3207 if (!NETCON_recv(&lpwhr
->netConnection
, buffer
,
3208 4048, MSG_PEEK
, (int *)lpdwNumberOfBytesAvailble
))
3210 SetLastError(ERROR_NO_MORE_FILES
);
3218 FIXME("unsupported file type\n");
3221 WININET_Release( &lpwhr
->hdr
);
3223 TRACE("<-- %i\n",retval
);
3228 /***********************************************************************
3231 BOOL WINAPI
InternetLockRequestFile( HINTERNET hInternet
, HANDLE
3238 BOOL WINAPI
InternetUnlockRequestFile( HANDLE hLockHandle
)
3245 /***********************************************************************
3248 * On windows this function is supposed to dial the default internet
3249 * connection. We don't want to have Wine dial out to the internet so
3250 * we return TRUE by default. It might be nice to check if we are connected.
3257 BOOL WINAPI
InternetAutodial(DWORD dwFlags
, HWND hwndParent
)
3261 /* Tell that we are connected to the internet. */
3265 /***********************************************************************
3266 * InternetAutodialHangup
3268 * Hangs up a connection made with InternetAutodial
3277 BOOL WINAPI
InternetAutodialHangup(DWORD dwReserved
)
3281 /* we didn't dial, we don't disconnect */
3285 /***********************************************************************
3287 * InternetCombineUrlA
3289 * Combine a base URL with a relative URL
3297 BOOL WINAPI
InternetCombineUrlA(LPCSTR lpszBaseUrl
, LPCSTR lpszRelativeUrl
,
3298 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3303 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_a(lpszBaseUrl
), debugstr_a(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3305 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3306 dwFlags
^= ICU_NO_ENCODE
;
3307 hr
=UrlCombineA(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3312 /***********************************************************************
3314 * InternetCombineUrlW
3316 * Combine a base URL with a relative URL
3324 BOOL WINAPI
InternetCombineUrlW(LPCWSTR lpszBaseUrl
, LPCWSTR lpszRelativeUrl
,
3325 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3330 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_w(lpszBaseUrl
), debugstr_w(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3332 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3333 dwFlags
^= ICU_NO_ENCODE
;
3334 hr
=UrlCombineW(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3339 /***********************************************************************
3341 * InternetCreateUrlA
3348 BOOL WINAPI
InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents
, DWORD dwFlags
,
3349 LPSTR lpszUrl
, LPDWORD lpdwUrlLength
)
3355 DWORD WINAPI
InternetConfirmZoneCrossingA( HWND hWnd
, LPSTR szUrlPrev
, LPSTR szUrlNew
, BOOL bPost
)
3357 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_a(szUrlPrev
), debugstr_a(szUrlNew
), bPost
);
3358 return ERROR_SUCCESS
;
3361 DWORD WINAPI
InternetConfirmZoneCrossingW( HWND hWnd
, LPWSTR szUrlPrev
, LPWSTR szUrlNew
, BOOL bPost
)
3363 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_w(szUrlPrev
), debugstr_w(szUrlNew
), bPost
);
3364 return ERROR_SUCCESS
;
3367 DWORD WINAPI
InternetDialA( HWND hwndParent
, LPSTR lpszConnectoid
, DWORD dwFlags
,
3368 LPDWORD lpdwConnection
, DWORD dwReserved
)
3370 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
3371 lpdwConnection
, dwReserved
);
3372 return ERROR_SUCCESS
;
3375 DWORD WINAPI
InternetDialW( HWND hwndParent
, LPWSTR lpszConnectoid
, DWORD dwFlags
,
3376 LPDWORD lpdwConnection
, DWORD dwReserved
)
3378 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
3379 lpdwConnection
, dwReserved
);
3380 return ERROR_SUCCESS
;
3383 BOOL WINAPI
InternetGoOnlineA( LPSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
3385 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_a(lpszURL
), hwndParent
, dwReserved
);
3389 BOOL WINAPI
InternetGoOnlineW( LPWSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
3391 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_w(lpszURL
), hwndParent
, dwReserved
);
3395 DWORD WINAPI
InternetHangUp( DWORD dwConnection
, DWORD dwReserved
)
3397 FIXME("(0x%08lx, 0x%08lx) stub\n", dwConnection
, dwReserved
);
3398 return ERROR_SUCCESS
;
3401 BOOL WINAPI
CreateMD5SSOHash( PWSTR pszChallengeInfo
, PWSTR pwszRealm
, PWSTR pwszTarget
,
3404 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo
), debugstr_w(pwszRealm
),
3405 debugstr_w(pwszTarget
), pbHexHash
);
3409 BOOL WINAPI
InternetClearAllPerSiteCookieDecisions( VOID
)
3415 BOOL WINAPI
InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName
, unsigned long *pcSiteNameSize
,
3416 unsigned long *pdwDecision
, unsigned long dwIndex
)
3418 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3419 debugstr_a(pszSiteName
), pcSiteNameSize
, pdwDecision
, dwIndex
);
3423 BOOL WINAPI
InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName
, unsigned long *pcSiteNameSize
,
3424 unsigned long *pdwDecision
, unsigned long dwIndex
)
3426 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3427 debugstr_w(pszSiteName
), pcSiteNameSize
, pdwDecision
, dwIndex
);
3431 BOOL WINAPI
InternetGetCookieExA( LPCSTR pchURL
, LPCSTR pchCookieName
, LPSTR pchCookieData
,
3432 LPDWORD pcchCookieData
, DWORD dwFlags
, LPVOID lpReserved
)
3434 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3435 debugstr_a(pchURL
), debugstr_a(pchCookieName
), debugstr_a(pchCookieData
),
3436 pcchCookieData
, dwFlags
, lpReserved
);
3440 BOOL WINAPI
InternetGetCookieExW( LPCWSTR pchURL
, LPCWSTR pchCookieName
, LPWSTR pchCookieData
,
3441 LPDWORD pcchCookieData
, DWORD dwFlags
, LPVOID lpReserved
)
3443 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3444 debugstr_w(pchURL
), debugstr_w(pchCookieName
), debugstr_w(pchCookieData
),
3445 pcchCookieData
, dwFlags
, lpReserved
);
3449 BOOL WINAPI
InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName
, unsigned long *pResult
)
3451 FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName
), pResult
);
3455 BOOL WINAPI
InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName
, unsigned long *pResult
)
3457 FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName
), pResult
);
3461 BOOL WINAPI
InternetSetPerSiteCookieDecisionA( LPCSTR pchHostName
, DWORD dwDecision
)
3463 FIXME("(%s, 0x%08lx) stub\n", debugstr_a(pchHostName
), dwDecision
);
3467 BOOL WINAPI
InternetSetPerSiteCookieDecisionW( LPCWSTR pchHostName
, DWORD dwDecision
)
3469 FIXME("(%s, 0x%08lx) stub\n", debugstr_w(pchHostName
), dwDecision
);
3473 DWORD WINAPI
InternetSetCookieExA( LPCSTR lpszURL
, LPCSTR lpszCookieName
, LPCSTR lpszCookieData
,
3474 DWORD dwFlags
, DWORD_PTR dwReserved
)
3476 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
3477 debugstr_a(lpszURL
), debugstr_a(lpszCookieName
), debugstr_a(lpszCookieData
),
3478 dwFlags
, dwReserved
);
3482 DWORD WINAPI
InternetSetCookieExW( LPCWSTR lpszURL
, LPCWSTR lpszCookieName
, LPCWSTR lpszCookieData
,
3483 DWORD dwFlags
, DWORD_PTR dwReserved
)
3485 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
3486 debugstr_w(lpszURL
), debugstr_w(lpszCookieName
), debugstr_w(lpszCookieData
),
3487 dwFlags
, dwReserved
);
3491 BOOL WINAPI
ResumeSuspendedDownload( HINTERNET hInternet
, DWORD dwError
)
3493 FIXME("(%p, 0x%08lx) stub\n", hInternet
, dwError
);
3497 /***********************************************************************
3499 * InternetCreateUrlW
3506 BOOL WINAPI
InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents
, DWORD dwFlags
,
3507 LPWSTR lpszUrl
, LPDWORD lpdwUrlLength
)
3513 /***********************************************************************
3514 * dump_INTERNET_FLAGS
3516 * Helper function to TRACE the internet flags.
3522 void dump_INTERNET_FLAGS(DWORD dwFlags
)
3524 #define FE(x) { x, #x }
3525 static const wininet_flag_info flag
[] = {
3526 FE(INTERNET_FLAG_RELOAD
),
3527 FE(INTERNET_FLAG_RAW_DATA
),
3528 FE(INTERNET_FLAG_EXISTING_CONNECT
),
3529 FE(INTERNET_FLAG_ASYNC
),
3530 FE(INTERNET_FLAG_PASSIVE
),
3531 FE(INTERNET_FLAG_NO_CACHE_WRITE
),
3532 FE(INTERNET_FLAG_MAKE_PERSISTENT
),
3533 FE(INTERNET_FLAG_FROM_CACHE
),
3534 FE(INTERNET_FLAG_SECURE
),
3535 FE(INTERNET_FLAG_KEEP_CONNECTION
),
3536 FE(INTERNET_FLAG_NO_AUTO_REDIRECT
),
3537 FE(INTERNET_FLAG_READ_PREFETCH
),
3538 FE(INTERNET_FLAG_NO_COOKIES
),
3539 FE(INTERNET_FLAG_NO_AUTH
),
3540 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL
),
3541 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
),
3542 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
),
3543 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
),
3544 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID
),
3545 FE(INTERNET_FLAG_RESYNCHRONIZE
),
3546 FE(INTERNET_FLAG_HYPERLINK
),
3547 FE(INTERNET_FLAG_NO_UI
),
3548 FE(INTERNET_FLAG_PRAGMA_NOCACHE
),
3549 FE(INTERNET_FLAG_CACHE_ASYNC
),
3550 FE(INTERNET_FLAG_FORMS_SUBMIT
),
3551 FE(INTERNET_FLAG_NEED_FILE
),
3552 FE(INTERNET_FLAG_TRANSFER_ASCII
),
3553 FE(INTERNET_FLAG_TRANSFER_BINARY
)
3558 for (i
= 0; i
< (sizeof(flag
) / sizeof(flag
[0])); i
++) {
3559 if (flag
[i
].val
& dwFlags
) {
3560 TRACE(" %s", flag
[i
].name
);
3561 dwFlags
&= ~flag
[i
].val
;
3565 TRACE(" Unknown flags (%08lx)\n", dwFlags
);