4 * Copyright 1999 Corel Corporation
5 * Copyright 2002 CodeWeavers Inc.
6 * Copyright 2002 Jaco Greeff
7 * Copyright 2002 TransGaming Technologies Inc.
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Lesser General Public
15 * License as published by the Free Software Foundation; either
16 * version 2.1 of the License, or (at your option) any later version.
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Lesser General Public License for more details.
23 * You should have received a copy of the GNU Lesser General Public
24 * License along with this library; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #define MAXHOSTNAME 100 /* from http.c */
35 #include <sys/types.h>
36 #ifdef HAVE_SYS_SOCKET_H
37 # include <sys/socket.h>
39 #ifdef HAVE_SYS_TIME_H
40 # include <sys/time.h>
54 #include "wine/debug.h"
56 #define NO_SHLWAPI_STREAM
59 #include "wine/exception.h"
64 #include "wine/unicode.h"
66 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
68 #define MAX_IDLE_WORKER 1000*60*1
69 #define MAX_WORKER_THREADS 10
70 #define RESPONSE_TIMEOUT 30
72 #define GET_HWININET_FROM_LPWININETFINDNEXT(lpwh) \
73 (LPWININETAPPINFOA)(((LPWININETFTPSESSIONA)(lpwh->hdr.lpwhparent))->hdr.lpwhparent)
75 /* filter for page-fault exceptions */
76 static WINE_EXCEPTION_FILTER(page_fault)
78 if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ||
79 GetExceptionCode() == EXCEPTION_PRIV_INSTRUCTION)
80 return EXCEPTION_EXECUTE_HANDLER;
81 return EXCEPTION_CONTINUE_SEARCH;
87 CHAR response[MAX_REPLY_LEN];
88 } WITHREADERROR, *LPWITHREADERROR;
90 BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData);
91 VOID INTERNET_ExecuteWork();
93 DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
95 DWORD dwNumIdleThreads;
97 HANDLE hEventArray[2];
98 #define hQuitEvent hEventArray[0]
99 #define hWorkEvent hEventArray[1]
100 CRITICAL_SECTION csQueue;
101 LPWORKREQUEST lpHeadWorkQueue;
102 LPWORKREQUEST lpWorkQueueTail;
104 /***********************************************************************
105 * DllMain [Internal] Initializes the internal 'WININET.DLL'.
108 * hinstDLL [I] handle to the DLL's instance
110 * lpvReserved [I] reserved, must be NULL
117 BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
119 TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
122 case DLL_PROCESS_ATTACH:
124 g_dwTlsErrIndex = TlsAlloc();
126 if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
129 hQuitEvent = CreateEventA(0, TRUE, FALSE, NULL);
130 hWorkEvent = CreateEventA(0, FALSE, FALSE, NULL);
131 InitializeCriticalSection(&csQueue);
134 dwNumIdleThreads = 0;
137 case DLL_THREAD_ATTACH:
139 LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR));
143 TlsSetValue(g_dwTlsErrIndex, (LPVOID)lpwite);
147 case DLL_THREAD_DETACH:
148 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
150 LPVOID lpwite = TlsGetValue(g_dwTlsErrIndex);
152 HeapFree(GetProcessHeap(), 0, lpwite);
156 case DLL_PROCESS_DETACH:
158 if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
160 HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex));
161 TlsFree(g_dwTlsErrIndex);
164 SetEvent(hQuitEvent);
166 CloseHandle(hQuitEvent);
167 CloseHandle(hWorkEvent);
168 DeleteCriticalSection(&csQueue);
176 /***********************************************************************
177 * InternetInitializeAutoProxyDll (WININET.@)
179 * Setup the internal proxy
188 BOOL WINAPI InternetInitializeAutoProxyDll(DWORD dwReserved)
191 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
195 /***********************************************************************
196 * DetectAutoProxyUrl (WININET.@)
198 * Auto detect the proxy url
204 BOOL WINAPI DetectAutoProxyUrl(LPSTR lpszAutoProxyUrl,
205 DWORD dwAutoProxyUrlLength, DWORD dwDetectFlags)
208 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
213 /***********************************************************************
214 * INTERNET_ConfigureProxyFromReg
217 * The proxy may be specified in the form 'http=proxy.my.org'
218 * Presumably that means there can be ftp=ftpproxy.my.org too.
220 static BOOL INTERNET_ConfigureProxyFromReg( LPWININETAPPINFOA lpwai )
223 DWORD r, keytype, len, enabled;
224 LPSTR lpszInternetSettings =
225 "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
227 r = RegOpenKeyA(HKEY_CURRENT_USER, lpszInternetSettings, &key);
228 if ( r != ERROR_SUCCESS )
231 len = sizeof enabled;
232 r = RegQueryValueExA( key, "ProxyEnable", NULL, &keytype,
233 (BYTE*)&enabled, &len);
234 if( (r == ERROR_SUCCESS) && enabled )
236 TRACE("Proxy is enabled.\n");
238 /* figure out how much memory the proxy setting takes */
239 r = RegQueryValueExA( key, "ProxyServer", NULL, &keytype,
241 if( (r == ERROR_SUCCESS) && len && (keytype == REG_SZ) )
243 LPSTR szProxy, p, szHttp = "http=";
245 szProxy=HeapAlloc( GetProcessHeap(), 0, len+1 );
246 RegQueryValueExA( key, "ProxyServer", NULL, &keytype,
247 (BYTE*)szProxy, &len);
249 /* find the http proxy, and strip away everything else */
250 p = strstr( szProxy, szHttp );
254 strcpy( szProxy, p );
256 p = strchr( szProxy, ' ' );
260 lpwai->dwAccessType = INTERNET_OPEN_TYPE_PROXY;
261 lpwai->lpszProxy = szProxy;
263 TRACE("http proxy = %s\n", lpwai->lpszProxy);
266 ERR("Couldn't read proxy server settings.\n");
269 TRACE("Proxy is not enabled.\n");
275 /***********************************************************************
276 * InternetOpenA (WININET.@)
278 * Per-application initialization of wininet
281 * HINTERNET on success
285 HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
286 LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
288 LPWININETAPPINFOA lpwai = NULL;
290 TRACE("(%s, %li, %s, %s, %li)\n", debugstr_a(lpszAgent), dwAccessType,
291 debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
293 /* Clear any error information */
294 INTERNET_SetLastError(0);
296 lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOA));
299 INTERNET_SetLastError(ERROR_OUTOFMEMORY);
303 memset(lpwai, 0, sizeof(WININETAPPINFOA));
304 lpwai->hdr.htype = WH_HINIT;
305 lpwai->hdr.lpwhparent = NULL;
306 lpwai->hdr.dwFlags = dwFlags;
307 lpwai->dwAccessType = dwAccessType;
308 lpwai->lpszProxyUsername = NULL;
309 lpwai->lpszProxyPassword = NULL;
311 if (NULL != lpszAgent)
313 lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,
314 strlen(lpszAgent)+1);
315 if (lpwai->lpszAgent)
316 strcpy( lpwai->lpszAgent, lpszAgent );
318 if(dwAccessType == INTERNET_OPEN_TYPE_PRECONFIG)
319 INTERNET_ConfigureProxyFromReg( lpwai );
320 else if (NULL != lpszProxy)
322 lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0,
323 strlen(lpszProxy)+1);
324 if (lpwai->lpszProxy)
325 strcpy( lpwai->lpszProxy, lpszProxy );
328 if (NULL != lpszProxyBypass)
330 lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0,
331 strlen(lpszProxyBypass)+1);
332 if (lpwai->lpszProxyBypass)
333 strcpy( lpwai->lpszProxyBypass, lpszProxyBypass );
336 TRACE("returning %p\n", (HINTERNET)lpwai);
337 return (HINTERNET)lpwai;
341 /***********************************************************************
342 * InternetOpenW (WININET.@)
344 * Per-application initialization of wininet
347 * HINTERNET on success
351 HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
352 LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
354 HINTERNET rc = (HINTERNET)NULL;
355 INT lenAgent = WideCharToMultiByte(CP_ACP, 0, lpszAgent, -1, NULL, 0, NULL, NULL);
356 INT lenProxy = WideCharToMultiByte(CP_ACP, 0, lpszProxy, -1, NULL, 0, NULL, NULL);
357 INT lenBypass = WideCharToMultiByte(CP_ACP, 0, lpszProxyBypass, -1, NULL, 0, NULL, NULL);
358 CHAR *szAgent = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenAgent*sizeof(CHAR));
359 CHAR *szProxy = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenProxy*sizeof(CHAR));
360 CHAR *szBypass = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenBypass*sizeof(CHAR));
362 if (!szAgent || !szProxy || !szBypass)
365 HeapFree(GetProcessHeap(), 0, szAgent);
367 HeapFree(GetProcessHeap(), 0, szProxy);
369 HeapFree(GetProcessHeap(), 0, szBypass);
370 return (HINTERNET)NULL;
373 WideCharToMultiByte(CP_ACP, 0, lpszAgent, -1, szAgent, lenAgent,
375 WideCharToMultiByte(CP_ACP, 0, lpszProxy, -1, szProxy, lenProxy,
377 WideCharToMultiByte(CP_ACP, 0, lpszProxyBypass, -1, szBypass, lenBypass,
380 rc = InternetOpenA(szAgent, dwAccessType, szProxy, szBypass, dwFlags);
382 HeapFree(GetProcessHeap(), 0, szAgent);
383 HeapFree(GetProcessHeap(), 0, szProxy);
384 HeapFree(GetProcessHeap(), 0, szBypass);
389 /***********************************************************************
390 * InternetGetLastResponseInfoA (WININET.@)
392 * Return last wininet error description on the calling thread
395 * TRUE on success of writing to buffer
399 BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
400 LPSTR lpszBuffer, LPDWORD lpdwBufferLength)
402 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
406 *lpdwError = lpwite->dwError;
409 strncpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
410 *lpdwBufferLength = strlen(lpszBuffer);
413 *lpdwBufferLength = 0;
419 /***********************************************************************
420 * InternetGetConnectedState (WININET.@)
422 * Return connected state
426 * if lpdwStatus is not null, return the status (off line,
427 * modem, lan...) in it.
428 * FALSE if not connected
430 BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved)
433 FIXME("always returning LAN connection.\n");
434 *lpdwStatus = INTERNET_CONNECTION_LAN;
439 /***********************************************************************
440 * InternetGetConnectedStateEx (WININET.@)
442 * Return connected state
446 * if lpdwStatus is not null, return the status (off line,
447 * modem, lan...) in it.
448 * FALSE if not connected
450 BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnectionName,
451 DWORD dwNameLen, DWORD dwReserved)
458 FIXME("always returning LAN connection.\n");
459 *lpdwStatus = INTERNET_CONNECTION_LAN;
464 /***********************************************************************
465 * InternetConnectA (WININET.@)
467 * Open a ftp, gopher or http session
470 * HINTERNET a session handle on success
474 HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
475 LPCSTR lpszServerName, INTERNET_PORT nServerPort,
476 LPCSTR lpszUserName, LPCSTR lpszPassword,
477 DWORD dwService, DWORD dwFlags, DWORD dwContext)
479 HINTERNET rc = (HINTERNET) NULL;
481 TRACE("(%p, %s, %i, %s, %s, %li, %li, %li)\n", hInternet, debugstr_a(lpszServerName),
482 nServerPort, debugstr_a(lpszUserName), debugstr_a(lpszPassword),
483 dwService, dwFlags, dwContext);
485 /* Clear any error information */
486 INTERNET_SetLastError(0);
490 case INTERNET_SERVICE_FTP:
491 rc = FTP_Connect(hInternet, lpszServerName, nServerPort,
492 lpszUserName, lpszPassword, dwFlags, dwContext);
495 case INTERNET_SERVICE_HTTP:
496 rc = HTTP_Connect(hInternet, lpszServerName, nServerPort,
497 lpszUserName, lpszPassword, dwFlags, dwContext);
500 case INTERNET_SERVICE_GOPHER:
505 TRACE("returning %p\n", rc);
510 /***********************************************************************
511 * InternetConnectW (WININET.@)
513 * Open a ftp, gopher or http session
516 * HINTERNET a session handle on success
520 HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
521 LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
522 LPCWSTR lpszUserName, LPCWSTR lpszPassword,
523 DWORD dwService, DWORD dwFlags, DWORD dwContext)
525 HINTERNET rc = (HINTERNET)NULL;
529 CHAR *szServerName = NULL;
530 CHAR *szUserName = NULL;
531 CHAR *szPassword = NULL;
535 lenServer = WideCharToMultiByte(CP_ACP, 0, lpszServerName, -1, NULL, 0,
537 szServerName = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenServer*sizeof(CHAR));
538 WideCharToMultiByte(CP_ACP, 0, lpszServerName, -1, szServerName, lenServer,
543 lenUser = WideCharToMultiByte(CP_ACP, 0, lpszUserName, -1, NULL, 0,
545 szUserName = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenUser*sizeof(CHAR));
546 WideCharToMultiByte(CP_ACP, 0, lpszUserName, -1, szUserName, lenUser,
551 lenPass = WideCharToMultiByte(CP_ACP, 0, lpszPassword, -1, NULL, 0,
553 szPassword = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenPass*sizeof(CHAR));
554 WideCharToMultiByte(CP_ACP, 0, lpszPassword, -1, szPassword, lenPass,
559 rc = InternetConnectA(hInternet, szServerName, nServerPort,
560 szUserName, szPassword, dwService, dwFlags, dwContext);
562 if (szServerName) HeapFree(GetProcessHeap(), 0, szServerName);
563 if (szUserName) HeapFree(GetProcessHeap(), 0, szUserName);
564 if (szPassword) HeapFree(GetProcessHeap(), 0, szPassword);
569 /***********************************************************************
570 * InternetFindNextFileA (WININET.@)
572 * Continues a file search from a previous call to FindFirstFile
579 BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
581 LPWININETAPPINFOA hIC = NULL;
582 LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
586 if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
588 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
592 hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
593 if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
595 WORKREQUEST workRequest;
596 struct WORKREQ_INTERNETFINDNEXTA *req;
598 workRequest.asyncall = INTERNETFINDNEXTA;
599 workRequest.handle = hFind;
600 req = &workRequest.u.InternetFindNextA;
601 req->lpFindFileData = lpvFindData;
603 return INTERNET_AsyncCall(&workRequest);
607 return INTERNET_FindNextFileA(hFind, lpvFindData);
611 /***********************************************************************
612 * INTERNET_FindNextFileA (Internal)
614 * Continues a file search from a previous call to FindFirstFile
621 BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
623 BOOL bSuccess = TRUE;
624 LPWININETAPPINFOA hIC = NULL;
625 LPWIN32_FIND_DATAA lpFindFileData;
626 LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
630 if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
632 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
636 /* Clear any error information */
637 INTERNET_SetLastError(0);
639 if (lpwh->hdr.lpwhparent->htype != WH_HFTPSESSION)
641 FIXME("Only FTP find next supported\n");
642 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
646 TRACE("index(%d) size(%ld)\n", lpwh->index, lpwh->size);
648 lpFindFileData = (LPWIN32_FIND_DATAA) lpvFindData;
649 ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
651 if (lpwh->index >= lpwh->size)
653 INTERNET_SetLastError(ERROR_NO_MORE_FILES);
658 FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
661 TRACE("\nName: %s\nSize: %ld\n", lpFindFileData->cFileName, lpFindFileData->nFileSizeLow);
665 hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
666 if (hIC->lpfnStatusCB)
668 INTERNET_ASYNC_RESULT iar;
670 iar.dwResult = (DWORD)bSuccess;
671 iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
672 INTERNET_GetLastError();
674 SendAsyncCallback(hIC, hFind, lpwh->hdr.dwContext,
675 INTERNET_STATUS_REQUEST_COMPLETE, &iar,
676 sizeof(INTERNET_ASYNC_RESULT));
683 /***********************************************************************
684 * INTERNET_CloseHandle (internal)
686 * Close internet handle
692 VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai)
696 SendAsyncCallback(lpwai, lpwai, lpwai->hdr.dwContext,
697 INTERNET_STATUS_HANDLE_CLOSING, lpwai,
700 if (lpwai->lpszAgent)
701 HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
703 if (lpwai->lpszProxy)
704 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxy);
706 if (lpwai->lpszProxyBypass)
707 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
709 if (lpwai->lpszProxyUsername)
710 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyUsername);
712 if (lpwai->lpszProxyPassword)
713 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyPassword);
715 HeapFree(GetProcessHeap(), 0, lpwai);
719 /***********************************************************************
720 * InternetCloseHandle (WININET.@)
722 * Generic close handle function
729 BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
732 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hInternet;
734 TRACE("%p\n",hInternet);
739 /* Clear any error information */
740 INTERNET_SetLastError(0);
746 INTERNET_CloseHandle((LPWININETAPPINFOA) lpwh);
750 case WH_HHTTPSESSION:
751 HTTP_CloseHTTPSessionHandle((LPWININETHTTPSESSIONA) lpwh);
756 HTTP_CloseHTTPRequestHandle((LPWININETHTTPREQA) lpwh);
761 retval = FTP_CloseSessionHandle((LPWININETFTPSESSIONA) lpwh);
765 retval = FTP_CloseFindNextHandle((LPWININETFINDNEXTA) lpwh);
769 retval = FTP_CloseFileTransferHandle((LPWININETFILE) lpwh);
775 } __EXCEPT(page_fault) {
776 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
785 /***********************************************************************
786 * ConvertUrlComponentValue (Internal)
788 * Helper function for InternetCrackUrlW
791 void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
792 LPWSTR lpwszComponent, DWORD dwwComponentLen,
796 if (*dwComponentLen != 0)
798 int nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
799 if (*lppszComponent == NULL)
801 int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL);
802 *lppszComponent = (LPSTR)lpszStart+nASCIIOffset;
803 *dwComponentLen = nASCIILength;
807 INT ncpylen = min((*dwComponentLen)-1, nASCIILength);
808 WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,*lppszComponent,ncpylen+1,NULL,NULL);
809 (*lppszComponent)[ncpylen]=0;
810 *dwComponentLen = ncpylen;
816 /***********************************************************************
817 * InternetCrackUrlA (WININET.@)
819 * Break up URL into its components
821 * TODO: Handle dwFlags
828 BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
829 LPURL_COMPONENTSA lpUrlComponents)
835 dwUrlLength=strlen(lpszUrl);
836 lpwszUrl=HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(dwUrlLength+1));
837 memset(lpwszUrl,0,sizeof(WCHAR)*(dwUrlLength+1));
838 nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,dwUrlLength+1);
839 memset(&UCW,0,sizeof(UCW));
840 if(lpUrlComponents->dwHostNameLength!=0)
841 UCW.dwHostNameLength=1;
842 if(lpUrlComponents->dwUserNameLength!=0)
843 UCW.dwUserNameLength=1;
844 if(lpUrlComponents->dwPasswordLength!=0)
845 UCW.dwPasswordLength=1;
846 if(lpUrlComponents->dwUrlPathLength!=0)
847 UCW.dwUrlPathLength=1;
848 if(lpUrlComponents->dwSchemeLength!=0)
849 UCW.dwSchemeLength=1;
850 if(lpUrlComponents->dwExtraInfoLength!=0)
851 UCW.dwExtraInfoLength=1;
852 if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
854 HeapFree(GetProcessHeap(), 0, lpwszUrl);
857 ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
858 UCW.lpszHostName, UCW.dwHostNameLength,
860 ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
861 UCW.lpszUserName, UCW.dwUserNameLength,
863 ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
864 UCW.lpszPassword, UCW.dwPasswordLength,
866 ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
867 UCW.lpszUrlPath, UCW.dwUrlPathLength,
869 ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
870 UCW.lpszScheme, UCW.dwSchemeLength,
872 ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
873 UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
875 lpUrlComponents->nScheme=UCW.nScheme;
876 lpUrlComponents->nPort=UCW.nPort;
877 HeapFree(GetProcessHeap(), 0, lpwszUrl);
879 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
880 debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength),
881 debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength),
882 debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength),
883 debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength));
888 /***********************************************************************
889 * GetInternetSchemeW (internal)
895 * INTERNET_SCHEME_UNKNOWN on failure
898 INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, INT nMaxCmp)
900 INTERNET_SCHEME iScheme=INTERNET_SCHEME_UNKNOWN;
901 WCHAR lpszFtp[]={'f','t','p',0};
902 WCHAR lpszGopher[]={'g','o','p','h','e','r',0};
903 WCHAR lpszHttp[]={'h','t','t','p',0};
904 WCHAR lpszHttps[]={'h','t','t','p','s',0};
905 WCHAR lpszFile[]={'f','i','l','e',0};
906 WCHAR lpszNews[]={'n','e','w','s',0};
907 WCHAR lpszMailto[]={'m','a','i','l','t','o',0};
908 WCHAR lpszRes[]={'r','e','s',0};
909 WCHAR* tempBuffer=NULL;
912 return INTERNET_SCHEME_UNKNOWN;
914 tempBuffer=HeapAlloc(GetProcessHeap(),0,(nMaxCmp+1)*sizeof(WCHAR));
915 strncpyW(tempBuffer,lpszScheme,nMaxCmp);
916 tempBuffer[nMaxCmp]=0;
918 if (nMaxCmp==strlenW(lpszFtp) && !strncmpW(lpszFtp, tempBuffer, nMaxCmp))
919 iScheme=INTERNET_SCHEME_FTP;
920 else if (nMaxCmp==strlenW(lpszGopher) && !strncmpW(lpszGopher, tempBuffer, nMaxCmp))
921 iScheme=INTERNET_SCHEME_GOPHER;
922 else if (nMaxCmp==strlenW(lpszHttp) && !strncmpW(lpszHttp, tempBuffer, nMaxCmp))
923 iScheme=INTERNET_SCHEME_HTTP;
924 else if (nMaxCmp==strlenW(lpszHttps) && !strncmpW(lpszHttps, tempBuffer, nMaxCmp))
925 iScheme=INTERNET_SCHEME_HTTPS;
926 else if (nMaxCmp==strlenW(lpszFile) && !strncmpW(lpszFile, tempBuffer, nMaxCmp))
927 iScheme=INTERNET_SCHEME_FILE;
928 else if (nMaxCmp==strlenW(lpszNews) && !strncmpW(lpszNews, tempBuffer, nMaxCmp))
929 iScheme=INTERNET_SCHEME_NEWS;
930 else if (nMaxCmp==strlenW(lpszMailto) && !strncmpW(lpszMailto, tempBuffer, nMaxCmp))
931 iScheme=INTERNET_SCHEME_MAILTO;
932 else if (nMaxCmp==strlenW(lpszRes) && !strncmpW(lpszRes, tempBuffer, nMaxCmp))
933 iScheme=INTERNET_SCHEME_RES;
934 HeapFree(GetProcessHeap(),0,tempBuffer);
938 /***********************************************************************
939 * SetUrlComponentValueW (Internal)
941 * Helper function for InternetCrackUrlW
948 BOOL SetUrlComponentValueW(LPWSTR* lppszComponent, LPDWORD dwComponentLen, LPCWSTR lpszStart, INT len)
950 TRACE("%s (%d)\n", debugstr_wn(lpszStart,len), len);
952 if (*dwComponentLen != 0 || *lppszComponent == NULL)
954 if (*lppszComponent == NULL)
956 *lppszComponent = (LPWSTR)lpszStart;
957 *dwComponentLen = len;
961 INT ncpylen = min((*dwComponentLen)-1, len);
962 strncpyW(*lppszComponent, lpszStart, ncpylen);
963 (*lppszComponent)[ncpylen] = '\0';
964 *dwComponentLen = ncpylen;
971 /***********************************************************************
972 * InternetCrackUrlW (WININET.@)
974 BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
975 LPURL_COMPONENTSW lpUC)
979 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
982 LPWSTR lpszParam = NULL;
983 BOOL bIsAbsolute = FALSE;
984 LPWSTR lpszap = (WCHAR*)lpszUrl;
985 LPWSTR lpszcp = NULL;
986 WCHAR lpszSeparators[3]={';','?',0};
987 WCHAR lpszSlash[2]={'/',0};
989 dwUrlLength=strlenW(lpszUrl);
993 /* Determine if the URI is absolute. */
994 while (*lpszap != '\0')
996 if (isalnumW(*lpszap))
1001 if ((*lpszap == ':') && (lpszap - lpszUrl >= 2))
1008 lpszcp = (LPWSTR)lpszUrl; /* Relative url */
1014 /* Parse <params> */
1015 lpszParam = strpbrkW(lpszap, lpszSeparators);
1016 if (lpszParam != NULL)
1018 if (!SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
1019 lpszParam, dwUrlLength-(lpszParam-lpszUrl)))
1025 if (bIsAbsolute) /* Parse <protocol>:[//<net_loc>] */
1028 WCHAR wszAbout[]={'a','b','o','u','t',':',0};
1030 /* Get scheme first. */
1031 lpUC->nScheme = GetInternetSchemeW(lpszUrl, lpszcp - lpszUrl);
1032 if (!SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength,
1033 lpszUrl, lpszcp - lpszUrl))
1036 /* Eat ':' in protocol. */
1039 /* if the scheme is "about", there is no host */
1040 if(strncmpW(wszAbout,lpszUrl, lpszcp - lpszUrl)==0)
1042 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1043 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1044 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
1049 /* Skip over slashes. */
1061 lpszNetLoc = strpbrkW(lpszcp, lpszSlash);
1065 lpszNetLoc = min(lpszNetLoc, lpszParam);
1067 lpszNetLoc = lpszParam;
1069 else if (!lpszNetLoc)
1070 lpszNetLoc = lpszcp + dwUrlLength-(lpszcp-lpszUrl);
1078 /* [<user>[<:password>]@]<host>[:<port>] */
1079 /* First find the user and password if they exist */
1081 lpszHost = strchrW(lpszcp, '@');
1082 if (lpszHost == NULL || lpszHost > lpszNetLoc)
1084 /* username and password not specified. */
1085 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1086 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1088 else /* Parse out username and password */
1090 LPWSTR lpszUser = lpszcp;
1091 LPWSTR lpszPasswd = lpszHost;
1093 while (lpszcp < lpszHost)
1096 lpszPasswd = lpszcp;
1101 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength,
1102 lpszUser, lpszPasswd - lpszUser);
1104 if (lpszPasswd != lpszHost)
1106 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength,
1107 lpszPasswd == lpszHost ? NULL : lpszPasswd,
1108 lpszHost - lpszPasswd);
1110 lpszcp++; /* Advance to beginning of host */
1113 /* Parse <host><:port> */
1116 lpszPort = lpszNetLoc;
1118 /* special case for res:// URLs: there is no port here, so the host is the
1119 entire string up to the first '/' */
1120 if(lpUC->nScheme==INTERNET_SCHEME_RES)
1122 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1123 lpszHost, lpszPort - lpszHost);
1129 while (lpszcp < lpszNetLoc)
1137 /* If the scheme is "file" and the host is just one letter, it's not a host */
1138 if(lpUC->nScheme==INTERNET_SCHEME_FILE && (lpszPort-lpszHost)==1)
1141 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1147 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1148 lpszHost, lpszPort - lpszHost);
1149 if (lpszPort != lpszNetLoc)
1150 lpUC->nPort = atoiW(++lpszPort);
1159 /* Here lpszcp points to:
1161 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1162 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1164 if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam))
1168 /* Only truncate the parameter list if it's already been saved
1169 * in lpUC->lpszExtraInfo.
1171 if (lpszParam && lpUC->dwExtraInfoLength)
1172 len = lpszParam - lpszcp;
1175 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1176 * newlines if necessary.
1178 LPWSTR lpsznewline = strchrW(lpszcp, '\n');
1179 if (lpsznewline != NULL)
1180 len = lpsznewline - lpszcp;
1182 len = dwUrlLength-(lpszcp-lpszUrl);
1185 if (!SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
1191 lpUC->dwUrlPathLength = 0;
1194 TRACE("%s: host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
1195 debugstr_wn(lpUC->lpszHostName,lpUC->dwHostNameLength),
1196 debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
1197 debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
1202 /***********************************************************************
1203 * InternetAttemptConnect (WININET.@)
1205 * Attempt to make a connection to the internet
1208 * ERROR_SUCCESS on success
1209 * Error value on failure
1212 DWORD WINAPI InternetAttemptConnect(DWORD dwReserved)
1215 return ERROR_SUCCESS;
1219 /***********************************************************************
1220 * InternetCanonicalizeUrlA (WININET.@)
1222 * Escape unsafe characters and spaces
1229 BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
1230 LPDWORD lpdwBufferLength, DWORD dwFlags)
1233 TRACE("%s %p %p %08lx\n",debugstr_a(lpszUrl), lpszBuffer,
1234 lpdwBufferLength, dwFlags);
1236 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1237 dwFlags ^= ICU_NO_ENCODE;
1239 dwFlags |= 0x80000000; /* Don't know what this means */
1241 hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
1243 return (hr == S_OK) ? TRUE : FALSE;
1246 /***********************************************************************
1247 * InternetCanonicalizeUrlW (WININET.@)
1249 * Escape unsafe characters and spaces
1256 BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
1257 LPDWORD lpdwBufferLength, DWORD dwFlags)
1260 TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl), lpszBuffer,
1261 lpdwBufferLength, dwFlags);
1263 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1264 dwFlags ^= ICU_NO_ENCODE;
1266 dwFlags |= 0x80000000; /* Don't know what this means */
1268 hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
1270 return (hr == S_OK) ? TRUE : FALSE;
1274 /***********************************************************************
1275 * InternetSetStatusCallbackA (WININET.@)
1277 * Sets up a callback function which is called as progress is made
1278 * during an operation.
1281 * Previous callback or NULL on success
1282 * INTERNET_INVALID_STATUS_CALLBACK on failure
1285 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
1286 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1288 INTERNET_STATUS_CALLBACK retVal;
1289 LPWININETAPPINFOA lpwai = (LPWININETAPPINFOA)hInternet;
1291 TRACE("0x%08lx\n", (ULONG)hInternet);
1292 if (lpwai->hdr.htype != WH_HINIT)
1293 return INTERNET_INVALID_STATUS_CALLBACK;
1295 retVal = lpwai->lpfnStatusCB;
1296 lpwai->lpfnStatusCB = lpfnIntCB;
1301 /***********************************************************************
1302 * InternetSetFilePointer (WININET.@)
1304 DWORD WINAPI InternetSetFilePointer(HINTERNET f1, LONG f2, PVOID f3, DWORD f4, DWORD f5)
1310 /***********************************************************************
1311 * InternetWriteFile (WININET.@)
1313 * Write data to an open internet file
1320 BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
1321 DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
1323 BOOL retval = FALSE;
1325 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
1331 switch (lpwh->htype)
1334 FIXME("This shouldn't be here! We don't support this kind"
1335 " of connection anymore. Must use NETCON functions,"
1336 " especially if using SSL\n");
1337 nSocket = ((LPWININETHTTPREQA)hFile)->netConnection.socketFD;
1341 nSocket = ((LPWININETFILE)hFile)->nDataSocket;
1350 int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0);
1351 retval = (res >= 0);
1352 *lpdwNumOfBytesWritten = retval ? res : 0;
1359 /***********************************************************************
1360 * InternetReadFile (WININET.@)
1362 * Read data from an open internet file
1369 BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
1370 DWORD dwNumOfBytesToRead, LPDWORD dwNumOfBytesRead)
1372 BOOL retval = FALSE;
1374 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
1381 /* FIXME: this should use NETCON functions! */
1382 switch (lpwh->htype)
1385 if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, lpBuffer,
1386 dwNumOfBytesToRead, 0, (int *)dwNumOfBytesRead))
1388 *dwNumOfBytesRead = 0;
1389 retval = TRUE; /* Under windows, it seems to return 0 even if nothing was read... */
1396 /* FIXME: FTP should use NETCON_ stuff */
1397 nSocket = ((LPWININETFILE)hFile)->nDataSocket;
1400 int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, 0);
1401 retval = (res >= 0);
1402 *dwNumOfBytesRead = retval ? res : 0;
1413 /***********************************************************************
1414 * InternetReadFileExA (WININET.@)
1416 * Read data from an open internet file
1423 BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffer,
1424 DWORD dwFlags, DWORD dwContext)
1430 /***********************************************************************
1431 * InternetReadFileExW (WININET.@)
1433 * Read data from an open internet file
1440 BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
1441 DWORD dwFlags, DWORD dwContext)
1445 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1449 /***********************************************************************
1450 * INET_QueryOptionHelper (internal)
1452 static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
1453 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1455 LPWININETHANDLEHEADER lpwhh;
1456 BOOL bSuccess = FALSE;
1458 TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
1460 if (NULL == hInternet)
1462 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
1466 lpwhh = (LPWININETHANDLEHEADER) hInternet;
1470 case INTERNET_OPTION_HANDLE_TYPE:
1472 ULONG type = lpwhh->htype;
1473 TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type);
1475 if (*lpdwBufferLength < sizeof(ULONG))
1476 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1479 memcpy(lpBuffer, &type, sizeof(ULONG));
1480 *lpdwBufferLength = sizeof(ULONG);
1486 case INTERNET_OPTION_REQUEST_FLAGS:
1489 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags);
1490 if (*lpdwBufferLength < sizeof(ULONG))
1491 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1494 memcpy(lpBuffer, &flags, sizeof(ULONG));
1495 *lpdwBufferLength = sizeof(ULONG);
1501 case INTERNET_OPTION_URL:
1502 case INTERNET_OPTION_DATAFILE_NAME:
1504 ULONG type = lpwhh->htype;
1505 if (type == WH_HHTTPREQ)
1507 LPWININETHTTPREQA lpreq = hInternet;
1510 sprintf(url,"http://%s%s",lpreq->lpszHostName,lpreq->lpszPath);
1511 TRACE("INTERNET_OPTION_URL: %s\n",url);
1512 if (*lpdwBufferLength < strlen(url)+1)
1513 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1518 *lpdwBufferLength=MultiByteToWideChar(CP_ACP,0,url,-1,lpBuffer,*lpdwBufferLength);
1522 memcpy(lpBuffer, url, strlen(url)+1);
1523 *lpdwBufferLength = strlen(url)+1;
1530 case INTERNET_OPTION_HTTP_VERSION:
1533 * Presently hardcoded to 1.1
1535 ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
1536 ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
1542 FIXME("Stub! %ld \n",dwOption);
1549 /***********************************************************************
1550 * InternetQueryOptionW (WININET.@)
1552 * Queries an options on the specified handle
1559 BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
1560 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1562 return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
1565 /***********************************************************************
1566 * InternetQueryOptionA (WININET.@)
1568 * Queries an options on the specified handle
1575 BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
1576 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1578 return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
1582 /***********************************************************************
1583 * InternetSetOptionW (WININET.@)
1585 * Sets an options on the specified handle
1592 BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
1593 LPVOID lpBuffer, DWORD dwBufferLength)
1595 LPWININETHANDLEHEADER lpwhh;
1597 TRACE("0x%08lx\n", dwOption);
1599 if (NULL == hInternet)
1601 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
1605 lpwhh = (LPWININETHANDLEHEADER) hInternet;
1609 case INTERNET_OPTION_HTTP_VERSION:
1611 HTTP_VERSION_INFO* pVersion=(HTTP_VERSION_INFO*)lpBuffer;
1612 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion->dwMajorVersion,pVersion->dwMinorVersion);
1615 case INTERNET_OPTION_ERROR_MASK:
1617 unsigned long flags=*(unsigned long*)lpBuffer;
1618 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
1621 case INTERNET_OPTION_CODEPAGE:
1623 unsigned long codepage=*(unsigned long*)lpBuffer;
1624 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
1627 case INTERNET_OPTION_REQUEST_PRIORITY:
1629 unsigned long priority=*(unsigned long*)lpBuffer;
1630 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
1634 FIXME("Option %ld STUB\n",dwOption);
1635 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
1643 /***********************************************************************
1644 * InternetSetOptionA (WININET.@)
1646 * Sets an options on the specified handle.
1653 BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
1654 LPVOID lpBuffer, DWORD dwBufferLength)
1662 case INTERNET_OPTION_PROXY:
1664 LPINTERNET_PROXY_INFOA pi = (LPINTERNET_PROXY_INFOA) lpBuffer;
1665 LPINTERNET_PROXY_INFOW piw;
1666 DWORD proxlen, prbylen;
1669 proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0);
1670 prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0);
1671 wlen = sizeof(*piw) + proxlen + prbylen;
1672 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
1673 piw = (LPINTERNET_PROXY_INFOW) wbuffer;
1674 piw->dwAccessType = pi->dwAccessType;
1675 prox = (LPWSTR) &piw[1];
1676 prby = &prox[proxlen+1];
1677 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, prox, proxlen);
1678 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, prby, prbylen);
1679 piw->lpszProxy = prox;
1680 piw->lpszProxyBypass = prby;
1683 case INTERNET_OPTION_USER_AGENT:
1684 case INTERNET_OPTION_USERNAME:
1685 case INTERNET_OPTION_PASSWORD:
1686 wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
1688 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
1689 MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
1694 wlen = dwBufferLength;
1697 r = InternetSetOptionW(hInternet,dwOption, wbuffer, wlen);
1699 if( lpBuffer != wbuffer )
1700 HeapFree( GetProcessHeap(), 0, wbuffer );
1706 /***********************************************************************
1707 * InternetSetOptionExA (WININET.@)
1709 BOOL WINAPI InternetSetOptionExA(HINTERNET hInternet, DWORD dwOption,
1710 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
1712 FIXME("Flags %08lx ignored\n", dwFlags);
1713 return InternetSetOptionA( hInternet, dwOption, lpBuffer, dwBufferLength );
1716 /***********************************************************************
1717 * InternetSetOptionExW (WININET.@)
1719 BOOL WINAPI InternetSetOptionExW(HINTERNET hInternet, DWORD dwOption,
1720 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
1722 FIXME("Flags %08lx ignored\n", dwFlags);
1723 if( dwFlags & ~ISO_VALID_FLAGS )
1725 SetLastError( ERROR_INVALID_PARAMETER );
1728 return InternetSetOptionW( hInternet, dwOption, lpBuffer, dwBufferLength );
1732 /***********************************************************************
1733 * InternetCheckConnectionA (WININET.@)
1735 * Pings a requested host to check internet connection
1738 * TRUE on success and FALSE on failure. If a failure then
1739 * ERROR_NOT_CONNECTED is placesd into GetLastError
1742 BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
1745 * this is a kludge which runs the resident ping program and reads the output.
1747 * Anyone have a better idea?
1758 * Crack or set the Address
1760 if (lpszUrl == NULL)
1763 * According to the doc we are supost to use the ip for the next
1764 * server in the WnInet internal server database. I have
1765 * no idea what that is or how to get it.
1767 * So someone needs to implement this.
1769 FIXME("Unimplemented with URL of NULL\n");
1774 URL_COMPONENTSA componets;
1776 ZeroMemory(&componets,sizeof(URL_COMPONENTSA));
1777 componets.lpszHostName = (LPSTR)&host;
1778 componets.dwHostNameLength = 1024;
1780 if (!InternetCrackUrlA(lpszUrl,0,0,&componets))
1783 TRACE("host name : %s\n",componets.lpszHostName);
1787 * Build our ping command
1789 strcpy(command,"ping -w 1 ");
1790 strcat(command,host);
1791 strcat(command," >/dev/null 2>/dev/null");
1793 TRACE("Ping command is : %s\n",command);
1795 status = system(command);
1797 TRACE("Ping returned a code of %i \n",status);
1799 /* Ping return code of 0 indicates success */
1806 SetLastError(ERROR_NOT_CONNECTED);
1812 /***********************************************************************
1813 * InternetCheckConnectionW (WININET.@)
1815 * Pings a requested host to check internet connection
1818 * TRUE on success and FALSE on failure. If a failure then
1819 * ERROR_NOT_CONNECTED is placed into GetLastError
1822 BOOL WINAPI InternetCheckConnectionW(LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
1828 len = WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, NULL, 0, NULL, NULL);
1829 if (!(szUrl = (CHAR *)HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR))))
1831 WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, szUrl, len, NULL, NULL);
1832 rc = InternetCheckConnectionA((LPCSTR)szUrl, dwFlags, dwReserved);
1833 HeapFree(GetProcessHeap(), 0, szUrl);
1839 /**********************************************************
1840 * InternetOpenUrlA (WININET.@)
1845 * handle of connection or NULL on failure
1847 HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
1848 LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
1850 URL_COMPONENTSA urlComponents;
1851 char protocol[32], hostName[MAXHOSTNAME], userName[1024];
1852 char password[1024], path[2048], extra[1024];
1853 HINTERNET client = NULL, client1 = NULL;
1855 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_a(lpszUrl), debugstr_a(lpszHeaders),
1856 dwHeadersLength, dwFlags, dwContext);
1858 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
1859 urlComponents.lpszScheme = protocol;
1860 urlComponents.dwSchemeLength = 32;
1861 urlComponents.lpszHostName = hostName;
1862 urlComponents.dwHostNameLength = MAXHOSTNAME;
1863 urlComponents.lpszUserName = userName;
1864 urlComponents.dwUserNameLength = 1024;
1865 urlComponents.lpszPassword = password;
1866 urlComponents.dwPasswordLength = 1024;
1867 urlComponents.lpszUrlPath = path;
1868 urlComponents.dwUrlPathLength = 2048;
1869 urlComponents.lpszExtraInfo = extra;
1870 urlComponents.dwExtraInfoLength = 1024;
1871 if(!InternetCrackUrlA(lpszUrl, strlen(lpszUrl), 0, &urlComponents))
1873 switch(urlComponents.nScheme) {
1874 case INTERNET_SCHEME_FTP:
1875 if(urlComponents.nPort == 0)
1876 urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
1877 client = InternetConnectA(hInternet, hostName, urlComponents.nPort,
1878 userName, password, INTERNET_SERVICE_FTP, dwFlags, dwContext);
1879 return FtpOpenFileA(client, path, GENERIC_READ, dwFlags, dwContext);
1880 case INTERNET_SCHEME_HTTP:
1881 case INTERNET_SCHEME_HTTPS:
1883 LPCSTR accept[2] = { "*/*", NULL };
1884 if(urlComponents.nPort == 0) {
1885 if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
1886 urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
1888 urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
1890 client = InternetConnectA(hInternet, hostName, urlComponents.nPort, userName,
1891 password, INTERNET_SERVICE_HTTP, dwFlags, dwContext);
1894 client1 = HttpOpenRequestA(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
1895 if(client1 == NULL) {
1896 InternetCloseHandle(client);
1899 HttpAddRequestHeadersA(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
1900 if(!HttpSendRequestA(client1, NULL, 0, NULL, 0)) {
1901 InternetCloseHandle(client1);
1902 InternetCloseHandle(client);
1907 case INTERNET_SCHEME_GOPHER:
1908 /* gopher doesn't seem to be implemented in wine, but it's supposed
1909 * to be supported by InternetOpenUrlA. */
1916 /**********************************************************
1917 * InternetOpenUrlW (WININET.@)
1922 * handle of connection or NULL on failure
1924 HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
1925 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
1927 HINTERNET rc = (HINTERNET)NULL;
1929 INT lenUrl = WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, NULL, 0, NULL, NULL);
1930 INT lenHeaders = WideCharToMultiByte(CP_ACP, 0, lpszHeaders, -1, NULL, 0, NULL, NULL);
1931 CHAR *szUrl = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(CHAR));
1932 CHAR *szHeaders = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(CHAR));
1934 if (!szUrl || !szHeaders)
1937 HeapFree(GetProcessHeap(), 0, szUrl);
1939 HeapFree(GetProcessHeap(), 0, szHeaders);
1940 return (HINTERNET)NULL;
1943 WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl,
1945 WideCharToMultiByte(CP_ACP, 0, lpszHeaders, -1, szHeaders, lenHeaders,
1948 rc = InternetOpenUrlA(hInternet, szUrl, szHeaders,
1949 dwHeadersLength, dwFlags, dwContext);
1951 HeapFree(GetProcessHeap(), 0, szUrl);
1952 HeapFree(GetProcessHeap(), 0, szHeaders);
1958 /***********************************************************************
1959 * INTERNET_SetLastError (internal)
1961 * Set last thread specific error
1966 void INTERNET_SetLastError(DWORD dwError)
1968 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
1970 SetLastError(dwError);
1972 lpwite->dwError = dwError;
1976 /***********************************************************************
1977 * INTERNET_GetLastError (internal)
1979 * Get last thread specific error
1984 DWORD INTERNET_GetLastError()
1986 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
1987 return lpwite->dwError;
1991 /***********************************************************************
1992 * INTERNET_WorkerThreadFunc (internal)
1994 * Worker thread execution function
1999 DWORD INTERNET_WorkerThreadFunc(LPVOID *lpvParam)
2006 INTERNET_ExecuteWork();
2009 dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
2011 if (dwWaitRes == WAIT_OBJECT_0 + 1)
2012 INTERNET_ExecuteWork();
2016 InterlockedIncrement(&dwNumIdleThreads);
2019 InterlockedDecrement(&dwNumIdleThreads);
2020 InterlockedDecrement(&dwNumThreads);
2021 TRACE("Worker thread exiting\n");
2026 /***********************************************************************
2027 * INTERNET_InsertWorkRequest (internal)
2029 * Insert work request into queue
2034 BOOL INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest)
2036 BOOL bSuccess = FALSE;
2037 LPWORKREQUEST lpNewRequest;
2041 lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
2044 memcpy(lpNewRequest, lpWorkRequest, sizeof(WORKREQUEST));
2045 lpNewRequest->prev = NULL;
2047 EnterCriticalSection(&csQueue);
2049 lpNewRequest->next = lpWorkQueueTail;
2050 if (lpWorkQueueTail)
2051 lpWorkQueueTail->prev = lpNewRequest;
2052 lpWorkQueueTail = lpNewRequest;
2053 if (!lpHeadWorkQueue)
2054 lpHeadWorkQueue = lpWorkQueueTail;
2056 LeaveCriticalSection(&csQueue);
2059 InterlockedIncrement(&dwNumJobs);
2066 /***********************************************************************
2067 * INTERNET_GetWorkRequest (internal)
2069 * Retrieves work request from queue
2074 BOOL INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest)
2076 BOOL bSuccess = FALSE;
2077 LPWORKREQUEST lpRequest = NULL;
2081 EnterCriticalSection(&csQueue);
2083 if (lpHeadWorkQueue)
2085 lpRequest = lpHeadWorkQueue;
2086 lpHeadWorkQueue = lpHeadWorkQueue->prev;
2087 if (lpRequest == lpWorkQueueTail)
2088 lpWorkQueueTail = lpHeadWorkQueue;
2091 LeaveCriticalSection(&csQueue);
2095 memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
2096 HeapFree(GetProcessHeap(), 0, lpRequest);
2098 InterlockedDecrement(&dwNumJobs);
2105 /***********************************************************************
2106 * INTERNET_AsyncCall (internal)
2108 * Retrieves work request from queue
2113 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
2117 BOOL bSuccess = FALSE;
2121 if (InterlockedDecrement(&dwNumIdleThreads) < 0)
2123 InterlockedIncrement(&dwNumIdleThreads);
2125 if (InterlockedIncrement(&dwNumThreads) > MAX_WORKER_THREADS ||
2126 !(hThread = CreateThread(NULL, 0,
2127 (LPTHREAD_START_ROUTINE)INTERNET_WorkerThreadFunc, NULL, 0, &dwTID)))
2129 InterlockedDecrement(&dwNumThreads);
2130 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
2134 TRACE("Created new thread\n");
2138 INTERNET_InsertWorkRequest(lpWorkRequest);
2139 SetEvent(hWorkEvent);
2147 /***********************************************************************
2148 * INTERNET_ExecuteWork (internal)
2153 VOID INTERNET_ExecuteWork()
2155 WORKREQUEST workRequest;
2159 if (!INTERNET_GetWorkRequest(&workRequest))
2161 TRACE("Got work %d\n", workRequest.asyncall);
2162 switch (workRequest.asyncall)
2166 struct WORKREQ_FTPPUTFILEA *req = &workRequest.u.FtpPutFileA;
2168 FTP_FtpPutFileA(workRequest.handle, req->lpszLocalFile,
2169 req->lpszNewRemoteFile, req->dwFlags, req->dwContext);
2171 HeapFree(GetProcessHeap(), 0, req->lpszLocalFile);
2172 HeapFree(GetProcessHeap(), 0, req->lpszNewRemoteFile);
2176 case FTPSETCURRENTDIRECTORYA:
2178 struct WORKREQ_FTPSETCURRENTDIRECTORYA *req;
2180 req = &workRequest.u.FtpSetCurrentDirectoryA;
2181 FTP_FtpSetCurrentDirectoryA(workRequest.handle, req->lpszDirectory);
2182 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
2186 case FTPCREATEDIRECTORYA:
2188 struct WORKREQ_FTPCREATEDIRECTORYA *req;
2190 req = &workRequest.u.FtpCreateDirectoryA;
2191 FTP_FtpCreateDirectoryA(workRequest.handle, req->lpszDirectory);
2192 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
2196 case FTPFINDFIRSTFILEA:
2198 struct WORKREQ_FTPFINDFIRSTFILEA *req;
2200 req = &workRequest.u.FtpFindFirstFileA;
2201 FTP_FtpFindFirstFileA(workRequest.handle, req->lpszSearchFile,
2202 req->lpFindFileData, req->dwFlags, req->dwContext);
2203 HeapFree(GetProcessHeap(), 0, req->lpszSearchFile);
2207 case FTPGETCURRENTDIRECTORYA:
2209 struct WORKREQ_FTPGETCURRENTDIRECTORYA *req;
2211 req = &workRequest.u.FtpGetCurrentDirectoryA;
2212 FTP_FtpGetCurrentDirectoryA(workRequest.handle,
2213 req->lpszDirectory, req->lpdwDirectory);
2219 struct WORKREQ_FTPOPENFILEA *req = &workRequest.u.FtpOpenFileA;
2221 FTP_FtpOpenFileA(workRequest.handle, req->lpszFilename,
2222 req->dwAccess, req->dwFlags, req->dwContext);
2223 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
2229 struct WORKREQ_FTPGETFILEA *req = &workRequest.u.FtpGetFileA;
2231 FTP_FtpGetFileA(workRequest.handle, req->lpszRemoteFile,
2232 req->lpszNewFile, req->fFailIfExists,
2233 req->dwLocalFlagsAttribute, req->dwFlags, req->dwContext);
2234 HeapFree(GetProcessHeap(), 0, req->lpszRemoteFile);
2235 HeapFree(GetProcessHeap(), 0, req->lpszNewFile);
2239 case FTPDELETEFILEA:
2241 struct WORKREQ_FTPDELETEFILEA *req = &workRequest.u.FtpDeleteFileA;
2243 FTP_FtpDeleteFileA(workRequest.handle, req->lpszFilename);
2244 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
2248 case FTPREMOVEDIRECTORYA:
2250 struct WORKREQ_FTPREMOVEDIRECTORYA *req;
2252 req = &workRequest.u.FtpRemoveDirectoryA;
2253 FTP_FtpRemoveDirectoryA(workRequest.handle, req->lpszDirectory);
2254 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
2258 case FTPRENAMEFILEA:
2260 struct WORKREQ_FTPRENAMEFILEA *req = &workRequest.u.FtpRenameFileA;
2262 FTP_FtpRenameFileA(workRequest.handle, req->lpszSrcFile, req->lpszDestFile);
2263 HeapFree(GetProcessHeap(), 0, req->lpszSrcFile);
2264 HeapFree(GetProcessHeap(), 0, req->lpszDestFile);
2268 case INTERNETFINDNEXTA:
2270 struct WORKREQ_INTERNETFINDNEXTA *req;
2272 req = &workRequest.u.InternetFindNextA;
2273 INTERNET_FindNextFileA(workRequest.handle, req->lpFindFileData);
2277 case HTTPSENDREQUESTA:
2279 struct WORKREQ_HTTPSENDREQUESTA *req = &workRequest.u.HttpSendRequestA;
2281 HTTP_HttpSendRequestA(workRequest.handle, req->lpszHeader,
2282 req->dwHeaderLength, req->lpOptional, req->dwOptionalLength);
2284 HeapFree(GetProcessHeap(), 0, req->lpszHeader);
2288 case HTTPOPENREQUESTA:
2290 struct WORKREQ_HTTPOPENREQUESTA *req = &workRequest.u.HttpOpenRequestA;
2292 HTTP_HttpOpenRequestA(workRequest.handle, req->lpszVerb,
2293 req->lpszObjectName, req->lpszVersion, req->lpszReferrer,
2294 req->lpszAcceptTypes, req->dwFlags, req->dwContext);
2296 HeapFree(GetProcessHeap(), 0, req->lpszVerb);
2297 HeapFree(GetProcessHeap(), 0, req->lpszObjectName);
2298 HeapFree(GetProcessHeap(), 0, req->lpszVersion);
2299 HeapFree(GetProcessHeap(), 0, req->lpszReferrer);
2305 struct WORKREQ_SENDCALLBACK *req = &workRequest.u.SendCallback;
2307 SendAsyncCallbackInt(workRequest.handle, req->hHttpSession,
2308 req->dwContext, req->dwInternetStatus, req->lpvStatusInfo,
2309 req->dwStatusInfoLength);
2316 /***********************************************************************
2317 * INTERNET_GetResponseBuffer
2322 LPSTR INTERNET_GetResponseBuffer()
2324 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2326 return lpwite->response;
2329 /***********************************************************************
2330 * INTERNET_GetNextLine (internal)
2332 * Parse next line in directory string listing
2335 * Pointer to beginning of next line
2340 LPSTR INTERNET_GetNextLine(INT nSocket, LPSTR lpszBuffer, LPDWORD dwBuffer)
2344 BOOL bSuccess = FALSE;
2350 FD_SET(nSocket, &infd);
2351 tv.tv_sec=RESPONSE_TIMEOUT;
2354 while (nRecv < *dwBuffer)
2356 if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0)
2358 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
2360 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
2364 if (lpszBuffer[nRecv] == '\n')
2369 if (lpszBuffer[nRecv] != '\r')
2374 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
2382 lpszBuffer[nRecv] = '\0';
2383 *dwBuffer = nRecv - 1;
2384 TRACE(":%d %s\n", nRecv, lpszBuffer);
2393 /***********************************************************************
2396 BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
2397 LPDWORD lpdwNumberOfBytesAvailble,
2398 DWORD dwFlags, DWORD dwConext)
2400 LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hFile;
2407 SetLastError(ERROR_NO_MORE_FILES);
2411 TRACE("--> %p %i\n",lpwhr,lpwhr->hdr.htype);
2413 switch (lpwhr->hdr.htype)
2416 if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, buffer,
2417 4048, MSG_PEEK, (int *)lpdwNumberOfBytesAvailble))
2419 SetLastError(ERROR_NO_MORE_FILES);
2427 FIXME("unsupported file type\n");
2431 TRACE("<-- %i\n",retval);
2436 /***********************************************************************
2439 BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
2446 BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
2453 /***********************************************************************
2456 * On windows this function is supposed to dial the default internet
2457 * connection. We don't want to have Wine dial out to the internet so
2458 * we return TRUE by default. It might be nice to check if we are connected.
2465 BOOL WINAPI InternetAutodial(DWORD dwFlags, HWND hwndParent)
2469 /* Tell that we are connected to the internet. */
2473 /***********************************************************************
2474 * InternetAutodialHangup
2476 * Hangs up an connection made with InternetAutodial
2485 BOOL WINAPI InternetAutodialHangup(DWORD dwReserved)
2489 /* we didn't dial, we don't disconnect */
2493 /***********************************************************************
2495 * InternetCombineUrlA
2497 * Combine a base URL with a relative URL
2505 BOOL WINAPI InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl,
2506 LPSTR lpszBuffer, LPDWORD lpdwBufferLength,
2510 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
2511 dwFlags ^= ICU_NO_ENCODE;
2512 hr=UrlCombineA(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
2517 /***********************************************************************
2519 * InternetCombineUrlW
2521 * Combine a base URL with a relative URL
2529 BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl,
2530 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength,
2534 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
2535 dwFlags ^= ICU_NO_ENCODE;
2536 hr=UrlCombineW(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
2541 /***********************************************************************
2543 * InternetCreateUrlA
2550 BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags,
2551 LPSTR lpszUrl, LPDWORD lpdwUrlLength)
2557 /***********************************************************************
2559 * InternetCreateUrlW
2566 BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
2567 LPWSTR lpszUrl, LPDWORD lpdwUrlLength)