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 = lstrlenW(lpszAgent)+1;
356 INT lenProxy = lstrlenW(lpszProxy)+1;
357 INT lenBypass = lstrlenW(lpszProxyBypass)+1;
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)
370 return (HINTERNET)NULL;
373 WideCharToMultiByte(CP_ACP, -1, lpszAgent, -1, szAgent, lenAgent,
375 WideCharToMultiByte(CP_ACP, -1, lpszProxy, -1, szProxy, lenProxy,
377 WideCharToMultiByte(CP_ACP, -1, 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 writting 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 = lstrlenW(lpszServerName)+1;
536 szServerName = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenServer*sizeof(CHAR));
537 WideCharToMultiByte(CP_ACP, -1, lpszServerName, -1, szServerName, lenServer,
542 lenUser = lstrlenW(lpszUserName)+1;
543 szUserName = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenUser*sizeof(CHAR));
544 WideCharToMultiByte(CP_ACP, -1, lpszUserName, -1, szUserName, lenUser,
549 lenPass = lstrlenW(lpszPassword)+1;
550 szPassword = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenPass*sizeof(CHAR));
551 WideCharToMultiByte(CP_ACP, -1, lpszPassword, -1, szPassword, lenPass,
556 rc = InternetConnectA(hInternet, szServerName, nServerPort,
557 szUserName, szPassword, dwService, dwFlags, dwContext);
559 if (szServerName) HeapFree(GetProcessHeap(), 0, szServerName);
560 if (szUserName) HeapFree(GetProcessHeap(), 0, szUserName);
561 if (szPassword) HeapFree(GetProcessHeap(), 0, szPassword);
566 /***********************************************************************
567 * InternetFindNextFileA (WININET.@)
569 * Continues a file search from a previous call to FindFirstFile
576 BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
578 LPWININETAPPINFOA hIC = NULL;
579 LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
583 if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
585 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
589 hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
590 if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
592 WORKREQUEST workRequest;
594 workRequest.asyncall = INTERNETFINDNEXTA;
595 workRequest.HFTPSESSION = (DWORD)hFind;
596 workRequest.LPFINDFILEDATA = (DWORD)lpvFindData;
598 return INTERNET_AsyncCall(&workRequest);
602 return INTERNET_FindNextFileA(hFind, lpvFindData);
606 /***********************************************************************
607 * INTERNET_FindNextFileA (Internal)
609 * Continues a file search from a previous call to FindFirstFile
616 BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
618 BOOL bSuccess = TRUE;
619 LPWININETAPPINFOA hIC = NULL;
620 LPWIN32_FIND_DATAA lpFindFileData;
621 LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
625 if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
627 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
631 /* Clear any error information */
632 INTERNET_SetLastError(0);
634 if (lpwh->hdr.lpwhparent->htype != WH_HFTPSESSION)
636 FIXME("Only FTP find next supported\n");
637 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
641 TRACE("index(%d) size(%ld)\n", lpwh->index, lpwh->size);
643 lpFindFileData = (LPWIN32_FIND_DATAA) lpvFindData;
644 ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
646 if (lpwh->index >= lpwh->size)
648 INTERNET_SetLastError(ERROR_NO_MORE_FILES);
653 FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
656 TRACE("\nName: %s\nSize: %ld\n", lpFindFileData->cFileName, lpFindFileData->nFileSizeLow);
660 hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
661 if (hIC->lpfnStatusCB)
663 INTERNET_ASYNC_RESULT iar;
665 iar.dwResult = (DWORD)bSuccess;
666 iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
667 INTERNET_GetLastError();
669 SendAsyncCallback(hIC, hFind, lpwh->hdr.dwContext,
670 INTERNET_STATUS_REQUEST_COMPLETE, &iar,
671 sizeof(INTERNET_ASYNC_RESULT));
678 /***********************************************************************
679 * INTERNET_CloseHandle (internal)
681 * Close internet handle
687 VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai)
691 SendAsyncCallback(lpwai, lpwai, lpwai->hdr.dwContext,
692 INTERNET_STATUS_HANDLE_CLOSING, lpwai,
695 if (lpwai->lpszAgent)
696 HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
698 if (lpwai->lpszProxy)
699 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxy);
701 if (lpwai->lpszProxyBypass)
702 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
704 if (lpwai->lpszProxyUsername)
705 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyUsername);
707 if (lpwai->lpszProxyPassword)
708 HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyPassword);
710 HeapFree(GetProcessHeap(), 0, lpwai);
714 /***********************************************************************
715 * InternetCloseHandle (WININET.@)
717 * Generic close handle function
724 BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
727 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hInternet;
729 TRACE("%p\n",hInternet);
734 /* Clear any error information */
735 INTERNET_SetLastError(0);
741 INTERNET_CloseHandle((LPWININETAPPINFOA) lpwh);
745 case WH_HHTTPSESSION:
746 HTTP_CloseHTTPSessionHandle((LPWININETHTTPSESSIONA) lpwh);
751 HTTP_CloseHTTPRequestHandle((LPWININETHTTPREQA) lpwh);
756 retval = FTP_CloseSessionHandle((LPWININETFTPSESSIONA) lpwh);
760 retval = FTP_CloseFindNextHandle((LPWININETFINDNEXTA) lpwh);
764 retval = FTP_CloseFileTransferHandle((LPWININETFILE) lpwh);
770 } __EXCEPT(page_fault) {
771 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
780 /***********************************************************************
781 * ConvertUrlComponentValue (Internal)
783 * Helper function for InternetCrackUrlW
786 void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
787 LPWSTR lpwszComponent, DWORD dwwComponentLen,
791 if (*dwComponentLen != 0)
793 int nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
794 if (*lppszComponent == NULL)
796 int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL);
797 *lppszComponent = (LPSTR)lpszStart+nASCIIOffset;
798 *dwComponentLen = nASCIILength;
802 INT ncpylen = min((*dwComponentLen)-1, nASCIILength);
803 WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,*lppszComponent,ncpylen+1,NULL,NULL);
804 (*lppszComponent)[ncpylen]=0;
805 *dwComponentLen = ncpylen;
811 /***********************************************************************
812 * InternetCrackUrlA (WININET.@)
814 * Break up URL into its components
816 * TODO: Handle dwFlags
823 BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
824 LPURL_COMPONENTSA lpUrlComponents)
830 dwUrlLength=strlen(lpszUrl);
831 lpwszUrl=HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(dwUrlLength+1));
832 memset(lpwszUrl,0,sizeof(WCHAR)*(dwUrlLength+1));
833 nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,dwUrlLength+1);
834 memset(&UCW,0,sizeof(UCW));
835 if(lpUrlComponents->dwHostNameLength!=0)
836 UCW.dwHostNameLength=1;
837 if(lpUrlComponents->dwUserNameLength!=0)
838 UCW.dwUserNameLength=1;
839 if(lpUrlComponents->dwPasswordLength!=0)
840 UCW.dwPasswordLength=1;
841 if(lpUrlComponents->dwUrlPathLength!=0)
842 UCW.dwUrlPathLength=1;
843 if(lpUrlComponents->dwSchemeLength!=0)
844 UCW.dwSchemeLength=1;
845 if(lpUrlComponents->dwExtraInfoLength!=0)
846 UCW.dwExtraInfoLength=1;
847 if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
849 HeapFree(GetProcessHeap(), 0, lpwszUrl);
852 ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
853 UCW.lpszHostName, UCW.dwHostNameLength,
855 ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
856 UCW.lpszUserName, UCW.dwUserNameLength,
858 ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
859 UCW.lpszPassword, UCW.dwPasswordLength,
861 ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
862 UCW.lpszUrlPath, UCW.dwUrlPathLength,
864 ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
865 UCW.lpszScheme, UCW.dwSchemeLength,
867 ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
868 UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
870 lpUrlComponents->nScheme=UCW.nScheme;
871 lpUrlComponents->nPort=UCW.nPort;
872 HeapFree(GetProcessHeap(), 0, lpwszUrl);
874 TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
875 debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength),
876 debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength),
877 debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength),
878 debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength));
883 /***********************************************************************
884 * GetInternetSchemeW (internal)
890 * INTERNET_SCHEME_UNKNOWN on failure
893 INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, INT nMaxCmp)
895 INTERNET_SCHEME iScheme=INTERNET_SCHEME_UNKNOWN;
896 WCHAR lpszFtp[]={'f','t','p',0};
897 WCHAR lpszGopher[]={'g','o','p','h','e','r',0};
898 WCHAR lpszHttp[]={'h','t','t','p',0};
899 WCHAR lpszHttps[]={'h','t','t','p','s',0};
900 WCHAR lpszFile[]={'f','i','l','e',0};
901 WCHAR lpszNews[]={'n','e','w','s',0};
902 WCHAR lpszMailto[]={'m','a','i','l','t','o',0};
903 WCHAR lpszRes[]={'r','e','s',0};
904 WCHAR* tempBuffer=NULL;
907 return INTERNET_SCHEME_UNKNOWN;
909 tempBuffer=malloc(nMaxCmp+1);
910 strncpyW(tempBuffer,lpszScheme,nMaxCmp);
911 tempBuffer[nMaxCmp]=0;
913 if (nMaxCmp==strlenW(lpszFtp) && !strncmpW(lpszFtp, tempBuffer, nMaxCmp))
914 iScheme=INTERNET_SCHEME_FTP;
915 else if (nMaxCmp==strlenW(lpszGopher) && !strncmpW(lpszGopher, tempBuffer, nMaxCmp))
916 iScheme=INTERNET_SCHEME_GOPHER;
917 else if (nMaxCmp==strlenW(lpszHttp) && !strncmpW(lpszHttp, tempBuffer, nMaxCmp))
918 iScheme=INTERNET_SCHEME_HTTP;
919 else if (nMaxCmp==strlenW(lpszHttps) && !strncmpW(lpszHttps, tempBuffer, nMaxCmp))
920 iScheme=INTERNET_SCHEME_HTTPS;
921 else if (nMaxCmp==strlenW(lpszFile) && !strncmpW(lpszFile, tempBuffer, nMaxCmp))
922 iScheme=INTERNET_SCHEME_FILE;
923 else if (nMaxCmp==strlenW(lpszNews) && !strncmpW(lpszNews, tempBuffer, nMaxCmp))
924 iScheme=INTERNET_SCHEME_NEWS;
925 else if (nMaxCmp==strlenW(lpszMailto) && !strncmpW(lpszMailto, tempBuffer, nMaxCmp))
926 iScheme=INTERNET_SCHEME_MAILTO;
927 else if (nMaxCmp==strlenW(lpszRes) && !strncmpW(lpszRes, tempBuffer, nMaxCmp))
928 iScheme=INTERNET_SCHEME_RES;
933 /***********************************************************************
934 * SetUrlComponentValueW (Internal)
936 * Helper function for InternetCrackUrlW
943 BOOL SetUrlComponentValueW(LPWSTR* lppszComponent, LPDWORD dwComponentLen, LPCWSTR lpszStart, INT len)
945 TRACE("%s (%d)\n", debugstr_wn(lpszStart,len), len);
947 if (*dwComponentLen != 0 || *lppszComponent == NULL)
949 if (*lppszComponent == NULL)
951 *lppszComponent = (LPWSTR)lpszStart;
952 *dwComponentLen = len;
956 INT ncpylen = min((*dwComponentLen)-1, len);
957 strncpyW(*lppszComponent, lpszStart, ncpylen);
958 (*lppszComponent)[ncpylen] = '\0';
959 *dwComponentLen = ncpylen;
966 /***********************************************************************
967 * InternetCrackUrlW (WININET.@)
969 BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
970 LPURL_COMPONENTSW lpUC)
974 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
977 LPWSTR lpszParam = NULL;
978 BOOL bIsAbsolute = FALSE;
979 LPWSTR lpszap = (WCHAR*)lpszUrl;
980 LPWSTR lpszcp = NULL;
981 WCHAR lpszSeparators[3]={';','?',0};
982 WCHAR lpszSlash[2]={'/',0};
984 dwUrlLength=strlenW(lpszUrl);
988 /* Determine if the URI is absolute. */
989 while (*lpszap != '\0')
991 if (isalnumW(*lpszap))
996 if ((*lpszap == ':') && (lpszap - lpszUrl >= 2))
1003 lpszcp = (LPWSTR)lpszUrl; /* Relative url */
1009 /* Parse <params> */
1010 lpszParam = strpbrkW(lpszap, lpszSeparators);
1011 if (lpszParam != NULL)
1013 if (!SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
1014 lpszParam, dwUrlLength-(lpszParam-lpszUrl)))
1020 if (bIsAbsolute) /* Parse <protocol>:[//<net_loc>] */
1023 WCHAR wszAbout[]={'a','b','o','u','t',':',0};
1025 /* Get scheme first. */
1026 lpUC->nScheme = GetInternetSchemeW(lpszUrl, lpszcp - lpszUrl);
1027 if (!SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength,
1028 lpszUrl, lpszcp - lpszUrl))
1031 /* Eat ':' in protocol. */
1034 /* if the scheme is "about", there is no host */
1035 if(strncmpW(wszAbout,lpszUrl, lpszcp - lpszUrl)==0)
1037 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1038 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1039 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
1044 /* Skip over slashes. */
1056 lpszNetLoc = strpbrkW(lpszcp, lpszSlash);
1060 lpszNetLoc = min(lpszNetLoc, lpszParam);
1062 lpszNetLoc = lpszParam;
1064 else if (!lpszNetLoc)
1065 lpszNetLoc = lpszcp + dwUrlLength-(lpszcp-lpszUrl);
1073 /* [<user>[<:password>]@]<host>[:<port>] */
1074 /* First find the user and password if they exist */
1076 lpszHost = strchrW(lpszcp, '@');
1077 if (lpszHost == NULL || lpszHost > lpszNetLoc)
1079 /* username and password not specified. */
1080 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
1081 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
1083 else /* Parse out username and password */
1085 LPWSTR lpszUser = lpszcp;
1086 LPWSTR lpszPasswd = lpszHost;
1088 while (lpszcp < lpszHost)
1091 lpszPasswd = lpszcp;
1096 SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength,
1097 lpszUser, lpszPasswd - lpszUser);
1099 if (lpszPasswd != lpszHost)
1101 SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength,
1102 lpszPasswd == lpszHost ? NULL : lpszPasswd,
1103 lpszHost - lpszPasswd);
1105 lpszcp++; /* Advance to beginning of host */
1108 /* Parse <host><:port> */
1111 lpszPort = lpszNetLoc;
1113 /* special case for res:// URLs: there is no port here, so the host is the
1114 entire string up to the first '/' */
1115 if(lpUC->nScheme==INTERNET_SCHEME_RES)
1117 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1118 lpszHost, lpszPort - lpszHost);
1124 while (lpszcp < lpszNetLoc)
1132 /* If the scheme is "file" and the host is just one letter, it's not a host */
1133 if(lpUC->nScheme==INTERNET_SCHEME_FILE && (lpszPort-lpszHost)==1)
1136 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1142 SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
1143 lpszHost, lpszPort - lpszHost);
1144 if (lpszPort != lpszNetLoc)
1145 lpUC->nPort = atoiW(++lpszPort);
1154 /* Here lpszcp points to:
1156 * <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
1157 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1159 if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam))
1163 /* Only truncate the parameter list if it's already been saved
1164 * in lpUC->lpszExtraInfo.
1166 if (lpszParam && lpUC->dwExtraInfoLength)
1167 len = lpszParam - lpszcp;
1170 /* Leave the parameter list in lpszUrlPath. Strip off any trailing
1171 * newlines if necessary.
1173 LPWSTR lpsznewline = strchrW(lpszcp, '\n');
1174 if (lpsznewline != NULL)
1175 len = lpsznewline - lpszcp;
1177 len = dwUrlLength-(lpszcp-lpszUrl);
1180 if (!SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
1186 lpUC->dwUrlPathLength = 0;
1189 TRACE("%s: host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
1190 debugstr_wn(lpUC->lpszHostName,lpUC->dwHostNameLength),
1191 debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
1192 debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
1197 /***********************************************************************
1198 * InternetAttemptConnect (WININET.@)
1200 * Attempt to make a connection to the internet
1203 * ERROR_SUCCESS on success
1204 * Error value on failure
1207 DWORD WINAPI InternetAttemptConnect(DWORD dwReserved)
1210 return ERROR_SUCCESS;
1214 /***********************************************************************
1215 * InternetCanonicalizeUrlA (WININET.@)
1217 * Escape unsafe characters and spaces
1224 BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
1225 LPDWORD lpdwBufferLength, DWORD dwFlags)
1228 TRACE("%s %p %p %08lx\n",debugstr_a(lpszUrl), lpszBuffer,
1229 lpdwBufferLength, dwFlags);
1231 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1232 dwFlags ^= ICU_NO_ENCODE;
1234 dwFlags |= 0x80000000; /* Don't know what this means */
1236 hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
1238 return (hr == S_OK) ? TRUE : FALSE;
1241 /***********************************************************************
1242 * InternetCanonicalizeUrlW (WININET.@)
1244 * Escape unsafe characters and spaces
1251 BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
1252 LPDWORD lpdwBufferLength, DWORD dwFlags)
1255 TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl), lpszBuffer,
1256 lpdwBufferLength, dwFlags);
1258 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
1259 dwFlags ^= ICU_NO_ENCODE;
1261 dwFlags |= 0x80000000; /* Don't know what this means */
1263 hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
1265 return (hr == S_OK) ? TRUE : FALSE;
1269 /***********************************************************************
1270 * InternetSetStatusCallbackA (WININET.@)
1272 * Sets up a callback function which is called as progress is made
1273 * during an operation.
1276 * Previous callback or NULL on success
1277 * INTERNET_INVALID_STATUS_CALLBACK on failure
1280 INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
1281 HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
1283 INTERNET_STATUS_CALLBACK retVal;
1284 LPWININETAPPINFOA lpwai = (LPWININETAPPINFOA)hInternet;
1286 TRACE("0x%08lx\n", (ULONG)hInternet);
1287 if (lpwai->hdr.htype != WH_HINIT)
1288 return INTERNET_INVALID_STATUS_CALLBACK;
1290 retVal = lpwai->lpfnStatusCB;
1291 lpwai->lpfnStatusCB = lpfnIntCB;
1297 /***********************************************************************
1298 * InternetWriteFile (WININET.@)
1300 * Write data to an open internet file
1307 BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
1308 DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
1310 BOOL retval = FALSE;
1312 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
1318 switch (lpwh->htype)
1321 FIXME("This shouldn't be here! We don't support this kind"
1322 " of connection anymore. Must use NETCON functions,"
1323 " especially if using SSL\n");
1324 nSocket = ((LPWININETHTTPREQA)hFile)->netConnection.socketFD;
1328 nSocket = ((LPWININETFILE)hFile)->nDataSocket;
1337 int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0);
1338 retval = (res >= 0);
1339 *lpdwNumOfBytesWritten = retval ? res : 0;
1346 /***********************************************************************
1347 * InternetReadFile (WININET.@)
1349 * Read data from an open internet file
1356 BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
1357 DWORD dwNumOfBytesToRead, LPDWORD dwNumOfBytesRead)
1359 BOOL retval = FALSE;
1361 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
1368 /* FIXME: this should use NETCON functions! */
1369 switch (lpwh->htype)
1372 if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, lpBuffer,
1373 dwNumOfBytesToRead, 0, (int *)dwNumOfBytesRead))
1375 *dwNumOfBytesRead = 0;
1376 retval = TRUE; /* Under windows, it seems to return 0 even if nothing was read... */
1383 /* FIXME: FTP should use NETCON_ stuff */
1384 nSocket = ((LPWININETFILE)hFile)->nDataSocket;
1387 int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, 0);
1388 retval = (res >= 0);
1389 *dwNumOfBytesRead = retval ? res : 0;
1400 /***********************************************************************
1401 * InternetReadFileExA (WININET.@)
1403 * Read data from an open internet file
1410 BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffer,
1411 DWORD dwFlags, DWORD dwContext)
1417 /***********************************************************************
1418 * InternetReadFileExW (WININET.@)
1420 * Read data from an open internet file
1427 BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
1428 DWORD dwFlags, DWORD dwContext)
1432 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1436 /***********************************************************************
1437 * INET_QueryOptionHelper (internal)
1439 static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
1440 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1442 LPWININETHANDLEHEADER lpwhh;
1443 BOOL bSuccess = FALSE;
1445 TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
1447 if (NULL == hInternet)
1449 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
1453 lpwhh = (LPWININETHANDLEHEADER) hInternet;
1457 case INTERNET_OPTION_HANDLE_TYPE:
1459 ULONG type = lpwhh->htype;
1460 TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type);
1462 if (*lpdwBufferLength < sizeof(ULONG))
1463 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1466 memcpy(lpBuffer, &type, sizeof(ULONG));
1467 *lpdwBufferLength = sizeof(ULONG);
1473 case INTERNET_OPTION_REQUEST_FLAGS:
1476 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags);
1477 if (*lpdwBufferLength < sizeof(ULONG))
1478 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1481 memcpy(lpBuffer, &flags, sizeof(ULONG));
1482 *lpdwBufferLength = sizeof(ULONG);
1488 case INTERNET_OPTION_URL:
1489 case INTERNET_OPTION_DATAFILE_NAME:
1491 ULONG type = lpwhh->htype;
1492 if (type == WH_HHTTPREQ)
1494 LPWININETHTTPREQA lpreq = hInternet;
1497 sprintf(url,"http://%s%s",lpreq->lpszHostName,lpreq->lpszPath);
1498 TRACE("INTERNET_OPTION_URL: %s\n",url);
1499 if (*lpdwBufferLength < strlen(url)+1)
1500 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1505 *lpdwBufferLength=MultiByteToWideChar(CP_ACP,0,url,-1,lpBuffer,*lpdwBufferLength);
1509 memcpy(lpBuffer, url, strlen(url)+1);
1510 *lpdwBufferLength = strlen(url)+1;
1517 case INTERNET_OPTION_HTTP_VERSION:
1520 * Presently hardcoded to 1.1
1522 ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
1523 ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
1529 FIXME("Stub! %ld \n",dwOption);
1536 /***********************************************************************
1537 * InternetQueryOptionW (WININET.@)
1539 * Queries an options on the specified handle
1546 BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
1547 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1549 return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
1552 /***********************************************************************
1553 * InternetQueryOptionA (WININET.@)
1555 * Queries an options on the specified handle
1562 BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
1563 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1565 return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
1569 /***********************************************************************
1570 * InternetSetOptionW (WININET.@)
1572 * Sets an options on the specified handle
1579 BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
1580 LPVOID lpBuffer, DWORD dwBufferLength)
1582 LPWININETHANDLEHEADER lpwhh;
1584 TRACE("0x%08lx\n", dwOption);
1586 if (NULL == hInternet)
1588 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
1592 lpwhh = (LPWININETHANDLEHEADER) hInternet;
1596 case INTERNET_OPTION_HTTP_VERSION:
1598 HTTP_VERSION_INFO* pVersion=(HTTP_VERSION_INFO*)lpBuffer;
1599 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion->dwMajorVersion,pVersion->dwMinorVersion);
1602 case INTERNET_OPTION_ERROR_MASK:
1604 unsigned long flags=*(unsigned long*)lpBuffer;
1605 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
1608 case INTERNET_OPTION_CODEPAGE:
1610 unsigned long codepage=*(unsigned long*)lpBuffer;
1611 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
1614 case INTERNET_OPTION_REQUEST_PRIORITY:
1616 unsigned long priority=*(unsigned long*)lpBuffer;
1617 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
1621 FIXME("Option %ld STUB\n",dwOption);
1622 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
1630 /***********************************************************************
1631 * InternetSetOptionA (WININET.@)
1633 * Sets an options on the specified handle.
1640 BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
1641 LPVOID lpBuffer, DWORD dwBufferLength)
1649 case INTERNET_OPTION_PROXY:
1651 LPINTERNET_PROXY_INFOA pi = (LPINTERNET_PROXY_INFOA) lpBuffer;
1652 LPINTERNET_PROXY_INFOW piw;
1653 DWORD proxlen, prbylen;
1656 proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0);
1657 prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0);
1658 wlen = sizeof(*piw) + proxlen + prbylen;
1659 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
1660 piw = (LPINTERNET_PROXY_INFOW) wbuffer;
1661 piw->dwAccessType = pi->dwAccessType;
1662 prox = (LPWSTR) &piw[1];
1663 prby = &prox[proxlen+1];
1664 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, prox, proxlen);
1665 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, prby, prbylen);
1666 piw->lpszProxy = prox;
1667 piw->lpszProxyBypass = prby;
1670 case INTERNET_OPTION_USER_AGENT:
1671 case INTERNET_OPTION_USERNAME:
1672 case INTERNET_OPTION_PASSWORD:
1673 wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
1675 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
1676 MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
1681 wlen = dwBufferLength;
1684 r = InternetSetOptionW(hInternet,dwOption, wbuffer, wlen);
1686 if( lpBuffer != wbuffer )
1687 HeapFree( GetProcessHeap(), 0, wbuffer );
1693 /***********************************************************************
1694 * InternetSetOptionExA (WININET.@)
1696 BOOL WINAPI InternetSetOptionExA(HINTERNET hInternet, DWORD dwOption,
1697 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
1699 FIXME("Flags %08lx ignored\n", dwFlags);
1700 return InternetSetOptionA( hInternet, dwOption, lpBuffer, dwBufferLength );
1703 /***********************************************************************
1704 * InternetSetOptionExW (WININET.@)
1706 BOOL WINAPI InternetSetOptionExW(HINTERNET hInternet, DWORD dwOption,
1707 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
1709 FIXME("Flags %08lx ignored\n", dwFlags);
1710 if( dwFlags & ~ISO_VALID_FLAGS )
1712 SetLastError( ERROR_INVALID_PARAMETER );
1715 return InternetSetOptionW( hInternet, dwOption, lpBuffer, dwBufferLength );
1719 /***********************************************************************
1720 * InternetCheckConnectionA (WININET.@)
1722 * Pings a requested host to check internet connection
1725 * TRUE on success and FALSE on failure. If a failure then
1726 * ERROR_NOT_CONNECTED is placesd into GetLastError
1729 BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
1732 * this is a kludge which runs the resident ping program and reads the output.
1734 * Anyone have a better idea?
1745 * Crack or set the Address
1747 if (lpszUrl == NULL)
1750 * According to the doc we are supost to use the ip for the next
1751 * server in the WnInet internal server database. I have
1752 * no idea what that is or how to get it.
1754 * So someone needs to implement this.
1756 FIXME("Unimplemented with URL of NULL\n");
1761 URL_COMPONENTSA componets;
1763 ZeroMemory(&componets,sizeof(URL_COMPONENTSA));
1764 componets.lpszHostName = (LPSTR)&host;
1765 componets.dwHostNameLength = 1024;
1767 if (!InternetCrackUrlA(lpszUrl,0,0,&componets))
1770 TRACE("host name : %s\n",componets.lpszHostName);
1774 * Build our ping command
1776 strcpy(command,"ping -w 1 ");
1777 strcat(command,host);
1778 strcat(command," >/dev/null 2>/dev/null");
1780 TRACE("Ping command is : %s\n",command);
1782 status = system(command);
1784 TRACE("Ping returned a code of %i \n",status);
1786 /* Ping return code of 0 indicates success */
1793 SetLastError(ERROR_NOT_CONNECTED);
1799 /***********************************************************************
1800 * InternetCheckConnectionW (WININET.@)
1802 * Pings a requested host to check internet connection
1805 * TRUE on success and FALSE on failure. If a failure then
1806 * ERROR_NOT_CONNECTED is placed into GetLastError
1809 BOOL WINAPI InternetCheckConnectionW(LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
1815 len = lstrlenW(lpszUrl)+1;
1816 if (!(szUrl = (CHAR *)HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR))))
1818 WideCharToMultiByte(CP_ACP, -1, lpszUrl, -1, szUrl, len, NULL, NULL);
1819 rc = InternetCheckConnectionA((LPCSTR)szUrl, dwFlags, dwReserved);
1820 HeapFree(GetProcessHeap(), 0, szUrl);
1826 /**********************************************************
1827 * InternetOpenUrlA (WININET.@)
1832 * handle of connection or NULL on failure
1834 HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
1835 LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
1837 URL_COMPONENTSA urlComponents;
1838 char protocol[32], hostName[MAXHOSTNAME], userName[1024];
1839 char password[1024], path[2048], extra[1024];
1840 HINTERNET client = NULL, client1 = NULL;
1842 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_a(lpszUrl), debugstr_a(lpszHeaders),
1843 dwHeadersLength, dwFlags, dwContext);
1845 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
1846 urlComponents.lpszScheme = protocol;
1847 urlComponents.dwSchemeLength = 32;
1848 urlComponents.lpszHostName = hostName;
1849 urlComponents.dwHostNameLength = MAXHOSTNAME;
1850 urlComponents.lpszUserName = userName;
1851 urlComponents.dwUserNameLength = 1024;
1852 urlComponents.lpszPassword = password;
1853 urlComponents.dwPasswordLength = 1024;
1854 urlComponents.lpszUrlPath = path;
1855 urlComponents.dwUrlPathLength = 2048;
1856 urlComponents.lpszExtraInfo = extra;
1857 urlComponents.dwExtraInfoLength = 1024;
1858 if(!InternetCrackUrlA(lpszUrl, strlen(lpszUrl), 0, &urlComponents))
1860 switch(urlComponents.nScheme) {
1861 case INTERNET_SCHEME_FTP:
1862 if(urlComponents.nPort == 0)
1863 urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
1864 client = InternetConnectA(hInternet, hostName, urlComponents.nPort,
1865 userName, password, INTERNET_SERVICE_FTP, dwFlags, dwContext);
1866 return FtpOpenFileA(client, path, GENERIC_READ, dwFlags, dwContext);
1867 case INTERNET_SCHEME_HTTP:
1868 case INTERNET_SCHEME_HTTPS:
1870 LPCSTR accept[2] = { "*/*", NULL };
1871 char *hostreq=(char*)malloc(strlen(hostName)+9);
1872 sprintf(hostreq, "Host: %s\r\n", hostName);
1873 if(urlComponents.nPort == 0) {
1874 if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
1875 urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
1877 urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
1879 client = InternetConnectA(hInternet, hostName, urlComponents.nPort, userName,
1880 password, INTERNET_SERVICE_HTTP, dwFlags, dwContext);
1883 client1 = HttpOpenRequestA(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
1884 if(client1 == NULL) {
1885 InternetCloseHandle(client);
1888 HttpAddRequestHeadersA(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
1889 if(!HttpSendRequestA(client1, NULL, 0, NULL, 0)) {
1890 InternetCloseHandle(client1);
1891 InternetCloseHandle(client);
1896 case INTERNET_SCHEME_GOPHER:
1897 /* gopher doesn't seem to be implemented in wine, but it's supposed
1898 * to be supported by InternetOpenUrlA. */
1905 /**********************************************************
1906 * InternetOpenUrlW (WININET.@)
1911 * handle of connection or NULL on failure
1913 HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
1914 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
1916 HINTERNET rc = (HINTERNET)NULL;
1918 INT lenUrl = lstrlenW(lpszUrl)+1;
1919 INT lenHeaders = lstrlenW(lpszHeaders)+1;
1920 CHAR *szUrl = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(CHAR));
1921 CHAR *szHeaders = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(CHAR));
1923 if (!szUrl || !szHeaders)
1926 HeapFree(GetProcessHeap(), 0, szUrl);
1928 HeapFree(GetProcessHeap(), 0, szHeaders);
1929 return (HINTERNET)NULL;
1932 WideCharToMultiByte(CP_ACP, -1, lpszUrl, -1, szUrl, lenUrl,
1934 WideCharToMultiByte(CP_ACP, -1, lpszHeaders, -1, szHeaders, lenHeaders,
1937 rc = InternetOpenUrlA(hInternet, szUrl, szHeaders,
1938 dwHeadersLength, dwFlags, dwContext);
1940 HeapFree(GetProcessHeap(), 0, szUrl);
1941 HeapFree(GetProcessHeap(), 0, szHeaders);
1947 /***********************************************************************
1948 * INTERNET_SetLastError (internal)
1950 * Set last thread specific error
1955 void INTERNET_SetLastError(DWORD dwError)
1957 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
1959 SetLastError(dwError);
1961 lpwite->dwError = dwError;
1965 /***********************************************************************
1966 * INTERNET_GetLastError (internal)
1968 * Get last thread specific error
1973 DWORD INTERNET_GetLastError()
1975 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
1976 return lpwite->dwError;
1980 /***********************************************************************
1981 * INTERNET_WorkerThreadFunc (internal)
1983 * Worker thread execution function
1988 DWORD INTERNET_WorkerThreadFunc(LPVOID *lpvParam)
1995 INTERNET_ExecuteWork();
1998 dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
2000 if (dwWaitRes == WAIT_OBJECT_0 + 1)
2001 INTERNET_ExecuteWork();
2005 InterlockedIncrement(&dwNumIdleThreads);
2008 InterlockedDecrement(&dwNumIdleThreads);
2009 InterlockedDecrement(&dwNumThreads);
2010 TRACE("Worker thread exiting\n");
2015 /***********************************************************************
2016 * INTERNET_InsertWorkRequest (internal)
2018 * Insert work request into queue
2023 BOOL INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest)
2025 BOOL bSuccess = FALSE;
2026 LPWORKREQUEST lpNewRequest;
2030 lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
2033 memcpy(lpNewRequest, lpWorkRequest, sizeof(WORKREQUEST));
2034 lpNewRequest->prev = NULL;
2036 EnterCriticalSection(&csQueue);
2038 lpNewRequest->next = lpWorkQueueTail;
2039 if (lpWorkQueueTail)
2040 lpWorkQueueTail->prev = lpNewRequest;
2041 lpWorkQueueTail = lpNewRequest;
2042 if (!lpHeadWorkQueue)
2043 lpHeadWorkQueue = lpWorkQueueTail;
2045 LeaveCriticalSection(&csQueue);
2048 InterlockedIncrement(&dwNumJobs);
2055 /***********************************************************************
2056 * INTERNET_GetWorkRequest (internal)
2058 * Retrieves work request from queue
2063 BOOL INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest)
2065 BOOL bSuccess = FALSE;
2066 LPWORKREQUEST lpRequest = NULL;
2070 EnterCriticalSection(&csQueue);
2072 if (lpHeadWorkQueue)
2074 lpRequest = lpHeadWorkQueue;
2075 lpHeadWorkQueue = lpHeadWorkQueue->prev;
2076 if (lpRequest == lpWorkQueueTail)
2077 lpWorkQueueTail = lpHeadWorkQueue;
2080 LeaveCriticalSection(&csQueue);
2084 memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
2085 HeapFree(GetProcessHeap(), 0, lpRequest);
2087 InterlockedDecrement(&dwNumJobs);
2094 /***********************************************************************
2095 * INTERNET_AsyncCall (internal)
2097 * Retrieves work request from queue
2102 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
2106 BOOL bSuccess = FALSE;
2110 if (InterlockedDecrement(&dwNumIdleThreads) < 0)
2112 InterlockedIncrement(&dwNumIdleThreads);
2114 if (InterlockedIncrement(&dwNumThreads) > MAX_WORKER_THREADS ||
2115 !(hThread = CreateThread(NULL, 0,
2116 (LPTHREAD_START_ROUTINE)INTERNET_WorkerThreadFunc, NULL, 0, &dwTID)))
2118 InterlockedDecrement(&dwNumThreads);
2119 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
2123 TRACE("Created new thread\n");
2127 INTERNET_InsertWorkRequest(lpWorkRequest);
2128 SetEvent(hWorkEvent);
2136 /***********************************************************************
2137 * INTERNET_ExecuteWork (internal)
2142 VOID INTERNET_ExecuteWork()
2144 WORKREQUEST workRequest;
2148 if (INTERNET_GetWorkRequest(&workRequest))
2150 TRACE("Got work %d\n", workRequest.asyncall);
2151 switch (workRequest.asyncall)
2154 FTP_FtpPutFileA((HINTERNET)workRequest.HFTPSESSION, (LPCSTR)workRequest.LPSZLOCALFILE,
2155 (LPCSTR)workRequest.LPSZNEWREMOTEFILE, workRequest.DWFLAGS, workRequest.DWCONTEXT);
2156 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZLOCALFILE);
2157 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZNEWREMOTEFILE);
2160 case FTPSETCURRENTDIRECTORYA:
2161 FTP_FtpSetCurrentDirectoryA((HINTERNET)workRequest.HFTPSESSION,
2162 (LPCSTR)workRequest.LPSZDIRECTORY);
2163 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDIRECTORY);
2166 case FTPCREATEDIRECTORYA:
2167 FTP_FtpCreateDirectoryA((HINTERNET)workRequest.HFTPSESSION,
2168 (LPCSTR)workRequest.LPSZDIRECTORY);
2169 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDIRECTORY);
2172 case FTPFINDFIRSTFILEA:
2173 FTP_FtpFindFirstFileA((HINTERNET)workRequest.HFTPSESSION,
2174 (LPCSTR)workRequest.LPSZSEARCHFILE,
2175 (LPWIN32_FIND_DATAA)workRequest.LPFINDFILEDATA, workRequest.DWFLAGS,
2176 workRequest.DWCONTEXT);
2177 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZSEARCHFILE);
2180 case FTPGETCURRENTDIRECTORYA:
2181 FTP_FtpGetCurrentDirectoryA((HINTERNET)workRequest.HFTPSESSION,
2182 (LPSTR)workRequest.LPSZDIRECTORY, (LPDWORD)workRequest.LPDWDIRECTORY);
2186 FTP_FtpOpenFileA((HINTERNET)workRequest.HFTPSESSION,
2187 (LPCSTR)workRequest.LPSZFILENAME,
2188 workRequest.FDWACCESS,
2189 workRequest.DWFLAGS,
2190 workRequest.DWCONTEXT);
2191 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZFILENAME);
2195 FTP_FtpGetFileA((HINTERNET)workRequest.HFTPSESSION,
2196 (LPCSTR)workRequest.LPSZREMOTEFILE,
2197 (LPCSTR)workRequest.LPSZNEWFILE,
2198 (BOOL)workRequest.FFAILIFEXISTS,
2199 workRequest.DWLOCALFLAGSATTRIBUTE,
2200 workRequest.DWFLAGS,
2201 workRequest.DWCONTEXT);
2202 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZREMOTEFILE);
2203 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZNEWFILE);
2206 case FTPDELETEFILEA:
2207 FTP_FtpDeleteFileA((HINTERNET)workRequest.HFTPSESSION,
2208 (LPCSTR)workRequest.LPSZFILENAME);
2209 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZFILENAME);
2212 case FTPREMOVEDIRECTORYA:
2213 FTP_FtpRemoveDirectoryA((HINTERNET)workRequest.HFTPSESSION,
2214 (LPCSTR)workRequest.LPSZDIRECTORY);
2215 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDIRECTORY);
2218 case FTPRENAMEFILEA:
2219 FTP_FtpRenameFileA((HINTERNET)workRequest.HFTPSESSION,
2220 (LPCSTR)workRequest.LPSZSRCFILE,
2221 (LPCSTR)workRequest.LPSZDESTFILE);
2222 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZSRCFILE);
2223 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDESTFILE);
2226 case INTERNETFINDNEXTA:
2227 INTERNET_FindNextFileA((HINTERNET)workRequest.HFTPSESSION,
2228 (LPWIN32_FIND_DATAA)workRequest.LPFINDFILEDATA);
2231 case HTTPSENDREQUESTA:
2232 HTTP_HttpSendRequestA((HINTERNET)workRequest.HFTPSESSION,
2233 (LPCSTR)workRequest.LPSZHEADER,
2234 workRequest.DWHEADERLENGTH,
2235 (LPVOID)workRequest.LPOPTIONAL,
2236 workRequest.DWOPTIONALLENGTH);
2237 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZHEADER);
2240 case HTTPOPENREQUESTA:
2241 HTTP_HttpOpenRequestA((HINTERNET)workRequest.HFTPSESSION,
2242 (LPCSTR)workRequest.LPSZVERB,
2243 (LPCSTR)workRequest.LPSZOBJECTNAME,
2244 (LPCSTR)workRequest.LPSZVERSION,
2245 (LPCSTR)workRequest.LPSZREFERRER,
2246 (LPCSTR*)workRequest.LPSZACCEPTTYPES,
2247 workRequest.DWFLAGS,
2248 workRequest.DWCONTEXT);
2249 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZVERB);
2250 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZOBJECTNAME);
2251 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZVERSION);
2252 HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZREFERRER);
2256 SendAsyncCallbackInt((LPWININETAPPINFOA)workRequest.param1,
2257 (HINTERNET)workRequest.param2, workRequest.param3,
2258 workRequest.param4, (LPVOID)workRequest.param5,
2259 workRequest.param6);
2266 /***********************************************************************
2267 * INTERNET_GetResponseBuffer
2272 LPSTR INTERNET_GetResponseBuffer()
2274 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2276 return lpwite->response;
2279 /***********************************************************************
2280 * INTERNET_GetNextLine (internal)
2282 * Parse next line in directory string listing
2285 * Pointer to beginning of next line
2290 LPSTR INTERNET_GetNextLine(INT nSocket, LPSTR lpszBuffer, LPDWORD dwBuffer)
2294 BOOL bSuccess = FALSE;
2300 FD_SET(nSocket, &infd);
2301 tv.tv_sec=RESPONSE_TIMEOUT;
2304 while (nRecv < *dwBuffer)
2306 if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0)
2308 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
2310 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
2314 if (lpszBuffer[nRecv] == '\n')
2319 if (lpszBuffer[nRecv] != '\r')
2324 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
2332 lpszBuffer[nRecv] = '\0';
2333 *dwBuffer = nRecv - 1;
2334 TRACE(":%d %s\n", nRecv, lpszBuffer);
2343 /***********************************************************************
2346 BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
2347 LPDWORD lpdwNumberOfBytesAvailble,
2348 DWORD dwFlags, DWORD dwConext)
2350 LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hFile;
2357 SetLastError(ERROR_NO_MORE_FILES);
2361 TRACE("--> %p %i\n",lpwhr,lpwhr->hdr.htype);
2363 switch (lpwhr->hdr.htype)
2366 if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, buffer,
2367 4048, MSG_PEEK, (int *)lpdwNumberOfBytesAvailble))
2369 SetLastError(ERROR_NO_MORE_FILES);
2377 FIXME("unsupported file type\n");
2381 TRACE("<-- %i\n",retval);
2386 /***********************************************************************
2389 BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
2396 BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
2403 /***********************************************************************
2406 * On windows this function is supposed to dial the default internet
2407 * connection. We don't want to have Wine dial out to the internet so
2408 * we return TRUE by default. It might be nice to check if we are connected.
2415 BOOL WINAPI InternetAutodial(DWORD dwFlags, HWND hwndParent)
2419 /* Tell that we are connected to the internet. */
2423 /***********************************************************************
2424 * InternetAutodialHangup
2426 * Hangs up an connection made with InternetAutodial
2435 BOOL WINAPI InternetAutodialHangup(DWORD dwReserved)
2439 /* we didn't dial, we don't disconnect */
2443 /***********************************************************************
2445 * InternetCombineUrlA
2447 * Combine a base URL with a relative URL
2455 BOOL WINAPI InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl,
2456 LPSTR lpszBuffer, LPDWORD lpdwBufferLength,
2460 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
2461 dwFlags ^= ICU_NO_ENCODE;
2462 hr=UrlCombineA(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
2467 /***********************************************************************
2469 * InternetCombineUrlW
2471 * Combine a base URL with a relative URL
2479 BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl,
2480 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength,
2484 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
2485 dwFlags ^= ICU_NO_ENCODE;
2486 hr=UrlCombineW(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
2491 /***********************************************************************
2493 * InternetCreateUrlA
2500 BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags,
2501 LPSTR lpszUrl, LPDWORD lpdwUrlLength)
2507 /***********************************************************************
2509 * InternetCreateUrlW
2516 BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
2517 LPWSTR lpszUrl, LPDWORD lpdwUrlLength)