d3d8: Render state additions.
[wine/multimedia.git] / dlls / wininet / internet.c
blobdcc6f91b581463d1a0aee4068a01777447ff6c9b
1 /*
2 * Wininet
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
10 * Ulrich Czekalla
11 * Aric Stewart
12 * David Hammerton
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
29 #include "config.h"
30 #include "wine/port.h"
32 #define MAXHOSTNAME 100 /* from http.c */
34 #include <string.h>
35 #include <stdarg.h>
36 #include <stdio.h>
37 #include <sys/types.h>
38 #ifdef HAVE_SYS_SOCKET_H
39 # include <sys/socket.h>
40 #endif
41 #ifdef HAVE_SYS_TIME_H
42 # include <sys/time.h>
43 #endif
44 #include <stdlib.h>
45 #include <ctype.h>
46 #ifdef HAVE_UNISTD_H
47 # include <unistd.h>
48 #endif
49 #include <assert.h>
51 #include "windef.h"
52 #include "winbase.h"
53 #include "winreg.h"
54 #include "winuser.h"
55 #include "wininet.h"
56 #include "winnls.h"
57 #include "wine/debug.h"
58 #include "winerror.h"
59 #define NO_SHLWAPI_STREAM
60 #include "shlwapi.h"
62 #include "wine/exception.h"
63 #include "excpt.h"
65 #include "internet.h"
66 #include "resource.h"
68 #include "wine/unicode.h"
70 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
72 #define MAX_IDLE_WORKER 1000*60*1
73 #define MAX_WORKER_THREADS 10
74 #define RESPONSE_TIMEOUT 30
76 #define GET_HWININET_FROM_LPWININETFINDNEXT(lpwh) \
77 (LPWININETAPPINFOW)(((LPWININETFTPSESSIONW)(lpwh->hdr.lpwhparent))->hdr.lpwhparent)
80 typedef struct
82 DWORD dwError;
83 CHAR response[MAX_REPLY_LEN];
84 } WITHREADERROR, *LPWITHREADERROR;
86 static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr);
87 BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData);
88 HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
89 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext);
90 static VOID INTERNET_ExecuteWork(void);
92 static DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
93 static LONG dwNumThreads;
94 static LONG dwNumIdleThreads;
95 static LONG dwNumJobs;
96 static HANDLE hEventArray[2];
97 #define hQuitEvent hEventArray[0]
98 #define hWorkEvent hEventArray[1]
99 static CRITICAL_SECTION csQueue;
100 static LPWORKREQUEST lpHeadWorkQueue;
101 static LPWORKREQUEST lpWorkQueueTail;
102 static HMODULE WININET_hModule;
104 #define HANDLE_CHUNK_SIZE 0x10
106 static CRITICAL_SECTION WININET_cs;
107 static CRITICAL_SECTION_DEBUG WININET_cs_debug =
109 0, 0, &WININET_cs,
110 { &WININET_cs_debug.ProcessLocksList, &WININET_cs_debug.ProcessLocksList },
111 0, 0, { (DWORD_PTR)(__FILE__ ": WININET_cs") }
113 static CRITICAL_SECTION WININET_cs = { &WININET_cs_debug, -1, 0, 0, 0, 0 };
115 static LPWININETHANDLEHEADER *WININET_Handles;
116 static UINT WININET_dwNextHandle;
117 static UINT WININET_dwMaxHandles;
119 HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info )
121 LPWININETHANDLEHEADER *p;
122 UINT handle = 0, num;
124 EnterCriticalSection( &WININET_cs );
125 if( !WININET_dwMaxHandles )
127 num = HANDLE_CHUNK_SIZE;
128 p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
129 sizeof (UINT)* num);
130 if( !p )
131 goto end;
132 WININET_Handles = p;
133 WININET_dwMaxHandles = num;
135 if( WININET_dwMaxHandles == WININET_dwNextHandle )
137 num = WININET_dwMaxHandles + HANDLE_CHUNK_SIZE;
138 p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
139 WININET_Handles, sizeof (UINT)* num);
140 if( !p )
141 goto end;
142 WININET_Handles = p;
143 WININET_dwMaxHandles = num;
146 handle = WININET_dwNextHandle;
147 if( WININET_Handles[handle] )
148 ERR("handle isn't free but should be\n");
149 WININET_Handles[handle] = WININET_AddRef( info );
151 while( WININET_Handles[WININET_dwNextHandle] &&
152 (WININET_dwNextHandle < WININET_dwMaxHandles ) )
153 WININET_dwNextHandle++;
155 end:
156 LeaveCriticalSection( &WININET_cs );
158 return (HINTERNET) (handle+1);
161 HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info )
163 UINT i, handle = 0;
165 EnterCriticalSection( &WININET_cs );
166 for( i=0; i<WININET_dwMaxHandles; i++ )
168 if( info == WININET_Handles[i] )
170 WININET_AddRef( info );
171 handle = i+1;
172 break;
175 LeaveCriticalSection( &WININET_cs );
177 return (HINTERNET) handle;
180 LPWININETHANDLEHEADER WININET_AddRef( LPWININETHANDLEHEADER info )
182 info->dwRefCount++;
183 TRACE("%p -> refcount = %ld\n", info, info->dwRefCount );
184 return info;
187 LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
189 LPWININETHANDLEHEADER info = NULL;
190 UINT handle = (UINT) hinternet;
192 EnterCriticalSection( &WININET_cs );
194 if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) &&
195 WININET_Handles[handle-1] )
196 info = WININET_AddRef( WININET_Handles[handle-1] );
198 LeaveCriticalSection( &WININET_cs );
200 TRACE("handle %d -> %p\n", handle, info);
202 return info;
205 BOOL WININET_Release( LPWININETHANDLEHEADER info )
207 info->dwRefCount--;
208 TRACE( "object %p refcount = %ld\n", info, info->dwRefCount );
209 if( !info->dwRefCount )
211 TRACE( "destroying object %p\n", info);
212 info->destroy( info );
214 return TRUE;
217 BOOL WININET_FreeHandle( HINTERNET hinternet )
219 BOOL ret = FALSE;
220 UINT handle = (UINT) hinternet;
221 LPWININETHANDLEHEADER info = NULL;
223 EnterCriticalSection( &WININET_cs );
225 if( (handle > 0) && ( handle <= WININET_dwMaxHandles ) )
227 handle--;
228 if( WININET_Handles[handle] )
230 info = WININET_Handles[handle];
231 TRACE( "destroying handle %d for object %p\n", handle+1, info);
232 WININET_Handles[handle] = NULL;
233 ret = TRUE;
234 if( WININET_dwNextHandle > handle )
235 WININET_dwNextHandle = handle;
239 LeaveCriticalSection( &WININET_cs );
241 if( info )
242 WININET_Release( info );
244 return ret;
247 /***********************************************************************
248 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
250 * PARAMS
251 * hinstDLL [I] handle to the DLL's instance
252 * fdwReason [I]
253 * lpvReserved [I] reserved, must be NULL
255 * RETURNS
256 * Success: TRUE
257 * Failure: FALSE
260 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
262 TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
264 switch (fdwReason) {
265 case DLL_PROCESS_ATTACH:
267 g_dwTlsErrIndex = TlsAlloc();
269 if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
270 return FALSE;
272 hQuitEvent = CreateEventW(0, TRUE, FALSE, NULL);
273 hWorkEvent = CreateEventW(0, FALSE, FALSE, NULL);
274 InitializeCriticalSection(&csQueue);
276 URLCacheContainers_CreateDefaults();
278 dwNumThreads = 0;
279 dwNumIdleThreads = 0;
280 dwNumJobs = 0;
282 WININET_hModule = (HMODULE)hinstDLL;
284 case DLL_THREAD_ATTACH:
286 LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR));
287 if (NULL == lpwite)
288 return FALSE;
290 TlsSetValue(g_dwTlsErrIndex, (LPVOID)lpwite);
292 break;
294 case DLL_THREAD_DETACH:
295 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
297 LPVOID lpwite = TlsGetValue(g_dwTlsErrIndex);
298 HeapFree(GetProcessHeap(), 0, lpwite);
300 break;
302 case DLL_PROCESS_DETACH:
304 URLCacheContainers_DeleteAll();
306 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
308 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex));
309 TlsFree(g_dwTlsErrIndex);
312 SetEvent(hQuitEvent);
314 CloseHandle(hQuitEvent);
315 CloseHandle(hWorkEvent);
316 DeleteCriticalSection(&csQueue);
317 break;
320 return TRUE;
324 /***********************************************************************
325 * InternetInitializeAutoProxyDll (WININET.@)
327 * Setup the internal proxy
329 * PARAMETERS
330 * dwReserved
332 * RETURNS
333 * FALSE on failure
336 BOOL WINAPI InternetInitializeAutoProxyDll(DWORD dwReserved)
338 FIXME("STUB\n");
339 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
340 return FALSE;
343 /***********************************************************************
344 * DetectAutoProxyUrl (WININET.@)
346 * Auto detect the proxy url
348 * RETURNS
349 * FALSE on failure
352 BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl,
353 DWORD dwAutoProxyUrlLength, DWORD dwDetectFlags)
355 FIXME("STUB\n");
356 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
357 return FALSE;
361 /***********************************************************************
362 * INTERNET_ConfigureProxyFromReg
364 * FIXME:
365 * The proxy may be specified in the form 'http=proxy.my.org'
366 * Presumably that means there can be ftp=ftpproxy.my.org too.
368 static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOW lpwai )
370 HKEY key;
371 DWORD r, keytype, len, enabled;
372 LPCSTR lpszInternetSettings =
373 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
374 static const WCHAR szProxyServer[] = { 'P','r','o','x','y','S','e','r','v','e','r', 0 };
376 r = RegOpenKeyA(HKEY_CURRENT_USER, lpszInternetSettings, &key);
377 if ( r != ERROR_SUCCESS )
378 return FALSE;
380 len = sizeof enabled;
381 r = RegQueryValueExA( key, "ProxyEnable", NULL, &keytype,
382 (BYTE*)&enabled, &len);
383 if( (r == ERROR_SUCCESS) && enabled )
385 TRACE("Proxy is enabled.\n");
387 /* figure out how much memory the proxy setting takes */
388 r = RegQueryValueExW( key, szProxyServer, NULL, &keytype,
389 NULL, &len);
390 if( (r == ERROR_SUCCESS) && len && (keytype == REG_SZ) )
392 LPWSTR szProxy, p;
393 static const WCHAR szHttp[] = {'h','t','t','p','=',0};
395 szProxy=HeapAlloc( GetProcessHeap(), 0, len );
396 RegQueryValueExW( key, szProxyServer, NULL, &keytype,
397 (BYTE*)szProxy, &len);
399 /* find the http proxy, and strip away everything else */
400 p = strstrW( szProxy, szHttp );
401 if( p )
403 p += lstrlenW(szHttp);
404 lstrcpyW( szProxy, p );
406 p = strchrW( szProxy, ' ' );
407 if( p )
408 *p = 0;
410 lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY;
411 lpwai->lpszProxy = szProxy;
413 TRACE("http proxy = %s\n", debugstr_w(lpwai->lpszProxy));
415 else
416 ERR("Couldn't read proxy server settings.\n");
418 else
419 TRACE("Proxy is not enabled.\n");
420 RegCloseKey(key);
422 return enabled;
425 /***********************************************************************
426 * dump_INTERNET_FLAGS
428 * Helper function to TRACE the internet flags.
430 * RETURNS
431 * None
434 static void dump_INTERNET_FLAGS(DWORD dwFlags)
436 #define FE(x) { x, #x }
437 static const wininet_flag_info flag[] = {
438 FE(INTERNET_FLAG_RELOAD),
439 FE(INTERNET_FLAG_RAW_DATA),
440 FE(INTERNET_FLAG_EXISTING_CONNECT),
441 FE(INTERNET_FLAG_ASYNC),
442 FE(INTERNET_FLAG_PASSIVE),
443 FE(INTERNET_FLAG_NO_CACHE_WRITE),
444 FE(INTERNET_FLAG_MAKE_PERSISTENT),
445 FE(INTERNET_FLAG_FROM_CACHE),
446 FE(INTERNET_FLAG_SECURE),
447 FE(INTERNET_FLAG_KEEP_CONNECTION),
448 FE(INTERNET_FLAG_NO_AUTO_REDIRECT),
449 FE(INTERNET_FLAG_READ_PREFETCH),
450 FE(INTERNET_FLAG_NO_COOKIES),
451 FE(INTERNET_FLAG_NO_AUTH),
452 FE(INTERNET_FLAG_CACHE_IF_NET_FAIL),
453 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTP),
454 FE(INTERNET_FLAG_IGNORE_REDIRECT_TO_HTTPS),
455 FE(INTERNET_FLAG_IGNORE_CERT_DATE_INVALID),
456 FE(INTERNET_FLAG_IGNORE_CERT_CN_INVALID),
457 FE(INTERNET_FLAG_RESYNCHRONIZE),
458 FE(INTERNET_FLAG_HYPERLINK),
459 FE(INTERNET_FLAG_NO_UI),
460 FE(INTERNET_FLAG_PRAGMA_NOCACHE),
461 FE(INTERNET_FLAG_CACHE_ASYNC),
462 FE(INTERNET_FLAG_FORMS_SUBMIT),
463 FE(INTERNET_FLAG_NEED_FILE),
464 FE(INTERNET_FLAG_TRANSFER_ASCII),
465 FE(INTERNET_FLAG_TRANSFER_BINARY)
467 #undef FE
468 int i;
470 for (i = 0; i < (sizeof(flag) / sizeof(flag[0])); i++) {
471 if (flag[i].val & dwFlags) {
472 TRACE(" %s", flag[i].name);
473 dwFlags &= ~flag[i].val;
476 if (dwFlags)
477 TRACE(" Unknown flags (%08lx)\n", dwFlags);
478 else
479 TRACE("\n");
482 /***********************************************************************
483 * InternetOpenW (WININET.@)
485 * Per-application initialization of wininet
487 * RETURNS
488 * HINTERNET on success
489 * NULL on failure
492 HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
493 LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
495 LPWININETAPPINFOW lpwai = NULL;
496 HINTERNET handle = NULL;
498 if (TRACE_ON(wininet)) {
499 #define FE(x) { x, #x }
500 static const wininet_flag_info access_type[] = {
501 FE(INTERNET_OPEN_TYPE_PRECONFIG),
502 FE(INTERNET_OPEN_TYPE_DIRECT),
503 FE(INTERNET_OPEN_TYPE_PROXY),
504 FE(INTERNET_OPEN_TYPE_PRECONFIG_WITH_NO_AUTOPROXY)
506 #undef FE
507 DWORD i;
508 const char *access_type_str = "Unknown";
510 TRACE("(%s, %li, %s, %s, %li)\n", debugstr_w(lpszAgent), dwAccessType,
511 debugstr_w(lpszProxy), debugstr_w(lpszProxyBypass), dwFlags);
512 for (i = 0; i < (sizeof(access_type) / sizeof(access_type[0])); i++) {
513 if (access_type[i].val == dwAccessType) {
514 access_type_str = access_type[i].name;
515 break;
518 TRACE(" access type : %s\n", access_type_str);
519 TRACE(" flags :");
520 dump_INTERNET_FLAGS(dwFlags);
523 /* Clear any error information */
524 INTERNET_SetLastError(0);
526 lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOW));
527 if (NULL == lpwai)
529 INTERNET_SetLastError(ERROR_OUTOFMEMORY);
530 goto lend;
533 memset(lpwai, 0, sizeof(WININETAPPINFOW));
534 lpwai->hdr.htype = WH_HINIT;
535 lpwai->hdr.lpwhparent = NULL;
536 lpwai->hdr.dwFlags = dwFlags;
537 lpwai->hdr.dwRefCount = 1;
538 lpwai->hdr.destroy = INTERNET_CloseHandle;
539 lpwai->dwAccessType = dwAccessType;
540 lpwai->lpszProxyUsername = NULL;
541 lpwai->lpszProxyPassword = NULL;
543 handle = WININET_AllocHandle( &lpwai->hdr );
544 if( !handle )
546 HeapFree( GetProcessHeap(), 0, lpwai );
547 INTERNET_SetLastError(ERROR_OUTOFMEMORY);
548 goto lend;
551 if (NULL != lpszAgent)
553 lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,
554 (strlenW(lpszAgent)+1)*sizeof(WCHAR));
555 if (lpwai->lpszAgent)
556 lstrcpyW( lpwai->lpszAgent, lpszAgent );
558 if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG)
559 INTERNET_ConfigureProxyFromReg( lpwai );
560 else if (NULL != lpszProxy)
562 lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0,
563 (strlenW(lpszProxy)+1)*sizeof(WCHAR));
564 if (lpwai->lpszProxy)
565 lstrcpyW( lpwai->lpszProxy, lpszProxy );
568 if (NULL != lpszProxyBypass)
570 lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0,
571 (strlenW(lpszProxyBypass)+1)*sizeof(WCHAR));
572 if (lpwai->lpszProxyBypass)
573 lstrcpyW( lpwai->lpszProxyBypass, lpszProxyBypass );
576 lend:
577 if( lpwai )
578 WININET_Release( &lpwai->hdr );
580 TRACE("returning %p\n", lpwai);
582 return handle;
586 /***********************************************************************
587 * InternetOpenA (WININET.@)
589 * Per-application initialization of wininet
591 * RETURNS
592 * HINTERNET on success
593 * NULL on failure
596 HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
597 LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
599 HINTERNET rc = (HINTERNET)NULL;
600 INT len;
601 WCHAR *szAgent = NULL, *szProxy = NULL, *szBypass = NULL;
603 TRACE("(%s, 0x%08lx, %s, %s, 0x%08lx)\n", debugstr_a(lpszAgent),
604 dwAccessType, debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
606 if( lpszAgent )
608 len = MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, NULL, 0);
609 szAgent = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
610 MultiByteToWideChar(CP_ACP, 0, lpszAgent, -1, szAgent, len);
613 if( lpszProxy )
615 len = MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, NULL, 0);
616 szProxy = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
617 MultiByteToWideChar(CP_ACP, 0, lpszProxy, -1, szProxy, len);
620 if( lpszProxyBypass )
622 len = MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, NULL, 0);
623 szBypass = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
624 MultiByteToWideChar(CP_ACP, 0, lpszProxyBypass, -1, szBypass, len);
627 rc = InternetOpenW(szAgent, dwAccessType, szProxy, szBypass, dwFlags);
629 HeapFree(GetProcessHeap(), 0, szAgent);
630 HeapFree(GetProcessHeap(), 0, szProxy);
631 HeapFree(GetProcessHeap(), 0, szBypass);
633 return rc;
636 /***********************************************************************
637 * InternetGetLastResponseInfoA (WININET.@)
639 * Return last wininet error description on the calling thread
641 * RETURNS
642 * TRUE on success of writing to buffer
643 * FALSE on failure
646 BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
647 LPSTR lpszBuffer, LPDWORD lpdwBufferLength)
649 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
651 TRACE("\n");
653 *lpdwError = lpwite->dwError;
654 if (lpwite->dwError)
656 memcpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
657 *lpdwBufferLength = strlen(lpszBuffer);
659 else
660 *lpdwBufferLength = 0;
662 return TRUE;
665 /***********************************************************************
666 * InternetGetLastResponseInfoW (WININET.@)
668 * Return last wininet error description on the calling thread
670 * RETURNS
671 * TRUE on success of writing to buffer
672 * FALSE on failure
675 BOOL WINAPI InternetGetLastResponseInfoW(LPDWORD lpdwError,
676 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength)
678 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
680 TRACE("\n");
682 *lpdwError = lpwite->dwError;
683 if (lpwite->dwError)
685 memcpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
686 *lpdwBufferLength = lstrlenW(lpszBuffer);
688 else
689 *lpdwBufferLength = 0;
691 return TRUE;
694 /***********************************************************************
695 * InternetGetConnectedState (WININET.@)
697 * Return connected state
699 * RETURNS
700 * TRUE if connected
701 * if lpdwStatus is not null, return the status (off line,
702 * modem, lan...) in it.
703 * FALSE if not connected
705 BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved)
707 TRACE("(%p, 0x%08lx)\n", lpdwStatus, dwReserved);
709 if (lpdwStatus) {
710 FIXME("always returning LAN connection.\n");
711 *lpdwStatus = INTERNET_CONNECTION_LAN;
713 return TRUE;
717 /***********************************************************************
718 * InternetGetConnectedStateExW (WININET.@)
720 * Return connected state
722 * PARAMS
724 * lpdwStatus [O] Flags specifying the status of the internet connection.
725 * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection.
726 * dwNameLen [I] Size of the buffer, in characters.
727 * dwReserved [I] Reserved. Must be set to 0.
729 * RETURNS
730 * TRUE if connected
731 * if lpdwStatus is not null, return the status (off line,
732 * modem, lan...) in it.
733 * FALSE if not connected
735 * NOTES
736 * If the system has no available network connections, an empty string is
737 * stored in lpszConnectionName. If there is a LAN connection, a localized
738 * "LAN Connection" string is stored. Presumably, if only a dial-up
739 * connection is available then the name of the dial-up connection is
740 * returned. Why any application, other than the "Internet Settings" CPL,
741 * would want to use this function instead of the simpler InternetGetConnectedStateW
742 * function is beyond me.
744 BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnectionName,
745 DWORD dwNameLen, DWORD dwReserved)
747 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
749 /* Must be zero */
750 if(dwReserved)
751 return FALSE;
753 if (lpdwStatus) {
754 FIXME("always returning LAN connection.\n");
755 *lpdwStatus = INTERNET_CONNECTION_LAN;
757 return LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen);
761 /***********************************************************************
762 * InternetGetConnectedStateExA (WININET.@)
764 BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectionName,
765 DWORD dwNameLen, DWORD dwReserved)
767 LPWSTR lpwszConnectionName = NULL;
768 BOOL rc;
770 TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved);
772 if (lpszConnectionName && dwNameLen > 0)
773 lpwszConnectionName= HeapAlloc(GetProcessHeap(), 0, dwNameLen * sizeof(WCHAR));
775 rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName, dwNameLen,
776 dwReserved);
777 if (rc && lpwszConnectionName)
779 WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName,
780 dwNameLen, NULL, NULL);
782 HeapFree(GetProcessHeap(),0,lpwszConnectionName);
785 return rc;
789 /***********************************************************************
790 * InternetConnectW (WININET.@)
792 * Open a ftp, gopher or http session
794 * RETURNS
795 * HINTERNET a session handle on success
796 * NULL on failure
799 HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
800 LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
801 LPCWSTR lpszUserName, LPCWSTR lpszPassword,
802 DWORD dwService, DWORD dwFlags, DWORD dwContext)
804 LPWININETAPPINFOW hIC;
805 HINTERNET rc = (HINTERNET) NULL;
807 TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet, debugstr_w(lpszServerName),
808 nServerPort, debugstr_w(lpszUserName), debugstr_w(lpszPassword),
809 dwService, dwFlags, dwContext);
811 /* Clear any error information */
812 INTERNET_SetLastError(0);
813 hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
814 if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
815 goto lend;
817 switch (dwService)
819 case INTERNET_SERVICE_FTP:
820 rc = FTP_Connect(hIC, lpszServerName, nServerPort,
821 lpszUserName, lpszPassword, dwFlags, dwContext, 0);
822 break;
824 case INTERNET_SERVICE_HTTP:
825 rc = HTTP_Connect(hIC, lpszServerName, nServerPort,
826 lpszUserName, lpszPassword, dwFlags, dwContext, 0);
827 break;
829 case INTERNET_SERVICE_GOPHER:
830 default:
831 break;
833 lend:
834 if( hIC )
835 WININET_Release( &hIC->hdr );
837 TRACE("returning %p\n", rc);
838 return rc;
842 /***********************************************************************
843 * InternetConnectA (WININET.@)
845 * Open a ftp, gopher or http session
847 * RETURNS
848 * HINTERNET a session handle on success
849 * NULL on failure
852 HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
853 LPCSTR lpszServerName, INTERNET_PORT nServerPort,
854 LPCSTR lpszUserName, LPCSTR lpszPassword,
855 DWORD dwService, DWORD dwFlags, DWORD dwContext)
857 HINTERNET rc = (HINTERNET)NULL;
858 INT len = 0;
859 LPWSTR szServerName = NULL;
860 LPWSTR szUserName = NULL;
861 LPWSTR szPassword = NULL;
863 if (lpszServerName)
865 len = MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, NULL, 0);
866 szServerName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
867 MultiByteToWideChar(CP_ACP, 0, lpszServerName, -1, szServerName, len);
869 if (lpszUserName)
871 len = MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, NULL, 0);
872 szUserName = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
873 MultiByteToWideChar(CP_ACP, 0, lpszUserName, -1, szUserName, len);
875 if (lpszPassword)
877 len = MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, NULL, 0);
878 szPassword = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
879 MultiByteToWideChar(CP_ACP, 0, lpszPassword, -1, szPassword, len);
883 rc = InternetConnectW(hInternet, szServerName, nServerPort,
884 szUserName, szPassword, dwService, dwFlags, dwContext);
886 HeapFree(GetProcessHeap(), 0, szServerName);
887 HeapFree(GetProcessHeap(), 0, szUserName);
888 HeapFree(GetProcessHeap(), 0, szPassword);
889 return rc;
893 /***********************************************************************
894 * InternetFindNextFileA (WININET.@)
896 * Continues a file search from a previous call to FindFirstFile
898 * RETURNS
899 * TRUE on success
900 * FALSE on failure
903 BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
905 BOOL ret;
906 WIN32_FIND_DATAW fd;
908 ret = InternetFindNextFileW(hFind, lpvFindData?&fd:NULL);
909 if(lpvFindData)
910 WININET_find_data_WtoA(&fd, (LPWIN32_FIND_DATAA)lpvFindData);
911 return ret;
914 /***********************************************************************
915 * InternetFindNextFileW (WININET.@)
917 * Continues a file search from a previous call to FindFirstFile
919 * RETURNS
920 * TRUE on success
921 * FALSE on failure
924 BOOL WINAPI InternetFindNextFileW(HINTERNET hFind, LPVOID lpvFindData)
926 LPWININETAPPINFOW hIC = NULL;
927 LPWININETFINDNEXTW lpwh;
928 BOOL bSuccess = FALSE;
930 TRACE("\n");
932 lpwh = (LPWININETFINDNEXTW) WININET_GetObject( hFind );
933 if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
935 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
936 goto lend;
939 hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
940 if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
942 WORKREQUEST workRequest;
943 struct WORKREQ_INTERNETFINDNEXTW *req;
945 workRequest.asyncall = INTERNETFINDNEXTW;
946 workRequest.hdr = WININET_AddRef( &lpwh->hdr );
947 req = &workRequest.u.InternetFindNextW;
948 req->lpFindFileData = lpvFindData;
950 bSuccess = INTERNET_AsyncCall(&workRequest);
952 else
954 bSuccess = INTERNET_FindNextFileW(lpwh, lpvFindData);
956 lend:
957 if( lpwh )
958 WININET_Release( &lpwh->hdr );
959 return bSuccess;
962 /***********************************************************************
963 * INTERNET_FindNextFileW (Internal)
965 * Continues a file search from a previous call to FindFirstFile
967 * RETURNS
968 * TRUE on success
969 * FALSE on failure
972 BOOL WINAPI INTERNET_FindNextFileW(LPWININETFINDNEXTW lpwh, LPVOID lpvFindData)
974 BOOL bSuccess = TRUE;
975 LPWIN32_FIND_DATAW lpFindFileData;
977 TRACE("\n");
979 assert (lpwh->hdr.htype == WH_HFINDNEXT);
981 /* Clear any error information */
982 INTERNET_SetLastError(0);
984 if (lpwh->hdr.lpwhparent->htype != WH_HFTPSESSION)
986 FIXME("Only FTP find next supported\n");
987 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
988 return FALSE;
991 TRACE("index(%ld) size(%ld)\n", lpwh->index, lpwh->size);
993 lpFindFileData = (LPWIN32_FIND_DATAW) lpvFindData;
994 ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
996 if (lpwh->index >= lpwh->size)
998 INTERNET_SetLastError(ERROR_NO_MORE_FILES);
999 bSuccess = FALSE;
1000 goto lend;
1003 FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
1004 lpwh->index++;
1006 TRACE("\nName: %s\nSize: %ld\n", debugstr_w(lpFindFileData->cFileName), lpFindFileData->nFileSizeLow);
1008 lend:
1010 if (lpwh->hdr.dwFlags & INTERNET_FLAG_ASYNC)
1012 INTERNET_ASYNC_RESULT iar;
1014 iar.dwResult = (DWORD)bSuccess;
1015 iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
1016 INTERNET_GetLastError();
1018 INTERNET_SendCallback(&lpwh->hdr, lpwh->hdr.dwContext,
1019 INTERNET_STATUS_REQUEST_COMPLETE, &iar,
1020 sizeof(INTERNET_ASYNC_RESULT));
1023 return bSuccess;
1027 /***********************************************************************
1028 * INTERNET_CloseHandle (internal)
1030 * Close internet handle
1032 * RETURNS
1033 * Void
1036 static VOID INTERNET_CloseHandle(LPWININETHANDLEHEADER hdr)
1038 LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW) hdr;
1040 TRACE("%p\n",lpwai);
1042 HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
1043 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxy);
1044 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
1045 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyUsername);
1046 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyPassword);
1047 HeapFree(GetProcessHeap(), 0, lpwai);
1051 /***********************************************************************
1052 * InternetCloseHandle (WININET.@)
1054 * Generic close handle function
1056 * RETURNS
1057 * TRUE on success
1058 * FALSE on failure
1061 BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
1063 LPWININETHANDLEHEADER lpwh;
1065 TRACE("%p\n",hInternet);
1067 lpwh = WININET_GetObject( hInternet );
1068 if (NULL == lpwh)
1070 INTERNET_SetLastError(ERROR_INVALID_HANDLE);
1071 return FALSE;
1074 /* FIXME: native appears to send this from the equivalent of
1075 * WININET_Release */
1076 INTERNET_SendCallback(lpwh, lpwh->dwContext,
1077 INTERNET_STATUS_HANDLE_CLOSING, &hInternet,
1078 sizeof(HINTERNET));
1080 if( lpwh->lpwhparent )
1081 WININET_Release( lpwh->lpwhparent );
1082 WININET_FreeHandle( hInternet );
1083 WININET_Release( lpwh );
1085 return TRUE;
1089 /***********************************************************************
1090 * ConvertUrlComponentValue (Internal)
1092 * Helper function for InternetCrackUrlW
1095 static void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
1096 LPWSTR lpwszComponent, DWORD dwwComponentLen,
1097 LPCSTR lpszStart, LPCWSTR lpwszStart)
1099 TRACE("%p %p %p %ld %p %p\n", lppszComponent, dwComponentLen, lpwszComponent, dwwComponentLen, lpszStart, lpwszStart);
1100 if (*dwComponentLen != 0)
1102 DWORD nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
1103 if (*lppszComponent == NULL)
1105 int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL);
1106 *lppszComponent = (LPSTR)lpszStart+nASCIIOffset;
1107 *dwComponentLen = nASCIILength;
1109 else
1111 DWORD ncpylen = min((*dwComponentLen)-1, nASCIILength);
1112 WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,*lppszComponent,ncpylen+1,NULL,NULL);
1113 (*lppszComponent)[ncpylen]=0;
1114 *dwComponentLen = ncpylen;
1120 /***********************************************************************
1121 * InternetCrackUrlA (WININET.@)
1123 * Break up URL into its components
1125 * TODO: Handle dwFlags
1127 * RETURNS
1128 * TRUE on success
1129 * FALSE on failure
1132 BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
1133 LPURL_COMPONENTSA lpUrlComponents)
1135 DWORD nLength;
1136 URL_COMPONENTSW UCW;
1137 WCHAR* lpwszUrl;
1139 TRACE("(%s %lu %lx %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents);
1140 if(dwUrlLength<=0)
1141 dwUrlLength=-1;
1142 nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,NULL,0);
1144 /* if dwUrlLength=-1 then nLength includes null but length to
1145 InternetCrackUrlW should not include it */
1146 if (dwUrlLength == -1) nLength--;
1148 lpwszUrl=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WCHAR)*nLength);
1149 MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
1151 memset(&UCW,0,sizeof(UCW));
1152 if(lpUrlComponents->dwHostNameLength!=0)
1153 UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength;
1154 if(lpUrlComponents->dwUserNameLength!=0)
1155 UCW.dwUserNameLength=lpUrlComponents->dwUserNameLength;
1156 if(lpUrlComponents->dwPasswordLength!=0)
1157 UCW.dwPasswordLength=lpUrlComponents->dwPasswordLength;
1158 if(lpUrlComponents->dwUrlPathLength!=0)
1159 UCW.dwUrlPathLength=lpUrlComponents->dwUrlPathLength;
1160 if(lpUrlComponents->dwSchemeLength!=0)
1161 UCW.dwSchemeLength=lpUrlComponents->dwSchemeLength;
1162 if(lpUrlComponents->dwExtraInfoLength!=0)
1163 UCW.dwExtraInfoLength=lpUrlComponents->dwExtraInfoLength;
1164 if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
1166 HeapFree(GetProcessHeap(), 0, lpwszUrl);
1167 return FALSE;
1170 ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
1171 UCW.lpszHostName, UCW.dwHostNameLength,
1172 lpszUrl, lpwszUrl);
1173 ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
1174 UCW.lpszUserName, UCW.dwUserNameLength,
1175 lpszUrl, lpwszUrl);
1176 ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
1177 UCW.lpszPassword, UCW.dwPasswordLength,
1178 lpszUrl, lpwszUrl);
1179 ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
1180 UCW.lpszUrlPath, UCW.dwUrlPathLength,
1181 lpszUrl, lpwszUrl);
1182 ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
1183 UCW.lpszScheme, UCW.dwSchemeLength,
1184 lpszUrl, lpwszUrl);
1185 ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
1186 UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
1187 lpszUrl, lpwszUrl);
1188 lpUrlComponents->nScheme=UCW.nScheme;
1189 lpUrlComponents->nPort=UCW.nPort;
1190 HeapFree(GetProcessHeap(), 0, lpwszUrl);
1192 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
1193 debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength),
1194 debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength),
1195 debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength),
1196 debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength));
1198 return TRUE;
1201 /***********************************************************************
1202 * GetInternetSchemeW (internal)
1204 * Get scheme of url
1206 * RETURNS
1207 * scheme on success
1208 * INTERNET_SCHEME_UNKNOWN on failure
1211 static INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, DWORD nMaxCmp)
1213 INTERNET_SCHEME iScheme=INTERNET_SCHEME_UNKNOWN;
1214 static const WCHAR lpszFtp[]={'f','t','p',0};
1215 static const WCHAR lpszGopher[]={'g','o','p','h','e','r',0};
1216 static const WCHAR lpszHttp[]={'h','t','t','p',0};
1217 static const WCHAR lpszHttps[]={'h','t','t','p','s',0};
1218 static const WCHAR lpszFile[]={'f','i','l','e',0};
1219 static const WCHAR lpszNews[]={'n','e','w','s',0};
1220 static const WCHAR lpszMailto[]={'m','a','i','l','t','o',0};
1221 static const WCHAR lpszRes[]={'r','e','s',0};
1222 WCHAR* tempBuffer=NULL;
1223 TRACE("%s %ld\n",debugstr_wn(lpszScheme, nMaxCmp), nMaxCmp);
1224 if(lpszScheme==NULL)
1225 return INTERNET_SCHEME_UNKNOWN;
1227 tempBuffer=HeapAlloc(GetProcessHeap(),0,(nMaxCmp+1)*sizeof(WCHAR));
1228 lstrcpynW(tempBuffer,lpszScheme,nMaxCmp+1);
1229 strlwrW(tempBuffer);
1230 if (nMaxCmp==strlenW(lpszFtp) && !strncmpW(lpszFtp, tempBuffer, nMaxCmp))
1231 iScheme=INTERNET_SCHEME_FTP;
1232 else if (nMaxCmp==strlenW(lpszGopher) && !strncmpW(lpszGopher, tempBuffer, nMaxCmp))
1233 iScheme=INTERNET_SCHEME_GOPHER;
1234 else if (nMaxCmp==strlenW(lpszHttp) && !strncmpW(lpszHttp, tempBuffer, nMaxCmp))
1235 iScheme=INTERNET_SCHEME_HTTP;
1236 else if (nMaxCmp==strlenW(lpszHttps) && !strncmpW(lpszHttps, tempBuffer, nMaxCmp))
1237 iScheme=INTERNET_SCHEME_HTTPS;
1238 else if (nMaxCmp==strlenW(lpszFile) && !strncmpW(lpszFile, tempBuffer, nMaxCmp))
1239 iScheme=INTERNET_SCHEME_FILE;
1240 else if (nMaxCmp==strlenW(lpszNews) && !strncmpW(lpszNews, tempBuffer, nMaxCmp))
1241 iScheme=INTERNET_SCHEME_NEWS;
1242 else if (nMaxCmp==strlenW(lpszMailto) && !strncmpW(lpszMailto, tempBuffer, nMaxCmp))
1243 iScheme=INTERNET_SCHEME_MAILTO;
1244 else if (nMaxCmp==strlenW(lpszRes) && !strncmpW(lpszRes, tempBuffer, nMaxCmp))
1245 iScheme=INTERNET_SCHEME_RES;
1246 HeapFree(GetProcessHeap(),0,tempBuffer);
1247 return iScheme;
1250 /***********************************************************************
1251 * SetUrlComponentValueW (Internal)
1253 * Helper function for InternetCrackUrlW
1255 * PARAMS
1256 * lppszComponent [O] Holds the returned string
1257 * dwComponentLen [I] Holds the size of lppszComponent
1258 * [O] Holds the length of the string in lppszComponent without '\0'
1259 * lpszStart [I] Holds the string to copy from
1260 * len [I] Holds the length of lpszStart without '\0'
1262 * RETURNS
1263 * TRUE on success
1264 * FALSE on failure
1267 static BOOL SetUrlComponentValueW(LPWSTR* lppszComponent, LPDWORD dwComponentLen, LPCWSTR lpszStart, DWORD len)
1269 TRACE("%s (%ld)\n", debugstr_wn(lpszStart,len), len);
1271 if ( (*dwComponentLen == 0) && (*lppszComponent == NULL) )
1272 return FALSE;
1274 if (*dwComponentLen != 0 || *lppszComponent == NULL)
1276 if (*lppszComponent == NULL)
1278 *lppszComponent = (LPWSTR)lpszStart;
1279 *dwComponentLen = len;
1281 else
1283 DWORD ncpylen = min((*dwComponentLen)-1, len);
1284 memcpy(*lppszComponent, lpszStart, ncpylen*sizeof(WCHAR));
1285 (*lppszComponent)[ncpylen] = '\0';
1286 *dwComponentLen = ncpylen;
1290 return TRUE;
1293 /***********************************************************************
1294 * InternetCrackUrlW (WININET.@)
1296 BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl_orig, DWORD dwUrlLength_orig, DWORD dwFlags,
1297 LPURL_COMPONENTSW lpUC)
1300 * RFC 1808
1301 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1304 LPCWSTR lpszParam = NULL;
1305 BOOL bIsAbsolute = FALSE;
1306 LPCWSTR lpszap, lpszUrl = lpszUrl_orig;
1307 LPCWSTR lpszcp = NULL;
1308 LPWSTR lpszUrl_decode = NULL;
1309 DWORD dwUrlLength = dwUrlLength_orig;
1310 const WCHAR lpszSeparators[3]={';','?',0};
1311 const WCHAR lpszSlash[2]={'/',0};
1312 if(dwUrlLength==0)
1313 dwUrlLength=strlenW(lpszUrl);
1315 TRACE("(%s %lu %lx %p)\n", debugstr_w(lpszUrl), dwUrlLength, dwFlags, lpUC);
1316 if (dwFlags & ICU_DECODE)
1318 lpszUrl_decode=HeapAlloc( GetProcessHeap(), 0, dwUrlLength * sizeof (WCHAR) );
1319 if( InternetCanonicalizeUrlW(lpszUrl_orig, lpszUrl_decode, &dwUrlLength, dwFlags))
1321 lpszUrl = lpszUrl_decode;
1324 lpszap = lpszUrl;
1326 /* Determine if the URI is absolute. */
1327 while (*lpszap != '\0')
1329 if (isalnumW(*lpszap))
1331 lpszap++;
1332 continue;
1334 if ((*lpszap == ':') && (lpszap - lpszUrl >= 2))
1336 bIsAbsolute = TRUE;
1337 lpszcp = lpszap;
1339 else
1341 lpszcp = lpszUrl; /* Relative url */
1344 break;
1347 /* Parse <params> */
1348 lpszParam = strpbrkW(lpszap, lpszSeparators);
1349 if (lpszParam != NULL)
1351 SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
1352 lpszParam, dwUrlLength-(lpszParam-lpszUrl));
1355 if (bIsAbsolute) /* Parse <protocol>:[//<net_loc>] */
1357 LPCWSTR lpszNetLoc;
1358 static const WCHAR wszAbout[]={'a','b','o','u','t',':',0};
1360 /* Get scheme first. */
1361 lpUC->nScheme = GetInternetSchemeW(lpszUrl, lpszcp - lpszUrl);
1362 SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength,
1363 lpszUrl, lpszcp - lpszUrl);
1365 /* Eat ':' in protocol. */
1366 lpszcp++;
1368 /* if the scheme is "about", there is no host */
1369 if(strncmpW(wszAbout,lpszUrl, lpszcp - lpszUrl)==0)
1371 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1372 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1373 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
1374 lpUC->nPort = 0;
1376 else
1378 /* Skip over slashes. */
1379 if (*lpszcp == '/')
1381 lpszcp++;
1382 if (*lpszcp == '/')
1384 lpszcp++;
1385 if (*lpszcp == '/')
1386 lpszcp++;
1390 lpszNetLoc = strpbrkW(lpszcp, lpszSlash);
1391 if (lpszParam)
1393 if (lpszNetLoc)
1394 lpszNetLoc = min(lpszNetLoc, lpszParam);
1395 else
1396 lpszNetLoc = lpszParam;
1398 else if (!lpszNetLoc)
1399 lpszNetLoc = lpszcp + dwUrlLength-(lpszcp-lpszUrl);
1401 /* Parse net-loc */
1402 if (lpszNetLoc)
1404 LPCWSTR lpszHost;
1405 LPCWSTR lpszPort;
1407 /* [<user>[<:password>]@]<host>[:<port>] */
1408 /* First find the user and password if they exist */
1410 lpszHost = strchrW(lpszcp, '@');
1411 if (lpszHost == NULL || lpszHost > lpszNetLoc)
1413 /* username and password not specified. */
1414 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1415 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1417 else /* Parse out username and password */
1419 LPCWSTR lpszUser = lpszcp;
1420 LPCWSTR lpszPasswd = lpszHost;
1422 while (lpszcp < lpszHost)
1424 if (*lpszcp == ':')
1425 lpszPasswd = lpszcp;
1427 lpszcp++;
1430 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength,
1431 lpszUser, lpszPasswd - lpszUser);
1433 if (lpszPasswd != lpszHost)
1434 lpszPasswd++;
1435 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength,
1436 lpszPasswd == lpszHost ? NULL : lpszPasswd,
1437 lpszHost - lpszPasswd);
1439 lpszcp++; /* Advance to beginning of host */
1442 /* Parse <host><:port> */
1444 lpszHost = lpszcp;
1445 lpszPort = lpszNetLoc;
1447 /* special case for res:// URLs: there is no port here, so the host is the
1448 entire string up to the first '/' */
1449 if(lpUC->nScheme==INTERNET_SCHEME_RES)
1451 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1452 lpszHost, lpszPort - lpszHost);
1453 lpUC->nPort = 0;
1454 lpszcp=lpszNetLoc;
1456 else
1458 while (lpszcp < lpszNetLoc)
1460 if (*lpszcp == ':')
1461 lpszPort = lpszcp;
1463 lpszcp++;
1466 /* If the scheme is "file" and the host is just one letter, it's not a host */
1467 if(lpUC->nScheme==INTERNET_SCHEME_FILE && (lpszPort-lpszHost)==1)
1469 lpszcp=lpszHost;
1470 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1471 NULL, 0);
1472 lpUC->nPort = 0;
1474 else
1476 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1477 lpszHost, lpszPort - lpszHost);
1478 if (lpszPort != lpszNetLoc)
1479 lpUC->nPort = atoiW(++lpszPort);
1480 else
1481 lpUC->nPort = 0;
1488 /* Here lpszcp points to:
1490 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1491 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1493 if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam))
1495 INT len;
1497 /* Only truncate the parameter list if it's already been saved
1498 * in lpUC->lpszExtraInfo.
1500 if (lpszParam && lpUC->dwExtraInfoLength && lpUC->lpszExtraInfo)
1501 len = lpszParam - lpszcp;
1502 else
1504 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1505 * newlines if necessary.
1507 LPWSTR lpsznewline = strchrW(lpszcp, '\n');
1508 if (lpsznewline != NULL)
1509 len = lpsznewline - lpszcp;
1510 else
1511 len = dwUrlLength-(lpszcp-lpszUrl);
1513 SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
1514 lpszcp, len);
1516 else
1518 lpUC->dwUrlPathLength = 0;
1521 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
1522 debugstr_wn(lpUC->lpszScheme,lpUC->dwSchemeLength),
1523 debugstr_wn(lpUC->lpszHostName,lpUC->dwHostNameLength),
1524 debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
1525 debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
1527 if (lpszUrl_decode)
1528 HeapFree(GetProcessHeap(), 0, lpszUrl_decode );
1529 return TRUE;
1532 /***********************************************************************
1533 * InternetAttemptConnect (WININET.@)
1535 * Attempt to make a connection to the internet
1537 * RETURNS
1538 * ERROR_SUCCESS on success
1539 * Error value on failure
1542 DWORD WINAPI InternetAttemptConnect(DWORD dwReserved)
1544 FIXME("Stub\n");
1545 return ERROR_SUCCESS;
1549 /***********************************************************************
1550 * InternetCanonicalizeUrlA (WININET.@)
1552 * Escape unsafe characters and spaces
1554 * RETURNS
1555 * TRUE on success
1556 * FALSE on failure
1559 BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
1560 LPDWORD lpdwBufferLength, DWORD dwFlags)
1562 HRESULT hr;
1563 DWORD dwURLFlags= 0x80000000; /* Don't know what this means */
1564 if(dwFlags & ICU_DECODE)
1566 dwURLFlags |= URL_UNESCAPE;
1567 dwFlags &= ~ICU_DECODE;
1570 if(dwFlags & ICU_ESCAPE)
1572 dwURLFlags |= URL_UNESCAPE;
1573 dwFlags &= ~ICU_ESCAPE;
1575 if(dwFlags & ICU_BROWSER_MODE)
1577 dwURLFlags |= URL_BROWSER_MODE;
1578 dwFlags &= ~ICU_BROWSER_MODE;
1580 if(dwFlags)
1581 FIXME("Unhandled flags 0x%08lx\n", dwFlags);
1582 TRACE("%s %p %p %08lx\n", debugstr_a(lpszUrl), lpszBuffer,
1583 lpdwBufferLength, dwURLFlags);
1585 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1586 dwFlags ^= ICU_NO_ENCODE;
1588 hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
1590 return (hr == S_OK) ? TRUE : FALSE;
1593 /***********************************************************************
1594 * InternetCanonicalizeUrlW (WININET.@)
1596 * Escape unsafe characters and spaces
1598 * RETURNS
1599 * TRUE on success
1600 * FALSE on failure
1603 BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
1604 LPDWORD lpdwBufferLength, DWORD dwFlags)
1606 HRESULT hr;
1607 DWORD dwURLFlags= 0x80000000; /* Don't know what this means */
1608 if(dwFlags & ICU_DECODE)
1610 dwURLFlags |= URL_UNESCAPE;
1611 dwFlags &= ~ICU_DECODE;
1614 if(dwFlags & ICU_ESCAPE)
1616 dwURLFlags |= URL_UNESCAPE;
1617 dwFlags &= ~ICU_ESCAPE;
1619 if(dwFlags & ICU_BROWSER_MODE)
1621 dwURLFlags |= URL_BROWSER_MODE;
1622 dwFlags &= ~ICU_BROWSER_MODE;
1624 if(dwFlags)
1625 FIXME("Unhandled flags 0x%08lx\n", dwFlags);
1626 TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl), lpszBuffer,
1627 lpdwBufferLength, dwURLFlags);
1629 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1630 dwFlags ^= ICU_NO_ENCODE;
1632 hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwURLFlags);
1634 return (hr == S_OK) ? TRUE : FALSE;
1638 /***********************************************************************
1639 * InternetSetStatusCallbackA (WININET.@)
1641 * Sets up a callback function which is called as progress is made
1642 * during an operation.
1644 * RETURNS
1645 * Previous callback or NULL on success
1646 * INTERNET_INVALID_STATUS_CALLBACK on failure
1649 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
1650 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1652 INTERNET_STATUS_CALLBACK retVal;
1653 LPWININETHANDLEHEADER lpwh;
1655 TRACE("0x%08lx\n", (ULONG)hInternet);
1657 lpwh = WININET_GetObject(hInternet);
1658 if (!lpwh)
1659 return INTERNET_INVALID_STATUS_CALLBACK;
1661 lpwh->dwInternalFlags &= ~INET_CALLBACKW;
1662 retVal = lpwh->lpfnStatusCB;
1663 lpwh->lpfnStatusCB = lpfnIntCB;
1665 WININET_Release( lpwh );
1667 return retVal;
1670 /***********************************************************************
1671 * InternetSetStatusCallbackW (WININET.@)
1673 * Sets up a callback function which is called as progress is made
1674 * during an operation.
1676 * RETURNS
1677 * Previous callback or NULL on success
1678 * INTERNET_INVALID_STATUS_CALLBACK on failure
1681 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackW(
1682 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1684 INTERNET_STATUS_CALLBACK retVal;
1685 LPWININETHANDLEHEADER lpwh;
1687 TRACE("0x%08lx\n", (ULONG)hInternet);
1689 lpwh = WININET_GetObject(hInternet);
1690 if (!lpwh)
1691 return INTERNET_INVALID_STATUS_CALLBACK;
1693 lpwh->dwInternalFlags |= INET_CALLBACKW;
1694 retVal = lpwh->lpfnStatusCB;
1695 lpwh->lpfnStatusCB = lpfnIntCB;
1697 WININET_Release( lpwh );
1699 return retVal;
1702 /***********************************************************************
1703 * InternetSetFilePointer (WININET.@)
1705 DWORD WINAPI InternetSetFilePointer(HINTERNET hFile, LONG lDistanceToMove,
1706 PVOID pReserved, DWORD dwMoveContext, DWORD dwContext)
1708 FIXME("stub\n");
1709 return FALSE;
1712 /***********************************************************************
1713 * InternetWriteFile (WININET.@)
1715 * Write data to an open internet file
1717 * RETURNS
1718 * TRUE on success
1719 * FALSE on failure
1722 BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
1723 DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
1725 BOOL retval = FALSE;
1726 int nSocket = -1;
1727 LPWININETHANDLEHEADER lpwh;
1729 TRACE("\n");
1730 lpwh = (LPWININETHANDLEHEADER) WININET_GetObject( hFile );
1731 if (NULL == lpwh)
1732 return FALSE;
1734 switch (lpwh->htype)
1736 case WH_HHTTPREQ:
1738 LPWININETHTTPREQW lpwhr;
1739 lpwhr = (LPWININETHTTPREQW)lpwh;
1741 TRACE("HTTPREQ %li\n",dwNumOfBytesToWrite);
1742 retval = NETCON_send(&lpwhr->netConnection, lpBuffer,
1743 dwNumOfBytesToWrite, 0, (LPINT)lpdwNumOfBytesWritten);
1745 WININET_Release( lpwh );
1746 return retval;
1748 break;
1750 case WH_HFILE:
1751 nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
1752 break;
1754 default:
1755 break;
1758 if (nSocket != -1)
1760 int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0);
1761 retval = (res >= 0);
1762 *lpdwNumOfBytesWritten = retval ? res : 0;
1764 WININET_Release( lpwh );
1766 return retval;
1770 static BOOL INTERNET_ReadFile(LPWININETHANDLEHEADER lpwh, LPVOID lpBuffer,
1771 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead,
1772 BOOL bWait, BOOL bSendCompletionStatus)
1774 BOOL retval = FALSE;
1775 int nSocket = -1;
1777 /* FIXME: this should use NETCON functions! */
1778 switch (lpwh->htype)
1780 case WH_HHTTPREQ:
1781 if (!NETCON_recv(&((LPWININETHTTPREQW)lpwh)->netConnection, lpBuffer,
1782 dwNumOfBytesToRead, bWait ? MSG_WAITALL : 0, (int *)pdwNumOfBytesRead))
1784 *pdwNumOfBytesRead = 0;
1785 retval = TRUE; /* Under windows, it seems to return 0 even if nothing was read... */
1787 else
1788 retval = TRUE;
1789 break;
1791 case WH_HFILE:
1792 /* FIXME: FTP should use NETCON_ stuff */
1793 nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
1794 if (nSocket != -1)
1796 int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, bWait ? MSG_WAITALL : 0);
1797 retval = (res >= 0);
1798 *pdwNumOfBytesRead = retval ? res : 0;
1800 break;
1802 default:
1803 break;
1806 if (bSendCompletionStatus)
1808 INTERNET_ASYNC_RESULT iar;
1810 iar.dwResult = retval;
1811 iar.dwError = iar.dwError = retval ? ERROR_SUCCESS :
1812 INTERNET_GetLastError();
1814 INTERNET_SendCallback(lpwh, lpwh->dwContext,
1815 INTERNET_STATUS_REQUEST_COMPLETE, &iar,
1816 sizeof(INTERNET_ASYNC_RESULT));
1818 return retval;
1821 /***********************************************************************
1822 * InternetReadFile (WININET.@)
1824 * Read data from an open internet file
1826 * RETURNS
1827 * TRUE on success
1828 * FALSE on failure
1831 BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
1832 DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
1834 LPWININETHANDLEHEADER lpwh;
1835 BOOL retval;
1837 TRACE("%p %p %ld %p\n", hFile, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead);
1839 lpwh = WININET_GetObject( hFile );
1840 if (!lpwh)
1842 SetLastError(ERROR_INVALID_HANDLE);
1843 return FALSE;
1846 retval = INTERNET_ReadFile(lpwh, lpBuffer, dwNumOfBytesToRead, pdwNumOfBytesRead, TRUE, FALSE);
1847 WININET_Release( lpwh );
1849 TRACE("-- %s (bytes read: %ld)\n", retval ? "TRUE": "FALSE", pdwNumOfBytesRead ? *pdwNumOfBytesRead : -1);
1850 return retval;
1853 /***********************************************************************
1854 * InternetReadFileExA (WININET.@)
1856 * Read data from an open internet file
1858 * PARAMS
1859 * hFile [I] Handle returned by InternetOpenUrl or HttpOpenRequest.
1860 * lpBuffersOut [I/O] Buffer.
1861 * dwFlags [I] Flags. See notes.
1862 * dwContext [I] Context for callbacks.
1864 * RETURNS
1865 * TRUE on success
1866 * FALSE on failure
1868 * NOTES
1869 * The parameter dwFlags include zero or more of the following flags:
1870 *|IRF_ASYNC - Makes the call asynchronous.
1871 *|IRF_SYNC - Makes the call synchronous.
1872 *|IRF_USE_CONTEXT - Forces dwContext to be used.
1873 *|IRF_NO_WAIT - Don't block if the data is not available, just return what is available.
1875 * However, in testing IRF_USE_CONTEXT seems to have no effect - dwContext isn't used.
1877 * SEE
1878 * InternetOpenUrlA(), HttpOpenRequestA()
1880 BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffersOut,
1881 DWORD dwFlags, DWORD dwContext)
1883 BOOL retval = FALSE;
1884 LPWININETHANDLEHEADER lpwh;
1886 TRACE("(%p %p 0x%lx 0x%lx)\n", hFile, lpBuffersOut, dwFlags, dwContext);
1888 if (dwFlags & ~(IRF_ASYNC|IRF_NO_WAIT))
1889 FIXME("these dwFlags aren't implemented: 0x%lx\n", dwFlags & ~(IRF_ASYNC|IRF_NO_WAIT));
1891 if (lpBuffersOut->dwStructSize != sizeof(*lpBuffersOut))
1893 SetLastError(ERROR_INVALID_PARAMETER);
1894 return FALSE;
1897 lpwh = (LPWININETHANDLEHEADER) WININET_GetObject( hFile );
1898 if (!lpwh)
1900 SetLastError(ERROR_INVALID_HANDLE);
1901 return FALSE;
1904 /* FIXME: native only does it asynchronously if the amount of data
1905 * requested isn't available. See NtReadFile. */
1906 /* FIXME: IRF_ASYNC may not be the right thing to test here;
1907 * hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC is probably better, but
1908 * we should implement the above first */
1909 if (dwFlags & IRF_ASYNC)
1911 WORKREQUEST workRequest;
1912 struct WORKREQ_INTERNETREADFILEEXA *req;
1914 workRequest.asyncall = INTERNETREADFILEEXA;
1915 workRequest.hdr = WININET_AddRef( lpwh );
1916 req = &workRequest.u.InternetReadFileExA;
1917 req->lpBuffersOut = lpBuffersOut;
1919 retval = INTERNET_AsyncCall(&workRequest);
1920 if (!retval) return FALSE;
1922 SetLastError(ERROR_IO_PENDING);
1923 return FALSE;
1926 retval = INTERNET_ReadFile(lpwh, lpBuffersOut->lpvBuffer,
1927 lpBuffersOut->dwBufferLength, &lpBuffersOut->dwBufferLength,
1928 !(dwFlags & IRF_NO_WAIT), FALSE);
1930 WININET_Release( lpwh );
1932 TRACE("-- %s (bytes read: %ld)\n", retval ? "TRUE": "FALSE", lpBuffersOut->dwBufferLength);
1933 return retval;
1936 /***********************************************************************
1937 * InternetReadFileExW (WININET.@)
1939 * Read data from an open internet file.
1941 * PARAMS
1942 * hFile [I] Handle returned by InternetOpenUrl() or HttpOpenRequest().
1943 * lpBuffersOut [I/O] Buffer.
1944 * dwFlags [I] Flags.
1945 * dwContext [I] Context for callbacks.
1947 * RETURNS
1948 * FALSE, last error is set to ERROR_CALL_NOT_IMPLEMENTED
1950 * NOTES
1951 * Not implemented in Wine or native either (as of IE6 SP2).
1954 BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
1955 DWORD dwFlags, DWORD dwContext)
1957 ERR("(%p, %p, 0x%lx, 0x%lx): not implemented in native\n", hFile, lpBuffer, dwFlags, dwContext);
1959 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1960 return FALSE;
1963 /***********************************************************************
1964 * INET_QueryOptionHelper (internal)
1966 static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
1967 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1969 LPWININETHANDLEHEADER lpwhh;
1970 BOOL bSuccess = FALSE;
1972 TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
1974 lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
1976 switch (dwOption)
1978 case INTERNET_OPTION_HANDLE_TYPE:
1980 ULONG type;
1982 if (!lpwhh)
1984 WARN("Invalid hInternet handle\n");
1985 SetLastError(ERROR_INVALID_HANDLE);
1986 return FALSE;
1989 type = lpwhh->htype;
1991 TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type);
1993 if (*lpdwBufferLength < sizeof(ULONG))
1994 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1995 else
1997 memcpy(lpBuffer, &type, sizeof(ULONG));
1998 bSuccess = TRUE;
2000 *lpdwBufferLength = sizeof(ULONG);
2001 break;
2004 case INTERNET_OPTION_REQUEST_FLAGS:
2006 ULONG flags = 4;
2007 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags);
2008 if (*lpdwBufferLength < sizeof(ULONG))
2009 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2010 else
2012 memcpy(lpBuffer, &flags, sizeof(ULONG));
2013 bSuccess = TRUE;
2015 *lpdwBufferLength = sizeof(ULONG);
2016 break;
2019 case INTERNET_OPTION_URL:
2020 case INTERNET_OPTION_DATAFILE_NAME:
2022 if (!lpwhh)
2024 WARN("Invalid hInternet handle\n");
2025 SetLastError(ERROR_INVALID_HANDLE);
2026 return FALSE;
2028 if (lpwhh->htype == WH_HHTTPREQ)
2030 LPWININETHTTPREQW lpreq = (LPWININETHTTPREQW) lpwhh;
2031 WCHAR url[1023];
2032 static const WCHAR szFmt[] = {'h','t','t','p',':','/','/','%','s','%','s',0};
2033 static const WCHAR szHost[] = {'H','o','s','t',0};
2034 DWORD sizeRequired;
2035 LPHTTPHEADERW Host;
2037 Host = HTTP_GetHeader(lpreq,szHost);
2038 sprintfW(url,szFmt,Host->lpszValue,lpreq->lpszPath);
2039 TRACE("INTERNET_OPTION_URL: %s\n",debugstr_w(url));
2040 if(!bIsUnicode)
2042 sizeRequired = WideCharToMultiByte(CP_ACP,0,url,-1,
2043 lpBuffer,*lpdwBufferLength,NULL,NULL);
2044 if (sizeRequired > *lpdwBufferLength)
2045 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2046 else
2047 bSuccess = TRUE;
2048 *lpdwBufferLength = sizeRequired;
2050 else
2052 sizeRequired = (lstrlenW(url)+1) * sizeof(WCHAR);
2053 if (*lpdwBufferLength < sizeRequired)
2054 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2055 else
2057 strcpyW(lpBuffer, url);
2058 bSuccess = TRUE;
2060 *lpdwBufferLength = sizeRequired;
2063 break;
2065 case INTERNET_OPTION_HTTP_VERSION:
2067 if (*lpdwBufferLength < sizeof(HTTP_VERSION_INFO))
2068 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2069 else
2072 * Presently hardcoded to 1.1
2074 ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
2075 ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
2076 bSuccess = TRUE;
2078 *lpdwBufferLength = sizeof(HTTP_VERSION_INFO);
2079 break;
2081 case INTERNET_OPTION_CONNECTED_STATE:
2083 DWORD *pdwConnectedState = (DWORD *)lpBuffer;
2084 FIXME("INTERNET_OPTION_CONNECTED_STATE: semi-stub\n");
2086 if (*lpdwBufferLength < sizeof(*pdwConnectedState))
2087 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2088 else
2090 *pdwConnectedState = INTERNET_STATE_CONNECTED;
2091 bSuccess = TRUE;
2093 *lpdwBufferLength = sizeof(*pdwConnectedState);
2094 break;
2096 case INTERNET_OPTION_PROXY:
2098 LPWININETAPPINFOW lpwai = (LPWININETAPPINFOW)lpwhh;
2099 WININETAPPINFOW wai;
2101 if (lpwai == NULL)
2103 TRACE("Getting global proxy info\n");
2104 memset(&wai, 0, sizeof(WININETAPPINFOW));
2105 INTERNET_ConfigureProxyFromReg( &wai );
2106 lpwai = &wai;
2109 if (bIsUnicode)
2111 INTERNET_PROXY_INFOW *pPI = (INTERNET_PROXY_INFOW *)lpBuffer;
2112 DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
2114 if (lpwai->lpszProxy)
2115 proxyBytesRequired = (lstrlenW(lpwai->lpszProxy) + 1) *
2116 sizeof(WCHAR);
2117 if (lpwai->lpszProxyBypass)
2118 proxyBypassBytesRequired =
2119 (lstrlenW(lpwai->lpszProxyBypass) + 1) * sizeof(WCHAR);
2120 if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOW) +
2121 proxyBytesRequired + proxyBypassBytesRequired)
2122 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2123 else
2125 pPI->dwAccessType = lpwai->dwAccessType;
2126 if (lpwai->lpszProxy)
2128 pPI->lpszProxy = (LPWSTR)((LPBYTE)lpBuffer +
2129 sizeof(INTERNET_PROXY_INFOW));
2130 lstrcpyW((LPWSTR)pPI->lpszProxy, lpwai->lpszProxy);
2132 else
2134 pPI->lpszProxy = (LPWSTR)((LPBYTE)lpBuffer +
2135 sizeof(INTERNET_PROXY_INFOW));
2136 *((LPWSTR)(pPI->lpszProxy)) = 0;
2139 if (lpwai->lpszProxyBypass)
2141 pPI->lpszProxyBypass = (LPWSTR)((LPBYTE)lpBuffer +
2142 sizeof(INTERNET_PROXY_INFOW) +
2143 proxyBytesRequired);
2144 lstrcpyW((LPWSTR)pPI->lpszProxyBypass,
2145 lpwai->lpszProxyBypass);
2147 else
2149 pPI->lpszProxyBypass = (LPWSTR)((LPBYTE)lpBuffer +
2150 sizeof(INTERNET_PROXY_INFOW) +
2151 proxyBytesRequired);
2152 *((LPWSTR)(pPI->lpszProxyBypass)) = 0;
2154 bSuccess = TRUE;
2156 *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOW) +
2157 proxyBytesRequired + proxyBypassBytesRequired;
2159 else
2161 INTERNET_PROXY_INFOA *pPI = (INTERNET_PROXY_INFOA *)lpBuffer;
2162 DWORD proxyBytesRequired = 0, proxyBypassBytesRequired = 0;
2164 if (lpwai->lpszProxy)
2165 proxyBytesRequired = WideCharToMultiByte(CP_ACP, 0,
2166 lpwai->lpszProxy, -1, NULL, 0, NULL, NULL);
2167 if (lpwai->lpszProxyBypass)
2168 proxyBypassBytesRequired = WideCharToMultiByte(CP_ACP, 0,
2169 lpwai->lpszProxyBypass, -1, NULL, 0, NULL, NULL);
2170 if (*lpdwBufferLength < sizeof(INTERNET_PROXY_INFOA) +
2171 proxyBytesRequired + proxyBypassBytesRequired)
2172 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2173 else
2175 pPI->dwAccessType = lpwai->dwAccessType;
2176 if (lpwai->lpszProxy)
2178 pPI->lpszProxy = (LPSTR)((LPBYTE)lpBuffer +
2179 sizeof(INTERNET_PROXY_INFOA));
2180 WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxy, -1,
2181 (LPSTR)pPI->lpszProxy, proxyBytesRequired, NULL, NULL);
2183 else
2185 pPI->lpszProxy = (LPSTR)((LPBYTE)lpBuffer +
2186 sizeof(INTERNET_PROXY_INFOA));
2187 *((LPSTR)(pPI->lpszProxy)) = '\0';
2190 if (lpwai->lpszProxyBypass)
2192 pPI->lpszProxyBypass = (LPSTR)((LPBYTE)lpBuffer +
2193 sizeof(INTERNET_PROXY_INFOA) + proxyBytesRequired);
2194 WideCharToMultiByte(CP_ACP, 0, lpwai->lpszProxyBypass,
2195 -1, (LPSTR)pPI->lpszProxyBypass,
2196 proxyBypassBytesRequired,
2197 NULL, NULL);
2199 else
2201 pPI->lpszProxyBypass = (LPSTR)((LPBYTE)lpBuffer +
2202 sizeof(INTERNET_PROXY_INFOA) +
2203 proxyBytesRequired);
2204 *((LPSTR)(pPI->lpszProxyBypass)) = '\0';
2206 bSuccess = TRUE;
2208 *lpdwBufferLength = sizeof(INTERNET_PROXY_INFOA) +
2209 proxyBytesRequired + proxyBypassBytesRequired;
2211 break;
2213 case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
2215 ULONG conn = 2;
2216 TRACE("INTERNET_OPTION_MAX_CONNS_PER_SERVER: %ld\n", conn);
2217 if (*lpdwBufferLength < sizeof(ULONG))
2218 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2219 else
2221 memcpy(lpBuffer, &conn, sizeof(ULONG));
2222 bSuccess = TRUE;
2224 *lpdwBufferLength = sizeof(ULONG);
2225 break;
2227 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
2229 ULONG conn = 4;
2230 TRACE("INTERNET_OPTION_MAX_CONNS_1_0_SERVER: %ld\n", conn);
2231 if (*lpdwBufferLength < sizeof(ULONG))
2232 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
2233 else
2235 memcpy(lpBuffer, &conn, sizeof(ULONG));
2236 bSuccess = TRUE;
2238 *lpdwBufferLength = sizeof(ULONG);
2239 break;
2241 case INTERNET_OPTION_SECURITY_FLAGS:
2242 FIXME("INTERNET_OPTION_SECURITY_FLAGS: Stub\n");
2243 break;
2245 default:
2246 FIXME("Stub! %ld\n", dwOption);
2247 break;
2249 if (lpwhh)
2250 WININET_Release( lpwhh );
2252 return bSuccess;
2255 /***********************************************************************
2256 * InternetQueryOptionW (WININET.@)
2258 * Queries an options on the specified handle
2260 * RETURNS
2261 * TRUE on success
2262 * FALSE on failure
2265 BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
2266 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
2268 return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
2271 /***********************************************************************
2272 * InternetQueryOptionA (WININET.@)
2274 * Queries an options on the specified handle
2276 * RETURNS
2277 * TRUE on success
2278 * FALSE on failure
2281 BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
2282 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
2284 return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
2288 /***********************************************************************
2289 * InternetSetOptionW (WININET.@)
2291 * Sets an options on the specified handle
2293 * RETURNS
2294 * TRUE on success
2295 * FALSE on failure
2298 BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
2299 LPVOID lpBuffer, DWORD dwBufferLength)
2301 LPWININETHANDLEHEADER lpwhh;
2302 BOOL ret = TRUE;
2304 TRACE("0x%08lx\n", dwOption);
2306 lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
2307 if( !lpwhh )
2308 return FALSE;
2310 switch (dwOption)
2312 case INTERNET_OPTION_HTTP_VERSION:
2314 HTTP_VERSION_INFO* pVersion=(HTTP_VERSION_INFO*)lpBuffer;
2315 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion->dwMajorVersion,pVersion->dwMinorVersion);
2317 break;
2318 case INTERNET_OPTION_ERROR_MASK:
2320 unsigned long flags=*(unsigned long*)lpBuffer;
2321 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
2323 break;
2324 case INTERNET_OPTION_CODEPAGE:
2326 unsigned long codepage=*(unsigned long*)lpBuffer;
2327 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
2329 break;
2330 case INTERNET_OPTION_REQUEST_PRIORITY:
2332 unsigned long priority=*(unsigned long*)lpBuffer;
2333 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
2335 break;
2336 case INTERNET_OPTION_CONNECT_TIMEOUT:
2338 unsigned long connecttimeout=*(unsigned long*)lpBuffer;
2339 FIXME("Option INTERNET_OPTION_CONNECT_TIMEOUT (%ld): STUB\n",connecttimeout);
2341 break;
2342 case INTERNET_OPTION_DATA_RECEIVE_TIMEOUT:
2344 unsigned long receivetimeout=*(unsigned long*)lpBuffer;
2345 FIXME("Option INTERNET_OPTION_DATA_RECEIVE_TIMEOUT (%ld): STUB\n",receivetimeout);
2347 break;
2348 case INTERNET_OPTION_MAX_CONNS_PER_SERVER:
2350 unsigned long conns=*(unsigned long*)lpBuffer;
2351 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_SERVER (%ld): STUB\n",conns);
2353 break;
2354 case INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER:
2356 unsigned long conns=*(unsigned long*)lpBuffer;
2357 FIXME("Option INTERNET_OPTION_MAX_CONNS_PER_1_0_SERVER (%ld): STUB\n",conns);
2359 break;
2360 case INTERNET_OPTION_RESET_URLCACHE_SESSION:
2361 FIXME("Option INTERNET_OPTION_RESET_URLCACHE_SESSION: STUB\n");
2362 break;
2363 case INTERNET_OPTION_END_BROWSER_SESSION:
2364 FIXME("Option INTERNET_OPTION_END_BROWSER_SESSION: STUB\n");
2365 break;
2366 case INTERNET_OPTION_CONNECTED_STATE:
2367 FIXME("Option INTERNET_OPTION_CONNECTED_STATE: STUB\n");
2368 break;
2369 case INTERNET_OPTION_DISABLE_PASSPORT_AUTH:
2370 TRACE("Option INTERNET_OPTION_DISABLE_PASSPORT_AUTH: harmless stub, since not enabled\n");
2371 break;
2372 case INTERNET_OPTION_RECEIVE_TIMEOUT:
2373 FIXME("Option INTERNET_OPTION_RECEIVE_TIMEOUT: STUB\n");
2374 break;
2375 case INTERNET_OPTION_SEND_TIMEOUT:
2376 FIXME("Option INTERNET_OPTION_SEND_TIMEOUT: STUB\n");
2377 break;
2378 case INTERNET_OPTION_CONNECT_RETRIES:
2379 FIXME("Option INTERNET_OPTION_CONNECT_RETRIES: STUB\n");
2380 break;
2381 default:
2382 FIXME("Option %ld STUB\n",dwOption);
2383 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
2384 ret = FALSE;
2385 break;
2387 WININET_Release( lpwhh );
2389 return ret;
2393 /***********************************************************************
2394 * InternetSetOptionA (WININET.@)
2396 * Sets an options on the specified handle.
2398 * RETURNS
2399 * TRUE on success
2400 * FALSE on failure
2403 BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
2404 LPVOID lpBuffer, DWORD dwBufferLength)
2406 LPVOID wbuffer;
2407 DWORD wlen;
2408 BOOL r;
2410 switch( dwOption )
2412 case INTERNET_OPTION_PROXY:
2414 LPINTERNET_PROXY_INFOA pi = (LPINTERNET_PROXY_INFOA) lpBuffer;
2415 LPINTERNET_PROXY_INFOW piw;
2416 DWORD proxlen, prbylen;
2417 LPWSTR prox, prby;
2419 proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0);
2420 prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0);
2421 wlen = sizeof(*piw) + proxlen + prbylen;
2422 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
2423 piw = (LPINTERNET_PROXY_INFOW) wbuffer;
2424 piw->dwAccessType = pi->dwAccessType;
2425 prox = (LPWSTR) &piw[1];
2426 prby = &prox[proxlen+1];
2427 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, prox, proxlen);
2428 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, prby, prbylen);
2429 piw->lpszProxy = prox;
2430 piw->lpszProxyBypass = prby;
2432 break;
2433 case INTERNET_OPTION_USER_AGENT:
2434 case INTERNET_OPTION_USERNAME:
2435 case INTERNET_OPTION_PASSWORD:
2436 wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
2437 NULL, 0 );
2438 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
2439 MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
2440 wbuffer, wlen );
2441 break;
2442 default:
2443 wbuffer = lpBuffer;
2444 wlen = dwBufferLength;
2447 r = InternetSetOptionW(hInternet,dwOption, wbuffer, wlen);
2449 if( lpBuffer != wbuffer )
2450 HeapFree( GetProcessHeap(), 0, wbuffer );
2452 return r;
2456 /***********************************************************************
2457 * InternetSetOptionExA (WININET.@)
2459 BOOL WINAPI InternetSetOptionExA(HINTERNET hInternet, DWORD dwOption,
2460 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
2462 FIXME("Flags %08lx ignored\n", dwFlags);
2463 return InternetSetOptionA( hInternet, dwOption, lpBuffer, dwBufferLength );
2466 /***********************************************************************
2467 * InternetSetOptionExW (WININET.@)
2469 BOOL WINAPI InternetSetOptionExW(HINTERNET hInternet, DWORD dwOption,
2470 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
2472 FIXME("Flags %08lx ignored\n", dwFlags);
2473 if( dwFlags & ~ISO_VALID_FLAGS )
2475 SetLastError( ERROR_INVALID_PARAMETER );
2476 return FALSE;
2478 return InternetSetOptionW( hInternet, dwOption, lpBuffer, dwBufferLength );
2481 static const WCHAR WININET_wkday[7][4] =
2482 { { 'S','u','n', 0 }, { 'M','o','n', 0 }, { 'T','u','e', 0 }, { 'W','e','d', 0 },
2483 { 'T','h','u', 0 }, { 'F','r','i', 0 }, { 'S','a','t', 0 } };
2484 static const WCHAR WININET_month[12][4] =
2485 { { 'J','a','n', 0 }, { 'F','e','b', 0 }, { 'M','a','r', 0 }, { 'A','p','r', 0 },
2486 { 'M','a','y', 0 }, { 'J','u','n', 0 }, { 'J','u','l', 0 }, { 'A','u','g', 0 },
2487 { 'S','e','p', 0 }, { 'O','c','t', 0 }, { 'N','o','v', 0 }, { 'D','e','c', 0 } };
2489 /***********************************************************************
2490 * InternetTimeFromSystemTimeA (WININET.@)
2492 BOOL WINAPI InternetTimeFromSystemTimeA( const SYSTEMTIME* time, DWORD format, LPSTR string, DWORD size )
2494 BOOL ret;
2495 WCHAR stringW[INTERNET_RFC1123_BUFSIZE];
2497 TRACE( "%p 0x%08lx %p 0x%08lx\n", time, format, string, size );
2499 ret = InternetTimeFromSystemTimeW( time, format, stringW, sizeof(stringW) );
2500 if (ret) WideCharToMultiByte( CP_ACP, 0, stringW, -1, string, size, NULL, NULL );
2502 return ret;
2505 /***********************************************************************
2506 * InternetTimeFromSystemTimeW (WININET.@)
2508 BOOL WINAPI InternetTimeFromSystemTimeW( const SYSTEMTIME* time, DWORD format, LPWSTR string, DWORD size )
2510 static const WCHAR date[] =
2511 { '%','s',',',' ','%','0','2','d',' ','%','s',' ','%','4','d',' ','%','0',
2512 '2','d',':','%','0','2','d',':','%','0','2','d',' ','G','M','T', 0 };
2514 TRACE( "%p 0x%08lx %p 0x%08lx\n", time, format, string, size );
2516 if (!time || !string) return FALSE;
2518 if (format != INTERNET_RFC1123_FORMAT || size < INTERNET_RFC1123_BUFSIZE * sizeof(WCHAR))
2519 return FALSE;
2521 sprintfW( string, date,
2522 WININET_wkday[time->wDayOfWeek],
2523 time->wDay,
2524 WININET_month[time->wMonth - 1],
2525 time->wYear,
2526 time->wHour,
2527 time->wMinute,
2528 time->wSecond );
2530 return TRUE;
2533 /***********************************************************************
2534 * InternetTimeToSystemTimeA (WININET.@)
2536 BOOL WINAPI InternetTimeToSystemTimeA( LPCSTR string, SYSTEMTIME* time, DWORD reserved )
2538 BOOL ret = FALSE;
2539 WCHAR *stringW;
2540 int len;
2542 TRACE( "%s %p 0x%08lx\n", debugstr_a(string), time, reserved );
2544 len = MultiByteToWideChar( CP_ACP, 0, string, -1, NULL, 0 );
2545 stringW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
2547 if (stringW)
2549 MultiByteToWideChar( CP_ACP, 0, string, -1, stringW, len );
2550 ret = InternetTimeToSystemTimeW( stringW, time, reserved );
2551 HeapFree( GetProcessHeap(), 0, stringW );
2553 return ret;
2556 /***********************************************************************
2557 * InternetTimeToSystemTimeW (WININET.@)
2559 BOOL WINAPI InternetTimeToSystemTimeW( LPCWSTR string, SYSTEMTIME* time, DWORD reserved )
2561 unsigned int i;
2562 WCHAR *s = (LPWSTR)string;
2564 TRACE( "%s %p 0x%08lx\n", debugstr_w(string), time, reserved );
2566 if (!string || !time) return FALSE;
2568 /* Windows does this too */
2569 GetSystemTime( time );
2571 /* Convert an RFC1123 time such as 'Fri, 07 Jan 2005 12:06:35 GMT' into
2572 * a SYSTEMTIME structure.
2575 while (*s && !isalphaW( *s )) s++;
2576 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2577 time->wDayOfWeek = 7;
2579 for (i = 0; i < 7; i++)
2581 if (toupperW( WININET_wkday[i][0] ) == toupperW( s[0] ) &&
2582 toupperW( WININET_wkday[i][1] ) == toupperW( s[1] ) &&
2583 toupperW( WININET_wkday[i][2] ) == toupperW( s[2] ) )
2585 time->wDayOfWeek = i;
2586 break;
2590 if (time->wDayOfWeek > 6) return TRUE;
2591 while (*s && !isdigitW( *s )) s++;
2592 time->wDay = strtolW( s, &s, 10 );
2594 while (*s && !isalphaW( *s )) s++;
2595 if (s[0] == '\0' || s[1] == '\0' || s[2] == '\0') return TRUE;
2596 time->wMonth = 0;
2598 for (i = 0; i < 12; i++)
2600 if (toupperW( WININET_month[i][0]) == toupperW( s[0] ) &&
2601 toupperW( WININET_month[i][1]) == toupperW( s[1] ) &&
2602 toupperW( WININET_month[i][2]) == toupperW( s[2] ) )
2604 time->wMonth = i + 1;
2605 break;
2608 if (time->wMonth == 0) return TRUE;
2610 while (*s && !isdigitW( *s )) s++;
2611 if (*s == '\0') return TRUE;
2612 time->wYear = strtolW( s, &s, 10 );
2614 while (*s && !isdigitW( *s )) s++;
2615 if (*s == '\0') return TRUE;
2616 time->wHour = strtolW( s, &s, 10 );
2618 while (*s && !isdigitW( *s )) s++;
2619 if (*s == '\0') return TRUE;
2620 time->wMinute = strtolW( s, &s, 10 );
2622 while (*s && !isdigitW( *s )) s++;
2623 if (*s == '\0') return TRUE;
2624 time->wSecond = strtolW( s, &s, 10 );
2626 time->wMilliseconds = 0;
2627 return TRUE;
2630 /***********************************************************************
2631 * InternetCheckConnectionW (WININET.@)
2633 * Pings a requested host to check internet connection
2635 * RETURNS
2636 * TRUE on success and FALSE on failure. If a failure then
2637 * ERROR_NOT_CONNECTED is placed into GetLastError
2640 BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
2643 * this is a kludge which runs the resident ping program and reads the output.
2645 * Anyone have a better idea?
2648 BOOL rc = FALSE;
2649 static const CHAR ping[] = "ping -w 1 ";
2650 static const CHAR redirect[] = " >/dev/null 2>/dev/null";
2651 CHAR *command = NULL;
2652 WCHAR hostW[1024];
2653 DWORD len;
2654 int status = -1;
2656 FIXME("\n");
2659 * Crack or set the Address
2661 if (lpszUrl == NULL)
2664 * According to the doc we are supost to use the ip for the next
2665 * server in the WnInet internal server database. I have
2666 * no idea what that is or how to get it.
2668 * So someone needs to implement this.
2670 FIXME("Unimplemented with URL of NULL\n");
2671 return TRUE;
2673 else
2675 URL_COMPONENTSW components;
2677 ZeroMemory(&components,sizeof(URL_COMPONENTSW));
2678 components.lpszHostName = (LPWSTR)&hostW;
2679 components.dwHostNameLength = 1024;
2681 if (!InternetCrackUrlW(lpszUrl,0,0,&components))
2682 goto End;
2684 TRACE("host name : %s\n",debugstr_w(components.lpszHostName));
2688 * Build our ping command
2690 len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
2691 command = HeapAlloc( GetProcessHeap(), 0, strlen(ping)+len+strlen(redirect) );
2692 strcpy(command,ping);
2693 WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
2694 strcat(command,redirect);
2696 TRACE("Ping command is : %s\n",command);
2698 status = system(command);
2700 TRACE("Ping returned a code of %i\n",status);
2702 /* Ping return code of 0 indicates success */
2703 if (status == 0)
2704 rc = TRUE;
2706 End:
2708 HeapFree( GetProcessHeap(), 0, command );
2709 if (rc == FALSE)
2710 SetLastError(ERROR_NOT_CONNECTED);
2712 return rc;
2716 /***********************************************************************
2717 * InternetCheckConnectionA (WININET.@)
2719 * Pings a requested host to check internet connection
2721 * RETURNS
2722 * TRUE on success and FALSE on failure. If a failure then
2723 * ERROR_NOT_CONNECTED is placed into GetLastError
2726 BOOL WINAPI InternetCheckConnectionA(LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
2728 WCHAR *szUrl;
2729 INT len;
2730 BOOL rc;
2732 len = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0);
2733 if (!(szUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR))))
2734 return FALSE;
2735 MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, len);
2736 rc = InternetCheckConnectionW(szUrl, dwFlags, dwReserved);
2737 HeapFree(GetProcessHeap(), 0, szUrl);
2739 return rc;
2743 /**********************************************************
2744 * INTERNET_InternetOpenUrlW (internal)
2746 * Opens an URL
2748 * RETURNS
2749 * handle of connection or NULL on failure
2751 HINTERNET WINAPI INTERNET_InternetOpenUrlW(LPWININETAPPINFOW hIC, LPCWSTR lpszUrl,
2752 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
2754 URL_COMPONENTSW urlComponents;
2755 WCHAR protocol[32], hostName[MAXHOSTNAME], userName[1024];
2756 WCHAR password[1024], path[2048], extra[1024];
2757 HINTERNET client = NULL, client1 = NULL;
2759 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hIC, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
2760 dwHeadersLength, dwFlags, dwContext);
2762 urlComponents.dwStructSize = sizeof(URL_COMPONENTSW);
2763 urlComponents.lpszScheme = protocol;
2764 urlComponents.dwSchemeLength = 32;
2765 urlComponents.lpszHostName = hostName;
2766 urlComponents.dwHostNameLength = MAXHOSTNAME;
2767 urlComponents.lpszUserName = userName;
2768 urlComponents.dwUserNameLength = 1024;
2769 urlComponents.lpszPassword = password;
2770 urlComponents.dwPasswordLength = 1024;
2771 urlComponents.lpszUrlPath = path;
2772 urlComponents.dwUrlPathLength = 2048;
2773 urlComponents.lpszExtraInfo = extra;
2774 urlComponents.dwExtraInfoLength = 1024;
2775 if(!InternetCrackUrlW(lpszUrl, strlenW(lpszUrl), 0, &urlComponents))
2776 return NULL;
2777 switch(urlComponents.nScheme) {
2778 case INTERNET_SCHEME_FTP:
2779 if(urlComponents.nPort == 0)
2780 urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
2781 client = FTP_Connect(hIC, hostName, urlComponents.nPort,
2782 userName, password, dwFlags, dwContext, INET_OPENURL);
2783 if(client == NULL)
2784 break;
2785 client1 = FtpOpenFileW(client, path, GENERIC_READ, dwFlags, dwContext);
2786 if(client1 == NULL) {
2787 InternetCloseHandle(client);
2788 break;
2790 break;
2792 case INTERNET_SCHEME_HTTP:
2793 case INTERNET_SCHEME_HTTPS: {
2794 static const WCHAR szStars[] = { '*','/','*', 0 };
2795 LPCWSTR accept[2] = { szStars, NULL };
2796 if(urlComponents.nPort == 0) {
2797 if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
2798 urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
2799 else
2800 urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
2802 /* FIXME: should use pointers, not handles, as handles are not thread-safe */
2803 client = HTTP_Connect(hIC, hostName, urlComponents.nPort,
2804 userName, password, dwFlags, dwContext, INET_OPENURL);
2805 if(client == NULL)
2806 break;
2807 client1 = HttpOpenRequestW(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
2808 if(client1 == NULL) {
2809 InternetCloseHandle(client);
2810 break;
2812 HttpAddRequestHeadersW(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
2813 if (!HttpSendRequestW(client1, NULL, 0, NULL, 0)) {
2814 InternetCloseHandle(client1);
2815 client1 = NULL;
2816 break;
2819 case INTERNET_SCHEME_GOPHER:
2820 /* gopher doesn't seem to be implemented in wine, but it's supposed
2821 * to be supported by InternetOpenUrlA. */
2822 default:
2823 break;
2826 TRACE(" %p <--\n", client1);
2828 return client1;
2831 /**********************************************************
2832 * InternetOpenUrlW (WININET.@)
2834 * Opens an URL
2836 * RETURNS
2837 * handle of connection or NULL on failure
2839 HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
2840 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
2842 HINTERNET ret = NULL;
2843 LPWININETAPPINFOW hIC = NULL;
2845 if (TRACE_ON(wininet)) {
2846 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx)\n", hInternet, debugstr_w(lpszUrl), debugstr_w(lpszHeaders),
2847 dwHeadersLength, dwFlags, dwContext);
2848 TRACE(" flags :");
2849 dump_INTERNET_FLAGS(dwFlags);
2852 hIC = (LPWININETAPPINFOW) WININET_GetObject( hInternet );
2853 if (NULL == hIC || hIC->hdr.htype != WH_HINIT) {
2854 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
2855 goto lend;
2858 if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC) {
2859 WORKREQUEST workRequest;
2860 struct WORKREQ_INTERNETOPENURLW *req;
2862 workRequest.asyncall = INTERNETOPENURLW;
2863 workRequest.hdr = WININET_AddRef( &hIC->hdr );
2864 req = &workRequest.u.InternetOpenUrlW;
2865 if (lpszUrl)
2866 req->lpszUrl = WININET_strdupW(lpszUrl);
2867 else
2868 req->lpszUrl = 0;
2869 if (lpszHeaders)
2870 req->lpszHeaders = WININET_strdupW(lpszHeaders);
2871 else
2872 req->lpszHeaders = 0;
2873 req->dwHeadersLength = dwHeadersLength;
2874 req->dwFlags = dwFlags;
2875 req->dwContext = dwContext;
2877 INTERNET_AsyncCall(&workRequest);
2879 * This is from windows.
2881 SetLastError(ERROR_IO_PENDING);
2882 } else {
2883 ret = INTERNET_InternetOpenUrlW(hIC, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext);
2886 lend:
2887 if( hIC )
2888 WININET_Release( &hIC->hdr );
2889 TRACE(" %p <--\n", ret);
2891 return ret;
2894 /**********************************************************
2895 * InternetOpenUrlA (WININET.@)
2897 * Opens an URL
2899 * RETURNS
2900 * handle of connection or NULL on failure
2902 HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
2903 LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
2905 HINTERNET rc = (HINTERNET)NULL;
2907 INT lenUrl;
2908 INT lenHeaders = 0;
2909 LPWSTR szUrl = NULL;
2910 LPWSTR szHeaders = NULL;
2912 TRACE("\n");
2914 if(lpszUrl) {
2915 lenUrl = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0 );
2916 szUrl = HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(WCHAR));
2917 if(!szUrl)
2918 return (HINTERNET)NULL;
2919 MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl);
2922 if(lpszHeaders) {
2923 lenHeaders = MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, NULL, 0 );
2924 szHeaders = HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(WCHAR));
2925 if(!szHeaders) {
2926 HeapFree(GetProcessHeap(), 0, szUrl);
2927 return (HINTERNET)NULL;
2929 MultiByteToWideChar(CP_ACP, 0, lpszHeaders, dwHeadersLength, szHeaders, lenHeaders);
2932 rc = InternetOpenUrlW(hInternet, szUrl, szHeaders,
2933 lenHeaders, dwFlags, dwContext);
2935 HeapFree(GetProcessHeap(), 0, szUrl);
2936 HeapFree(GetProcessHeap(), 0, szHeaders);
2938 return rc;
2942 /***********************************************************************
2943 * INTERNET_SetLastError (internal)
2945 * Set last thread specific error
2947 * RETURNS
2950 void INTERNET_SetLastError(DWORD dwError)
2952 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2954 SetLastError(dwError);
2955 if(lpwite)
2956 lpwite->dwError = dwError;
2960 /***********************************************************************
2961 * INTERNET_GetLastError (internal)
2963 * Get last thread specific error
2965 * RETURNS
2968 DWORD INTERNET_GetLastError(void)
2970 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2971 /* TlsGetValue clears last error, so set it again here */
2972 SetLastError(lpwite->dwError);
2973 return lpwite->dwError;
2977 /***********************************************************************
2978 * INTERNET_WorkerThreadFunc (internal)
2980 * Worker thread execution function
2982 * RETURNS
2985 static DWORD CALLBACK INTERNET_WorkerThreadFunc(LPVOID lpvParam)
2987 DWORD dwWaitRes;
2989 while (1)
2991 if(dwNumJobs > 0) {
2992 INTERNET_ExecuteWork();
2993 continue;
2995 dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
2997 if (dwWaitRes == WAIT_OBJECT_0 + 1)
2998 INTERNET_ExecuteWork();
2999 else
3000 break;
3002 InterlockedIncrement(&dwNumIdleThreads);
3005 InterlockedDecrement(&dwNumIdleThreads);
3006 InterlockedDecrement(&dwNumThreads);
3007 TRACE("Worker thread exiting\n");
3008 return TRUE;
3012 /***********************************************************************
3013 * INTERNET_InsertWorkRequest (internal)
3015 * Insert work request into queue
3017 * RETURNS
3020 static BOOL INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest)
3022 BOOL bSuccess = FALSE;
3023 LPWORKREQUEST lpNewRequest;
3025 TRACE("\n");
3027 lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
3028 if (lpNewRequest)
3030 memcpy(lpNewRequest, lpWorkRequest, sizeof(WORKREQUEST));
3031 lpNewRequest->prev = NULL;
3033 EnterCriticalSection(&csQueue);
3035 lpNewRequest->next = lpWorkQueueTail;
3036 if (lpWorkQueueTail)
3037 lpWorkQueueTail->prev = lpNewRequest;
3038 lpWorkQueueTail = lpNewRequest;
3039 if (!lpHeadWorkQueue)
3040 lpHeadWorkQueue = lpWorkQueueTail;
3042 LeaveCriticalSection(&csQueue);
3044 bSuccess = TRUE;
3045 InterlockedIncrement(&dwNumJobs);
3048 return bSuccess;
3052 /***********************************************************************
3053 * INTERNET_GetWorkRequest (internal)
3055 * Retrieves work request from queue
3057 * RETURNS
3060 static BOOL INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest)
3062 BOOL bSuccess = FALSE;
3063 LPWORKREQUEST lpRequest = NULL;
3065 TRACE("\n");
3067 EnterCriticalSection(&csQueue);
3069 if (lpHeadWorkQueue)
3071 lpRequest = lpHeadWorkQueue;
3072 lpHeadWorkQueue = lpHeadWorkQueue->prev;
3073 if (lpRequest == lpWorkQueueTail)
3074 lpWorkQueueTail = lpHeadWorkQueue;
3077 LeaveCriticalSection(&csQueue);
3079 if (lpRequest)
3081 memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
3082 HeapFree(GetProcessHeap(), 0, lpRequest);
3083 bSuccess = TRUE;
3084 InterlockedDecrement(&dwNumJobs);
3087 return bSuccess;
3091 /***********************************************************************
3092 * INTERNET_AsyncCall (internal)
3094 * Retrieves work request from queue
3096 * RETURNS
3099 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
3101 HANDLE hThread;
3102 DWORD dwTID;
3103 BOOL bSuccess = FALSE;
3105 TRACE("\n");
3107 if (InterlockedDecrement(&dwNumIdleThreads) < 0)
3109 InterlockedIncrement(&dwNumIdleThreads);
3111 if (InterlockedIncrement(&dwNumThreads) > MAX_WORKER_THREADS ||
3112 !(hThread = CreateThread(NULL, 0,
3113 INTERNET_WorkerThreadFunc, NULL, 0, &dwTID)))
3115 InterlockedDecrement(&dwNumThreads);
3116 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
3117 goto lerror;
3120 TRACE("Created new thread\n");
3123 bSuccess = TRUE;
3124 INTERNET_InsertWorkRequest(lpWorkRequest);
3125 SetEvent(hWorkEvent);
3127 lerror:
3129 return bSuccess;
3133 /***********************************************************************
3134 * INTERNET_ExecuteWork (internal)
3136 * RETURNS
3139 static VOID INTERNET_ExecuteWork(void)
3141 WORKREQUEST workRequest;
3143 TRACE("\n");
3145 if (!INTERNET_GetWorkRequest(&workRequest))
3146 return;
3148 switch (workRequest.asyncall)
3150 case FTPPUTFILEW:
3152 struct WORKREQ_FTPPUTFILEW *req = &workRequest.u.FtpPutFileW;
3153 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3155 TRACE("FTPPUTFILEW %p\n", lpwfs);
3157 FTP_FtpPutFileW(lpwfs, req->lpszLocalFile,
3158 req->lpszNewRemoteFile, req->dwFlags, req->dwContext);
3160 HeapFree(GetProcessHeap(), 0, req->lpszLocalFile);
3161 HeapFree(GetProcessHeap(), 0, req->lpszNewRemoteFile);
3163 break;
3165 case FTPSETCURRENTDIRECTORYW:
3167 struct WORKREQ_FTPSETCURRENTDIRECTORYW *req;
3168 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3170 TRACE("FTPSETCURRENTDIRECTORYW %p\n", lpwfs);
3172 req = &workRequest.u.FtpSetCurrentDirectoryW;
3173 FTP_FtpSetCurrentDirectoryW(lpwfs, req->lpszDirectory);
3174 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
3176 break;
3178 case FTPCREATEDIRECTORYW:
3180 struct WORKREQ_FTPCREATEDIRECTORYW *req;
3181 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3183 TRACE("FTPCREATEDIRECTORYW %p\n", lpwfs);
3185 req = &workRequest.u.FtpCreateDirectoryW;
3186 FTP_FtpCreateDirectoryW(lpwfs, req->lpszDirectory);
3187 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
3189 break;
3191 case FTPFINDFIRSTFILEW:
3193 struct WORKREQ_FTPFINDFIRSTFILEW *req;
3194 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3196 TRACE("FTPFINDFIRSTFILEW %p\n", lpwfs);
3198 req = &workRequest.u.FtpFindFirstFileW;
3199 FTP_FtpFindFirstFileW(lpwfs, req->lpszSearchFile,
3200 req->lpFindFileData, req->dwFlags, req->dwContext);
3201 HeapFree(GetProcessHeap(), 0, req->lpszSearchFile);
3203 break;
3205 case FTPGETCURRENTDIRECTORYW:
3207 struct WORKREQ_FTPGETCURRENTDIRECTORYW *req;
3208 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3210 TRACE("FTPGETCURRENTDIRECTORYW %p\n", lpwfs);
3212 req = &workRequest.u.FtpGetCurrentDirectoryW;
3213 FTP_FtpGetCurrentDirectoryW(lpwfs,
3214 req->lpszDirectory, req->lpdwDirectory);
3216 break;
3218 case FTPOPENFILEW:
3220 struct WORKREQ_FTPOPENFILEW *req = &workRequest.u.FtpOpenFileW;
3221 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3223 TRACE("FTPOPENFILEW %p\n", lpwfs);
3225 FTP_FtpOpenFileW(lpwfs, req->lpszFilename,
3226 req->dwAccess, req->dwFlags, req->dwContext);
3227 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
3229 break;
3231 case FTPGETFILEW:
3233 struct WORKREQ_FTPGETFILEW *req = &workRequest.u.FtpGetFileW;
3234 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3236 TRACE("FTPGETFILEW %p\n", lpwfs);
3238 FTP_FtpGetFileW(lpwfs, req->lpszRemoteFile,
3239 req->lpszNewFile, req->fFailIfExists,
3240 req->dwLocalFlagsAttribute, req->dwFlags, req->dwContext);
3241 HeapFree(GetProcessHeap(), 0, req->lpszRemoteFile);
3242 HeapFree(GetProcessHeap(), 0, req->lpszNewFile);
3244 break;
3246 case FTPDELETEFILEW:
3248 struct WORKREQ_FTPDELETEFILEW *req = &workRequest.u.FtpDeleteFileW;
3249 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3251 TRACE("FTPDELETEFILEW %p\n", lpwfs);
3253 FTP_FtpDeleteFileW(lpwfs, req->lpszFilename);
3254 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
3256 break;
3258 case FTPREMOVEDIRECTORYW:
3260 struct WORKREQ_FTPREMOVEDIRECTORYW *req;
3261 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3263 TRACE("FTPREMOVEDIRECTORYW %p\n", lpwfs);
3265 req = &workRequest.u.FtpRemoveDirectoryW;
3266 FTP_FtpRemoveDirectoryW(lpwfs, req->lpszDirectory);
3267 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
3269 break;
3271 case FTPRENAMEFILEW:
3273 struct WORKREQ_FTPRENAMEFILEW *req = &workRequest.u.FtpRenameFileW;
3274 LPWININETFTPSESSIONW lpwfs = (LPWININETFTPSESSIONW) workRequest.hdr;
3276 TRACE("FTPRENAMEFILEW %p\n", lpwfs);
3278 FTP_FtpRenameFileW(lpwfs, req->lpszSrcFile, req->lpszDestFile);
3279 HeapFree(GetProcessHeap(), 0, req->lpszSrcFile);
3280 HeapFree(GetProcessHeap(), 0, req->lpszDestFile);
3282 break;
3284 case INTERNETFINDNEXTW:
3286 struct WORKREQ_INTERNETFINDNEXTW *req;
3287 LPWININETFINDNEXTW lpwh = (LPWININETFINDNEXTW) workRequest.hdr;
3289 TRACE("INTERNETFINDNEXTW %p\n", lpwh);
3291 req = &workRequest.u.InternetFindNextW;
3292 INTERNET_FindNextFileW(lpwh, req->lpFindFileData);
3294 break;
3296 case HTTPSENDREQUESTW:
3298 struct WORKREQ_HTTPSENDREQUESTW *req = &workRequest.u.HttpSendRequestW;
3299 LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW) workRequest.hdr;
3301 TRACE("HTTPSENDREQUESTW %p\n", lpwhr);
3303 HTTP_HttpSendRequestW(lpwhr, req->lpszHeader,
3304 req->dwHeaderLength, req->lpOptional, req->dwOptionalLength,
3305 req->dwContentLength, req->bEndRequest);
3307 HeapFree(GetProcessHeap(), 0, req->lpszHeader);
3309 break;
3311 case HTTPOPENREQUESTW:
3313 struct WORKREQ_HTTPOPENREQUESTW *req = &workRequest.u.HttpOpenRequestW;
3314 LPWININETHTTPSESSIONW lpwhs = (LPWININETHTTPSESSIONW) workRequest.hdr;
3316 TRACE("HTTPOPENREQUESTW %p\n", lpwhs);
3318 HTTP_HttpOpenRequestW(lpwhs, req->lpszVerb,
3319 req->lpszObjectName, req->lpszVersion, req->lpszReferrer,
3320 req->lpszAcceptTypes, req->dwFlags, req->dwContext);
3322 HeapFree(GetProcessHeap(), 0, req->lpszVerb);
3323 HeapFree(GetProcessHeap(), 0, req->lpszObjectName);
3324 HeapFree(GetProcessHeap(), 0, req->lpszVersion);
3325 HeapFree(GetProcessHeap(), 0, req->lpszReferrer);
3327 break;
3329 case SENDCALLBACK:
3331 struct WORKREQ_SENDCALLBACK *req = &workRequest.u.SendCallback;
3333 TRACE("SENDCALLBACK %p\n", workRequest.hdr);
3335 INTERNET_SendCallback(workRequest.hdr,
3336 req->dwContext, req->dwInternetStatus, req->lpvStatusInfo,
3337 req->dwStatusInfoLength);
3339 /* And frees the copy of the status info */
3340 HeapFree(GetProcessHeap(), 0, req->lpvStatusInfo);
3342 break;
3344 case INTERNETOPENURLW:
3346 struct WORKREQ_INTERNETOPENURLW *req = &workRequest.u.InternetOpenUrlW;
3347 LPWININETAPPINFOW hIC = (LPWININETAPPINFOW) workRequest.hdr;
3349 TRACE("INTERNETOPENURLW %p\n", hIC);
3351 INTERNET_InternetOpenUrlW(hIC, req->lpszUrl,
3352 req->lpszHeaders, req->dwHeadersLength, req->dwFlags, req->dwContext);
3353 HeapFree(GetProcessHeap(), 0, req->lpszUrl);
3354 HeapFree(GetProcessHeap(), 0, req->lpszHeaders);
3356 break;
3357 case INTERNETREADFILEEXA:
3359 struct WORKREQ_INTERNETREADFILEEXA *req = &workRequest.u.InternetReadFileExA;
3361 TRACE("INTERNETREADFILEEXA %p\n", workRequest.hdr);
3363 INTERNET_ReadFile(workRequest.hdr, req->lpBuffersOut->lpvBuffer,
3364 req->lpBuffersOut->dwBufferLength,
3365 &req->lpBuffersOut->dwBufferLength, TRUE, TRUE);
3367 break;
3369 WININET_Release( workRequest.hdr );
3373 /***********************************************************************
3374 * INTERNET_GetResponseBuffer (internal)
3376 * RETURNS
3379 LPSTR INTERNET_GetResponseBuffer(void)
3381 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
3382 TRACE("\n");
3383 return lpwite->response;
3386 /***********************************************************************
3387 * INTERNET_GetNextLine (internal)
3389 * Parse next line in directory string listing
3391 * RETURNS
3392 * Pointer to beginning of next line
3393 * NULL on failure
3397 LPSTR INTERNET_GetNextLine(INT nSocket, LPDWORD dwLen)
3399 struct timeval tv;
3400 fd_set infd;
3401 BOOL bSuccess = FALSE;
3402 INT nRecv = 0;
3403 LPSTR lpszBuffer = INTERNET_GetResponseBuffer();
3405 TRACE("\n");
3407 FD_ZERO(&infd);
3408 FD_SET(nSocket, &infd);
3409 tv.tv_sec=RESPONSE_TIMEOUT;
3410 tv.tv_usec=0;
3412 while (nRecv < MAX_REPLY_LEN)
3414 if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0)
3416 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
3418 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
3419 goto lend;
3422 if (lpszBuffer[nRecv] == '\n')
3424 bSuccess = TRUE;
3425 break;
3427 if (lpszBuffer[nRecv] != '\r')
3428 nRecv++;
3430 else
3432 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
3433 goto lend;
3437 lend:
3438 if (bSuccess)
3440 lpszBuffer[nRecv] = '\0';
3441 *dwLen = nRecv - 1;
3442 TRACE(":%d %s\n", nRecv, lpszBuffer);
3443 return lpszBuffer;
3445 else
3447 return NULL;
3451 /**********************************************************
3452 * InternetQueryDataAvailable (WININET.@)
3454 * Determines how much data is available to be read.
3456 * RETURNS
3457 * If there is data available then TRUE, otherwise if there
3458 * is not or an error occurred then FALSE. Use GetLastError() to
3459 * check for ERROR_NO_MORE_FILES to see if it was the former.
3461 BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
3462 LPDWORD lpdwNumberOfBytesAvailble,
3463 DWORD dwFlags, DWORD dwConext)
3465 LPWININETHTTPREQW lpwhr;
3466 BOOL retval = FALSE;
3467 char buffer[4048];
3469 lpwhr = (LPWININETHTTPREQW) WININET_GetObject( hFile );
3470 if (NULL == lpwhr)
3472 SetLastError(ERROR_NO_MORE_FILES);
3473 return FALSE;
3476 TRACE("--> %p %i\n",lpwhr,lpwhr->hdr.htype);
3478 switch (lpwhr->hdr.htype)
3480 case WH_HHTTPREQ:
3481 if (!NETCON_recv(&lpwhr->netConnection, buffer,
3482 4048, MSG_PEEK, (int *)lpdwNumberOfBytesAvailble))
3484 SetLastError(ERROR_NO_MORE_FILES);
3485 retval = FALSE;
3487 else
3488 retval = TRUE;
3489 break;
3491 default:
3492 FIXME("unsupported file type\n");
3493 break;
3495 WININET_Release( &lpwhr->hdr );
3497 TRACE("<-- %i\n",retval);
3498 return retval;
3502 /***********************************************************************
3503 * InternetLockRequestFile (WININET.@)
3505 BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
3506 *lphLockReqHandle)
3508 FIXME("STUB\n");
3509 return FALSE;
3512 BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
3514 FIXME("STUB\n");
3515 return FALSE;
3519 /***********************************************************************
3520 * InternetAutodial (WININET.@)
3522 * On windows this function is supposed to dial the default internet
3523 * connection. We don't want to have Wine dial out to the internet so
3524 * we return TRUE by default. It might be nice to check if we are connected.
3526 * RETURNS
3527 * TRUE on success
3528 * FALSE on failure
3531 BOOL WINAPI InternetAutodial(DWORD dwFlags, HWND hwndParent)
3533 FIXME("STUB\n");
3535 /* Tell that we are connected to the internet. */
3536 return TRUE;
3539 /***********************************************************************
3540 * InternetAutodialHangup (WININET.@)
3542 * Hangs up a connection made with InternetAutodial
3544 * PARAM
3545 * dwReserved
3546 * RETURNS
3547 * TRUE on success
3548 * FALSE on failure
3551 BOOL WINAPI InternetAutodialHangup(DWORD dwReserved)
3553 FIXME("STUB\n");
3555 /* we didn't dial, we don't disconnect */
3556 return TRUE;
3559 /***********************************************************************
3560 * InternetCombineUrlA (WININET.@)
3562 * Combine a base URL with a relative URL
3564 * RETURNS
3565 * TRUE on success
3566 * FALSE on failure
3570 BOOL WINAPI InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl,
3571 LPSTR lpszBuffer, LPDWORD lpdwBufferLength,
3572 DWORD dwFlags)
3574 HRESULT hr=S_OK;
3576 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_a(lpszBaseUrl), debugstr_a(lpszRelativeUrl), lpszBuffer, lpdwBufferLength, dwFlags);
3578 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3579 dwFlags ^= ICU_NO_ENCODE;
3580 hr=UrlCombineA(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
3582 return (hr==S_OK);
3585 /***********************************************************************
3586 * InternetCombineUrlW (WININET.@)
3588 * Combine a base URL with a relative URL
3590 * RETURNS
3591 * TRUE on success
3592 * FALSE on failure
3596 BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl,
3597 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength,
3598 DWORD dwFlags)
3600 HRESULT hr=S_OK;
3602 TRACE("(%s, %s, %p, %p, 0x%08lx)\n", debugstr_w(lpszBaseUrl), debugstr_w(lpszRelativeUrl), lpszBuffer, lpdwBufferLength, dwFlags);
3604 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
3605 dwFlags ^= ICU_NO_ENCODE;
3606 hr=UrlCombineW(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
3608 return (hr==S_OK);
3611 /* max port num is 65535 => 5 digits */
3612 #define MAX_WORD_DIGITS 5
3614 /* we can calculate using ansi strings because we're just
3615 * calculating string length, not size
3617 static BOOL calc_url_length(LPURL_COMPONENTSW lpUrlComponents,
3618 LPDWORD lpdwUrlLength, LPDWORD lpdwSchemeLength)
3620 static const WCHAR httpW[] = {'h','t','t','p',0};
3622 *lpdwUrlLength = 0;
3624 switch (lpUrlComponents->nScheme)
3626 case INTERNET_SCHEME_FTP:
3627 case INTERNET_SCHEME_RES:
3628 *lpdwSchemeLength = 3;
3629 break;
3630 case INTERNET_SCHEME_HTTP:
3631 case INTERNET_SCHEME_FILE:
3632 case INTERNET_SCHEME_NEWS:
3633 *lpdwSchemeLength = 4;
3634 break;
3636 default:
3637 *lpdwSchemeLength = 4;
3638 break;
3641 *lpdwUrlLength += *lpdwSchemeLength;
3642 *lpdwUrlLength += strlen("://");
3644 if (lpUrlComponents->lpszUserName)
3646 *lpdwUrlLength += lpUrlComponents->dwUserNameLength;
3647 *lpdwUrlLength += strlen("@");
3649 else
3651 if (lpUrlComponents->lpszPassword)
3653 SetLastError(ERROR_INVALID_PARAMETER);
3654 return FALSE;
3658 if (lpUrlComponents->lpszPassword)
3660 *lpdwUrlLength += strlen(":");
3661 *lpdwUrlLength += lpUrlComponents->dwPasswordLength;
3664 *lpdwUrlLength += lpUrlComponents->dwHostNameLength;
3666 if (lpUrlComponents->nPort != 80 ||
3667 (lpUrlComponents->lpszScheme && strncmpW(lpUrlComponents->lpszScheme, httpW, lpUrlComponents->dwSchemeLength)))
3669 char szPort[MAX_WORD_DIGITS];
3671 sprintf(szPort, "%d", lpUrlComponents->nPort);
3672 *lpdwUrlLength += strlen(szPort);
3673 *lpdwUrlLength += strlen(":");
3676 *lpdwUrlLength += lpUrlComponents->dwUrlPathLength;
3677 return TRUE;
3680 static void convert_urlcomp_atow(LPURL_COMPONENTSA lpUrlComponents, LPURL_COMPONENTSW urlCompW)
3682 INT len;
3684 ZeroMemory(urlCompW, sizeof(URL_COMPONENTSW));
3686 urlCompW->dwStructSize = sizeof(URL_COMPONENTSW);
3687 urlCompW->dwSchemeLength = lpUrlComponents->dwSchemeLength;
3688 urlCompW->nScheme = lpUrlComponents->nScheme;
3689 urlCompW->dwHostNameLength = lpUrlComponents->dwHostNameLength;
3690 urlCompW->nPort = lpUrlComponents->nPort;
3691 urlCompW->dwUserNameLength = lpUrlComponents->dwUserNameLength;
3692 urlCompW->dwPasswordLength = lpUrlComponents->dwPasswordLength;
3693 urlCompW->dwUrlPathLength = lpUrlComponents->dwUrlPathLength;
3694 urlCompW->dwExtraInfoLength = lpUrlComponents->dwExtraInfoLength;
3696 if (lpUrlComponents->lpszScheme)
3698 len = lpUrlComponents->dwSchemeLength + 1;
3699 urlCompW->lpszScheme = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3700 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszScheme,
3701 -1, urlCompW->lpszScheme, len);
3704 if (lpUrlComponents->lpszHostName)
3706 len = lpUrlComponents->dwHostNameLength + 1;
3707 urlCompW->lpszHostName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3708 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszHostName,
3709 -1, urlCompW->lpszHostName, len);
3712 if (lpUrlComponents->lpszUserName)
3714 len = lpUrlComponents->dwUserNameLength + 1;
3715 urlCompW->lpszUserName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3716 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUserName,
3717 -1, urlCompW->lpszUserName, len);
3720 if (lpUrlComponents->lpszPassword)
3722 len = lpUrlComponents->dwPasswordLength + 1;
3723 urlCompW->lpszPassword = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3724 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszPassword,
3725 -1, urlCompW->lpszPassword, len);
3728 if (lpUrlComponents->lpszUrlPath)
3730 len = lpUrlComponents->dwUrlPathLength + 1;
3731 urlCompW->lpszUrlPath = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3732 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszUrlPath,
3733 -1, urlCompW->lpszUrlPath, len);
3736 if (lpUrlComponents->lpszExtraInfo)
3738 len = lpUrlComponents->dwExtraInfoLength + 1;
3739 urlCompW->lpszExtraInfo = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3740 MultiByteToWideChar(CP_ACP, 0, lpUrlComponents->lpszExtraInfo,
3741 -1, urlCompW->lpszExtraInfo, len);
3745 /***********************************************************************
3746 * InternetCreateUrlA (WININET.@)
3748 * RETURNS
3749 * TRUE on success
3750 * FALSE on failure
3753 BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags,
3754 LPSTR lpszUrl, LPDWORD lpdwUrlLength)
3756 BOOL ret;
3757 LPWSTR urlW = NULL;
3758 URL_COMPONENTSW urlCompW;
3760 TRACE("(%p,%ld,%s,%p)\n", lpUrlComponents, dwFlags, debugstr_a(lpszUrl), lpdwUrlLength);
3762 if (!lpUrlComponents)
3763 return FALSE;
3765 if (lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSW) || !lpdwUrlLength)
3767 SetLastError(ERROR_INVALID_PARAMETER);
3768 return FALSE;
3771 convert_urlcomp_atow(lpUrlComponents, &urlCompW);
3773 if (lpszUrl)
3774 urlW = HeapAlloc(GetProcessHeap(), 0, *lpdwUrlLength * sizeof(WCHAR));
3776 ret = InternetCreateUrlW(&urlCompW, dwFlags, urlW, lpdwUrlLength);
3778 /* on success, lpdwUrlLength points to the size of urlW in WCHARS
3779 * minus one, so add one to leave room for NULL terminator
3781 if (ret)
3782 WideCharToMultiByte(CP_ACP, 0, urlW, -1, lpszUrl, *lpdwUrlLength + 1, NULL, NULL);
3784 HeapFree(GetProcessHeap(), 0, urlCompW.lpszScheme);
3785 HeapFree(GetProcessHeap(), 0, urlCompW.lpszHostName);
3786 HeapFree(GetProcessHeap(), 0, urlCompW.lpszUserName);
3787 HeapFree(GetProcessHeap(), 0, urlCompW.lpszPassword);
3788 HeapFree(GetProcessHeap(), 0, urlCompW.lpszUrlPath);
3789 HeapFree(GetProcessHeap(), 0, urlCompW.lpszExtraInfo);
3790 HeapFree(GetProcessHeap(), 0, urlW);
3792 return ret;
3795 /***********************************************************************
3796 * InternetCreateUrlW (WININET.@)
3798 * RETURNS
3799 * TRUE on success
3800 * FALSE on failure
3803 BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
3804 LPWSTR lpszUrl, LPDWORD lpdwUrlLength)
3806 DWORD dwLen, dwSchemeLen;
3808 static const WCHAR colonSlashW[] = {':','/','/',0};
3809 static const WCHAR httpW[] = {'h','t','t','p',0};
3810 static const WCHAR colonW[] = {':',0};
3811 static const WCHAR atW[] = {'@',0};
3812 static const WCHAR percentD[] = {'%','d',0};
3814 TRACE("(%p,%ld,%s,%p)\n", lpUrlComponents, dwFlags, debugstr_w(lpszUrl), lpdwUrlLength);
3816 if (!lpUrlComponents)
3817 return FALSE;
3819 if (lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSW) || !lpdwUrlLength)
3821 SetLastError(ERROR_INVALID_PARAMETER);
3822 return FALSE;
3825 if (!calc_url_length(lpUrlComponents, &dwLen, &dwSchemeLen))
3826 return FALSE;
3828 if (!lpszUrl || *lpdwUrlLength < dwLen)
3830 *lpdwUrlLength = dwLen + 1; /* terminating null */
3831 SetLastError(ERROR_INSUFFICIENT_BUFFER);
3832 return FALSE;
3835 *lpdwUrlLength = dwLen;
3836 lpszUrl[0] = 0x00;
3838 if (lpUrlComponents->lpszScheme)
3839 lstrcpynW(lpszUrl, lpUrlComponents->lpszScheme,
3840 min(lpUrlComponents->dwSchemeLength, dwSchemeLen) + 1);
3842 lstrcatW(lpszUrl, colonSlashW);
3844 if (lpUrlComponents->lpszUserName)
3846 if (!*lpUrlComponents->lpszUserName)
3847 return TRUE;
3849 lstrcatW(lpszUrl, lpUrlComponents->lpszUserName);
3851 if (lpUrlComponents->lpszPassword)
3853 lstrcatW(lpszUrl, colonW);
3855 if (!*lpUrlComponents->lpszPassword)
3856 return TRUE;
3857 else
3858 lstrcatW(lpszUrl, lpUrlComponents->lpszPassword);
3861 lstrcatW(lpszUrl, atW);
3864 lstrcatW(lpszUrl, lpUrlComponents->lpszHostName);
3866 if (lpUrlComponents->nPort != 80 || (lpUrlComponents->lpszScheme &&
3867 strncmpW(lpUrlComponents->lpszScheme, httpW, lpUrlComponents->dwSchemeLength)))
3869 WCHAR szPort[MAX_WORD_DIGITS];
3871 sprintfW(szPort, percentD, lpUrlComponents->nPort);
3872 lstrcatW(lpszUrl, colonW);
3873 lstrcatW(lpszUrl, szPort);
3876 lstrcatW(lpszUrl, lpUrlComponents->lpszUrlPath);
3878 return TRUE;
3881 /***********************************************************************
3882 * InternetConfirmZoneCrossingA (WININET.@)
3885 DWORD WINAPI InternetConfirmZoneCrossingA( HWND hWnd, LPSTR szUrlPrev, LPSTR szUrlNew, BOOL bPost )
3887 FIXME("(%p, %s, %s, %x) stub\n", hWnd, debugstr_a(szUrlPrev), debugstr_a(szUrlNew), bPost);
3888 return ERROR_SUCCESS;
3891 /***********************************************************************
3892 * InternetConfirmZoneCrossingW (WININET.@)
3895 DWORD WINAPI InternetConfirmZoneCrossingW( HWND hWnd, LPWSTR szUrlPrev, LPWSTR szUrlNew, BOOL bPost )
3897 FIXME("(%p, %s, %s, %x) stub\n", hWnd, debugstr_w(szUrlPrev), debugstr_w(szUrlNew), bPost);
3898 return ERROR_SUCCESS;
3901 DWORD WINAPI InternetDialA( HWND hwndParent, LPSTR lpszConnectoid, DWORD dwFlags,
3902 LPDWORD lpdwConnection, DWORD dwReserved )
3904 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent, lpszConnectoid, dwFlags,
3905 lpdwConnection, dwReserved);
3906 return ERROR_SUCCESS;
3909 DWORD WINAPI InternetDialW( HWND hwndParent, LPWSTR lpszConnectoid, DWORD dwFlags,
3910 LPDWORD lpdwConnection, DWORD dwReserved )
3912 FIXME("(%p, %p, 0x%08lx, %p, 0x%08lx) stub\n", hwndParent, lpszConnectoid, dwFlags,
3913 lpdwConnection, dwReserved);
3914 return ERROR_SUCCESS;
3917 BOOL WINAPI InternetGoOnlineA( LPSTR lpszURL, HWND hwndParent, DWORD dwReserved )
3919 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_a(lpszURL), hwndParent, dwReserved);
3920 return TRUE;
3923 BOOL WINAPI InternetGoOnlineW( LPWSTR lpszURL, HWND hwndParent, DWORD dwReserved )
3925 FIXME("(%s, %p, 0x%08lx) stub\n", debugstr_w(lpszURL), hwndParent, dwReserved);
3926 return TRUE;
3929 DWORD WINAPI InternetHangUp( DWORD dwConnection, DWORD dwReserved )
3931 FIXME("(0x%08lx, 0x%08lx) stub\n", dwConnection, dwReserved);
3932 return ERROR_SUCCESS;
3935 BOOL WINAPI CreateMD5SSOHash( PWSTR pszChallengeInfo, PWSTR pwszRealm, PWSTR pwszTarget,
3936 PBYTE pbHexHash )
3938 FIXME("(%s, %s, %s, %p) stub\n", debugstr_w(pszChallengeInfo), debugstr_w(pwszRealm),
3939 debugstr_w(pwszTarget), pbHexHash);
3940 return FALSE;
3943 BOOL WINAPI InternetClearAllPerSiteCookieDecisions( VOID )
3945 FIXME("stub\n");
3946 return TRUE;
3949 BOOL WINAPI InternetEnumPerSiteCookieDecisionA( LPSTR pszSiteName, unsigned long *pcSiteNameSize,
3950 unsigned long *pdwDecision, unsigned long dwIndex )
3952 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3953 debugstr_a(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
3954 return FALSE;
3957 BOOL WINAPI InternetEnumPerSiteCookieDecisionW( LPWSTR pszSiteName, unsigned long *pcSiteNameSize,
3958 unsigned long *pdwDecision, unsigned long dwIndex )
3960 FIXME("(%s, %p, %p, 0x%08lx) stub\n",
3961 debugstr_w(pszSiteName), pcSiteNameSize, pdwDecision, dwIndex);
3962 return FALSE;
3965 BOOL WINAPI InternetGetCookieExA( LPCSTR pchURL, LPCSTR pchCookieName, LPSTR pchCookieData,
3966 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
3968 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3969 debugstr_a(pchURL), debugstr_a(pchCookieName), debugstr_a(pchCookieData),
3970 pcchCookieData, dwFlags, lpReserved);
3971 return FALSE;
3974 BOOL WINAPI InternetGetCookieExW( LPCWSTR pchURL, LPCWSTR pchCookieName, LPWSTR pchCookieData,
3975 LPDWORD pcchCookieData, DWORD dwFlags, LPVOID lpReserved)
3977 FIXME("(%s, %s, %s, %p, 0x%08lx, %p) stub\n",
3978 debugstr_w(pchURL), debugstr_w(pchCookieName), debugstr_w(pchCookieData),
3979 pcchCookieData, dwFlags, lpReserved);
3980 return FALSE;
3983 BOOL WINAPI InternetGetPerSiteCookieDecisionA( LPCSTR pwchHostName, unsigned long *pResult )
3985 FIXME("(%s, %p) stub\n", debugstr_a(pwchHostName), pResult);
3986 return FALSE;
3989 BOOL WINAPI InternetGetPerSiteCookieDecisionW( LPCWSTR pwchHostName, unsigned long *pResult )
3991 FIXME("(%s, %p) stub\n", debugstr_w(pwchHostName), pResult);
3992 return FALSE;
3995 BOOL WINAPI InternetSetPerSiteCookieDecisionA( LPCSTR pchHostName, DWORD dwDecision )
3997 FIXME("(%s, 0x%08lx) stub\n", debugstr_a(pchHostName), dwDecision);
3998 return FALSE;
4001 BOOL WINAPI InternetSetPerSiteCookieDecisionW( LPCWSTR pchHostName, DWORD dwDecision )
4003 FIXME("(%s, 0x%08lx) stub\n", debugstr_w(pchHostName), dwDecision);
4004 return FALSE;
4007 DWORD WINAPI InternetSetCookieExA( LPCSTR lpszURL, LPCSTR lpszCookieName, LPCSTR lpszCookieData,
4008 DWORD dwFlags, DWORD_PTR dwReserved)
4010 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
4011 debugstr_a(lpszURL), debugstr_a(lpszCookieName), debugstr_a(lpszCookieData),
4012 dwFlags, dwReserved);
4013 return TRUE;
4016 DWORD WINAPI InternetSetCookieExW( LPCWSTR lpszURL, LPCWSTR lpszCookieName, LPCWSTR lpszCookieData,
4017 DWORD dwFlags, DWORD_PTR dwReserved)
4019 FIXME("(%s, %s, %s, 0x%08lx, 0x%08lx) stub\n",
4020 debugstr_w(lpszURL), debugstr_w(lpszCookieName), debugstr_w(lpszCookieData),
4021 dwFlags, dwReserved);
4022 return TRUE;
4025 BOOL WINAPI ResumeSuspendedDownload( HINTERNET hInternet, DWORD dwError )
4027 FIXME("(%p, 0x%08lx) stub\n", hInternet, dwError);
4028 return FALSE;