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 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 = 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;
1302 /***********************************************************************
1303 * InternetWriteFile (WININET.@)
1305 * Write data to an open internet file
1312 BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
1313 DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
1315 BOOL retval = FALSE;
1317 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
1323 switch (lpwh->htype)
1326 FIXME("This shouldn't be here! We don't support this kind"
1327 " of connection anymore. Must use NETCON functions,"
1328 " especially if using SSL\n");
1329 nSocket = ((LPWININETHTTPREQA)hFile)->netConnection.socketFD;
1333 nSocket = ((LPWININETFILE)hFile)->nDataSocket;
1342 int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0);
1343 retval = (res >= 0);
1344 *lpdwNumOfBytesWritten = retval ? res : 0;
1351 /***********************************************************************
1352 * InternetReadFile (WININET.@)
1354 * Read data from an open internet file
1361 BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
1362 DWORD dwNumOfBytesToRead, LPDWORD dwNumOfBytesRead)
1364 BOOL retval = FALSE;
1366 LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
1373 /* FIXME: this should use NETCON functions! */
1374 switch (lpwh->htype)
1377 if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, lpBuffer,
1378 dwNumOfBytesToRead, 0, (int *)dwNumOfBytesRead))
1380 *dwNumOfBytesRead = 0;
1381 retval = TRUE; /* Under windows, it seems to return 0 even if nothing was read... */
1388 /* FIXME: FTP should use NETCON_ stuff */
1389 nSocket = ((LPWININETFILE)hFile)->nDataSocket;
1392 int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, 0);
1393 retval = (res >= 0);
1394 *dwNumOfBytesRead = retval ? res : 0;
1405 /***********************************************************************
1406 * InternetReadFileExA (WININET.@)
1408 * Read data from an open internet file
1415 BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffer,
1416 DWORD dwFlags, DWORD dwContext)
1422 /***********************************************************************
1423 * InternetReadFileExW (WININET.@)
1425 * Read data from an open internet file
1432 BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
1433 DWORD dwFlags, DWORD dwContext)
1437 INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
1441 /***********************************************************************
1442 * INET_QueryOptionHelper (internal)
1444 static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
1445 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1447 LPWININETHANDLEHEADER lpwhh;
1448 BOOL bSuccess = FALSE;
1450 TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
1452 if (NULL == hInternet)
1454 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
1458 lpwhh = (LPWININETHANDLEHEADER) hInternet;
1462 case INTERNET_OPTION_HANDLE_TYPE:
1464 ULONG type = lpwhh->htype;
1465 TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type);
1467 if (*lpdwBufferLength < sizeof(ULONG))
1468 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1471 memcpy(lpBuffer, &type, sizeof(ULONG));
1472 *lpdwBufferLength = sizeof(ULONG);
1478 case INTERNET_OPTION_REQUEST_FLAGS:
1481 TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags);
1482 if (*lpdwBufferLength < sizeof(ULONG))
1483 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1486 memcpy(lpBuffer, &flags, sizeof(ULONG));
1487 *lpdwBufferLength = sizeof(ULONG);
1493 case INTERNET_OPTION_URL:
1494 case INTERNET_OPTION_DATAFILE_NAME:
1496 ULONG type = lpwhh->htype;
1497 if (type == WH_HHTTPREQ)
1499 LPWININETHTTPREQA lpreq = hInternet;
1502 sprintf(url,"http://%s%s",lpreq->lpszHostName,lpreq->lpszPath);
1503 TRACE("INTERNET_OPTION_URL: %s\n",url);
1504 if (*lpdwBufferLength < strlen(url)+1)
1505 INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
1510 *lpdwBufferLength=MultiByteToWideChar(CP_ACP,0,url,-1,lpBuffer,*lpdwBufferLength);
1514 memcpy(lpBuffer, url, strlen(url)+1);
1515 *lpdwBufferLength = strlen(url)+1;
1522 case INTERNET_OPTION_HTTP_VERSION:
1525 * Presently hardcoded to 1.1
1527 ((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
1528 ((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
1534 FIXME("Stub! %ld \n",dwOption);
1541 /***********************************************************************
1542 * InternetQueryOptionW (WININET.@)
1544 * Queries an options on the specified handle
1551 BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
1552 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1554 return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
1557 /***********************************************************************
1558 * InternetQueryOptionA (WININET.@)
1560 * Queries an options on the specified handle
1567 BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
1568 LPVOID lpBuffer, LPDWORD lpdwBufferLength)
1570 return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
1574 /***********************************************************************
1575 * InternetSetOptionW (WININET.@)
1577 * Sets an options on the specified handle
1584 BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
1585 LPVOID lpBuffer, DWORD dwBufferLength)
1587 LPWININETHANDLEHEADER lpwhh;
1589 TRACE("0x%08lx\n", dwOption);
1591 if (NULL == hInternet)
1593 INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
1597 lpwhh = (LPWININETHANDLEHEADER) hInternet;
1601 case INTERNET_OPTION_HTTP_VERSION:
1603 HTTP_VERSION_INFO* pVersion=(HTTP_VERSION_INFO*)lpBuffer;
1604 FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion->dwMajorVersion,pVersion->dwMinorVersion);
1607 case INTERNET_OPTION_ERROR_MASK:
1609 unsigned long flags=*(unsigned long*)lpBuffer;
1610 FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
1613 case INTERNET_OPTION_CODEPAGE:
1615 unsigned long codepage=*(unsigned long*)lpBuffer;
1616 FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
1619 case INTERNET_OPTION_REQUEST_PRIORITY:
1621 unsigned long priority=*(unsigned long*)lpBuffer;
1622 FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
1626 FIXME("Option %ld STUB\n",dwOption);
1627 INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
1635 /***********************************************************************
1636 * InternetSetOptionA (WININET.@)
1638 * Sets an options on the specified handle.
1645 BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
1646 LPVOID lpBuffer, DWORD dwBufferLength)
1654 case INTERNET_OPTION_PROXY:
1656 LPINTERNET_PROXY_INFOA pi = (LPINTERNET_PROXY_INFOA) lpBuffer;
1657 LPINTERNET_PROXY_INFOW piw;
1658 DWORD proxlen, prbylen;
1661 proxlen = MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, NULL, 0);
1662 prbylen= MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, NULL, 0);
1663 wlen = sizeof(*piw) + proxlen + prbylen;
1664 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
1665 piw = (LPINTERNET_PROXY_INFOW) wbuffer;
1666 piw->dwAccessType = pi->dwAccessType;
1667 prox = (LPWSTR) &piw[1];
1668 prby = &prox[proxlen+1];
1669 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxy, -1, prox, proxlen);
1670 MultiByteToWideChar( CP_ACP, 0, pi->lpszProxyBypass, -1, prby, prbylen);
1671 piw->lpszProxy = prox;
1672 piw->lpszProxyBypass = prby;
1675 case INTERNET_OPTION_USER_AGENT:
1676 case INTERNET_OPTION_USERNAME:
1677 case INTERNET_OPTION_PASSWORD:
1678 wlen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
1680 wbuffer = HeapAlloc( GetProcessHeap(), 0, wlen*sizeof(WCHAR) );
1681 MultiByteToWideChar( CP_ACP, 0, lpBuffer, dwBufferLength,
1686 wlen = dwBufferLength;
1689 r = InternetSetOptionW(hInternet,dwOption, wbuffer, wlen);
1691 if( lpBuffer != wbuffer )
1692 HeapFree( GetProcessHeap(), 0, wbuffer );
1698 /***********************************************************************
1699 * InternetSetOptionExA (WININET.@)
1701 BOOL WINAPI InternetSetOptionExA(HINTERNET hInternet, DWORD dwOption,
1702 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
1704 FIXME("Flags %08lx ignored\n", dwFlags);
1705 return InternetSetOptionA( hInternet, dwOption, lpBuffer, dwBufferLength );
1708 /***********************************************************************
1709 * InternetSetOptionExW (WININET.@)
1711 BOOL WINAPI InternetSetOptionExW(HINTERNET hInternet, DWORD dwOption,
1712 LPVOID lpBuffer, DWORD dwBufferLength, DWORD dwFlags)
1714 FIXME("Flags %08lx ignored\n", dwFlags);
1715 if( dwFlags & ~ISO_VALID_FLAGS )
1717 SetLastError( ERROR_INVALID_PARAMETER );
1720 return InternetSetOptionW( hInternet, dwOption, lpBuffer, dwBufferLength );
1724 /***********************************************************************
1725 * InternetCheckConnectionA (WININET.@)
1727 * Pings a requested host to check internet connection
1730 * TRUE on success and FALSE on failure. If a failure then
1731 * ERROR_NOT_CONNECTED is placesd into GetLastError
1734 BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
1737 * this is a kludge which runs the resident ping program and reads the output.
1739 * Anyone have a better idea?
1750 * Crack or set the Address
1752 if (lpszUrl == NULL)
1755 * According to the doc we are supost to use the ip for the next
1756 * server in the WnInet internal server database. I have
1757 * no idea what that is or how to get it.
1759 * So someone needs to implement this.
1761 FIXME("Unimplemented with URL of NULL\n");
1766 URL_COMPONENTSA componets;
1768 ZeroMemory(&componets,sizeof(URL_COMPONENTSA));
1769 componets.lpszHostName = (LPSTR)&host;
1770 componets.dwHostNameLength = 1024;
1772 if (!InternetCrackUrlA(lpszUrl,0,0,&componets))
1775 TRACE("host name : %s\n",componets.lpszHostName);
1779 * Build our ping command
1781 strcpy(command,"ping -w 1 ");
1782 strcat(command,host);
1783 strcat(command," >/dev/null 2>/dev/null");
1785 TRACE("Ping command is : %s\n",command);
1787 status = system(command);
1789 TRACE("Ping returned a code of %i \n",status);
1791 /* Ping return code of 0 indicates success */
1798 SetLastError(ERROR_NOT_CONNECTED);
1804 /***********************************************************************
1805 * InternetCheckConnectionW (WININET.@)
1807 * Pings a requested host to check internet connection
1810 * TRUE on success and FALSE on failure. If a failure then
1811 * ERROR_NOT_CONNECTED is placed into GetLastError
1814 BOOL WINAPI InternetCheckConnectionW(LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
1820 len = WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, NULL, 0, NULL, NULL);
1821 if (!(szUrl = (CHAR *)HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR))))
1823 WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, szUrl, len, NULL, NULL);
1824 rc = InternetCheckConnectionA((LPCSTR)szUrl, dwFlags, dwReserved);
1825 HeapFree(GetProcessHeap(), 0, szUrl);
1831 /**********************************************************
1832 * InternetOpenUrlA (WININET.@)
1837 * handle of connection or NULL on failure
1839 HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
1840 LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
1842 URL_COMPONENTSA urlComponents;
1843 char protocol[32], hostName[MAXHOSTNAME], userName[1024];
1844 char password[1024], path[2048], extra[1024];
1845 HINTERNET client = NULL, client1 = NULL;
1847 TRACE("(%p, %s, %s, %08lx, %08lx, %08lx\n", hInternet, debugstr_a(lpszUrl), debugstr_a(lpszHeaders),
1848 dwHeadersLength, dwFlags, dwContext);
1850 urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
1851 urlComponents.lpszScheme = protocol;
1852 urlComponents.dwSchemeLength = 32;
1853 urlComponents.lpszHostName = hostName;
1854 urlComponents.dwHostNameLength = MAXHOSTNAME;
1855 urlComponents.lpszUserName = userName;
1856 urlComponents.dwUserNameLength = 1024;
1857 urlComponents.lpszPassword = password;
1858 urlComponents.dwPasswordLength = 1024;
1859 urlComponents.lpszUrlPath = path;
1860 urlComponents.dwUrlPathLength = 2048;
1861 urlComponents.lpszExtraInfo = extra;
1862 urlComponents.dwExtraInfoLength = 1024;
1863 if(!InternetCrackUrlA(lpszUrl, strlen(lpszUrl), 0, &urlComponents))
1865 switch(urlComponents.nScheme) {
1866 case INTERNET_SCHEME_FTP:
1867 if(urlComponents.nPort == 0)
1868 urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
1869 client = InternetConnectA(hInternet, hostName, urlComponents.nPort,
1870 userName, password, INTERNET_SERVICE_FTP, dwFlags, dwContext);
1871 return FtpOpenFileA(client, path, GENERIC_READ, dwFlags, dwContext);
1872 case INTERNET_SCHEME_HTTP:
1873 case INTERNET_SCHEME_HTTPS:
1875 LPCSTR accept[2] = { "*/*", NULL };
1876 if(urlComponents.nPort == 0) {
1877 if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
1878 urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
1880 urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
1882 client = InternetConnectA(hInternet, hostName, urlComponents.nPort, userName,
1883 password, INTERNET_SERVICE_HTTP, dwFlags, dwContext);
1886 client1 = HttpOpenRequestA(client, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
1887 if(client1 == NULL) {
1888 InternetCloseHandle(client);
1891 HttpAddRequestHeadersA(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
1892 if(!HttpSendRequestA(client1, NULL, 0, NULL, 0)) {
1893 InternetCloseHandle(client1);
1894 InternetCloseHandle(client);
1899 case INTERNET_SCHEME_GOPHER:
1900 /* gopher doesn't seem to be implemented in wine, but it's supposed
1901 * to be supported by InternetOpenUrlA. */
1908 /**********************************************************
1909 * InternetOpenUrlW (WININET.@)
1914 * handle of connection or NULL on failure
1916 HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
1917 LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
1919 HINTERNET rc = (HINTERNET)NULL;
1921 INT lenUrl = WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, NULL, 0, NULL, NULL);
1922 INT lenHeaders = WideCharToMultiByte(CP_ACP, 0, lpszHeaders, -1, NULL, 0, NULL, NULL);
1923 CHAR *szUrl = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenUrl*sizeof(CHAR));
1924 CHAR *szHeaders = (CHAR *)HeapAlloc(GetProcessHeap(), 0, lenHeaders*sizeof(CHAR));
1926 if (!szUrl || !szHeaders)
1929 HeapFree(GetProcessHeap(), 0, szUrl);
1931 HeapFree(GetProcessHeap(), 0, szHeaders);
1932 return (HINTERNET)NULL;
1935 WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, szUrl, lenUrl,
1937 WideCharToMultiByte(CP_ACP, 0, lpszHeaders, -1, szHeaders, lenHeaders,
1940 rc = InternetOpenUrlA(hInternet, szUrl, szHeaders,
1941 dwHeadersLength, dwFlags, dwContext);
1943 HeapFree(GetProcessHeap(), 0, szUrl);
1944 HeapFree(GetProcessHeap(), 0, szHeaders);
1950 /***********************************************************************
1951 * INTERNET_SetLastError (internal)
1953 * Set last thread specific error
1958 void INTERNET_SetLastError(DWORD dwError)
1960 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
1962 SetLastError(dwError);
1964 lpwite->dwError = dwError;
1968 /***********************************************************************
1969 * INTERNET_GetLastError (internal)
1971 * Get last thread specific error
1976 DWORD INTERNET_GetLastError()
1978 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
1979 return lpwite->dwError;
1983 /***********************************************************************
1984 * INTERNET_WorkerThreadFunc (internal)
1986 * Worker thread execution function
1991 DWORD INTERNET_WorkerThreadFunc(LPVOID *lpvParam)
1998 INTERNET_ExecuteWork();
2001 dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
2003 if (dwWaitRes == WAIT_OBJECT_0 + 1)
2004 INTERNET_ExecuteWork();
2008 InterlockedIncrement(&dwNumIdleThreads);
2011 InterlockedDecrement(&dwNumIdleThreads);
2012 InterlockedDecrement(&dwNumThreads);
2013 TRACE("Worker thread exiting\n");
2018 /***********************************************************************
2019 * INTERNET_InsertWorkRequest (internal)
2021 * Insert work request into queue
2026 BOOL INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest)
2028 BOOL bSuccess = FALSE;
2029 LPWORKREQUEST lpNewRequest;
2033 lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
2036 memcpy(lpNewRequest, lpWorkRequest, sizeof(WORKREQUEST));
2037 lpNewRequest->prev = NULL;
2039 EnterCriticalSection(&csQueue);
2041 lpNewRequest->next = lpWorkQueueTail;
2042 if (lpWorkQueueTail)
2043 lpWorkQueueTail->prev = lpNewRequest;
2044 lpWorkQueueTail = lpNewRequest;
2045 if (!lpHeadWorkQueue)
2046 lpHeadWorkQueue = lpWorkQueueTail;
2048 LeaveCriticalSection(&csQueue);
2051 InterlockedIncrement(&dwNumJobs);
2058 /***********************************************************************
2059 * INTERNET_GetWorkRequest (internal)
2061 * Retrieves work request from queue
2066 BOOL INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest)
2068 BOOL bSuccess = FALSE;
2069 LPWORKREQUEST lpRequest = NULL;
2073 EnterCriticalSection(&csQueue);
2075 if (lpHeadWorkQueue)
2077 lpRequest = lpHeadWorkQueue;
2078 lpHeadWorkQueue = lpHeadWorkQueue->prev;
2079 if (lpRequest == lpWorkQueueTail)
2080 lpWorkQueueTail = lpHeadWorkQueue;
2083 LeaveCriticalSection(&csQueue);
2087 memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
2088 HeapFree(GetProcessHeap(), 0, lpRequest);
2090 InterlockedDecrement(&dwNumJobs);
2097 /***********************************************************************
2098 * INTERNET_AsyncCall (internal)
2100 * Retrieves work request from queue
2105 BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
2109 BOOL bSuccess = FALSE;
2113 if (InterlockedDecrement(&dwNumIdleThreads) < 0)
2115 InterlockedIncrement(&dwNumIdleThreads);
2117 if (InterlockedIncrement(&dwNumThreads) > MAX_WORKER_THREADS ||
2118 !(hThread = CreateThread(NULL, 0,
2119 (LPTHREAD_START_ROUTINE)INTERNET_WorkerThreadFunc, NULL, 0, &dwTID)))
2121 InterlockedDecrement(&dwNumThreads);
2122 INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
2126 TRACE("Created new thread\n");
2130 INTERNET_InsertWorkRequest(lpWorkRequest);
2131 SetEvent(hWorkEvent);
2139 /***********************************************************************
2140 * INTERNET_ExecuteWork (internal)
2145 VOID INTERNET_ExecuteWork()
2147 WORKREQUEST workRequest;
2151 if (!INTERNET_GetWorkRequest(&workRequest))
2153 TRACE("Got work %d\n", workRequest.asyncall);
2154 switch (workRequest.asyncall)
2158 struct WORKREQ_FTPPUTFILEA *req = &workRequest.u.FtpPutFileA;
2160 FTP_FtpPutFileA(workRequest.handle, req->lpszLocalFile,
2161 req->lpszNewRemoteFile, req->dwFlags, req->dwContext);
2163 HeapFree(GetProcessHeap(), 0, req->lpszLocalFile);
2164 HeapFree(GetProcessHeap(), 0, req->lpszNewRemoteFile);
2168 case FTPSETCURRENTDIRECTORYA:
2170 struct WORKREQ_FTPSETCURRENTDIRECTORYA *req;
2172 req = &workRequest.u.FtpSetCurrentDirectoryA;
2173 FTP_FtpSetCurrentDirectoryA(workRequest.handle, req->lpszDirectory);
2174 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
2178 case FTPCREATEDIRECTORYA:
2180 struct WORKREQ_FTPCREATEDIRECTORYA *req;
2182 req = &workRequest.u.FtpCreateDirectoryA;
2183 FTP_FtpCreateDirectoryA(workRequest.handle, req->lpszDirectory);
2184 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
2188 case FTPFINDFIRSTFILEA:
2190 struct WORKREQ_FTPFINDFIRSTFILEA *req;
2192 req = &workRequest.u.FtpFindFirstFileA;
2193 FTP_FtpFindFirstFileA(workRequest.handle, req->lpszSearchFile,
2194 req->lpFindFileData, req->dwFlags, req->dwContext);
2195 HeapFree(GetProcessHeap(), 0, req->lpszSearchFile);
2199 case FTPGETCURRENTDIRECTORYA:
2201 struct WORKREQ_FTPGETCURRENTDIRECTORYA *req;
2203 req = &workRequest.u.FtpGetCurrentDirectoryA;
2204 FTP_FtpGetCurrentDirectoryA(workRequest.handle,
2205 req->lpszDirectory, req->lpdwDirectory);
2211 struct WORKREQ_FTPOPENFILEA *req = &workRequest.u.FtpOpenFileA;
2213 FTP_FtpOpenFileA(workRequest.handle, req->lpszFilename,
2214 req->dwAccess, req->dwFlags, req->dwContext);
2215 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
2221 struct WORKREQ_FTPGETFILEA *req = &workRequest.u.FtpGetFileA;
2223 FTP_FtpGetFileA(workRequest.handle, req->lpszRemoteFile,
2224 req->lpszNewFile, req->fFailIfExists,
2225 req->dwLocalFlagsAttribute, req->dwFlags, req->dwContext);
2226 HeapFree(GetProcessHeap(), 0, req->lpszRemoteFile);
2227 HeapFree(GetProcessHeap(), 0, req->lpszNewFile);
2231 case FTPDELETEFILEA:
2233 struct WORKREQ_FTPDELETEFILEA *req = &workRequest.u.FtpDeleteFileA;
2235 FTP_FtpDeleteFileA(workRequest.handle, req->lpszFilename);
2236 HeapFree(GetProcessHeap(), 0, req->lpszFilename);
2240 case FTPREMOVEDIRECTORYA:
2242 struct WORKREQ_FTPREMOVEDIRECTORYA *req;
2244 req = &workRequest.u.FtpRemoveDirectoryA;
2245 FTP_FtpRemoveDirectoryA(workRequest.handle, req->lpszDirectory);
2246 HeapFree(GetProcessHeap(), 0, req->lpszDirectory);
2250 case FTPRENAMEFILEA:
2252 struct WORKREQ_FTPRENAMEFILEA *req = &workRequest.u.FtpRenameFileA;
2254 FTP_FtpRenameFileA(workRequest.handle, req->lpszSrcFile, req->lpszDestFile);
2255 HeapFree(GetProcessHeap(), 0, req->lpszSrcFile);
2256 HeapFree(GetProcessHeap(), 0, req->lpszDestFile);
2260 case INTERNETFINDNEXTA:
2262 struct WORKREQ_INTERNETFINDNEXTA *req;
2264 req = &workRequest.u.InternetFindNextA;
2265 INTERNET_FindNextFileA(workRequest.handle, req->lpFindFileData);
2269 case HTTPSENDREQUESTA:
2271 struct WORKREQ_HTTPSENDREQUESTA *req = &workRequest.u.HttpSendRequestA;
2273 HTTP_HttpSendRequestA(workRequest.handle, req->lpszHeader,
2274 req->dwHeaderLength, req->lpOptional, req->dwOptionalLength);
2276 HeapFree(GetProcessHeap(), 0, req->lpszHeader);
2280 case HTTPOPENREQUESTA:
2282 struct WORKREQ_HTTPOPENREQUESTA *req = &workRequest.u.HttpOpenRequestA;
2284 HTTP_HttpOpenRequestA(workRequest.handle, req->lpszVerb,
2285 req->lpszObjectName, req->lpszVersion, req->lpszReferrer,
2286 req->lpszAcceptTypes, req->dwFlags, req->dwContext);
2288 HeapFree(GetProcessHeap(), 0, req->lpszVerb);
2289 HeapFree(GetProcessHeap(), 0, req->lpszObjectName);
2290 HeapFree(GetProcessHeap(), 0, req->lpszVersion);
2291 HeapFree(GetProcessHeap(), 0, req->lpszReferrer);
2297 struct WORKREQ_SENDCALLBACK *req = &workRequest.u.SendCallback;
2299 SendAsyncCallbackInt(workRequest.handle, req->hHttpSession,
2300 req->dwContext, req->dwInternetStatus, req->lpvStatusInfo,
2301 req->dwStatusInfoLength);
2308 /***********************************************************************
2309 * INTERNET_GetResponseBuffer
2314 LPSTR INTERNET_GetResponseBuffer()
2316 LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
2318 return lpwite->response;
2321 /***********************************************************************
2322 * INTERNET_GetNextLine (internal)
2324 * Parse next line in directory string listing
2327 * Pointer to beginning of next line
2332 LPSTR INTERNET_GetNextLine(INT nSocket, LPSTR lpszBuffer, LPDWORD dwBuffer)
2336 BOOL bSuccess = FALSE;
2342 FD_SET(nSocket, &infd);
2343 tv.tv_sec=RESPONSE_TIMEOUT;
2346 while (nRecv < *dwBuffer)
2348 if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0)
2350 if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
2352 INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
2356 if (lpszBuffer[nRecv] == '\n')
2361 if (lpszBuffer[nRecv] != '\r')
2366 INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
2374 lpszBuffer[nRecv] = '\0';
2375 *dwBuffer = nRecv - 1;
2376 TRACE(":%d %s\n", nRecv, lpszBuffer);
2385 /***********************************************************************
2388 BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
2389 LPDWORD lpdwNumberOfBytesAvailble,
2390 DWORD dwFlags, DWORD dwConext)
2392 LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hFile;
2399 SetLastError(ERROR_NO_MORE_FILES);
2403 TRACE("--> %p %i\n",lpwhr,lpwhr->hdr.htype);
2405 switch (lpwhr->hdr.htype)
2408 if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, buffer,
2409 4048, MSG_PEEK, (int *)lpdwNumberOfBytesAvailble))
2411 SetLastError(ERROR_NO_MORE_FILES);
2419 FIXME("unsupported file type\n");
2423 TRACE("<-- %i\n",retval);
2428 /***********************************************************************
2431 BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
2438 BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
2445 /***********************************************************************
2448 * On windows this function is supposed to dial the default internet
2449 * connection. We don't want to have Wine dial out to the internet so
2450 * we return TRUE by default. It might be nice to check if we are connected.
2457 BOOL WINAPI InternetAutodial(DWORD dwFlags, HWND hwndParent)
2461 /* Tell that we are connected to the internet. */
2465 /***********************************************************************
2466 * InternetAutodialHangup
2468 * Hangs up an connection made with InternetAutodial
2477 BOOL WINAPI InternetAutodialHangup(DWORD dwReserved)
2481 /* we didn't dial, we don't disconnect */
2485 /***********************************************************************
2487 * InternetCombineUrlA
2489 * Combine a base URL with a relative URL
2497 BOOL WINAPI InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl,
2498 LPSTR lpszBuffer, LPDWORD lpdwBufferLength,
2502 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
2503 dwFlags ^= ICU_NO_ENCODE;
2504 hr=UrlCombineA(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
2509 /***********************************************************************
2511 * InternetCombineUrlW
2513 * Combine a base URL with a relative URL
2521 BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl,
2522 LPWSTR lpszBuffer, LPDWORD lpdwBufferLength,
2526 /* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
2527 dwFlags ^= ICU_NO_ENCODE;
2528 hr=UrlCombineW(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
2533 /***********************************************************************
2535 * InternetCreateUrlA
2542 BOOL WINAPI InternetCreateUrlA(LPURL_COMPONENTSA lpUrlComponents, DWORD dwFlags,
2543 LPSTR lpszUrl, LPDWORD lpdwUrlLength)
2549 /***********************************************************************
2551 * InternetCreateUrlW
2558 BOOL WINAPI InternetCreateUrlW(LPURL_COMPONENTSW lpUrlComponents, DWORD dwFlags,
2559 LPWSTR lpszUrl, LPDWORD lpdwUrlLength)