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 #define HANDLE_CHUNK_SIZE 0x10
107 static CRITICAL_SECTION WININET_cs
;
108 static CRITICAL_SECTION_DEBUG WININET_cs_debug
=
111 { &WININET_cs_debug
.ProcessLocksList
, &WININET_cs_debug
.ProcessLocksList
},
112 0, 0, { 0, (DWORD
)(__FILE__
": WININET_cs") }
114 static CRITICAL_SECTION WININET_cs
= { &WININET_cs_debug
, -1, 0, 0, 0, 0 };
116 static LPWININETHANDLEHEADER
*WININET_Handles
;
117 static UINT WININET_dwNextHandle
;
118 static UINT WININET_dwMaxHandles
;
120 HINTERNET
WININET_AllocHandle( LPWININETHANDLEHEADER info
)
122 LPWININETHANDLEHEADER
*p
;
123 UINT handle
= 0, num
;
125 EnterCriticalSection( &WININET_cs
);
126 if( !WININET_dwMaxHandles
)
128 num
= HANDLE_CHUNK_SIZE
;
129 p
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
134 WININET_dwMaxHandles
= num
;
136 if( WININET_dwMaxHandles
== WININET_dwNextHandle
)
138 num
= WININET_dwMaxHandles
+ HANDLE_CHUNK_SIZE
;
139 p
= HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
140 WININET_Handles
, sizeof (UINT
)* num
);
144 WININET_dwMaxHandles
= num
;
147 handle
= WININET_dwNextHandle
;
148 if( WININET_Handles
[handle
] )
149 ERR("handle isn't free but should be\n");
150 WININET_Handles
[handle
] = WININET_AddRef( info
);
152 while( WININET_Handles
[WININET_dwNextHandle
] &&
153 (WININET_dwNextHandle
< WININET_dwMaxHandles
) )
154 WININET_dwNextHandle
++;
157 LeaveCriticalSection( &WININET_cs
);
159 return (HINTERNET
) (handle
+1);
162 HINTERNET
WININET_FindHandle( LPWININETHANDLEHEADER info
)
166 EnterCriticalSection( &WININET_cs
);
167 for( i
=0; i
<WININET_dwMaxHandles
; i
++ )
169 if( info
== WININET_Handles
[i
] )
171 WININET_AddRef( info
);
176 LeaveCriticalSection( &WININET_cs
);
178 return (HINTERNET
) handle
;
181 LPWININETHANDLEHEADER
WININET_AddRef( LPWININETHANDLEHEADER info
)
184 TRACE("%p -> refcount = %ld\n", info
, info
->dwRefCount
);
188 LPWININETHANDLEHEADER
WININET_GetObject( HINTERNET hinternet
)
190 LPWININETHANDLEHEADER info
= NULL
;
191 UINT handle
= (UINT
) hinternet
;
193 EnterCriticalSection( &WININET_cs
);
195 if( (handle
> 0) && ( handle
<= WININET_dwMaxHandles
) &&
196 WININET_Handles
[handle
-1] )
197 info
= WININET_AddRef( WININET_Handles
[handle
-1] );
199 LeaveCriticalSection( &WININET_cs
);
201 TRACE("handle %d -> %p\n", handle
, info
);
206 BOOL
WININET_Release( LPWININETHANDLEHEADER info
)
209 TRACE( "object %p refcount = %ld\n", info
, info
->dwRefCount
);
210 if( !info
->dwRefCount
)
212 TRACE( "destroying object %p\n", info
);
213 info
->destroy( info
);
218 BOOL
WININET_FreeHandle( HINTERNET hinternet
)
221 UINT handle
= (UINT
) hinternet
;
222 LPWININETHANDLEHEADER info
= NULL
;
224 EnterCriticalSection( &WININET_cs
);
226 if( (handle
> 0) && ( handle
<= WININET_dwMaxHandles
) )
229 if( WININET_Handles
[handle
] )
231 info
= WININET_Handles
[handle
];
232 TRACE( "destroying handle %d for object %p\n", handle
+1, info
);
233 WININET_Handles
[handle
] = NULL
;
235 if( WININET_dwNextHandle
> handle
)
236 WININET_dwNextHandle
= handle
;
240 LeaveCriticalSection( &WININET_cs
);
243 WININET_Release( info
);
248 /***********************************************************************
249 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
252 * hinstDLL [I] handle to the DLL's instance
254 * lpvReserved [I] reserved, must be NULL
261 BOOL WINAPI
DllMain (HINSTANCE hinstDLL
, DWORD fdwReason
, LPVOID lpvReserved
)
263 TRACE("%p,%lx,%p\n", hinstDLL
, fdwReason
, lpvReserved
);
266 case DLL_PROCESS_ATTACH
:
268 g_dwTlsErrIndex
= TlsAlloc();
270 if (g_dwTlsErrIndex
== TLS_OUT_OF_INDEXES
)
273 hQuitEvent
= CreateEventW(0, TRUE
, FALSE
, NULL
);
274 hWorkEvent
= CreateEventW(0, FALSE
, FALSE
, NULL
);
275 InitializeCriticalSection(&csQueue
);
277 URLCacheContainers_CreateDefaults();
280 dwNumIdleThreads
= 0;
283 WININET_hModule
= (HMODULE
)hinstDLL
;
285 case DLL_THREAD_ATTACH
:
287 LPWITHREADERROR lpwite
= HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR
));
291 TlsSetValue(g_dwTlsErrIndex
, (LPVOID
)lpwite
);
295 case DLL_THREAD_DETACH
:
296 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
298 LPVOID lpwite
= TlsGetValue(g_dwTlsErrIndex
);
299 HeapFree(GetProcessHeap(), 0, lpwite
);
303 case DLL_PROCESS_DETACH
:
305 URLCacheContainers_DeleteAll();
307 if (g_dwTlsErrIndex
!= TLS_OUT_OF_INDEXES
)
309 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex
));
310 TlsFree(g_dwTlsErrIndex
);
313 SetEvent(hQuitEvent
);
315 CloseHandle(hQuitEvent
);
316 CloseHandle(hWorkEvent
);
317 DeleteCriticalSection(&csQueue
);
325 /***********************************************************************
326 * InternetInitializeAutoProxyDll (WININET.@)
328 * Setup the internal proxy
337 BOOL WINAPI
InternetInitializeAutoProxyDll(DWORD dwReserved
)
340 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
344 /***********************************************************************
345 * DetectAutoProxyUrl (WININET.@)
347 * Auto detect the proxy url
353 BOOL WINAPI
DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl
,
354 DWORD dwAutoProxyUrlLength
, DWORD dwDetectFlags
)
357 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
362 /***********************************************************************
363 * INTERNET_ConfigureProxyFromReg
366 * The proxy may be specified in the form 'http=proxy.my.org'
367 * Presumably that means there can be ftp=ftpproxy.my.org too.
369 static BOOL
INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOW lpwai
)
372 DWORD r
, keytype
, len
, enabled
;
373 LPCSTR lpszInternetSettings
=
374 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
375 static const WCHAR szProxyServer
[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
377 r
= RegOpenKeyA(HKEY_CURRENT_USER
, lpszInternetSettings
, &key
);
378 if ( r
!= ERROR_SUCCESS
)
381 len
= sizeof enabled
;
382 r
= RegQueryValueExA( key
, "ProxyEnable", NULL
, &keytype
,
383 (BYTE
*)&enabled
, &len
);
384 if( (r
== ERROR_SUCCESS
) && enabled
)
386 TRACE("Proxy is enabled.\n");
388 /* figure out how much memory the proxy setting takes */
389 r
= RegQueryValueExW( key
, szProxyServer
, NULL
, &keytype
,
391 if( (r
== ERROR_SUCCESS
) && len
&& (keytype
== REG_SZ
) )
394 static const WCHAR szHttp
[] = {'h','t','t','p','=',0};
396 szProxy
=HeapAlloc( GetProcessHeap(), 0, len
);
397 RegQueryValueExW( key
, szProxyServer
, NULL
, &keytype
,
398 (BYTE
*)szProxy
, &len
);
400 /* find the http proxy, and strip away everything else */
401 p
= strstrW( szProxy
, szHttp
);
404 p
+= lstrlenW(szHttp
);
405 lstrcpyW( szProxy
, p
);
407 p
= strchrW( szProxy
, ' ' );
411 lpwai
->dwAccessType
= INTERNET_OPEN_TYPE_PROXY
;
412 lpwai
->lpszProxy
= szProxy
;
414 TRACE("http proxy = %s\n", debugstr_w(lpwai
->lpszProxy
));
417 ERR("Couldn't read proxy server settings.\n");
420 TRACE("Proxy is not enabled.\n");
426 /***********************************************************************
427 * InternetOpenW (WININET.@)
429 * Per-application initialization of wininet
432 * HINTERNET on success
436 HINTERNET WINAPI
InternetOpenW(LPCWSTR lpszAgent
, DWORD dwAccessType
,
437 LPCWSTR lpszProxy
, LPCWSTR lpszProxyBypass
, DWORD dwFlags
)
439 LPWININETAPPINFOW lpwai
= NULL
;
440 HINTERNET handle
= NULL
;
442 if (TRACE_ON(wininet
)) {
443 #define FE(x) { x, #x }
444 static const wininet_flag_info access_type
[] = {
445 FE(INTERNET_OPEN_TYPE_PRECONFIG
),
446 FE(INTERNET_OPEN_TYPE_DIRECT
),
447 FE(INTERNET_OPEN_TYPE_PROXY
),
448 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY
)
452 const char *access_type_str
= "Unknown";
454 TRACE("(%s, %li, %s, %s, %li)\n", debugstr_w(lpszAgent
), dwAccessType
,
455 debugstr_w(lpszProxy
), debugstr_w(lpszProxyBypass
), dwFlags
);
456 for (i
= 0; i
< (sizeof(access_type
) / sizeof(access_type
[0])); i
++) {
457 if (access_type
[i
].val
== dwAccessType
) {
458 access_type_str
= access_type
[i
].name
;
462 TRACE(" access type : %s\n", access_type_str
);
464 dump_INTERNET_FLAGS(dwFlags
);
467 /* Clear any error information */
468 INTERNET_SetLastError(0);
470 lpwai
= HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOW
));
473 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
477 memset(lpwai
, 0, sizeof(WININETAPPINFOW
));
478 lpwai
->hdr
.htype
= WH_HINIT
;
479 lpwai
->hdr
.lpwhparent
= NULL
;
480 lpwai
->hdr
.dwFlags
= dwFlags
;
481 lpwai
->hdr
.dwRefCount
= 1;
482 lpwai
->hdr
.destroy
= INTERNET_CloseHandle
;
483 lpwai
->dwAccessType
= dwAccessType
;
484 lpwai
->lpszProxyUsername
= NULL
;
485 lpwai
->lpszProxyPassword
= NULL
;
487 handle
= WININET_AllocHandle( &lpwai
->hdr
);
490 HeapFree( GetProcessHeap(), 0, lpwai
);
491 INTERNET_SetLastError(ERROR_OUTOFMEMORY
);
495 if (NULL
!= lpszAgent
)
497 lpwai
->lpszAgent
= HeapAlloc( GetProcessHeap(),0,
498 (strlenW(lpszAgent
)+1)*sizeof(WCHAR
));
499 if (lpwai
->lpszAgent
)
500 lstrcpyW( lpwai
->lpszAgent
, lpszAgent
);
502 if(dwAccessType
== INTERNET_OPEN_TYPE_PRECONFIG
)
503 INTERNET_ConfigureProxyFromReg( lpwai
);
504 else if (NULL
!= lpszProxy
)
506 lpwai
->lpszProxy
= HeapAlloc( GetProcessHeap(), 0,
507 (strlenW(lpszProxy
)+1)*sizeof(WCHAR
));
508 if (lpwai
->lpszProxy
)
509 lstrcpyW( lpwai
->lpszProxy
, lpszProxy
);
512 if (NULL
!= lpszProxyBypass
)
514 lpwai
->lpszProxyBypass
= HeapAlloc( GetProcessHeap(), 0,
515 (strlenW(lpszProxyBypass
)+1)*sizeof(WCHAR
));
516 if (lpwai
->lpszProxyBypass
)
517 lstrcpyW( lpwai
->lpszProxyBypass
, lpszProxyBypass
);
522 WININET_Release( &lpwai
->hdr
);
524 TRACE("returning %p\n", lpwai
);
530 /***********************************************************************
531 * InternetOpenA (WININET.@)
533 * Per-application initialization of wininet
536 * HINTERNET on success
540 HINTERNET WINAPI
InternetOpenA(LPCSTR lpszAgent
, DWORD dwAccessType
,
541 LPCSTR lpszProxy
, LPCSTR lpszProxyBypass
, DWORD dwFlags
)
543 HINTERNET rc
= (HINTERNET
)NULL
;
545 WCHAR
*szAgent
= NULL
, *szProxy
= NULL
, *szBypass
= NULL
;
547 TRACE("(%s, 0x%08lx, %s, %s, 0x%08lx)\n", debugstr_a(lpszAgent
),
548 dwAccessType
, debugstr_a(lpszProxy
), debugstr_a(lpszProxyBypass
), dwFlags
);
552 len
= MultiByteToWideChar(CP_ACP
, 0, lpszAgent
, -1, NULL
, 0);
553 szAgent
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
554 MultiByteToWideChar(CP_ACP
, 0, lpszAgent
, -1, szAgent
, len
);
559 len
= MultiByteToWideChar(CP_ACP
, 0, lpszProxy
, -1, NULL
, 0);
560 szProxy
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
561 MultiByteToWideChar(CP_ACP
, 0, lpszProxy
, -1, szProxy
, len
);
564 if( lpszProxyBypass
)
566 len
= MultiByteToWideChar(CP_ACP
, 0, lpszProxyBypass
, -1, NULL
, 0);
567 szBypass
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
568 MultiByteToWideChar(CP_ACP
, 0, lpszProxyBypass
, -1, szBypass
, len
);
571 rc
= InternetOpenW(szAgent
, dwAccessType
, szProxy
, szBypass
, dwFlags
);
573 HeapFree(GetProcessHeap(), 0, szAgent
);
574 HeapFree(GetProcessHeap(), 0, szProxy
);
575 HeapFree(GetProcessHeap(), 0, szBypass
);
580 /***********************************************************************
581 * InternetGetLastResponseInfoA (WININET.@)
583 * Return last wininet error description on the calling thread
586 * TRUE on success of writing to buffer
590 BOOL WINAPI
InternetGetLastResponseInfoA(LPDWORD lpdwError
,
591 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
593 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
597 *lpdwError
= lpwite
->dwError
;
600 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
601 *lpdwBufferLength
= strlen(lpszBuffer
);
604 *lpdwBufferLength
= 0;
609 /***********************************************************************
610 * InternetGetLastResponseInfoW (WININET.@)
612 * Return last wininet error description on the calling thread
615 * TRUE on success of writing to buffer
619 BOOL WINAPI
InternetGetLastResponseInfoW(LPDWORD lpdwError
,
620 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
)
622 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
626 *lpdwError
= lpwite
->dwError
;
629 memcpy(lpszBuffer
, lpwite
->response
, *lpdwBufferLength
);
630 *lpdwBufferLength
= lstrlenW(lpszBuffer
);
633 *lpdwBufferLength
= 0;
638 /***********************************************************************
639 * InternetGetConnectedState (WININET.@)
641 * Return connected state
645 * if lpdwStatus is not null, return the status (off line,
646 * modem, lan...) in it.
647 * FALSE if not connected
649 BOOL WINAPI
InternetGetConnectedState(LPDWORD lpdwStatus
, DWORD dwReserved
)
651 TRACE("(%p, 0x%08lx)\n", lpdwStatus
, dwReserved
);
654 FIXME("always returning LAN connection.\n");
655 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
661 /***********************************************************************
662 * InternetGetConnectedStateExW (WININET.@)
664 * Return connected state
668 * lpdwStatus [O] Flags specifying the status of the internet connection.
669 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
670 * dwNameLen [I] Size of the buffer, in characters.
671 * dwReserved [I] Reserved. Must be set to 0.
675 * if lpdwStatus is not null, return the status (off line,
676 * modem, lan...) in it.
677 * FALSE if not connected
680 * If the system has no available network connections, an empty string is
681 * stored in lpszConnectionName. If there is a LAN connection, a localized
682 * "LAN Connection" string is stored. Presumably, if only a dial-up
683 * connection is available then the name of the dial-up connection is
684 * returned. Why any application, other than the "Internet Settings" CPL,
685 * would want to use this function instead of the simpler InternetGetConnectedStateW
686 * function is beyond me.
688 BOOL WINAPI
InternetGetConnectedStateExW(LPDWORD lpdwStatus
, LPWSTR lpszConnectionName
,
689 DWORD dwNameLen
, DWORD dwReserved
)
691 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
698 FIXME("always returning LAN connection.\n");
699 *lpdwStatus
= INTERNET_CONNECTION_LAN
;
701 return LoadStringW(WININET_hModule
, IDS_LANCONNECTION
, lpszConnectionName
, dwNameLen
);
705 /***********************************************************************
706 * InternetGetConnectedStateExA (WININET.@)
708 BOOL WINAPI
InternetGetConnectedStateExA(LPDWORD lpdwStatus
, LPSTR lpszConnectionName
,
709 DWORD dwNameLen
, DWORD dwReserved
)
711 LPWSTR lpwszConnectionName
= NULL
;
714 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus
, lpszConnectionName
, dwNameLen
, dwReserved
);
716 if (lpszConnectionName
&& dwNameLen
> 0)
717 lpwszConnectionName
= HeapAlloc(GetProcessHeap(), 0, dwNameLen
* sizeof(WCHAR
));
719 rc
= InternetGetConnectedStateExW(lpdwStatus
,lpwszConnectionName
, dwNameLen
,
721 if (rc
&& lpwszConnectionName
)
723 WideCharToMultiByte(CP_ACP
,0,lpwszConnectionName
,-1,lpszConnectionName
,
724 dwNameLen
, NULL
, NULL
);
726 HeapFree(GetProcessHeap(),0,lpwszConnectionName
);
733 /***********************************************************************
734 * InternetConnectW (WININET.@)
736 * Open a ftp, gopher or http session
739 * HINTERNET a session handle on success
743 HINTERNET WINAPI
InternetConnectW(HINTERNET hInternet
,
744 LPCWSTR lpszServerName
, INTERNET_PORT nServerPort
,
745 LPCWSTR lpszUserName
, LPCWSTR lpszPassword
,
746 DWORD dwService
, DWORD dwFlags
, DWORD dwContext
)
748 LPWININETAPPINFOW hIC
;
749 HINTERNET rc
= (HINTERNET
) NULL
;
751 TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet
, debugstr_w(lpszServerName
),
752 nServerPort
, debugstr_w(lpszUserName
), debugstr_w(lpszPassword
),
753 dwService
, dwFlags
, dwContext
);
755 /* Clear any error information */
756 INTERNET_SetLastError(0);
757 hIC
= (LPWININETAPPINFOW
) WININET_GetObject( hInternet
);
758 if ( (hIC
== NULL
) || (hIC
->hdr
.htype
!= WH_HINIT
) )
763 case INTERNET_SERVICE_FTP
:
764 rc
= FTP_Connect(hIC
, lpszServerName
, nServerPort
,
765 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0);
768 case INTERNET_SERVICE_HTTP
:
769 rc
= HTTP_Connect(hIC
, lpszServerName
, nServerPort
,
770 lpszUserName
, lpszPassword
, dwFlags
, dwContext
, 0);
773 case INTERNET_SERVICE_GOPHER
:
779 WININET_Release( &hIC
->hdr
);
781 TRACE("returning %p\n", rc
);
786 /***********************************************************************
787 * InternetConnectA (WININET.@)
789 * Open a ftp, gopher or http session
792 * HINTERNET a session handle on success
796 HINTERNET WINAPI
InternetConnectA(HINTERNET hInternet
,
797 LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
798 LPCSTR lpszUserName
, LPCSTR lpszPassword
,
799 DWORD dwService
, DWORD dwFlags
, DWORD dwContext
)
801 HINTERNET rc
= (HINTERNET
)NULL
;
803 LPWSTR szServerName
= NULL
;
804 LPWSTR szUserName
= NULL
;
805 LPWSTR szPassword
= NULL
;
809 len
= MultiByteToWideChar(CP_ACP
, 0, lpszServerName
, -1, NULL
, 0);
810 szServerName
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
811 MultiByteToWideChar(CP_ACP
, 0, lpszServerName
, -1, szServerName
, len
);
815 len
= MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, NULL
, 0);
816 szUserName
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
817 MultiByteToWideChar(CP_ACP
, 0, lpszUserName
, -1, szUserName
, len
);
821 len
= MultiByteToWideChar(CP_ACP
, 0, lpszPassword
, -1, NULL
, 0);
822 szPassword
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
823 MultiByteToWideChar(CP_ACP
, 0, lpszPassword
, -1, szPassword
, len
);
827 rc
= InternetConnectW(hInternet
, szServerName
, nServerPort
,
828 szUserName
, szPassword
, dwService
, dwFlags
, dwContext
);
830 HeapFree(GetProcessHeap(), 0, szServerName
);
831 HeapFree(GetProcessHeap(), 0, szUserName
);
832 HeapFree(GetProcessHeap(), 0, szPassword
);
837 /***********************************************************************
838 * InternetFindNextFileA (WININET.@)
840 * Continues a file search from a previous call to FindFirstFile
847 BOOL WINAPI
InternetFindNextFileA(HINTERNET hFind
, LPVOID lpvFindData
)
852 ret
= InternetFindNextFileW(hFind
, lpvFindData
?&fd
:NULL
);
854 WININET_find_data_WtoA(&fd
, (LPWIN32_FIND_DATAA
)lpvFindData
);
858 /***********************************************************************
859 * InternetFindNextFileW (WININET.@)
861 * Continues a file search from a previous call to FindFirstFile
868 BOOL WINAPI
InternetFindNextFileW(HINTERNET hFind
, LPVOID lpvFindData
)
870 LPWININETAPPINFOW hIC
= NULL
;
871 LPWININETFINDNEXTW lpwh
;
872 BOOL bSuccess
= FALSE
;
876 lpwh
= (LPWININETFINDNEXTW
) WININET_GetObject( hFind
);
877 if (NULL
== lpwh
|| lpwh
->hdr
.htype
!= WH_HFINDNEXT
)
879 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
883 hIC
= GET_HWININET_FROM_LPWININETFINDNEXT(lpwh
);
884 if (hIC
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
)
886 WORKREQUEST workRequest
;
887 struct WORKREQ_INTERNETFINDNEXTW
*req
;
889 workRequest
.asyncall
= INTERNETFINDNEXTW
;
890 workRequest
.hdr
= WININET_AddRef( &lpwh
->hdr
);
891 req
= &workRequest
.u
.InternetFindNextW
;
892 req
->lpFindFileData
= lpvFindData
;
894 bSuccess
= INTERNET_AsyncCall(&workRequest
);
898 bSuccess
= INTERNET_FindNextFileW(lpwh
, lpvFindData
);
902 WININET_Release( &lpwh
->hdr
);
906 /***********************************************************************
907 * INTERNET_FindNextFileW (Internal)
909 * Continues a file search from a previous call to FindFirstFile
916 BOOL WINAPI
INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh
, LPVOID lpvFindData
)
918 BOOL bSuccess
= TRUE
;
919 LPWIN32_FIND_DATAW lpFindFileData
;
923 assert (lpwh
->hdr
.htype
== WH_HFINDNEXT
);
925 /* Clear any error information */
926 INTERNET_SetLastError(0);
928 if (lpwh
->hdr
.lpwhparent
->htype
!= WH_HFTPSESSION
)
930 FIXME("Only FTP find next supported\n");
931 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
935 TRACE("index(%ld) size(%ld)\n", lpwh
->index
, lpwh
->size
);
937 lpFindFileData
= (LPWIN32_FIND_DATAW
) lpvFindData
;
938 ZeroMemory(lpFindFileData
, sizeof(WIN32_FIND_DATAA
));
940 if (lpwh
->index
>= lpwh
->size
)
942 INTERNET_SetLastError(ERROR_NO_MORE_FILES
);
947 FTP_ConvertFileProp(&lpwh
->lpafp
[lpwh
->index
], lpFindFileData
);
950 TRACE("\nName: %s\nSize: %ld\n", debugstr_w(lpFindFileData
->cFileName
), lpFindFileData
->nFileSizeLow
);
954 if (lpwh
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
&& lpwh
->hdr
.lpfnStatusCB
)
956 INTERNET_ASYNC_RESULT iar
;
958 iar
.dwResult
= (DWORD
)bSuccess
;
959 iar
.dwError
= iar
.dwError
= bSuccess
? ERROR_SUCCESS
:
960 INTERNET_GetLastError();
962 SendAsyncCallback(&lpwh
->hdr
, lpwh
->hdr
.dwContext
,
963 INTERNET_STATUS_REQUEST_COMPLETE
, &iar
,
964 sizeof(INTERNET_ASYNC_RESULT
));
971 /***********************************************************************
972 * INTERNET_CloseHandle (internal)
974 * Close internet handle
980 static VOID
INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr
)
982 LPWININETAPPINFOW lpwai
= (LPWININETAPPINFOW
) hdr
;
986 HeapFree(GetProcessHeap(), 0, lpwai
->lpszAgent
);
987 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxy
);
988 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyBypass
);
989 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyUsername
);
990 HeapFree(GetProcessHeap(), 0, lpwai
->lpszProxyPassword
);
991 HeapFree(GetProcessHeap(), 0, lpwai
);
995 /***********************************************************************
996 * InternetCloseHandle (WININET.@)
998 * Generic close handle function
1005 BOOL WINAPI
InternetCloseHandle(HINTERNET hInternet
)
1007 LPWININETHANDLEHEADER lpwh
;
1009 TRACE("%p\n",hInternet
);
1011 lpwh
= WININET_GetObject( hInternet
);
1014 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
1018 SendAsyncCallback(lpwh
, lpwh
->dwContext
,
1019 INTERNET_STATUS_HANDLE_CLOSING
, &hInternet
,
1020 sizeof(HINTERNET
*));
1022 if( lpwh
->lpwhparent
)
1023 WININET_Release( lpwh
->lpwhparent
);
1024 WININET_FreeHandle( hInternet
);
1025 WININET_Release( lpwh
);
1031 /***********************************************************************
1032 * ConvertUrlComponentValue (Internal)
1034 * Helper function for InternetCrackUrlW
1037 static void ConvertUrlComponentValue(LPSTR
* lppszComponent
, LPDWORD dwComponentLen
,
1038 LPWSTR lpwszComponent
, DWORD dwwComponentLen
,
1039 LPCSTR lpszStart
, LPCWSTR lpwszStart
)
1041 TRACE("%p %p %p %ld %p %p\n", lppszComponent
, dwComponentLen
, lpwszComponent
, dwwComponentLen
, lpszStart
, lpwszStart
);
1042 if (*dwComponentLen
!= 0)
1044 DWORD nASCIILength
=WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,NULL
,0,NULL
,NULL
);
1045 if (*lppszComponent
== NULL
)
1047 int nASCIIOffset
=WideCharToMultiByte(CP_ACP
,0,lpwszStart
,lpwszComponent
-lpwszStart
,NULL
,0,NULL
,NULL
);
1048 *lppszComponent
= (LPSTR
)lpszStart
+nASCIIOffset
;
1049 *dwComponentLen
= nASCIILength
;
1053 DWORD ncpylen
= min((*dwComponentLen
)-1, nASCIILength
);
1054 WideCharToMultiByte(CP_ACP
,0,lpwszComponent
,dwwComponentLen
,*lppszComponent
,ncpylen
+1,NULL
,NULL
);
1055 (*lppszComponent
)[ncpylen
]=0;
1056 *dwComponentLen
= ncpylen
;
1062 /***********************************************************************
1063 * InternetCrackUrlA (WININET.@)
1065 * Break up URL into its components
1067 * TODO: Handle dwFlags
1074 BOOL WINAPI
InternetCrackUrlA(LPCSTR lpszUrl
, DWORD dwUrlLength
, DWORD dwFlags
,
1075 LPURL_COMPONENTSA lpUrlComponents
)
1078 URL_COMPONENTSW UCW
;
1081 TRACE("(%s %lu %lx %p)\n", debugstr_a(lpszUrl
), dwUrlLength
, dwFlags
, lpUrlComponents
);
1084 nLength
=MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,NULL
,0);
1086 /* if dwUrlLength=-1 then nLength includes null but length to
1087 InternetCrackUrlW should not include it */
1088 if (dwUrlLength
== -1) nLength
--;
1090 lpwszUrl
=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(WCHAR
)*nLength
);
1091 MultiByteToWideChar(CP_ACP
,0,lpszUrl
,dwUrlLength
,lpwszUrl
,nLength
);
1093 memset(&UCW
,0,sizeof(UCW
));
1094 if(lpUrlComponents
->dwHostNameLength
!=0)
1095 UCW
.dwHostNameLength
= lpUrlComponents
->dwHostNameLength
;
1096 if(lpUrlComponents
->dwUserNameLength
!=0)
1097 UCW
.dwUserNameLength
=lpUrlComponents
->dwUserNameLength
;
1098 if(lpUrlComponents
->dwPasswordLength
!=0)
1099 UCW
.dwPasswordLength
=lpUrlComponents
->dwPasswordLength
;
1100 if(lpUrlComponents
->dwUrlPathLength
!=0)
1101 UCW
.dwUrlPathLength
=lpUrlComponents
->dwUrlPathLength
;
1102 if(lpUrlComponents
->dwSchemeLength
!=0)
1103 UCW
.dwSchemeLength
=lpUrlComponents
->dwSchemeLength
;
1104 if(lpUrlComponents
->dwExtraInfoLength
!=0)
1105 UCW
.dwExtraInfoLength
=lpUrlComponents
->dwExtraInfoLength
;
1106 if(!InternetCrackUrlW(lpwszUrl
,nLength
,dwFlags
,&UCW
))
1108 HeapFree(GetProcessHeap(), 0, lpwszUrl
);
1112 ConvertUrlComponentValue(&lpUrlComponents
->lpszHostName
, &lpUrlComponents
->dwHostNameLength
,
1113 UCW
.lpszHostName
, UCW
.dwHostNameLength
,
1115 ConvertUrlComponentValue(&lpUrlComponents
->lpszUserName
, &lpUrlComponents
->dwUserNameLength
,
1116 UCW
.lpszUserName
, UCW
.dwUserNameLength
,
1118 ConvertUrlComponentValue(&lpUrlComponents
->lpszPassword
, &lpUrlComponents
->dwPasswordLength
,
1119 UCW
.lpszPassword
, UCW
.dwPasswordLength
,
1121 ConvertUrlComponentValue(&lpUrlComponents
->lpszUrlPath
, &lpUrlComponents
->dwUrlPathLength
,
1122 UCW
.lpszUrlPath
, UCW
.dwUrlPathLength
,
1124 ConvertUrlComponentValue(&lpUrlComponents
->lpszScheme
, &lpUrlComponents
->dwSchemeLength
,
1125 UCW
.lpszScheme
, UCW
.dwSchemeLength
,
1127 ConvertUrlComponentValue(&lpUrlComponents
->lpszExtraInfo
, &lpUrlComponents
->dwExtraInfoLength
,
1128 UCW
.lpszExtraInfo
, UCW
.dwExtraInfoLength
,
1130 lpUrlComponents
->nScheme
=UCW
.nScheme
;
1131 lpUrlComponents
->nPort
=UCW
.nPort
;
1132 HeapFree(GetProcessHeap(), 0, lpwszUrl
);
1134 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl
,
1135 debugstr_an(lpUrlComponents
->lpszScheme
,lpUrlComponents
->dwSchemeLength
),
1136 debugstr_an(lpUrlComponents
->lpszHostName
,lpUrlComponents
->dwHostNameLength
),
1137 debugstr_an(lpUrlComponents
->lpszUrlPath
,lpUrlComponents
->dwUrlPathLength
),
1138 debugstr_an(lpUrlComponents
->lpszExtraInfo
,lpUrlComponents
->dwExtraInfoLength
));
1143 /***********************************************************************
1144 * GetInternetSchemeW (internal)
1150 * INTERNET_SCHEME_UNKNOWN on failure
1153 static INTERNET_SCHEME
GetInternetSchemeW(LPCWSTR lpszScheme
, DWORD nMaxCmp
)
1155 INTERNET_SCHEME iScheme
=INTERNET_SCHEME_UNKNOWN
;
1156 static const WCHAR lpszFtp
[]={'f','t','p',0};
1157 static const WCHAR lpszGopher
[]={'g','o','p','h','e','r',0};
1158 static const WCHAR lpszHttp
[]={'h','t','t','p',0};
1159 static const WCHAR lpszHttps
[]={'h','t','t','p','s',0};
1160 static const WCHAR lpszFile
[]={'f','i','l','e',0};
1161 static const WCHAR lpszNews
[]={'n','e','w','s',0};
1162 static const WCHAR lpszMailto
[]={'m','a','i','l','t','o',0};
1163 static const WCHAR lpszRes
[]={'r','e','s',0};
1164 WCHAR
* tempBuffer
=NULL
;
1165 TRACE("%s %ld\n",debugstr_wn(lpszScheme
, nMaxCmp
), nMaxCmp
);
1166 if(lpszScheme
==NULL
)
1167 return INTERNET_SCHEME_UNKNOWN
;
1169 tempBuffer
=HeapAlloc(GetProcessHeap(),0,(nMaxCmp
+1)*sizeof(WCHAR
));
1170 lstrcpynW(tempBuffer
,lpszScheme
,nMaxCmp
+1);
1171 strlwrW(tempBuffer
);
1172 if (nMaxCmp
==strlenW(lpszFtp
) && !strncmpW(lpszFtp
, tempBuffer
, nMaxCmp
))
1173 iScheme
=INTERNET_SCHEME_FTP
;
1174 else if (nMaxCmp
==strlenW(lpszGopher
) && !strncmpW(lpszGopher
, tempBuffer
, nMaxCmp
))
1175 iScheme
=INTERNET_SCHEME_GOPHER
;
1176 else if (nMaxCmp
==strlenW(lpszHttp
) && !strncmpW(lpszHttp
, tempBuffer
, nMaxCmp
))
1177 iScheme
=INTERNET_SCHEME_HTTP
;
1178 else if (nMaxCmp
==strlenW(lpszHttps
) && !strncmpW(lpszHttps
, tempBuffer
, nMaxCmp
))
1179 iScheme
=INTERNET_SCHEME_HTTPS
;
1180 else if (nMaxCmp
==strlenW(lpszFile
) && !strncmpW(lpszFile
, tempBuffer
, nMaxCmp
))
1181 iScheme
=INTERNET_SCHEME_FILE
;
1182 else if (nMaxCmp
==strlenW(lpszNews
) && !strncmpW(lpszNews
, tempBuffer
, nMaxCmp
))
1183 iScheme
=INTERNET_SCHEME_NEWS
;
1184 else if (nMaxCmp
==strlenW(lpszMailto
) && !strncmpW(lpszMailto
, tempBuffer
, nMaxCmp
))
1185 iScheme
=INTERNET_SCHEME_MAILTO
;
1186 else if (nMaxCmp
==strlenW(lpszRes
) && !strncmpW(lpszRes
, tempBuffer
, nMaxCmp
))
1187 iScheme
=INTERNET_SCHEME_RES
;
1188 HeapFree(GetProcessHeap(),0,tempBuffer
);
1192 /***********************************************************************
1193 * SetUrlComponentValueW (Internal)
1195 * Helper function for InternetCrackUrlW
1198 * lppszComponent [O] Holds the returned string
1199 * dwComponentLen [I] Holds the size of lppszComponent
1200 * [O] Holds the length of the string in lppszComponent without '\0'
1201 * lpszStart [I] Holds the string to copy from
1202 * len [I] Holds the length of lpszStart without '\0'
1209 static BOOL
SetUrlComponentValueW(LPWSTR
* lppszComponent
, LPDWORD dwComponentLen
, LPCWSTR lpszStart
, DWORD len
)
1211 TRACE("%s (%ld)\n", debugstr_wn(lpszStart
,len
), len
);
1213 if ( (*dwComponentLen
== 0) && (*lppszComponent
== NULL
) )
1216 if (*dwComponentLen
!= 0 || *lppszComponent
== NULL
)
1218 if (*lppszComponent
== NULL
)
1220 *lppszComponent
= (LPWSTR
)lpszStart
;
1221 *dwComponentLen
= len
;
1225 DWORD ncpylen
= min((*dwComponentLen
)-1, len
);
1226 memcpy(*lppszComponent
, lpszStart
, ncpylen
*sizeof(WCHAR
));
1227 (*lppszComponent
)[ncpylen
] = '\0';
1228 *dwComponentLen
= ncpylen
;
1235 /***********************************************************************
1236 * InternetCrackUrlW (WININET.@)
1238 BOOL WINAPI
InternetCrackUrlW(LPCWSTR lpszUrl_orig
, DWORD dwUrlLength_orig
, DWORD dwFlags
,
1239 LPURL_COMPONENTSW lpUC
)
1243 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1246 LPCWSTR lpszParam
= NULL
;
1247 BOOL bIsAbsolute
= FALSE
;
1248 LPCWSTR lpszap
, lpszUrl
= lpszUrl_orig
;
1249 LPCWSTR lpszcp
= NULL
;
1250 LPWSTR lpszUrl_decode
= NULL
;
1251 DWORD dwUrlLength
= dwUrlLength_orig
;
1252 const WCHAR lpszSeparators
[3]={';','?',0};
1253 const WCHAR lpszSlash
[2]={'/',0};
1255 dwUrlLength
=strlenW(lpszUrl
);
1257 TRACE("(%s %lu %lx %p)\n", debugstr_w(lpszUrl
), dwUrlLength
, dwFlags
, lpUC
);
1258 if (dwFlags
& ICU_DECODE
)
1260 lpszUrl_decode
=HeapAlloc( GetProcessHeap(), 0, dwUrlLength
* sizeof (WCHAR
) );
1261 if( InternetCanonicalizeUrlW(lpszUrl_orig
, lpszUrl_decode
, &dwUrlLength
, dwFlags
))
1263 lpszUrl
= lpszUrl_decode
;
1268 /* Determine if the URI is absolute. */
1269 while (*lpszap
!= '\0')
1271 if (isalnumW(*lpszap
))
1276 if ((*lpszap
== ':') && (lpszap
- lpszUrl
>= 2))
1283 lpszcp
= lpszUrl
; /* Relative url */
1289 /* Parse <params> */
1290 lpszParam
= strpbrkW(lpszap
, lpszSeparators
);
1291 if (lpszParam
!= NULL
)
1293 SetUrlComponentValueW(&lpUC
->lpszExtraInfo
, &lpUC
->dwExtraInfoLength
,
1294 lpszParam
, dwUrlLength
-(lpszParam
-lpszUrl
));
1297 if (bIsAbsolute
) /* Parse <protocol>:[//<net_loc>] */
1300 static const WCHAR wszAbout
[]={'a','b','o','u','t',':',0};
1302 /* Get scheme first. */
1303 lpUC
->nScheme
= GetInternetSchemeW(lpszUrl
, lpszcp
- lpszUrl
);
1304 SetUrlComponentValueW(&lpUC
->lpszScheme
, &lpUC
->dwSchemeLength
,
1305 lpszUrl
, lpszcp
- lpszUrl
);
1307 /* Eat ':' in protocol. */
1310 /* if the scheme is "about", there is no host */
1311 if(strncmpW(wszAbout
,lpszUrl
, lpszcp
- lpszUrl
)==0)
1313 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1314 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1315 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
, NULL
, 0);
1320 /* Skip over slashes. */
1332 lpszNetLoc
= strpbrkW(lpszcp
, lpszSlash
);
1336 lpszNetLoc
= min(lpszNetLoc
, lpszParam
);
1338 lpszNetLoc
= lpszParam
;
1340 else if (!lpszNetLoc
)
1341 lpszNetLoc
= lpszcp
+ dwUrlLength
-(lpszcp
-lpszUrl
);
1349 /* [<user>[<:password>]@]<host>[:<port>] */
1350 /* First find the user and password if they exist */
1352 lpszHost
= strchrW(lpszcp
, '@');
1353 if (lpszHost
== NULL
|| lpszHost
> lpszNetLoc
)
1355 /* username and password not specified. */
1356 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
, NULL
, 0);
1357 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
, NULL
, 0);
1359 else /* Parse out username and password */
1361 LPCWSTR lpszUser
= lpszcp
;
1362 LPCWSTR lpszPasswd
= lpszHost
;
1364 while (lpszcp
< lpszHost
)
1367 lpszPasswd
= lpszcp
;
1372 SetUrlComponentValueW(&lpUC
->lpszUserName
, &lpUC
->dwUserNameLength
,
1373 lpszUser
, lpszPasswd
- lpszUser
);
1375 if (lpszPasswd
!= lpszHost
)
1377 SetUrlComponentValueW(&lpUC
->lpszPassword
, &lpUC
->dwPasswordLength
,
1378 lpszPasswd
== lpszHost
? NULL
: lpszPasswd
,
1379 lpszHost
- lpszPasswd
);
1381 lpszcp
++; /* Advance to beginning of host */
1384 /* Parse <host><:port> */
1387 lpszPort
= lpszNetLoc
;
1389 /* special case for res:// URLs: there is no port here, so the host is the
1390 entire string up to the first '/' */
1391 if(lpUC
->nScheme
==INTERNET_SCHEME_RES
)
1393 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1394 lpszHost
, lpszPort
- lpszHost
);
1400 while (lpszcp
< lpszNetLoc
)
1408 /* If the scheme is "file" and the host is just one letter, it's not a host */
1409 if(lpUC
->nScheme
==INTERNET_SCHEME_FILE
&& (lpszPort
-lpszHost
)==1)
1412 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1418 SetUrlComponentValueW(&lpUC
->lpszHostName
, &lpUC
->dwHostNameLength
,
1419 lpszHost
, lpszPort
- lpszHost
);
1420 if (lpszPort
!= lpszNetLoc
)
1421 lpUC
->nPort
= atoiW(++lpszPort
);
1430 /* Here lpszcp points to:
1432 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1433 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1435 if (lpszcp
!= 0 && *lpszcp
!= '\0' && (!lpszParam
|| lpszcp
< lpszParam
))
1439 /* Only truncate the parameter list if it's already been saved
1440 * in lpUC->lpszExtraInfo.
1442 if (lpszParam
&& lpUC
->dwExtraInfoLength
&& lpUC
->lpszExtraInfo
)
1443 len
= lpszParam
- lpszcp
;
1446 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1447 * newlines if necessary.
1449 LPWSTR lpsznewline
= strchrW(lpszcp
, '\n');
1450 if (lpsznewline
!= NULL
)
1451 len
= lpsznewline
- lpszcp
;
1453 len
= dwUrlLength
-(lpszcp
-lpszUrl
);
1455 SetUrlComponentValueW(&lpUC
->lpszUrlPath
, &lpUC
->dwUrlPathLength
,
1460 lpUC
->dwUrlPathLength
= 0;
1463 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl
,dwUrlLength
),
1464 debugstr_wn(lpUC
->lpszScheme
,lpUC
->dwSchemeLength
),
1465 debugstr_wn(lpUC
->lpszHostName
,lpUC
->dwHostNameLength
),
1466 debugstr_wn(lpUC
->lpszUrlPath
,lpUC
->dwUrlPathLength
),
1467 debugstr_wn(lpUC
->lpszExtraInfo
,lpUC
->dwExtraInfoLength
));
1470 HeapFree(GetProcessHeap(), 0, lpszUrl_decode
);
1474 /***********************************************************************
1475 * InternetAttemptConnect (WININET.@)
1477 * Attempt to make a connection to the internet
1480 * ERROR_SUCCESS on success
1481 * Error value on failure
1484 DWORD WINAPI
InternetAttemptConnect(DWORD dwReserved
)
1487 return ERROR_SUCCESS
;
1491 /***********************************************************************
1492 * InternetCanonicalizeUrlA (WININET.@)
1494 * Escape unsafe characters and spaces
1501 BOOL WINAPI
InternetCanonicalizeUrlA(LPCSTR lpszUrl
, LPSTR lpszBuffer
,
1502 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1505 DWORD dwURLFlags
= 0x80000000; /* Don't know what this means */
1506 if(dwFlags
& ICU_DECODE
)
1508 dwURLFlags
|= URL_UNESCAPE
;
1509 dwFlags
&= ~ICU_DECODE
;
1512 if(dwFlags
& ICU_ESCAPE
)
1514 dwURLFlags
|= URL_UNESCAPE
;
1515 dwFlags
&= ~ICU_ESCAPE
;
1518 FIXME("Unhandled flags 0x%08lx\n", dwFlags
);
1519 TRACE("%s %p %p %08lx\n", debugstr_a(lpszUrl
), lpszBuffer
,
1520 lpdwBufferLength
, dwURLFlags
);
1522 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1523 dwFlags
^= ICU_NO_ENCODE
;
1525 hr
= UrlCanonicalizeA(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1527 return (hr
== S_OK
) ? TRUE
: FALSE
;
1530 /***********************************************************************
1531 * InternetCanonicalizeUrlW (WININET.@)
1533 * Escape unsafe characters and spaces
1540 BOOL WINAPI
InternetCanonicalizeUrlW(LPCWSTR lpszUrl
, LPWSTR lpszBuffer
,
1541 LPDWORD lpdwBufferLength
, DWORD dwFlags
)
1544 DWORD dwURLFlags
= 0x80000000; /* Don't know what this means */
1545 if(dwFlags
& ICU_DECODE
)
1547 dwURLFlags
|= URL_UNESCAPE
;
1548 dwFlags
&= ~ICU_DECODE
;
1551 if(dwFlags
& ICU_ESCAPE
)
1553 dwURLFlags
|= URL_UNESCAPE
;
1554 dwFlags
&= ~ICU_ESCAPE
;
1557 FIXME("Unhandled flags 0x%08lx\n", dwFlags
);
1558 TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl
), lpszBuffer
,
1559 lpdwBufferLength
, dwURLFlags
);
1561 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1562 dwFlags
^= ICU_NO_ENCODE
;
1564 hr
= UrlCanonicalizeW(lpszUrl
, lpszBuffer
, lpdwBufferLength
, dwURLFlags
);
1566 return (hr
== S_OK
) ? TRUE
: FALSE
;
1570 /***********************************************************************
1571 * InternetSetStatusCallbackA (WININET.@)
1573 * Sets up a callback function which is called as progress is made
1574 * during an operation.
1577 * Previous callback or NULL on success
1578 * INTERNET_INVALID_STATUS_CALLBACK on failure
1581 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackA(
1582 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
1584 INTERNET_STATUS_CALLBACK retVal
;
1585 LPWININETHANDLEHEADER lpwh
;
1587 TRACE("0x%08lx\n", (ULONG
)hInternet
);
1589 lpwh
= WININET_GetObject(hInternet
);
1591 return INTERNET_INVALID_STATUS_CALLBACK
;
1593 lpwh
->dwInternalFlags
&= ~INET_CALLBACKW
;
1594 retVal
= lpwh
->lpfnStatusCB
;
1595 lpwh
->lpfnStatusCB
= lpfnIntCB
;
1597 WININET_Release( lpwh
);
1602 /***********************************************************************
1603 * InternetSetStatusCallbackW (WININET.@)
1605 * Sets up a callback function which is called as progress is made
1606 * during an operation.
1609 * Previous callback or NULL on success
1610 * INTERNET_INVALID_STATUS_CALLBACK on failure
1613 INTERNET_STATUS_CALLBACK WINAPI
InternetSetStatusCallbackW(
1614 HINTERNET hInternet
,INTERNET_STATUS_CALLBACK lpfnIntCB
)
1616 INTERNET_STATUS_CALLBACK retVal
;
1617 LPWININETHANDLEHEADER lpwh
;
1619 TRACE("0x%08lx\n", (ULONG
)hInternet
);
1621 lpwh
= WININET_GetObject(hInternet
);
1623 return INTERNET_INVALID_STATUS_CALLBACK
;
1625 lpwh
->dwInternalFlags
|= INET_CALLBACKW
;
1626 retVal
= lpwh
->lpfnStatusCB
;
1627 lpwh
->lpfnStatusCB
= lpfnIntCB
;
1629 WININET_Release( lpwh
);
1634 /***********************************************************************
1635 * InternetSetFilePointer (WININET.@)
1637 DWORD WINAPI
InternetSetFilePointer(HINTERNET f1
, LONG f2
, PVOID f3
, DWORD f4
, DWORD f5
)
1643 /***********************************************************************
1644 * InternetWriteFile (WININET.@)
1646 * Write data to an open internet file
1653 BOOL WINAPI
InternetWriteFile(HINTERNET hFile
, LPCVOID lpBuffer
,
1654 DWORD dwNumOfBytesToWrite
, LPDWORD lpdwNumOfBytesWritten
)
1656 BOOL retval
= FALSE
;
1658 LPWININETHANDLEHEADER lpwh
;
1661 lpwh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hFile
);
1665 switch (lpwh
->htype
)
1668 FIXME("This shouldn't be here! We don't support this kind"
1669 " of connection anymore. Must use NETCON functions,"
1670 " especially if using SSL\n");
1671 nSocket
= ((LPWININETHTTPREQW
)lpwh
)->netConnection
.socketFD
;
1675 nSocket
= ((LPWININETFILE
)lpwh
)->nDataSocket
;
1684 int res
= send(nSocket
, lpBuffer
, dwNumOfBytesToWrite
, 0);
1685 retval
= (res
>= 0);
1686 *lpdwNumOfBytesWritten
= retval
? res
: 0;
1688 WININET_Release( lpwh
);
1694 /***********************************************************************
1695 * InternetReadFile (WININET.@)
1697 * Read data from an open internet file
1704 BOOL WINAPI
InternetReadFile(HINTERNET hFile
, LPVOID lpBuffer
,
1705 DWORD dwNumOfBytesToRead
, LPDWORD dwNumOfBytesRead
)
1707 BOOL retval
= FALSE
;
1709 LPWININETHANDLEHEADER lpwh
;
1711 TRACE("%p %p %ld %p\n", hFile
, lpBuffer
, dwNumOfBytesToRead
, dwNumOfBytesRead
);
1713 lpwh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hFile
);
1717 /* FIXME: this should use NETCON functions! */
1718 switch (lpwh
->htype
)
1721 if (!NETCON_recv(&((LPWININETHTTPREQW
)lpwh
)->netConnection
, lpBuffer
,
1722 dwNumOfBytesToRead
, MSG_WAITALL
, (int *)dwNumOfBytesRead
))
1724 *dwNumOfBytesRead
= 0;
1725 retval
= TRUE
; /* Under windows, it seems to return 0 even if nothing was read... */
1732 /* FIXME: FTP should use NETCON_ stuff */
1733 nSocket
= ((LPWININETFILE
)lpwh
)->nDataSocket
;
1736 int res
= recv(nSocket
, lpBuffer
, dwNumOfBytesToRead
, MSG_WAITALL
);
1737 retval
= (res
>= 0);
1738 *dwNumOfBytesRead
= retval
? res
: 0;
1745 WININET_Release( lpwh
);
1747 TRACE("-- %s (bytes read: %ld)\n", retval
? "TRUE": "FALSE", dwNumOfBytesRead
? *dwNumOfBytesRead
: -1);
1751 /***********************************************************************
1752 * InternetReadFileExA (WININET.@)
1754 * Read data from an open internet file
1761 BOOL WINAPI
InternetReadFileExA(HINTERNET hFile
, LPINTERNET_BUFFERSA lpBuffer
,
1762 DWORD dwFlags
, DWORD dwContext
)
1768 /***********************************************************************
1769 * InternetReadFileExW (WININET.@)
1771 * Read data from an open internet file
1778 BOOL WINAPI
InternetReadFileExW(HINTERNET hFile
, LPINTERNET_BUFFERSW lpBuffer
,
1779 DWORD dwFlags
, DWORD dwContext
)
1783 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1787 /***********************************************************************
1788 * INET_QueryOptionHelper (internal)
1790 static BOOL
INET_QueryOptionHelper(BOOL bIsUnicode
, HINTERNET hInternet
, DWORD dwOption
,
1791 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
1793 LPWININETHANDLEHEADER lpwhh
;
1794 BOOL bSuccess
= FALSE
;
1796 TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
1798 lpwhh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hInternet
);
1802 case INTERNET_OPTION_HANDLE_TYPE
:
1808 WARN("Invalid hInternet handle\n");
1809 SetLastError(ERROR_INVALID_HANDLE
);
1813 type
= lpwhh
->htype
;
1815 TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type
);
1817 if (*lpdwBufferLength
< sizeof(ULONG
))
1818 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1821 memcpy(lpBuffer
, &type
, sizeof(ULONG
));
1824 *lpdwBufferLength
= sizeof(ULONG
);
1828 case INTERNET_OPTION_REQUEST_FLAGS
:
1831 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags
);
1832 if (*lpdwBufferLength
< sizeof(ULONG
))
1833 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1836 memcpy(lpBuffer
, &flags
, sizeof(ULONG
));
1839 *lpdwBufferLength
= sizeof(ULONG
);
1843 case INTERNET_OPTION_URL
:
1844 case INTERNET_OPTION_DATAFILE_NAME
:
1848 WARN("Invalid hInternet handle\n");
1849 SetLastError(ERROR_INVALID_HANDLE
);
1852 if (lpwhh
->htype
== WH_HHTTPREQ
)
1854 LPWININETHTTPREQW lpreq
= (LPWININETHTTPREQW
) lpwhh
;
1856 static const WCHAR szFmt
[] = {'h','t','t','p',':','/','/','%','s','%','s',0};
1859 sprintfW(url
,szFmt
,lpreq
->StdHeaders
[HTTP_QUERY_HOST
].lpszValue
,lpreq
->lpszPath
);
1860 TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url
));
1863 sizeRequired
= WideCharToMultiByte(CP_ACP
,0,url
,-1,
1864 lpBuffer
,*lpdwBufferLength
,NULL
,NULL
);
1865 if (sizeRequired
> *lpdwBufferLength
)
1866 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1869 *lpdwBufferLength
= sizeRequired
;
1873 sizeRequired
= (lstrlenW(url
)+1) * sizeof(WCHAR
);
1874 if (*lpdwBufferLength
< sizeRequired
)
1875 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1878 strcpyW(lpBuffer
, url
);
1881 *lpdwBufferLength
= sizeRequired
;
1886 case INTERNET_OPTION_HTTP_VERSION
:
1888 if (*lpdwBufferLength
< sizeof(HTTP_VERSION_INFO
))
1889 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1893 * Presently hardcoded to 1.1
1895 ((HTTP_VERSION_INFO
*)lpBuffer
)->dwMajorVersion
= 1;
1896 ((HTTP_VERSION_INFO
*)lpBuffer
)->dwMinorVersion
= 1;
1899 *lpdwBufferLength
= sizeof(HTTP_VERSION_INFO
);
1902 case INTERNET_OPTION_CONNECTED_STATE
:
1904 INTERNET_CONNECTED_INFO
* pCi
= (INTERNET_CONNECTED_INFO
*)lpBuffer
;
1905 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
1907 if (*lpdwBufferLength
< sizeof(INTERNET_CONNECTED_INFO
))
1908 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1911 pCi
->dwConnectedState
= INTERNET_STATE_CONNECTED
;
1915 *lpdwBufferLength
= sizeof(INTERNET_CONNECTED_INFO
);
1918 case INTERNET_OPTION_PROXY
:
1920 LPWININETAPPINFOW lpwai
= (LPWININETAPPINFOW
)lpwhh
;
1921 WININETAPPINFOW wai
;
1925 TRACE("Getting global proxy info\n");
1926 memset(&wai
, 0, sizeof(WININETAPPINFOW
));
1927 INTERNET_ConfigureProxyFromReg( &wai
);
1933 INTERNET_PROXY_INFOW
*pPI
= (INTERNET_PROXY_INFOW
*)lpBuffer
;
1934 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
1936 if (lpwai
->lpszProxy
)
1937 proxyBytesRequired
= (lstrlenW(lpwai
->lpszProxy
) + 1) *
1939 if (lpwai
->lpszProxyBypass
)
1940 proxyBypassBytesRequired
=
1941 (lstrlenW(lpwai
->lpszProxyBypass
) + 1) * sizeof(WCHAR
);
1942 if (*lpdwBufferLength
< sizeof(INTERNET_PROXY_INFOW
) +
1943 proxyBytesRequired
+ proxyBypassBytesRequired
)
1944 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1947 pPI
->dwAccessType
= lpwai
->dwAccessType
;
1948 if (lpwai
->lpszProxy
)
1950 pPI
->lpszProxy
= (LPWSTR
)((LPBYTE
)lpBuffer
+
1951 sizeof(INTERNET_PROXY_INFOW
));
1952 lstrcpyW((LPWSTR
)pPI
->lpszProxy
, lpwai
->lpszProxy
);
1956 pPI
->lpszProxy
= (LPWSTR
)((LPBYTE
)lpBuffer
+
1957 sizeof(INTERNET_PROXY_INFOW
));
1958 *((LPWSTR
)(pPI
->lpszProxy
)) = 0;
1961 if (lpwai
->lpszProxyBypass
)
1963 pPI
->lpszProxyBypass
= (LPWSTR
)((LPBYTE
)lpBuffer
+
1964 sizeof(INTERNET_PROXY_INFOW
) +
1965 proxyBytesRequired
);
1966 lstrcpyW((LPWSTR
)pPI
->lpszProxyBypass
,
1967 lpwai
->lpszProxyBypass
);
1971 pPI
->lpszProxyBypass
= (LPWSTR
)((LPBYTE
)lpBuffer
+
1972 sizeof(INTERNET_PROXY_INFOW
) +
1973 proxyBytesRequired
);
1974 *((LPWSTR
)(pPI
->lpszProxyBypass
)) = 0;
1978 *lpdwBufferLength
= sizeof(INTERNET_PROXY_INFOW
) +
1979 proxyBytesRequired
+ proxyBypassBytesRequired
;
1983 INTERNET_PROXY_INFOA
*pPI
= (INTERNET_PROXY_INFOA
*)lpBuffer
;
1984 DWORD proxyBytesRequired
= 0, proxyBypassBytesRequired
= 0;
1986 if (lpwai
->lpszProxy
)
1987 proxyBytesRequired
= WideCharToMultiByte(CP_ACP
, 0,
1988 lpwai
->lpszProxy
, -1, NULL
, 0, NULL
, NULL
);
1989 if (lpwai
->lpszProxyBypass
)
1990 proxyBypassBytesRequired
= WideCharToMultiByte(CP_ACP
, 0,
1991 lpwai
->lpszProxyBypass
, -1, NULL
, 0, NULL
, NULL
);
1992 if (*lpdwBufferLength
< sizeof(INTERNET_PROXY_INFOA
) +
1993 proxyBytesRequired
+ proxyBypassBytesRequired
)
1994 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER
);
1997 pPI
->dwAccessType
= lpwai
->dwAccessType
;
1998 if (lpwai
->lpszProxy
)
2000 pPI
->lpszProxy
= (LPSTR
)((LPBYTE
)lpBuffer
+
2001 sizeof(INTERNET_PROXY_INFOA
));
2002 WideCharToMultiByte(CP_ACP
, 0, lpwai
->lpszProxy
, -1,
2003 (LPSTR
)pPI
->lpszProxy
, proxyBytesRequired
, NULL
, NULL
);
2007 pPI
->lpszProxy
= (LPSTR
)((LPBYTE
)lpBuffer
+
2008 sizeof(INTERNET_PROXY_INFOA
));
2009 *((LPSTR
)(pPI
->lpszProxy
)) = '\0';
2012 if (lpwai
->lpszProxyBypass
)
2014 pPI
->lpszProxyBypass
= (LPSTR
)((LPBYTE
)lpBuffer
+
2015 sizeof(INTERNET_PROXY_INFOA
) + proxyBytesRequired
);
2016 WideCharToMultiByte(CP_ACP
, 0, lpwai
->lpszProxyBypass
,
2017 -1, (LPSTR
)pPI
->lpszProxyBypass
,
2018 proxyBypassBytesRequired
,
2023 pPI
->lpszProxyBypass
= (LPSTR
)((LPBYTE
)lpBuffer
+
2024 sizeof(INTERNET_PROXY_INFOA
) +
2025 proxyBytesRequired
);
2026 *((LPSTR
)(pPI
->lpszProxyBypass
)) = '\0';
2030 *lpdwBufferLength
= sizeof(INTERNET_PROXY_INFOA
) +
2031 proxyBytesRequired
+ proxyBypassBytesRequired
;
2035 case INTERNET_OPTION_SECURITY_FLAGS
:
2036 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2040 FIXME("Stub! %ld \n",dwOption
);
2044 WININET_Release( lpwhh
);
2049 /***********************************************************************
2050 * InternetQueryOptionW (WININET.@)
2052 * Queries an options on the specified handle
2059 BOOL WINAPI
InternetQueryOptionW(HINTERNET hInternet
, DWORD dwOption
,
2060 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2062 return INET_QueryOptionHelper(TRUE
, hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2065 /***********************************************************************
2066 * InternetQueryOptionA (WININET.@)
2068 * Queries an options on the specified handle
2075 BOOL WINAPI
InternetQueryOptionA(HINTERNET hInternet
, DWORD dwOption
,
2076 LPVOID lpBuffer
, LPDWORD lpdwBufferLength
)
2078 return INET_QueryOptionHelper(FALSE
, hInternet
, dwOption
, lpBuffer
, lpdwBufferLength
);
2082 /***********************************************************************
2083 * InternetSetOptionW (WININET.@)
2085 * Sets an options on the specified handle
2092 BOOL WINAPI
InternetSetOptionW(HINTERNET hInternet
, DWORD dwOption
,
2093 LPVOID lpBuffer
, DWORD dwBufferLength
)
2095 LPWININETHANDLEHEADER lpwhh
;
2098 TRACE("0x%08lx\n", dwOption
);
2100 lpwhh
= (LPWININETHANDLEHEADER
) WININET_GetObject( hInternet
);
2106 case INTERNET_OPTION_HTTP_VERSION
:
2108 HTTP_VERSION_INFO
* pVersion
=(HTTP_VERSION_INFO
*)lpBuffer
;
2109 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion
->dwMajorVersion
,pVersion
->dwMinorVersion
);
2112 case INTERNET_OPTION_ERROR_MASK
:
2114 unsigned long flags
=*(unsigned long*)lpBuffer
;
2115 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags
);
2118 case INTERNET_OPTION_CODEPAGE
:
2120 unsigned long codepage
=*(unsigned long*)lpBuffer
;
2121 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage
);
2124 case INTERNET_OPTION_REQUEST_PRIORITY
:
2126 unsigned long priority
=*(unsigned long*)lpBuffer
;
2127 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority
);
2130 case INTERNET_OPTION_CONNECT_TIMEOUT
:
2132 unsigned long connecttimeout
=*(unsigned long*)lpBuffer
;
2133 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%ld): STUB\n",connecttimeout
);
2136 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT
:
2138 unsigned long receivetimeout
=*(unsigned long*)lpBuffer
;
2139 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%ld): STUB\n",receivetimeout
);
2142 case INTERNET_OPTION_RESET_URLCACHE_SESSION
:
2143 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2145 case INTERNET_OPTION_END_BROWSER_SESSION
:
2146 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2148 case INTERNET_OPTION_CONNECTED_STATE
:
2149 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2151 case INTERNET_OPTION_DISABLE_PASSPORT_AUTH
:
2152 TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
2155 FIXME("Option %ld STUB\n",dwOption
);
2156 INTERNET_SetLastError(ERROR_INVALID_PARAMETER
);
2160 WININET_Release( lpwhh
);
2166 /***********************************************************************
2167 * InternetSetOptionA (WININET.@)
2169 * Sets an options on the specified handle.
2176 BOOL WINAPI
InternetSetOptionA(HINTERNET hInternet
, DWORD dwOption
,
2177 LPVOID lpBuffer
, DWORD dwBufferLength
)
2185 case INTERNET_OPTION_PROXY
:
2187 LPINTERNET_PROXY_INFOA pi
= (LPINTERNET_PROXY_INFOA
) lpBuffer
;
2188 LPINTERNET_PROXY_INFOW piw
;
2189 DWORD proxlen
, prbylen
;
2192 proxlen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, NULL
, 0);
2193 prbylen
= MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, NULL
, 0);
2194 wlen
= sizeof(*piw
) + proxlen
+ prbylen
;
2195 wbuffer
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2196 piw
= (LPINTERNET_PROXY_INFOW
) wbuffer
;
2197 piw
->dwAccessType
= pi
->dwAccessType
;
2198 prox
= (LPWSTR
) &piw
[1];
2199 prby
= &prox
[proxlen
+1];
2200 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxy
, -1, prox
, proxlen
);
2201 MultiByteToWideChar( CP_ACP
, 0, pi
->lpszProxyBypass
, -1, prby
, prbylen
);
2202 piw
->lpszProxy
= prox
;
2203 piw
->lpszProxyBypass
= prby
;
2206 case INTERNET_OPTION_USER_AGENT
:
2207 case INTERNET_OPTION_USERNAME
:
2208 case INTERNET_OPTION_PASSWORD
:
2209 wlen
= MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2211 wbuffer
= HeapAlloc( GetProcessHeap(), 0, wlen
*sizeof(WCHAR
) );
2212 MultiByteToWideChar( CP_ACP
, 0, lpBuffer
, dwBufferLength
,
2217 wlen
= dwBufferLength
;
2220 r
= InternetSetOptionW(hInternet
,dwOption
, wbuffer
, wlen
);
2222 if( lpBuffer
!= wbuffer
)
2223 HeapFree( GetProcessHeap(), 0, wbuffer
);
2229 /***********************************************************************
2230 * InternetSetOptionExA (WININET.@)
2232 BOOL WINAPI
InternetSetOptionExA(HINTERNET hInternet
, DWORD dwOption
,
2233 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2235 FIXME("Flags %08lx ignored\n", dwFlags
);
2236 return InternetSetOptionA( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2239 /***********************************************************************
2240 * InternetSetOptionExW (WININET.@)
2242 BOOL WINAPI
InternetSetOptionExW(HINTERNET hInternet
, DWORD dwOption
,
2243 LPVOID lpBuffer
, DWORD dwBufferLength
, DWORD dwFlags
)
2245 FIXME("Flags %08lx ignored\n", dwFlags
);
2246 if( dwFlags
& ~ISO_VALID_FLAGS
)
2248 SetLastError( ERROR_INVALID_PARAMETER
);
2251 return InternetSetOptionW( hInternet
, dwOption
, lpBuffer
, dwBufferLength
);
2254 static const WCHAR WININET_wkday
[7][4] =
2255 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2256 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2257 static const WCHAR WININET_month
[12][4] =
2258 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2259 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2260 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2262 /***********************************************************************
2263 * InternetTimeFromSystemTimeA (WININET.@)
2265 BOOL WINAPI
InternetTimeFromSystemTimeA( const SYSTEMTIME
* time
, DWORD format
, LPSTR string
, DWORD size
)
2268 WCHAR stringW
[INTERNET_RFC1123_BUFSIZE
];
2270 TRACE( "%p 0x%08lx %p 0x%08lx\n", time
, format
, string
, size
);
2272 ret
= InternetTimeFromSystemTimeW( time
, format
, stringW
, sizeof(stringW
) );
2273 if (ret
) WideCharToMultiByte( CP_ACP
, 0, stringW
, -1, string
, size
, NULL
, NULL
);
2278 /***********************************************************************
2279 * InternetTimeFromSystemTimeW (WININET.@)
2281 BOOL WINAPI
InternetTimeFromSystemTimeW( const SYSTEMTIME
* time
, DWORD format
, LPWSTR string
, DWORD size
)
2283 static const WCHAR date
[] =
2284 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2285 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
2287 TRACE( "%p 0x%08lx %p 0x%08lx\n", time
, format
, string
, size
);
2289 if (!time
|| !string
) return FALSE
;
2291 if (format
!= INTERNET_RFC1123_FORMAT
|| size
< INTERNET_RFC1123_BUFSIZE
* sizeof(WCHAR
))
2294 sprintfW( string
, date
,
2295 WININET_wkday
[time
->wDayOfWeek
],
2297 WININET_month
[time
->wMonth
- 1],
2306 /***********************************************************************
2307 * InternetTimeToSystemTimeA (WININET.@)
2309 BOOL WINAPI
InternetTimeToSystemTimeA( LPCSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
2315 TRACE( "%s %p 0x%08lx\n", debugstr_a(string
), time
, reserved
);
2317 len
= MultiByteToWideChar( CP_ACP
, 0, string
, -1, NULL
, 0 );
2318 stringW
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
2322 MultiByteToWideChar( CP_ACP
, 0, string
, -1, stringW
, len
);
2323 ret
= InternetTimeToSystemTimeW( stringW
, time
, reserved
);
2324 HeapFree( GetProcessHeap(), 0, stringW
);
2329 /***********************************************************************
2330 * InternetTimeToSystemTimeW (WININET.@)
2332 BOOL WINAPI
InternetTimeToSystemTimeW( LPCWSTR string
, SYSTEMTIME
* time
, DWORD reserved
)
2335 WCHAR
*s
= (LPWSTR
)string
;
2337 TRACE( "%s %p 0x%08lx\n", debugstr_w(string
), time
, reserved
);
2339 if (!string
|| !time
) return FALSE
;
2341 /* Windows does this too */
2342 GetSystemTime( time
);
2344 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2345 * a SYSTEMTIME structure.
2348 while (*s
&& !isalphaW( *s
)) s
++;
2349 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
2350 time
->wDayOfWeek
= 7;
2352 for (i
= 0; i
< 7; i
++)
2354 if (toupperW( WININET_wkday
[i
][0] ) == toupperW( s
[0] ) &&
2355 toupperW( WININET_wkday
[i
][1] ) == toupperW( s
[1] ) &&
2356 toupperW( WININET_wkday
[i
][2] ) == toupperW( s
[2] ) )
2358 time
->wDayOfWeek
= i
;
2363 if (time
->wDayOfWeek
> 6) return TRUE
;
2364 while (*s
&& !isdigitW( *s
)) s
++;
2365 time
->wDay
= strtolW( s
, &s
, 10 );
2367 while (*s
&& !isalphaW( *s
)) s
++;
2368 if (s
[0] == '\0' || s
[1] == '\0' || s
[2] == '\0') return TRUE
;
2371 for (i
= 0; i
< 12; i
++)
2373 if (toupperW( WININET_month
[i
][0]) == toupperW( s
[0] ) &&
2374 toupperW( WININET_month
[i
][1]) == toupperW( s
[1] ) &&
2375 toupperW( WININET_month
[i
][2]) == toupperW( s
[2] ) )
2377 time
->wMonth
= i
+ 1;
2381 if (time
->wMonth
== 0) return TRUE
;
2383 while (*s
&& !isdigitW( *s
)) s
++;
2384 if (*s
== '\0') return TRUE
;
2385 time
->wYear
= strtolW( s
, &s
, 10 );
2387 while (*s
&& !isdigitW( *s
)) s
++;
2388 if (*s
== '\0') return TRUE
;
2389 time
->wHour
= strtolW( s
, &s
, 10 );
2391 while (*s
&& !isdigitW( *s
)) s
++;
2392 if (*s
== '\0') return TRUE
;
2393 time
->wMinute
= strtolW( s
, &s
, 10 );
2395 while (*s
&& !isdigitW( *s
)) s
++;
2396 if (*s
== '\0') return TRUE
;
2397 time
->wSecond
= strtolW( s
, &s
, 10 );
2399 time
->wMilliseconds
= 0;
2403 /***********************************************************************
2404 * InternetCheckConnectionA (WININET.@)
2406 * Pings a requested host to check internet connection
2409 * TRUE on success and FALSE on failure. If a failure then
2410 * ERROR_NOT_CONNECTED is placesd into GetLastError
2413 BOOL WINAPI
InternetCheckConnectionA( LPCSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
2416 * this is a kludge which runs the resident ping program and reads the output.
2418 * Anyone have a better idea?
2429 * Crack or set the Address
2431 if (lpszUrl
== NULL
)
2434 * According to the doc we are supost to use the ip for the next
2435 * server in the WnInet internal server database. I have
2436 * no idea what that is or how to get it.
2438 * So someone needs to implement this.
2440 FIXME("Unimplemented with URL of NULL\n");
2445 URL_COMPONENTSA components
;
2447 ZeroMemory(&components
,sizeof(URL_COMPONENTSA
));
2448 components
.lpszHostName
= (LPSTR
)&host
;
2449 components
.dwHostNameLength
= 1024;
2451 if (!InternetCrackUrlA(lpszUrl
,0,0,&components
))
2454 TRACE("host name : %s\n",components
.lpszHostName
);
2458 * Build our ping command
2460 strcpy(command
,"ping -w 1 ");
2461 strcat(command
,host
);
2462 strcat(command
," >/dev/null 2>/dev/null");
2464 TRACE("Ping command is : %s\n",command
);
2466 status
= system(command
);
2468 TRACE("Ping returned a code of %i \n",status
);
2470 /* Ping return code of 0 indicates success */
2477 SetLastError(ERROR_NOT_CONNECTED
);
2483 /***********************************************************************
2484 * InternetCheckConnectionW (WININET.@)
2486 * Pings a requested host to check internet connection
2489 * TRUE on success and FALSE on failure. If a failure then
2490 * ERROR_NOT_CONNECTED is placed into GetLastError
2493 BOOL WINAPI
InternetCheckConnectionW(LPCWSTR lpszUrl
, DWORD dwFlags
, DWORD dwReserved
)
2499 len
= WideCharToMultiByte(CP_ACP
, 0, lpszUrl
, -1, NULL
, 0, NULL
, NULL
);
2500 if (!(szUrl
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(CHAR
))))
2502 WideCharToMultiByte(CP_ACP
, 0, lpszUrl
, -1, szUrl
, len
, NULL
, NULL
);
2503 rc
= InternetCheckConnectionA((LPCSTR
)szUrl
, dwFlags
, dwReserved
);
2504 HeapFree(GetProcessHeap(), 0, szUrl
);
2510 /**********************************************************
2511 * INTERNET_InternetOpenUrlW (internal)
2516 * handle of connection or NULL on failure
2518 HINTERNET WINAPI
INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC
, LPCWSTR lpszUrl
,
2519 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD dwContext
)
2521 URL_COMPONENTSW urlComponents
;
2522 WCHAR protocol
[32], hostName
[MAXHOSTNAME
], userName
[1024];
2523 WCHAR password
[1024], path
[2048], extra
[1024];
2524 HINTERNET client
= NULL
, client1
= NULL
;
2526 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hIC
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
2527 dwHeadersLength
, dwFlags
, dwContext
);
2529 urlComponents
.dwStructSize
= sizeof(URL_COMPONENTSW
);
2530 urlComponents
.lpszScheme
= protocol
;
2531 urlComponents
.dwSchemeLength
= 32;
2532 urlComponents
.lpszHostName
= hostName
;
2533 urlComponents
.dwHostNameLength
= MAXHOSTNAME
;
2534 urlComponents
.lpszUserName
= userName
;
2535 urlComponents
.dwUserNameLength
= 1024;
2536 urlComponents
.lpszPassword
= password
;
2537 urlComponents
.dwPasswordLength
= 1024;
2538 urlComponents
.lpszUrlPath
= path
;
2539 urlComponents
.dwUrlPathLength
= 2048;
2540 urlComponents
.lpszExtraInfo
= extra
;
2541 urlComponents
.dwExtraInfoLength
= 1024;
2542 if(!InternetCrackUrlW(lpszUrl
, strlenW(lpszUrl
), 0, &urlComponents
))
2544 switch(urlComponents
.nScheme
) {
2545 case INTERNET_SCHEME_FTP
:
2546 if(urlComponents
.nPort
== 0)
2547 urlComponents
.nPort
= INTERNET_DEFAULT_FTP_PORT
;
2548 client
= FTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
2549 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
);
2552 client1
= FtpOpenFileW(client
, path
, GENERIC_READ
, dwFlags
, dwContext
);
2553 if(client1
== NULL
) {
2554 InternetCloseHandle(client
);
2559 case INTERNET_SCHEME_HTTP
:
2560 case INTERNET_SCHEME_HTTPS
: {
2561 static const WCHAR szStars
[] = { '*','/','*', 0 };
2562 LPCWSTR accept
[2] = { szStars
, NULL
};
2563 if(urlComponents
.nPort
== 0) {
2564 if(urlComponents
.nScheme
== INTERNET_SCHEME_HTTP
)
2565 urlComponents
.nPort
= INTERNET_DEFAULT_HTTP_PORT
;
2567 urlComponents
.nPort
= INTERNET_DEFAULT_HTTPS_PORT
;
2569 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
2570 client
= HTTP_Connect(hIC
, hostName
, urlComponents
.nPort
,
2571 userName
, password
, dwFlags
, dwContext
, INET_OPENURL
);
2574 client1
= HttpOpenRequestW(client
, NULL
, path
, NULL
, NULL
, accept
, dwFlags
, dwContext
);
2575 if(client1
== NULL
) {
2576 InternetCloseHandle(client
);
2579 HttpAddRequestHeadersW(client1
, lpszHeaders
, dwHeadersLength
, HTTP_ADDREQ_FLAG_ADD
);
2580 if (!HttpSendRequestW(client1
, NULL
, 0, NULL
, 0)) {
2581 InternetCloseHandle(client1
);
2586 case INTERNET_SCHEME_GOPHER
:
2587 /* gopher doesn't seem to be implemented in wine, but it's supposed
2588 * to be supported by InternetOpenUrlA. */
2593 TRACE(" %p <--\n", client1
);
2598 /**********************************************************
2599 * InternetOpenUrlW (WININET.@)
2604 * handle of connection or NULL on failure
2606 HINTERNET WINAPI
InternetOpenUrlW(HINTERNET hInternet
, LPCWSTR lpszUrl
,
2607 LPCWSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD dwContext
)
2609 HINTERNET ret
= NULL
;
2610 LPWININETAPPINFOW hIC
= NULL
;
2612 if (TRACE_ON(wininet
)) {
2613 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hInternet
, debugstr_w(lpszUrl
), debugstr_w(lpszHeaders
),
2614 dwHeadersLength
, dwFlags
, dwContext
);
2616 dump_INTERNET_FLAGS(dwFlags
);
2619 hIC
= (LPWININETAPPINFOW
) WININET_GetObject( hInternet
);
2620 if (NULL
== hIC
|| hIC
->hdr
.htype
!= WH_HINIT
) {
2621 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE
);
2625 if (hIC
->hdr
.dwFlags
& INTERNET_FLAG_ASYNC
) {
2626 WORKREQUEST workRequest
;
2627 struct WORKREQ_INTERNETOPENURLW
*req
;
2629 workRequest
.asyncall
= INTERNETOPENURLW
;
2630 workRequest
.hdr
= WININET_AddRef( &hIC
->hdr
);
2631 req
= &workRequest
.u
.InternetOpenUrlW
;
2633 req
->lpszUrl
= WININET_strdupW(lpszUrl
);
2637 req
->lpszHeaders
= WININET_strdupW(lpszHeaders
);
2639 req
->lpszHeaders
= 0;
2640 req
->dwHeadersLength
= dwHeadersLength
;
2641 req
->dwFlags
= dwFlags
;
2642 req
->dwContext
= dwContext
;
2644 INTERNET_AsyncCall(&workRequest
);
2646 * This is from windows.
2648 SetLastError(ERROR_IO_PENDING
);
2650 ret
= INTERNET_InternetOpenUrlW(hIC
, lpszUrl
, lpszHeaders
, dwHeadersLength
, dwFlags
, dwContext
);
2655 WININET_Release( &hIC
->hdr
);
2656 TRACE(" %p <--\n", ret
);
2661 /**********************************************************
2662 * InternetOpenUrlA (WININET.@)
2667 * handle of connection or NULL on failure
2669 HINTERNET WINAPI
InternetOpenUrlA(HINTERNET hInternet
, LPCSTR lpszUrl
,
2670 LPCSTR lpszHeaders
, DWORD dwHeadersLength
, DWORD dwFlags
, DWORD dwContext
)
2672 HINTERNET rc
= (HINTERNET
)NULL
;
2676 LPWSTR szUrl
= NULL
;
2677 LPWSTR szHeaders
= NULL
;
2682 lenUrl
= MultiByteToWideChar(CP_ACP
, 0, lpszUrl
, -1, NULL
, 0 );
2683 szUrl
= HeapAlloc(GetProcessHeap(), 0, lenUrl
*sizeof(WCHAR
));
2685 return (HINTERNET
)NULL
;
2686 MultiByteToWideChar(CP_ACP
, 0, lpszUrl
, -1, szUrl
, lenUrl
);
2690 lenHeaders
= MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, NULL
, 0 );
2691 szHeaders
= HeapAlloc(GetProcessHeap(), 0, lenHeaders
*sizeof(WCHAR
));
2693 HeapFree(GetProcessHeap(), 0, szUrl
);
2694 return (HINTERNET
)NULL
;
2696 MultiByteToWideChar(CP_ACP
, 0, lpszHeaders
, dwHeadersLength
, szHeaders
, lenHeaders
);
2699 rc
= InternetOpenUrlW(hInternet
, szUrl
, szHeaders
,
2700 lenHeaders
, dwFlags
, dwContext
);
2702 HeapFree(GetProcessHeap(), 0, szUrl
);
2703 HeapFree(GetProcessHeap(), 0, szHeaders
);
2709 /***********************************************************************
2710 * INTERNET_SetLastError (internal)
2712 * Set last thread specific error
2717 void INTERNET_SetLastError(DWORD dwError
)
2719 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
2721 SetLastError(dwError
);
2723 lpwite
->dwError
= dwError
;
2727 /***********************************************************************
2728 * INTERNET_GetLastError (internal)
2730 * Get last thread specific error
2735 DWORD
INTERNET_GetLastError(void)
2737 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
2738 return lpwite
->dwError
;
2742 /***********************************************************************
2743 * INTERNET_WorkerThreadFunc (internal)
2745 * Worker thread execution function
2750 static DWORD
INTERNET_WorkerThreadFunc(LPVOID
*lpvParam
)
2757 INTERNET_ExecuteWork();
2760 dwWaitRes
= WaitForMultipleObjects(2, hEventArray
, FALSE
, MAX_IDLE_WORKER
);
2762 if (dwWaitRes
== WAIT_OBJECT_0
+ 1)
2763 INTERNET_ExecuteWork();
2767 InterlockedIncrement(&dwNumIdleThreads
);
2770 InterlockedDecrement(&dwNumIdleThreads
);
2771 InterlockedDecrement(&dwNumThreads
);
2772 TRACE("Worker thread exiting\n");
2777 /***********************************************************************
2778 * INTERNET_InsertWorkRequest (internal)
2780 * Insert work request into queue
2785 static BOOL
INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest
)
2787 BOOL bSuccess
= FALSE
;
2788 LPWORKREQUEST lpNewRequest
;
2792 lpNewRequest
= HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST
));
2795 memcpy(lpNewRequest
, lpWorkRequest
, sizeof(WORKREQUEST
));
2796 lpNewRequest
->prev
= NULL
;
2798 EnterCriticalSection(&csQueue
);
2800 lpNewRequest
->next
= lpWorkQueueTail
;
2801 if (lpWorkQueueTail
)
2802 lpWorkQueueTail
->prev
= lpNewRequest
;
2803 lpWorkQueueTail
= lpNewRequest
;
2804 if (!lpHeadWorkQueue
)
2805 lpHeadWorkQueue
= lpWorkQueueTail
;
2807 LeaveCriticalSection(&csQueue
);
2810 InterlockedIncrement(&dwNumJobs
);
2817 /***********************************************************************
2818 * INTERNET_GetWorkRequest (internal)
2820 * Retrieves work request from queue
2825 static BOOL
INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest
)
2827 BOOL bSuccess
= FALSE
;
2828 LPWORKREQUEST lpRequest
= NULL
;
2832 EnterCriticalSection(&csQueue
);
2834 if (lpHeadWorkQueue
)
2836 lpRequest
= lpHeadWorkQueue
;
2837 lpHeadWorkQueue
= lpHeadWorkQueue
->prev
;
2838 if (lpRequest
== lpWorkQueueTail
)
2839 lpWorkQueueTail
= lpHeadWorkQueue
;
2842 LeaveCriticalSection(&csQueue
);
2846 memcpy(lpWorkRequest
, lpRequest
, sizeof(WORKREQUEST
));
2847 HeapFree(GetProcessHeap(), 0, lpRequest
);
2849 InterlockedDecrement(&dwNumJobs
);
2856 /***********************************************************************
2857 * INTERNET_AsyncCall (internal)
2859 * Retrieves work request from queue
2864 BOOL
INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest
)
2868 BOOL bSuccess
= FALSE
;
2872 if (InterlockedDecrement(&dwNumIdleThreads
) < 0)
2874 InterlockedIncrement(&dwNumIdleThreads
);
2876 if (InterlockedIncrement(&dwNumThreads
) > MAX_WORKER_THREADS
||
2877 !(hThread
= CreateThread(NULL
, 0,
2878 (LPTHREAD_START_ROUTINE
)INTERNET_WorkerThreadFunc
, NULL
, 0, &dwTID
)))
2880 InterlockedDecrement(&dwNumThreads
);
2881 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED
);
2885 TRACE("Created new thread\n");
2889 INTERNET_InsertWorkRequest(lpWorkRequest
);
2890 SetEvent(hWorkEvent
);
2898 /***********************************************************************
2899 * INTERNET_ExecuteWork (internal)
2904 static VOID
INTERNET_ExecuteWork(void)
2906 WORKREQUEST workRequest
;
2910 if (!INTERNET_GetWorkRequest(&workRequest
))
2913 switch (workRequest
.asyncall
)
2917 struct WORKREQ_FTPPUTFILEW
*req
= &workRequest
.u
.FtpPutFileW
;
2918 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2920 TRACE("FTPPUTFILEW %p\n", lpwfs
);
2922 FTP_FtpPutFileW(lpwfs
, req
->lpszLocalFile
,
2923 req
->lpszNewRemoteFile
, req
->dwFlags
, req
->dwContext
);
2925 HeapFree(GetProcessHeap(), 0, req
->lpszLocalFile
);
2926 HeapFree(GetProcessHeap(), 0, req
->lpszNewRemoteFile
);
2930 case FTPSETCURRENTDIRECTORYW
:
2932 struct WORKREQ_FTPSETCURRENTDIRECTORYW
*req
;
2933 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2935 TRACE("FTPSETCURRENTDIRECTORYW %p\n", lpwfs
);
2937 req
= &workRequest
.u
.FtpSetCurrentDirectoryW
;
2938 FTP_FtpSetCurrentDirectoryW(lpwfs
, req
->lpszDirectory
);
2939 HeapFree(GetProcessHeap(), 0, req
->lpszDirectory
);
2943 case FTPCREATEDIRECTORYW
:
2945 struct WORKREQ_FTPCREATEDIRECTORYW
*req
;
2946 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2948 TRACE("FTPCREATEDIRECTORYW %p\n", lpwfs
);
2950 req
= &workRequest
.u
.FtpCreateDirectoryW
;
2951 FTP_FtpCreateDirectoryW(lpwfs
, req
->lpszDirectory
);
2952 HeapFree(GetProcessHeap(), 0, req
->lpszDirectory
);
2956 case FTPFINDFIRSTFILEW
:
2958 struct WORKREQ_FTPFINDFIRSTFILEW
*req
;
2959 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2961 TRACE("FTPFINDFIRSTFILEW %p\n", lpwfs
);
2963 req
= &workRequest
.u
.FtpFindFirstFileW
;
2964 FTP_FtpFindFirstFileW(lpwfs
, req
->lpszSearchFile
,
2965 req
->lpFindFileData
, req
->dwFlags
, req
->dwContext
);
2966 HeapFree(GetProcessHeap(), 0, req
->lpszSearchFile
);
2970 case FTPGETCURRENTDIRECTORYW
:
2972 struct WORKREQ_FTPGETCURRENTDIRECTORYW
*req
;
2973 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2975 TRACE("FTPGETCURRENTDIRECTORYW %p\n", lpwfs
);
2977 req
= &workRequest
.u
.FtpGetCurrentDirectoryW
;
2978 FTP_FtpGetCurrentDirectoryW(lpwfs
,
2979 req
->lpszDirectory
, req
->lpdwDirectory
);
2985 struct WORKREQ_FTPOPENFILEW
*req
= &workRequest
.u
.FtpOpenFileW
;
2986 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
2988 TRACE("FTPOPENFILEW %p\n", lpwfs
);
2990 FTP_FtpOpenFileW(lpwfs
, req
->lpszFilename
,
2991 req
->dwAccess
, req
->dwFlags
, req
->dwContext
);
2992 HeapFree(GetProcessHeap(), 0, req
->lpszFilename
);
2998 struct WORKREQ_FTPGETFILEW
*req
= &workRequest
.u
.FtpGetFileW
;
2999 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
3001 TRACE("FTPGETFILEW %p\n", lpwfs
);
3003 FTP_FtpGetFileW(lpwfs
, req
->lpszRemoteFile
,
3004 req
->lpszNewFile
, req
->fFailIfExists
,
3005 req
->dwLocalFlagsAttribute
, req
->dwFlags
, req
->dwContext
);
3006 HeapFree(GetProcessHeap(), 0, req
->lpszRemoteFile
);
3007 HeapFree(GetProcessHeap(), 0, req
->lpszNewFile
);
3011 case FTPDELETEFILEW
:
3013 struct WORKREQ_FTPDELETEFILEW
*req
= &workRequest
.u
.FtpDeleteFileW
;
3014 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
3016 TRACE("FTPDELETEFILEW %p\n", lpwfs
);
3018 FTP_FtpDeleteFileW(lpwfs
, req
->lpszFilename
);
3019 HeapFree(GetProcessHeap(), 0, req
->lpszFilename
);
3023 case FTPREMOVEDIRECTORYW
:
3025 struct WORKREQ_FTPREMOVEDIRECTORYW
*req
;
3026 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
3028 TRACE("FTPREMOVEDIRECTORYW %p\n", lpwfs
);
3030 req
= &workRequest
.u
.FtpRemoveDirectoryW
;
3031 FTP_FtpRemoveDirectoryW(lpwfs
, req
->lpszDirectory
);
3032 HeapFree(GetProcessHeap(), 0, req
->lpszDirectory
);
3036 case FTPRENAMEFILEW
:
3038 struct WORKREQ_FTPRENAMEFILEW
*req
= &workRequest
.u
.FtpRenameFileW
;
3039 LPWININETFTPSESSIONW lpwfs
= (LPWININETFTPSESSIONW
) workRequest
.hdr
;
3041 TRACE("FTPRENAMEFILEW %p\n", lpwfs
);
3043 FTP_FtpRenameFileW(lpwfs
, req
->lpszSrcFile
, req
->lpszDestFile
);
3044 HeapFree(GetProcessHeap(), 0, req
->lpszSrcFile
);
3045 HeapFree(GetProcessHeap(), 0, req
->lpszDestFile
);
3049 case INTERNETFINDNEXTW
:
3051 struct WORKREQ_INTERNETFINDNEXTW
*req
;
3052 LPWININETFINDNEXTW lpwh
= (LPWININETFINDNEXTW
) workRequest
.hdr
;
3054 TRACE("INTERNETFINDNEXTW %p\n", lpwh
);
3056 req
= &workRequest
.u
.InternetFindNextW
;
3057 INTERNET_FindNextFileW(lpwh
, req
->lpFindFileData
);
3061 case HTTPSENDREQUESTW
:
3063 struct WORKREQ_HTTPSENDREQUESTW
*req
= &workRequest
.u
.HttpSendRequestW
;
3064 LPWININETHTTPREQW lpwhr
= (LPWININETHTTPREQW
) workRequest
.hdr
;
3066 TRACE("HTTPSENDREQUESTW %p\n", lpwhr
);
3068 HTTP_HttpSendRequestW(lpwhr
, req
->lpszHeader
,
3069 req
->dwHeaderLength
, req
->lpOptional
, req
->dwOptionalLength
);
3071 HeapFree(GetProcessHeap(), 0, req
->lpszHeader
);
3075 case HTTPOPENREQUESTW
:
3077 struct WORKREQ_HTTPOPENREQUESTW
*req
= &workRequest
.u
.HttpOpenRequestW
;
3078 LPWININETHTTPSESSIONW lpwhs
= (LPWININETHTTPSESSIONW
) workRequest
.hdr
;
3080 TRACE("HTTPOPENREQUESTW %p\n", lpwhs
);
3082 HTTP_HttpOpenRequestW(lpwhs
, req
->lpszVerb
,
3083 req
->lpszObjectName
, req
->lpszVersion
, req
->lpszReferrer
,
3084 req
->lpszAcceptTypes
, req
->dwFlags
, req
->dwContext
);
3086 HeapFree(GetProcessHeap(), 0, req
->lpszVerb
);
3087 HeapFree(GetProcessHeap(), 0, req
->lpszObjectName
);
3088 HeapFree(GetProcessHeap(), 0, req
->lpszVersion
);
3089 HeapFree(GetProcessHeap(), 0, req
->lpszReferrer
);
3095 struct WORKREQ_SENDCALLBACK
*req
= &workRequest
.u
.SendCallback
;
3097 TRACE("SENDCALLBACK %p\n", workRequest
.hdr
);
3099 SendSyncCallback(workRequest
.hdr
,
3100 req
->dwContext
, req
->dwInternetStatus
, req
->lpvStatusInfo
,
3101 req
->dwStatusInfoLength
);
3103 /* And frees the copy of the status info */
3104 HeapFree(GetProcessHeap(), 0, req
->lpvStatusInfo
);
3108 case INTERNETOPENURLW
:
3110 struct WORKREQ_INTERNETOPENURLW
*req
= &workRequest
.u
.InternetOpenUrlW
;
3111 LPWININETAPPINFOW hIC
= (LPWININETAPPINFOW
) workRequest
.hdr
;
3113 TRACE("INTERNETOPENURLW %p\n", hIC
);
3115 INTERNET_InternetOpenUrlW(hIC
, req
->lpszUrl
,
3116 req
->lpszHeaders
, req
->dwHeadersLength
, req
->dwFlags
, req
->dwContext
);
3117 HeapFree(GetProcessHeap(), 0, req
->lpszUrl
);
3118 HeapFree(GetProcessHeap(), 0, req
->lpszHeaders
);
3122 WININET_Release( workRequest
.hdr
);
3126 /***********************************************************************
3127 * INTERNET_GetResponseBuffer
3132 LPSTR
INTERNET_GetResponseBuffer(void)
3134 LPWITHREADERROR lpwite
= (LPWITHREADERROR
)TlsGetValue(g_dwTlsErrIndex
);
3136 return lpwite
->response
;
3139 /***********************************************************************
3140 * INTERNET_GetNextLine (internal)
3142 * Parse next line in directory string listing
3145 * Pointer to beginning of next line
3150 LPSTR
INTERNET_GetNextLine(INT nSocket
, LPDWORD dwLen
)
3154 BOOL bSuccess
= FALSE
;
3156 LPSTR lpszBuffer
= INTERNET_GetResponseBuffer();
3161 FD_SET(nSocket
, &infd
);
3162 tv
.tv_sec
=RESPONSE_TIMEOUT
;
3165 while (nRecv
< MAX_REPLY_LEN
)
3167 if (select(nSocket
+1,&infd
,NULL
,NULL
,&tv
) > 0)
3169 if (recv(nSocket
, &lpszBuffer
[nRecv
], 1, 0) <= 0)
3171 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS
);
3175 if (lpszBuffer
[nRecv
] == '\n')
3180 if (lpszBuffer
[nRecv
] != '\r')
3185 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT
);
3193 lpszBuffer
[nRecv
] = '\0';
3195 TRACE(":%d %s\n", nRecv
, lpszBuffer
);
3204 /***********************************************************************
3207 BOOL WINAPI
InternetQueryDataAvailable( HINTERNET hFile
,
3208 LPDWORD lpdwNumberOfBytesAvailble
,
3209 DWORD dwFlags
, DWORD dwConext
)
3211 LPWININETHTTPREQW lpwhr
;
3215 lpwhr
= (LPWININETHTTPREQW
) WININET_GetObject( hFile
);
3218 SetLastError(ERROR_NO_MORE_FILES
);
3222 TRACE("--> %p %i\n",lpwhr
,lpwhr
->hdr
.htype
);
3224 switch (lpwhr
->hdr
.htype
)
3227 if (!NETCON_recv(&lpwhr
->netConnection
, buffer
,
3228 4048, MSG_PEEK
, (int *)lpdwNumberOfBytesAvailble
))
3230 SetLastError(ERROR_NO_MORE_FILES
);
3238 FIXME("unsupported file type\n");
3241 WININET_Release( &lpwhr
->hdr
);
3243 TRACE("<-- %i\n",retval
);
3248 /***********************************************************************
3251 BOOL WINAPI
InternetLockRequestFile( HINTERNET hInternet
, HANDLE
3258 BOOL WINAPI
InternetUnlockRequestFile( HANDLE hLockHandle
)
3265 /***********************************************************************
3268 * On windows this function is supposed to dial the default internet
3269 * connection. We don't want to have Wine dial out to the internet so
3270 * we return TRUE by default. It might be nice to check if we are connected.
3277 BOOL WINAPI
InternetAutodial(DWORD dwFlags
, HWND hwndParent
)
3281 /* Tell that we are connected to the internet. */
3285 /***********************************************************************
3286 * InternetAutodialHangup
3288 * Hangs up a connection made with InternetAutodial
3297 BOOL WINAPI
InternetAutodialHangup(DWORD dwReserved
)
3301 /* we didn't dial, we don't disconnect */
3305 /***********************************************************************
3307 * InternetCombineUrlA
3309 * Combine a base URL with a relative URL
3317 BOOL WINAPI
InternetCombineUrlA(LPCSTR lpszBaseUrl
, LPCSTR lpszRelativeUrl
,
3318 LPSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3323 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_a(lpszBaseUrl
), debugstr_a(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3325 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3326 dwFlags
^= ICU_NO_ENCODE
;
3327 hr
=UrlCombineA(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3332 /***********************************************************************
3334 * InternetCombineUrlW
3336 * Combine a base URL with a relative URL
3344 BOOL WINAPI
InternetCombineUrlW(LPCWSTR lpszBaseUrl
, LPCWSTR lpszRelativeUrl
,
3345 LPWSTR lpszBuffer
, LPDWORD lpdwBufferLength
,
3350 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_w(lpszBaseUrl
), debugstr_w(lpszRelativeUrl
), lpszBuffer
, lpdwBufferLength
, dwFlags
);
3352 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3353 dwFlags
^= ICU_NO_ENCODE
;
3354 hr
=UrlCombineW(lpszBaseUrl
,lpszRelativeUrl
,lpszBuffer
,lpdwBufferLength
,dwFlags
);
3359 /***********************************************************************
3361 * InternetCreateUrlA
3368 BOOL WINAPI
InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents
, DWORD dwFlags
,
3369 LPSTR lpszUrl
, LPDWORD lpdwUrlLength
)
3375 DWORD WINAPI
InternetConfirmZoneCrossingA( HWND hWnd
, LPSTR szUrlPrev
, LPSTR szUrlNew
, BOOL bPost
)
3377 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_a(szUrlPrev
), debugstr_a(szUrlNew
), bPost
);
3378 return ERROR_SUCCESS
;
3381 DWORD WINAPI
InternetConfirmZoneCrossingW( HWND hWnd
, LPWSTR szUrlPrev
, LPWSTR szUrlNew
, BOOL bPost
)
3383 FIXME("(%p, %s, %s, %x) stub\n", hWnd
, debugstr_w(szUrlPrev
), debugstr_w(szUrlNew
), bPost
);
3384 return ERROR_SUCCESS
;
3387 DWORD WINAPI
InternetDialA( HWND hwndParent
, LPSTR lpszConnectoid
, DWORD dwFlags
,
3388 LPDWORD lpdwConnection
, DWORD dwReserved
)
3390 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
3391 lpdwConnection
, dwReserved
);
3392 return ERROR_SUCCESS
;
3395 DWORD WINAPI
InternetDialW( HWND hwndParent
, LPWSTR lpszConnectoid
, DWORD dwFlags
,
3396 LPDWORD lpdwConnection
, DWORD dwReserved
)
3398 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent
, lpszConnectoid
, dwFlags
,
3399 lpdwConnection
, dwReserved
);
3400 return ERROR_SUCCESS
;
3403 BOOL WINAPI
InternetGoOnlineA( LPSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
3405 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_a(lpszURL
), hwndParent
, dwReserved
);
3409 BOOL WINAPI
InternetGoOnlineW( LPWSTR lpszURL
, HWND hwndParent
, DWORD dwReserved
)
3411 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_w(lpszURL
), hwndParent
, dwReserved
);
3415 DWORD WINAPI
InternetHangUp( DWORD dwConnection
, DWORD dwReserved
)
3417 FIXME("(0x%08lx, 0x%08lx) stub\n", dwConnection
, dwReserved
);
3418 return ERROR_SUCCESS
;
3421 BOOL WINAPI
CreateMD5SSOHash( PWSTR pszChallengeInfo
, PWSTR pwszRealm
, PWSTR pwszTarget
,
3424 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo
), debugstr_w(pwszRealm
),
3425 debugstr_w(pwszTarget
), pbHexHash
);
3429 BOOL WINAPI
InternetClearAllPerSiteCookieDecisions( VOID
)
3435 BOOL WINAPI
InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName
, unsigned long *pcSiteNameSize
,
3436 unsigned long *pdwDecision
, unsigned long dwIndex
)
3438 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3439 debugstr_a(pszSiteName
), pcSiteNameSize
, pdwDecision
, dwIndex
);
3443 BOOL WINAPI
InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName
, unsigned long *pcSiteNameSize
,
3444 unsigned long *pdwDecision
, unsigned long dwIndex
)
3446 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3447 debugstr_w(pszSiteName
), pcSiteNameSize
, pdwDecision
, dwIndex
);
3451 BOOL WINAPI
InternetGetCookieExA( LPCSTR pchURL
, LPCSTR pchCookieName
, LPSTR pchCookieData
,
3452 LPDWORD pcchCookieData
, DWORD dwFlags
, LPVOID lpReserved
)
3454 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3455 debugstr_a(pchURL
), debugstr_a(pchCookieName
), debugstr_a(pchCookieData
),
3456 pcchCookieData
, dwFlags
, lpReserved
);
3460 BOOL WINAPI
InternetGetCookieExW( LPCWSTR pchURL
, LPCWSTR pchCookieName
, LPWSTR pchCookieData
,
3461 LPDWORD pcchCookieData
, DWORD dwFlags
, LPVOID lpReserved
)
3463 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3464 debugstr_w(pchURL
), debugstr_w(pchCookieName
), debugstr_w(pchCookieData
),
3465 pcchCookieData
, dwFlags
, lpReserved
);
3469 BOOL WINAPI
InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName
, unsigned long *pResult
)
3471 FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName
), pResult
);
3475 BOOL WINAPI
InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName
, unsigned long *pResult
)
3477 FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName
), pResult
);
3481 BOOL WINAPI
InternetSetPerSiteCookieDecisionA( LPCSTR pchHostName
, DWORD dwDecision
)
3483 FIXME("(%s, 0x%08lx) stub\n", debugstr_a(pchHostName
), dwDecision
);
3487 BOOL WINAPI
InternetSetPerSiteCookieDecisionW( LPCWSTR pchHostName
, DWORD dwDecision
)
3489 FIXME("(%s, 0x%08lx) stub\n", debugstr_w(pchHostName
), dwDecision
);
3493 DWORD WINAPI
InternetSetCookieExA( LPCSTR lpszURL
, LPCSTR lpszCookieName
, LPCSTR lpszCookieData
,
3494 DWORD dwFlags
, DWORD_PTR dwReserved
)
3496 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
3497 debugstr_a(lpszURL
), debugstr_a(lpszCookieName
), debugstr_a(lpszCookieData
),
3498 dwFlags
, dwReserved
);
3502 DWORD WINAPI
InternetSetCookieExW( LPCWSTR lpszURL
, LPCWSTR lpszCookieName
, LPCWSTR lpszCookieData
,
3503 DWORD dwFlags
, DWORD_PTR dwReserved
)
3505 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
3506 debugstr_w(lpszURL
), debugstr_w(lpszCookieName
), debugstr_w(lpszCookieData
),
3507 dwFlags
, dwReserved
);
3511 BOOL WINAPI
ResumeSuspendedDownload( HINTERNET hInternet
, DWORD dwError
)
3513 FIXME("(%p, 0x%08lx) stub\n", hInternet
, dwError
);
3517 /***********************************************************************
3519 * InternetCreateUrlW
3526 BOOL WINAPI
InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents
, DWORD dwFlags
,
3527 LPWSTR lpszUrl
, LPDWORD lpdwUrlLength
)
3533 /***********************************************************************
3534 * dump_INTERNET_FLAGS
3536 * Helper function to TRACE the internet flags.
3542 void dump_INTERNET_FLAGS(DWORD dwFlags
)
3544 #define FE(x) { x, #x }
3545 static const wininet_flag_info flag
[] = {
3546 FE(INTERNET_FLAG_RELOAD
),
3547 FE(INTERNET_FLAG_RAW_DATA
),
3548 FE(INTERNET_FLAG_EXISTING_CONNECT
),
3549 FE(INTERNET_FLAG_ASYNC
),
3550 FE(INTERNET_FLAG_PASSIVE
),
3551 FE(INTERNET_FLAG_NO_CACHE_WRITE
),
3552 FE(INTERNET_FLAG_MAKE_PERSISTENT
),
3553 FE(INTERNET_FLAG_FROM_CACHE
),
3554 FE(INTERNET_FLAG_SECURE
),
3555 FE(INTERNET_FLAG_KEEP_CONNECTION
),
3556 FE(INTERNET_FLAG_NO_AUTO_REDIRECT
),
3557 FE(INTERNET_FLAG_READ_PREFETCH
),
3558 FE(INTERNET_FLAG_NO_COOKIES
),
3559 FE(INTERNET_FLAG_NO_AUTH
),
3560 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL
),
3561 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP
),
3562 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS
),
3563 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID
),
3564 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID
),
3565 FE(INTERNET_FLAG_RESYNCHRONIZE
),
3566 FE(INTERNET_FLAG_HYPERLINK
),
3567 FE(INTERNET_FLAG_NO_UI
),
3568 FE(INTERNET_FLAG_PRAGMA_NOCACHE
),
3569 FE(INTERNET_FLAG_CACHE_ASYNC
),
3570 FE(INTERNET_FLAG_FORMS_SUBMIT
),
3571 FE(INTERNET_FLAG_NEED_FILE
),
3572 FE(INTERNET_FLAG_TRANSFER_ASCII
),
3573 FE(INTERNET_FLAG_TRANSFER_BINARY
)
3578 for (i
= 0; i
< (sizeof(flag
) / sizeof(flag
[0])); i
++) {
3579 if (flag
[i
].val
& dwFlags
) {
3580 TRACE(" %s", flag
[i
].name
);
3581 dwFlags
&= ~flag
[i
].val
;
3585 TRACE(" Unknown flags (%08lx)\n", dwFlags
);