2000-04-11 22:07:00 +02:00
|
|
|
/*
|
|
|
|
* Wininet
|
|
|
|
*
|
|
|
|
* Copyright 1999 Corel Corporation
|
2002-06-22 01:59:49 +02:00
|
|
|
* Copyright 2002 CodeWeavers Inc.
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Ulrich Czekalla
|
2002-06-22 01:59:49 +02:00
|
|
|
* Aric Stewart
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
2002-10-28 19:48:24 +01:00
|
|
|
* Copyright 2002 Jaco Greeff
|
|
|
|
*
|
2002-03-10 00:29:33 +01:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2000-04-11 22:07:00 +02:00
|
|
|
*/
|
|
|
|
|
2000-04-15 22:44:21 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2002-03-20 01:56:49 +01:00
|
|
|
#define MAXHOSTNAME 100 /* from http.c */
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
#include <string.h>
|
2002-03-20 01:56:49 +01:00
|
|
|
#include <stdio.h>
|
2000-04-11 22:07:00 +02:00
|
|
|
#include <sys/types.h>
|
2000-04-15 22:44:21 +02:00
|
|
|
#ifdef HAVE_SYS_SOCKET_H
|
|
|
|
# include <sys/socket.h>
|
|
|
|
#endif
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
# include <sys/time.h>
|
|
|
|
#endif
|
2000-04-11 22:07:00 +02:00
|
|
|
#include <stdlib.h>
|
2000-06-11 22:04:44 +02:00
|
|
|
#include <ctype.h>
|
2002-08-17 02:43:16 +02:00
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
# include <unistd.h>
|
|
|
|
#endif
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2000-11-30 02:31:28 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2001-11-06 23:31:19 +01:00
|
|
|
#include "winreg.h"
|
2000-04-11 22:07:00 +02:00
|
|
|
#include "wininet.h"
|
2002-10-28 19:48:24 +01:00
|
|
|
#include "winnls.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2000-04-11 22:07:00 +02:00
|
|
|
#include "winerror.h"
|
2001-12-11 01:30:17 +01:00
|
|
|
#define NO_SHLWAPI_STREAM
|
2001-01-06 01:36:43 +01:00
|
|
|
#include "shlwapi.h"
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2002-07-19 05:12:18 +02:00
|
|
|
#include "wine/exception.h"
|
2002-12-13 00:34:01 +01:00
|
|
|
#include "excpt.h"
|
2002-07-19 05:12:18 +02:00
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
#include "internet.h"
|
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wininet);
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
#define MAX_IDLE_WORKER 1000*60*1
|
|
|
|
#define MAX_WORKER_THREADS 10
|
2000-06-11 22:04:44 +02:00
|
|
|
#define RESPONSE_TIMEOUT 30
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
#define GET_HWININET_FROM_LPWININETFINDNEXT(lpwh) \
|
|
|
|
(LPWININETAPPINFOA)(((LPWININETFTPSESSIONA)(lpwh->hdr.lpwhparent))->hdr.lpwhparent)
|
|
|
|
|
2002-07-19 05:12:18 +02:00
|
|
|
/* filter for page-fault exceptions */
|
|
|
|
static WINE_EXCEPTION_FILTER(page_fault)
|
|
|
|
{
|
|
|
|
if (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ||
|
|
|
|
GetExceptionCode() == EXCEPTION_PRIV_INSTRUCTION)
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
return EXCEPTION_CONTINUE_SEARCH;
|
|
|
|
}
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
DWORD dwError;
|
|
|
|
CHAR response[MAX_REPLY_LEN];
|
|
|
|
} WITHREADERROR, *LPWITHREADERROR;
|
|
|
|
|
2000-04-15 22:44:21 +02:00
|
|
|
BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData);
|
2000-04-11 22:07:00 +02:00
|
|
|
VOID INTERNET_ExecuteWork();
|
|
|
|
|
|
|
|
DWORD g_dwTlsErrIndex = TLS_OUT_OF_INDEXES;
|
|
|
|
DWORD dwNumThreads;
|
|
|
|
DWORD dwNumIdleThreads;
|
2002-11-13 20:40:50 +01:00
|
|
|
DWORD dwNumJobs;
|
2000-04-11 22:07:00 +02:00
|
|
|
HANDLE hEventArray[2];
|
|
|
|
#define hQuitEvent hEventArray[0]
|
|
|
|
#define hWorkEvent hEventArray[1]
|
|
|
|
CRITICAL_SECTION csQueue;
|
|
|
|
LPWORKREQUEST lpHeadWorkQueue;
|
|
|
|
LPWORKREQUEST lpWorkQueueTail;
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-11-05 00:53:41 +01:00
|
|
|
* DllMain [Internal] Initializes the internal 'WININET.DLL'.
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* PARAMS
|
2000-07-16 17:44:22 +02:00
|
|
|
* hinstDLL [I] handle to the DLL's instance
|
2000-04-11 22:07:00 +02:00
|
|
|
* fdwReason [I]
|
2000-07-16 17:44:22 +02:00
|
|
|
* lpvReserved [I] reserved, must be NULL
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: TRUE
|
|
|
|
* Failure: FALSE
|
|
|
|
*/
|
|
|
|
|
2002-11-05 00:53:41 +01:00
|
|
|
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("%p,%lx,%p\n", hinstDLL, fdwReason, lpvReserved);
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
switch (fdwReason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
|
|
|
|
g_dwTlsErrIndex = TlsAlloc();
|
|
|
|
|
|
|
|
if (g_dwTlsErrIndex == TLS_OUT_OF_INDEXES)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
hQuitEvent = CreateEventA(0, TRUE, FALSE, NULL);
|
|
|
|
hWorkEvent = CreateEventA(0, FALSE, FALSE, NULL);
|
|
|
|
InitializeCriticalSection(&csQueue);
|
|
|
|
|
|
|
|
dwNumThreads = 0;
|
|
|
|
dwNumIdleThreads = 0;
|
2002-11-13 20:40:50 +01:00
|
|
|
dwNumJobs = 0;
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
case DLL_THREAD_ATTACH:
|
|
|
|
{
|
|
|
|
LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR));
|
2002-06-01 01:06:46 +02:00
|
|
|
if (NULL == lpwite)
|
2000-04-11 22:07:00 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
TlsSetValue(g_dwTlsErrIndex, (LPVOID)lpwite);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_THREAD_DETACH:
|
|
|
|
if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
|
2000-06-11 22:04:44 +02:00
|
|
|
{
|
|
|
|
LPVOID lpwite = TlsGetValue(g_dwTlsErrIndex);
|
|
|
|
if (lpwite)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwite);
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
|
|
|
|
if (g_dwTlsErrIndex != TLS_OUT_OF_INDEXES)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, TlsGetValue(g_dwTlsErrIndex));
|
|
|
|
TlsFree(g_dwTlsErrIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetEvent(hQuitEvent);
|
|
|
|
|
|
|
|
CloseHandle(hQuitEvent);
|
|
|
|
CloseHandle(hWorkEvent);
|
|
|
|
DeleteCriticalSection(&csQueue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-28 19:48:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetInitializeAutoProxyDll (WININET.@)
|
|
|
|
*
|
|
|
|
* Setup the internal proxy
|
|
|
|
*
|
|
|
|
* PARAMETERS
|
|
|
|
* dwReserved
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-10-29 22:31:26 +01:00
|
|
|
BOOL WINAPI InternetInitializeAutoProxyDll(DWORD dwReserved)
|
2002-10-28 19:48:24 +01:00
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetOpenA (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Per-application initialization of wininet
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* HINTERNET on success
|
|
|
|
* NULL on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-10-28 19:48:24 +01:00
|
|
|
HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
|
|
|
|
LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
|
|
|
LPWININETAPPINFOA lpwai = NULL;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
/* Clear any error information */
|
|
|
|
INTERNET_SetLastError(0);
|
|
|
|
|
|
|
|
lpwai = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETAPPINFOA));
|
|
|
|
if (NULL == lpwai)
|
|
|
|
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memset(lpwai, 0, sizeof(WININETAPPINFOA));
|
|
|
|
lpwai->hdr.htype = WH_HINIT;
|
|
|
|
lpwai->hdr.lpwhparent = NULL;
|
|
|
|
lpwai->hdr.dwFlags = dwFlags;
|
|
|
|
if (NULL != lpszAgent)
|
2000-11-16 01:28:52 +01:00
|
|
|
{
|
|
|
|
if ((lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,strlen(lpszAgent)+1)))
|
|
|
|
strcpy( lpwai->lpszAgent, lpszAgent );
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
if (NULL != lpszProxy)
|
2000-11-16 01:28:52 +01:00
|
|
|
{
|
|
|
|
if ((lpwai->lpszProxy = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxy)+1 )))
|
|
|
|
strcpy( lpwai->lpszProxy, lpszProxy );
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
if (NULL != lpszProxyBypass)
|
2000-11-16 01:28:52 +01:00
|
|
|
{
|
|
|
|
if ((lpwai->lpszProxyBypass = HeapAlloc( GetProcessHeap(), 0, strlen(lpszProxyBypass)+1)))
|
|
|
|
strcpy( lpwai->lpszProxyBypass, lpszProxyBypass );
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
lpwai->dwAccessType = dwAccessType;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (HINTERNET)lpwai;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-10-28 19:48:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetOpenW (WININET.@)
|
|
|
|
*
|
|
|
|
* Per-application initialization of wininet
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* HINTERNET on success
|
|
|
|
* NULL on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType,
|
|
|
|
LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
HINTERNET rc = (HINTERNET)NULL;
|
|
|
|
INT lenAgent = lstrlenW(lpszAgent)+1;
|
|
|
|
INT lenProxy = lstrlenW(lpszProxy)+1;
|
|
|
|
INT lenBypass = lstrlenW(lpszProxyBypass)+1;
|
|
|
|
CHAR *szAgent = (CHAR *)malloc(lenAgent*sizeof(CHAR));
|
|
|
|
CHAR *szProxy = (CHAR *)malloc(lenProxy*sizeof(CHAR));
|
|
|
|
CHAR *szBypass = (CHAR *)malloc(lenBypass*sizeof(CHAR));
|
|
|
|
|
|
|
|
if (!szAgent || !szProxy || !szBypass)
|
|
|
|
{
|
|
|
|
if (szAgent)
|
|
|
|
free(szAgent);
|
|
|
|
if (szProxy)
|
|
|
|
free(szProxy);
|
|
|
|
if (szBypass)
|
|
|
|
free(szBypass);
|
|
|
|
return (HINTERNET)NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszAgent, -1, szAgent, lenAgent,
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszProxy, -1, szProxy, lenProxy,
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszProxyBypass, -1, szBypass, lenBypass,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
rc = InternetOpenA(szAgent, dwAccessType, szProxy, szBypass, dwFlags);
|
|
|
|
|
|
|
|
free(szAgent);
|
|
|
|
free(szProxy);
|
|
|
|
free(szBypass);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetGetLastResponseInfoA (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Return last wininet error description on the calling thread
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success of writting to buffer
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2000-04-15 22:44:21 +02:00
|
|
|
BOOL WINAPI InternetGetLastResponseInfoA(LPDWORD lpdwError,
|
2000-04-11 22:07:00 +02:00
|
|
|
LPSTR lpszBuffer, LPDWORD lpdwBufferLength)
|
|
|
|
{
|
|
|
|
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
*lpdwError = lpwite->dwError;
|
|
|
|
if (lpwite->dwError)
|
|
|
|
{
|
|
|
|
strncpy(lpszBuffer, lpwite->response, *lpdwBufferLength);
|
|
|
|
*lpdwBufferLength = strlen(lpszBuffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*lpdwBufferLength = 0;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-23 21:55:26 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetGetConnectedState (WININET.@)
|
2000-04-23 21:55:26 +02:00
|
|
|
*
|
|
|
|
* Return connected state
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE if connected
|
2002-06-01 01:06:46 +02:00
|
|
|
* if lpdwStatus is not null, return the status (off line,
|
2000-04-23 21:55:26 +02:00
|
|
|
* modem, lan...) in it.
|
|
|
|
* FALSE if not connected
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved)
|
|
|
|
{
|
2001-07-11 19:24:39 +02:00
|
|
|
if (lpdwStatus) {
|
|
|
|
FIXME("always returning LAN connection.\n");
|
|
|
|
*lpdwStatus = INTERNET_CONNECTION_LAN;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2000-04-23 21:55:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetConnectA (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Open a ftp, gopher or http session
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* HINTERNET a session handle on success
|
|
|
|
* NULL on failure
|
|
|
|
*
|
|
|
|
*/
|
2001-09-11 02:32:32 +02:00
|
|
|
HINTERNET WINAPI InternetConnectA(HINTERNET hInternet,
|
2000-04-11 22:07:00 +02:00
|
|
|
LPCSTR lpszServerName, INTERNET_PORT nServerPort,
|
|
|
|
LPCSTR lpszUserName, LPCSTR lpszPassword,
|
|
|
|
DWORD dwService, DWORD dwFlags, DWORD dwContext)
|
|
|
|
{
|
|
|
|
HINTERNET rc = (HINTERNET) NULL;
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
TRACE("ServerPort %i\n",nServerPort);
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
/* Clear any error information */
|
|
|
|
INTERNET_SetLastError(0);
|
|
|
|
|
|
|
|
switch (dwService)
|
|
|
|
{
|
|
|
|
case INTERNET_SERVICE_FTP:
|
|
|
|
rc = FTP_Connect(hInternet, lpszServerName, nServerPort,
|
|
|
|
lpszUserName, lpszPassword, dwFlags, dwContext);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SERVICE_HTTP:
|
2000-06-11 22:04:44 +02:00
|
|
|
rc = HTTP_Connect(hInternet, lpszServerName, nServerPort,
|
|
|
|
lpszUserName, lpszPassword, dwFlags, dwContext);
|
2000-04-11 22:07:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNET_SERVICE_GOPHER:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-10-28 19:48:24 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetConnectW (WININET.@)
|
|
|
|
*
|
|
|
|
* Open a ftp, gopher or http session
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* HINTERNET a session handle on success
|
|
|
|
* NULL on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
|
|
|
|
LPCWSTR lpszServerName, INTERNET_PORT nServerPort,
|
|
|
|
LPCWSTR lpszUserName, LPCWSTR lpszPassword,
|
|
|
|
DWORD dwService, DWORD dwFlags, DWORD dwContext)
|
|
|
|
{
|
|
|
|
HINTERNET rc = (HINTERNET)NULL;
|
|
|
|
INT lenServer = lstrlenW(lpszServerName)+1;
|
|
|
|
INT lenUser = lstrlenW(lpszUserName)+1;
|
|
|
|
INT lenPass = lstrlenW(lpszPassword)+1;
|
|
|
|
CHAR *szServerName = (CHAR *)malloc(lenServer*sizeof(CHAR));
|
|
|
|
CHAR *szUserName = (CHAR *)malloc(lenUser*sizeof(CHAR));
|
|
|
|
CHAR *szPassword = (CHAR *)malloc(lenPass*sizeof(CHAR));
|
|
|
|
|
|
|
|
if (!szServerName || !szUserName || !szPassword)
|
|
|
|
{
|
|
|
|
if (szServerName)
|
|
|
|
free(szServerName);
|
|
|
|
if (szUserName)
|
|
|
|
free(szUserName);
|
|
|
|
if (szPassword)
|
|
|
|
free(szPassword);
|
|
|
|
return (HINTERNET)NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszServerName, -1, szServerName, lenServer,
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszUserName, -1, szUserName, lenUser,
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszPassword, -1, szPassword, lenPass,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
rc = InternetConnectA(hInternet, szServerName, nServerPort,
|
|
|
|
szUserName, szPassword, dwService, dwFlags, dwContext);
|
|
|
|
|
|
|
|
free(szServerName);
|
|
|
|
free(szUserName);
|
|
|
|
free(szPassword);
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetFindNextFileA (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Continues a file search from a previous call to FindFirstFile
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2000-04-15 22:44:21 +02:00
|
|
|
BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
|
|
|
LPWININETAPPINFOA hIC = NULL;
|
|
|
|
LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
|
|
|
|
{
|
|
|
|
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
|
|
|
|
if (hIC->hdr.dwFlags & INTERNET_FLAG_ASYNC)
|
|
|
|
{
|
|
|
|
WORKREQUEST workRequest;
|
|
|
|
|
|
|
|
workRequest.asyncall = INTERNETFINDNEXTA;
|
|
|
|
workRequest.HFTPSESSION = (DWORD)hFind;
|
|
|
|
workRequest.LPFINDFILEDATA = (DWORD)lpvFindData;
|
|
|
|
|
|
|
|
return INTERNET_AsyncCall(&workRequest);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return INTERNET_FindNextFileA(hFind, lpvFindData);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_FindNextFileA (Internal)
|
|
|
|
*
|
|
|
|
* Continues a file search from a previous call to FindFirstFile
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2000-04-15 22:44:21 +02:00
|
|
|
BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
|
|
|
BOOL bSuccess = TRUE;
|
|
|
|
LPWININETAPPINFOA hIC = NULL;
|
|
|
|
LPWIN32_FIND_DATAA lpFindFileData;
|
|
|
|
LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
|
|
|
|
{
|
|
|
|
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear any error information */
|
|
|
|
INTERNET_SetLastError(0);
|
|
|
|
|
|
|
|
if (lpwh->hdr.lpwhparent->htype != WH_HFTPSESSION)
|
|
|
|
{
|
|
|
|
FIXME("Only FTP find next supported\n");
|
|
|
|
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("index(%d) size(%ld)\n", lpwh->index, lpwh->size);
|
|
|
|
|
|
|
|
lpFindFileData = (LPWIN32_FIND_DATAA) lpvFindData;
|
|
|
|
ZeroMemory(lpFindFileData, sizeof(WIN32_FIND_DATAA));
|
|
|
|
|
|
|
|
if (lpwh->index >= lpwh->size)
|
|
|
|
{
|
|
|
|
INTERNET_SetLastError(ERROR_NO_MORE_FILES);
|
|
|
|
bSuccess = FALSE;
|
|
|
|
goto lend;
|
|
|
|
}
|
|
|
|
|
|
|
|
FTP_ConvertFileProp(&lpwh->lpafp[lpwh->index], lpFindFileData);
|
|
|
|
lpwh->index++;
|
|
|
|
|
|
|
|
TRACE("\nName: %s\nSize: %ld\n", lpFindFileData->cFileName, lpFindFileData->nFileSizeLow);
|
|
|
|
|
|
|
|
lend:
|
|
|
|
|
|
|
|
hIC = GET_HWININET_FROM_LPWININETFINDNEXT(lpwh);
|
2002-06-22 01:59:49 +02:00
|
|
|
if (hIC->lpfnStatusCB)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2000-04-11 22:07:00 +02:00
|
|
|
INTERNET_ASYNC_RESULT iar;
|
|
|
|
|
|
|
|
iar.dwResult = (DWORD)bSuccess;
|
2002-06-22 01:59:49 +02:00
|
|
|
iar.dwError = iar.dwError = bSuccess ? ERROR_SUCCESS :
|
|
|
|
INTERNET_GetLastError();
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
SendAsyncCallback(hIC, hFind, lpwh->hdr.dwContext,
|
|
|
|
INTERNET_STATUS_REQUEST_COMPLETE, &iar,
|
|
|
|
sizeof(INTERNET_ASYNC_RESULT));
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-11 22:04:44 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_CloseHandle (internal)
|
|
|
|
*
|
|
|
|
* Close internet handle
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Void
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai)
|
|
|
|
{
|
2002-06-22 01:59:49 +02:00
|
|
|
TRACE("%p\n",lpwai);
|
|
|
|
|
|
|
|
SendAsyncCallback(lpwai, lpwai, lpwai->hdr.dwContext,
|
|
|
|
INTERNET_STATUS_HANDLE_CLOSING, lpwai,
|
|
|
|
sizeof(HINTERNET));
|
|
|
|
|
2000-06-11 22:04:44 +02:00
|
|
|
if (lpwai->lpszAgent)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwai->lpszAgent);
|
|
|
|
|
|
|
|
if (lpwai->lpszProxy)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwai->lpszProxy);
|
|
|
|
|
|
|
|
if (lpwai->lpszProxyBypass)
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwai->lpszProxyBypass);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwai);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetCloseHandle (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
2000-06-11 22:04:44 +02:00
|
|
|
* Generic close handle function
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2000-04-15 22:44:21 +02:00
|
|
|
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2002-07-19 05:12:18 +02:00
|
|
|
BOOL retval;
|
2000-04-11 22:07:00 +02:00
|
|
|
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hInternet;
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
TRACE("%p\n",hInternet);
|
2000-04-11 22:07:00 +02:00
|
|
|
if (NULL == lpwh)
|
|
|
|
return FALSE;
|
|
|
|
|
2002-07-19 05:12:18 +02:00
|
|
|
__TRY {
|
|
|
|
/* Clear any error information */
|
|
|
|
INTERNET_SetLastError(0);
|
|
|
|
retval = FALSE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-07-19 05:12:18 +02:00
|
|
|
switch (lpwh->htype)
|
|
|
|
{
|
|
|
|
case WH_HINIT:
|
|
|
|
INTERNET_CloseHandle((LPWININETAPPINFOA) lpwh);
|
|
|
|
retval = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WH_HHTTPSESSION:
|
|
|
|
HTTP_CloseHTTPSessionHandle((LPWININETHTTPSESSIONA) lpwh);
|
|
|
|
retval = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WH_HHTTPREQ:
|
|
|
|
HTTP_CloseHTTPRequestHandle((LPWININETHTTPREQA) lpwh);
|
|
|
|
retval = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WH_HFTPSESSION:
|
|
|
|
retval = FTP_CloseSessionHandle((LPWININETFTPSESSIONA) lpwh);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WH_HFINDNEXT:
|
|
|
|
retval = FTP_CloseFindNextHandle((LPWININETFINDNEXTA) lpwh);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} __EXCEPT(page_fault) {
|
|
|
|
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
2002-07-19 05:12:18 +02:00
|
|
|
__ENDTRY
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-11 22:04:44 +02:00
|
|
|
/***********************************************************************
|
2003-01-03 00:08:22 +01:00
|
|
|
* ConvertUrlComponentValue (Internal)
|
2000-06-11 22:04:44 +02:00
|
|
|
*
|
|
|
|
* Helper function for InternetCrackUrlA
|
|
|
|
*
|
|
|
|
*/
|
2003-01-03 00:08:22 +01:00
|
|
|
void ConvertUrlComponentValue(LPSTR* lppszComponent, LPDWORD dwComponentLen,
|
|
|
|
LPWSTR lpwszComponent, DWORD dwwComponentLen,
|
|
|
|
LPCSTR lpszStart,
|
|
|
|
LPCWSTR lpwszStart)
|
2000-06-11 22:04:44 +02:00
|
|
|
{
|
|
|
|
if (*dwComponentLen != 0)
|
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
int nASCIILength=WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,NULL,0,NULL,NULL);
|
|
|
|
if (*lppszComponent == NULL)
|
|
|
|
{
|
|
|
|
int nASCIIOffset=WideCharToMultiByte(CP_ACP,0,lpwszStart,lpwszComponent-lpwszStart,NULL,0,NULL,NULL);
|
|
|
|
*lppszComponent = (LPSTR)lpszStart+nASCIIOffset;
|
|
|
|
*dwComponentLen = nASCIILength;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
INT ncpylen = min((*dwComponentLen)-1, nASCIILength);
|
|
|
|
WideCharToMultiByte(CP_ACP,0,lpwszComponent,dwwComponentLen,*lppszComponent,ncpylen+1,NULL,NULL);
|
|
|
|
(*lppszComponent)[ncpylen]=0;
|
|
|
|
*dwComponentLen = ncpylen;
|
|
|
|
}
|
2000-06-11 22:04:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetCrackUrlA (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Break up URL into its components
|
|
|
|
*
|
2002-03-20 01:56:49 +01:00
|
|
|
* TODO: Handle dwFlags
|
2000-06-11 22:04:44 +02:00
|
|
|
*
|
2000-04-11 22:07:00 +02:00
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
|
2002-10-28 19:48:24 +01:00
|
|
|
LPURL_COMPONENTSA lpUrlComponents)
|
2003-01-03 00:08:22 +01:00
|
|
|
{
|
|
|
|
DWORD nLength;
|
|
|
|
URL_COMPONENTSW UCW;
|
|
|
|
WCHAR* lpwszUrl;
|
|
|
|
if(dwUrlLength==0)
|
|
|
|
dwUrlLength=strlen(lpszUrl);
|
|
|
|
lpwszUrl=HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*(dwUrlLength+1));
|
|
|
|
memset(lpwszUrl,0,sizeof(WCHAR)*(dwUrlLength+1));
|
|
|
|
nLength=MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,dwUrlLength+1);
|
|
|
|
memset(&UCW,0,sizeof(UCW));
|
|
|
|
if(lpUrlComponents->dwHostNameLength!=0)
|
|
|
|
UCW.dwHostNameLength=1;
|
|
|
|
if(lpUrlComponents->dwUserNameLength!=0)
|
|
|
|
UCW.dwUserNameLength=1;
|
|
|
|
if(lpUrlComponents->dwPasswordLength!=0)
|
|
|
|
UCW.dwPasswordLength=1;
|
|
|
|
if(lpUrlComponents->dwUrlPathLength!=0)
|
|
|
|
UCW.dwUrlPathLength=1;
|
|
|
|
if(lpUrlComponents->dwSchemeLength!=0)
|
|
|
|
UCW.dwSchemeLength=1;
|
|
|
|
if(lpUrlComponents->dwExtraInfoLength!=0)
|
|
|
|
UCW.dwExtraInfoLength=1;
|
|
|
|
if(!InternetCrackUrlW(lpwszUrl,nLength,dwFlags,&UCW))
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwszUrl);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
ConvertUrlComponentValue(&lpUrlComponents->lpszHostName, &lpUrlComponents->dwHostNameLength,
|
|
|
|
UCW.lpszHostName, UCW.dwHostNameLength,
|
|
|
|
lpszUrl, lpwszUrl);
|
|
|
|
ConvertUrlComponentValue(&lpUrlComponents->lpszUserName, &lpUrlComponents->dwUserNameLength,
|
|
|
|
UCW.lpszUserName, UCW.dwUserNameLength,
|
|
|
|
lpszUrl, lpwszUrl);
|
|
|
|
ConvertUrlComponentValue(&lpUrlComponents->lpszPassword, &lpUrlComponents->dwPasswordLength,
|
|
|
|
UCW.lpszPassword, UCW.dwPasswordLength,
|
|
|
|
lpszUrl, lpwszUrl);
|
|
|
|
ConvertUrlComponentValue(&lpUrlComponents->lpszUrlPath, &lpUrlComponents->dwUrlPathLength,
|
|
|
|
UCW.lpszUrlPath, UCW.dwUrlPathLength,
|
|
|
|
lpszUrl, lpwszUrl);
|
|
|
|
ConvertUrlComponentValue(&lpUrlComponents->lpszScheme, &lpUrlComponents->dwSchemeLength,
|
|
|
|
UCW.lpszScheme, UCW.dwSchemeLength,
|
|
|
|
lpszUrl, lpwszUrl);
|
|
|
|
ConvertUrlComponentValue(&lpUrlComponents->lpszExtraInfo, &lpUrlComponents->dwExtraInfoLength,
|
|
|
|
UCW.lpszExtraInfo, UCW.dwExtraInfoLength,
|
|
|
|
lpszUrl, lpwszUrl);
|
|
|
|
lpUrlComponents->nScheme=UCW.nScheme;
|
|
|
|
lpUrlComponents->nPort=UCW.nPort;
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwszUrl);
|
|
|
|
|
|
|
|
TRACE("%s: scheme(%s) host(%s) path(%s) extra(%s)\n", lpszUrl,
|
|
|
|
debugstr_an(lpUrlComponents->lpszScheme,lpUrlComponents->dwSchemeLength),
|
|
|
|
debugstr_an(lpUrlComponents->lpszHostName,lpUrlComponents->dwHostNameLength),
|
|
|
|
debugstr_an(lpUrlComponents->lpszUrlPath,lpUrlComponents->dwUrlPathLength),
|
|
|
|
debugstr_an(lpUrlComponents->lpszExtraInfo,lpUrlComponents->dwExtraInfoLength));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetInternetSchemeW (internal)
|
|
|
|
*
|
|
|
|
* Get scheme of url
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* scheme on success
|
|
|
|
* INTERNET_SCHEME_UNKNOWN on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INTERNET_SCHEME GetInternetSchemeW(LPCWSTR lpszScheme, INT nMaxCmp)
|
|
|
|
{
|
|
|
|
INTERNET_SCHEME iScheme=INTERNET_SCHEME_UNKNOWN;
|
|
|
|
WCHAR lpszFtp[]={'f','t','p',0};
|
|
|
|
WCHAR lpszGopher[]={'g','o','p','h','e','r',0};
|
|
|
|
WCHAR lpszHttp[]={'h','t','t','p',0};
|
|
|
|
WCHAR lpszHttps[]={'h','t','t','p','s',0};
|
|
|
|
WCHAR lpszFile[]={'f','i','l','e',0};
|
|
|
|
WCHAR lpszNews[]={'n','e','w','s',0};
|
|
|
|
WCHAR lpszMailto[]={'m','a','i','l','t','o',0};
|
|
|
|
WCHAR lpszRes[]={'r','e','s',0};
|
|
|
|
WCHAR* tempBuffer=NULL;
|
|
|
|
TRACE("\n");
|
|
|
|
if(lpszScheme==NULL)
|
|
|
|
return INTERNET_SCHEME_UNKNOWN;
|
|
|
|
|
|
|
|
tempBuffer=malloc(nMaxCmp+1);
|
|
|
|
strncpyW(tempBuffer,lpszScheme,nMaxCmp);
|
|
|
|
tempBuffer[nMaxCmp]=0;
|
|
|
|
strlwrW(tempBuffer);
|
|
|
|
if (nMaxCmp==strlenW(lpszFtp) && !strncmpW(lpszFtp, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_FTP;
|
|
|
|
else if (nMaxCmp==strlenW(lpszGopher) && !strncmpW(lpszGopher, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_GOPHER;
|
|
|
|
else if (nMaxCmp==strlenW(lpszHttp) && !strncmpW(lpszHttp, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_HTTP;
|
|
|
|
else if (nMaxCmp==strlenW(lpszHttps) && !strncmpW(lpszHttps, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_HTTPS;
|
|
|
|
else if (nMaxCmp==strlenW(lpszFile) && !strncmpW(lpszFile, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_FILE;
|
|
|
|
else if (nMaxCmp==strlenW(lpszNews) && !strncmpW(lpszNews, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_NEWS;
|
|
|
|
else if (nMaxCmp==strlenW(lpszMailto) && !strncmpW(lpszMailto, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_MAILTO;
|
|
|
|
else if (nMaxCmp==strlenW(lpszRes) && !strncmpW(lpszRes, tempBuffer, nMaxCmp))
|
|
|
|
iScheme=INTERNET_SCHEME_RES;
|
|
|
|
free(tempBuffer);
|
|
|
|
return iScheme;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetUrlComponentValueW (Internal)
|
|
|
|
*
|
|
|
|
* Helper function for InternetCrackUrlW
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL SetUrlComponentValueW(LPWSTR* lppszComponent, LPDWORD dwComponentLen, LPCWSTR lpszStart, INT len)
|
|
|
|
{
|
|
|
|
TRACE("%s (%d)\n", debugstr_wn(lpszStart,len), len);
|
|
|
|
|
|
|
|
if (*dwComponentLen != 0)
|
|
|
|
{
|
|
|
|
if (*lppszComponent == NULL)
|
|
|
|
{
|
|
|
|
*lppszComponent = (LPWSTR)lpszStart;
|
|
|
|
*dwComponentLen = len;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
INT ncpylen = min((*dwComponentLen)-1, len);
|
|
|
|
strncpyW(*lppszComponent, lpszStart, ncpylen);
|
|
|
|
(*lppszComponent)[ncpylen] = '\0';
|
|
|
|
*dwComponentLen = ncpylen;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetCrackUrlW (WININET.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetCrackUrlW(LPCWSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
|
|
|
|
LPURL_COMPONENTSW lpUC)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* RFC 1808
|
|
|
|
* <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
|
|
|
|
*
|
|
|
|
*/
|
2003-01-03 00:08:22 +01:00
|
|
|
LPWSTR lpszParam = NULL;
|
2000-04-11 22:07:00 +02:00
|
|
|
BOOL bIsAbsolute = FALSE;
|
2003-01-03 00:08:22 +01:00
|
|
|
LPWSTR lpszap = (WCHAR*)lpszUrl;
|
|
|
|
LPWSTR lpszcp = NULL;
|
|
|
|
WCHAR lpszSeparators[3]={';','?',0};
|
|
|
|
WCHAR lpszSlash[2]={'/',0};
|
|
|
|
if(dwUrlLength==0)
|
|
|
|
dwUrlLength=strlenW(lpszUrl);
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
TRACE("\n");
|
2000-06-11 22:04:44 +02:00
|
|
|
|
|
|
|
/* Determine if the URI is absolute. */
|
|
|
|
while (*lpszap != '\0')
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
if (isalnumW(*lpszap))
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2000-06-11 22:04:44 +02:00
|
|
|
lpszap++;
|
2000-04-11 22:07:00 +02:00
|
|
|
continue;
|
|
|
|
}
|
2000-06-11 22:04:44 +02:00
|
|
|
if ((*lpszap == ':') && (lpszap - lpszUrl >= 2))
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
|
|
|
bIsAbsolute = TRUE;
|
2000-06-11 22:04:44 +02:00
|
|
|
lpszcp = lpszap;
|
|
|
|
}
|
2003-01-03 00:08:22 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
lpszcp = (LPWSTR)lpszUrl; /* Relative url */
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-06-11 22:04:44 +02:00
|
|
|
/* Parse <params> */
|
2003-01-03 00:08:22 +01:00
|
|
|
lpszParam = strpbrkW(lpszap, lpszSeparators);
|
2000-06-11 22:04:44 +02:00
|
|
|
if (lpszParam != NULL)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
if (!SetUrlComponentValueW(&lpUC->lpszExtraInfo, &lpUC->dwExtraInfoLength,
|
|
|
|
lpszParam, dwUrlLength-(lpszParam-lpszUrl)))
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
return FALSE;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
2003-01-03 00:08:22 +01:00
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2000-06-11 22:04:44 +02:00
|
|
|
if (bIsAbsolute) /* Parse <protocol>:[//<net_loc>] */
|
2003-01-03 00:08:22 +01:00
|
|
|
{
|
|
|
|
LPWSTR lpszNetLoc;
|
|
|
|
WCHAR wszAbout[]={'a','b','o','u','t',':',0};
|
2000-06-11 22:04:44 +02:00
|
|
|
|
|
|
|
/* Get scheme first. */
|
2003-01-03 00:08:22 +01:00
|
|
|
lpUC->nScheme = GetInternetSchemeW(lpszUrl, lpszcp - lpszUrl);
|
|
|
|
if (!SetUrlComponentValueW(&lpUC->lpszScheme, &lpUC->dwSchemeLength,
|
|
|
|
lpszUrl, lpszcp - lpszUrl))
|
|
|
|
return FALSE;
|
2000-06-11 22:04:44 +02:00
|
|
|
|
|
|
|
/* Eat ':' in protocol. */
|
|
|
|
lpszcp++;
|
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
/* if the scheme is "about", there is no host */
|
|
|
|
if(strncmpW(wszAbout,lpszUrl, lpszcp - lpszUrl)==0)
|
2000-06-11 22:04:44 +02:00
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength, NULL, 0);
|
|
|
|
lpUC->nPort = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Skip over slashes. */
|
2000-06-11 22:04:44 +02:00
|
|
|
if (*lpszcp == '/')
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2000-06-11 22:04:44 +02:00
|
|
|
lpszcp++;
|
|
|
|
if (*lpszcp == '/')
|
2003-01-03 00:08:22 +01:00
|
|
|
{
|
2000-06-11 22:04:44 +02:00
|
|
|
lpszcp++;
|
2003-01-03 00:08:22 +01:00
|
|
|
if (*lpszcp == '/')
|
|
|
|
lpszcp++;
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
lpszNetLoc = strpbrkW(lpszcp, lpszSlash);
|
|
|
|
if (lpszParam)
|
|
|
|
{
|
|
|
|
if (lpszNetLoc)
|
|
|
|
lpszNetLoc = min(lpszNetLoc, lpszParam);
|
|
|
|
else
|
|
|
|
lpszNetLoc = lpszParam;
|
|
|
|
}
|
|
|
|
else if (!lpszNetLoc)
|
|
|
|
lpszNetLoc = lpszcp + dwUrlLength-(lpszcp-lpszUrl);
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
/* Parse net-loc */
|
|
|
|
if (lpszNetLoc)
|
|
|
|
{
|
|
|
|
LPWSTR lpszHost;
|
|
|
|
LPWSTR lpszPort;
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/* [<user>[<:password>]@]<host>[:<port>] */
|
2003-01-03 00:08:22 +01:00
|
|
|
/* First find the user and password if they exist */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
lpszHost = strchrW(lpszcp, '@');
|
|
|
|
if (lpszHost == NULL || lpszHost > lpszNetLoc)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
/* username and password not specified. */
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength, NULL, 0);
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength, NULL, 0);
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
2003-01-03 00:08:22 +01:00
|
|
|
else /* Parse out username and password */
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
LPWSTR lpszUser = lpszcp;
|
|
|
|
LPWSTR lpszPasswd = lpszHost;
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
while (lpszcp < lpszHost)
|
|
|
|
{
|
|
|
|
if (*lpszcp == ':')
|
|
|
|
lpszPasswd = lpszcp;
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
lpszcp++;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
SetUrlComponentValueW(&lpUC->lpszUserName, &lpUC->dwUserNameLength,
|
|
|
|
lpszUser, lpszPasswd - lpszUser);
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
if (lpszPasswd != lpszHost)
|
|
|
|
lpszPasswd++;
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszPassword, &lpUC->dwPasswordLength,
|
|
|
|
lpszPasswd == lpszHost ? NULL : lpszPasswd,
|
|
|
|
lpszHost - lpszPasswd);
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
lpszcp++; /* Advance to beginning of host */
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
/* Parse <host><:port> */
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
lpszHost = lpszcp;
|
|
|
|
lpszPort = lpszNetLoc;
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
/* special case for res:// URLs: there is no port here, so the host is the
|
|
|
|
entire string up to the first '/' */
|
|
|
|
if(lpUC->nScheme==INTERNET_SCHEME_RES)
|
|
|
|
{
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
|
|
|
|
lpszHost, lpszPort - lpszHost);
|
|
|
|
lpUC->nPort = 0;
|
|
|
|
lpszcp=lpszNetLoc;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
2003-01-03 00:08:22 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
while (lpszcp < lpszNetLoc)
|
|
|
|
{
|
|
|
|
if (*lpszcp == ':')
|
|
|
|
lpszPort = lpszcp;
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
lpszcp++;
|
|
|
|
}
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
/* If the scheme is "file" and the host is just one letter, it's not a host */
|
|
|
|
if(lpUC->nScheme==INTERNET_SCHEME_FILE && (lpszPort-lpszHost)==1)
|
|
|
|
{
|
|
|
|
lpszcp=lpszHost;
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
|
|
|
|
NULL, 0);
|
|
|
|
lpUC->nPort = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetUrlComponentValueW(&lpUC->lpszHostName, &lpUC->dwHostNameLength,
|
|
|
|
lpszHost, lpszPort - lpszHost);
|
|
|
|
if (lpszPort != lpszNetLoc)
|
|
|
|
lpUC->nPort = atoiW(++lpszPort);
|
|
|
|
else
|
|
|
|
lpUC->nPort = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
}
|
2003-01-03 00:08:22 +01:00
|
|
|
}
|
2000-06-11 22:04:44 +02:00
|
|
|
|
|
|
|
/* Here lpszcp points to:
|
|
|
|
*
|
|
|
|
* <protocol>:[//<net_loc>][/path][;<params>][?<query>][#<fragment>]
|
|
|
|
* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
*/
|
|
|
|
if (lpszcp != 0 && *lpszcp != '\0' && (!lpszParam || lpszcp < lpszParam))
|
|
|
|
{
|
2000-07-23 15:34:21 +02:00
|
|
|
INT len;
|
|
|
|
|
|
|
|
/* Only truncate the parameter list if it's already been saved
|
2003-01-03 00:08:22 +01:00
|
|
|
* in lpUC->lpszExtraInfo.
|
2000-07-23 15:34:21 +02:00
|
|
|
*/
|
2003-01-03 00:08:22 +01:00
|
|
|
if (lpszParam && lpUC->dwExtraInfoLength)
|
2000-07-23 15:34:21 +02:00
|
|
|
len = lpszParam - lpszcp;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Leave the parameter list in lpszUrlPath. Strip off any trailing
|
|
|
|
* newlines if necessary.
|
|
|
|
*/
|
2003-01-03 00:08:22 +01:00
|
|
|
LPWSTR lpsznewline = strchrW(lpszcp, '\n');
|
2000-07-23 15:34:21 +02:00
|
|
|
if (lpsznewline != NULL)
|
|
|
|
len = lpsznewline - lpszcp;
|
|
|
|
else
|
2003-01-03 00:08:22 +01:00
|
|
|
len = dwUrlLength-(lpszcp-lpszUrl);
|
2000-07-23 15:34:21 +02:00
|
|
|
}
|
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
if (!SetUrlComponentValueW(&lpUC->lpszUrlPath, &lpUC->dwUrlPathLength,
|
|
|
|
lpszcp, len))
|
|
|
|
return FALSE;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
else
|
2000-06-11 22:04:44 +02:00
|
|
|
{
|
2003-01-03 00:08:22 +01:00
|
|
|
lpUC->dwUrlPathLength = 0;
|
2000-06-11 22:04:44 +02:00
|
|
|
}
|
|
|
|
|
2003-01-03 00:08:22 +01:00
|
|
|
TRACE("%s: host(%s) path(%s) extra(%s)\n", debugstr_wn(lpszUrl,dwUrlLength),
|
|
|
|
debugstr_wn(lpUC->lpszHostName,lpUC->dwHostNameLength),
|
|
|
|
debugstr_wn(lpUC->lpszUrlPath,lpUC->dwUrlPathLength),
|
|
|
|
debugstr_wn(lpUC->lpszExtraInfo,lpUC->dwExtraInfoLength));
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetAttemptConnect (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Attempt to make a connection to the internet
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* ERROR_SUCCESS on success
|
|
|
|
* Error value on failure
|
|
|
|
*
|
|
|
|
*/
|
2001-09-11 02:32:32 +02:00
|
|
|
DWORD WINAPI InternetAttemptConnect(DWORD dwReserved)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
|
|
|
FIXME("Stub\n");
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetCanonicalizeUrlA (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Escape unsafe characters and spaces
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2000-04-15 22:44:21 +02:00
|
|
|
BOOL WINAPI InternetCanonicalizeUrlA(LPCSTR lpszUrl, LPSTR lpszBuffer,
|
2000-04-11 22:07:00 +02:00
|
|
|
LPDWORD lpdwBufferLength, DWORD dwFlags)
|
|
|
|
{
|
2001-01-06 01:36:43 +01:00
|
|
|
HRESULT hr;
|
|
|
|
TRACE("%s %p %p %08lx\n",debugstr_a(lpszUrl), lpszBuffer,
|
|
|
|
lpdwBufferLength, dwFlags);
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2001-01-06 01:36:43 +01:00
|
|
|
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
|
|
|
|
dwFlags ^= ICU_NO_ENCODE;
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2001-01-06 01:36:43 +01:00
|
|
|
dwFlags |= 0x80000000; /* Don't know what this means */
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2001-01-06 01:36:43 +01:00
|
|
|
hr = UrlCanonicalizeA(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2001-01-06 01:36:43 +01:00
|
|
|
return (hr == S_OK) ? TRUE : FALSE;
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2002-10-28 19:48:24 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetCanonicalizeUrlW (WININET.@)
|
|
|
|
*
|
|
|
|
* Escape unsafe characters and spaces
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer,
|
|
|
|
LPDWORD lpdwBufferLength, DWORD dwFlags)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("%s %p %p %08lx\n", debugstr_w(lpszUrl), lpszBuffer,
|
|
|
|
lpdwBufferLength, dwFlags);
|
|
|
|
|
|
|
|
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
|
|
|
|
dwFlags ^= ICU_NO_ENCODE;
|
|
|
|
|
|
|
|
dwFlags |= 0x80000000; /* Don't know what this means */
|
|
|
|
|
|
|
|
hr = UrlCanonicalizeW(lpszUrl, lpszBuffer, lpdwBufferLength, dwFlags);
|
|
|
|
|
|
|
|
return (hr == S_OK) ? TRUE : FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetSetStatusCallback (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Sets up a callback function which is called as progress is made
|
2002-06-01 01:06:46 +02:00
|
|
|
* during an operation.
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Previous callback or NULL on success
|
|
|
|
* INTERNET_INVALID_STATUS_CALLBACK on failure
|
|
|
|
*
|
|
|
|
*/
|
2001-09-11 02:32:32 +02:00
|
|
|
INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallback(
|
2000-04-11 22:07:00 +02:00
|
|
|
HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
|
|
|
|
{
|
|
|
|
INTERNET_STATUS_CALLBACK retVal;
|
|
|
|
LPWININETAPPINFOA lpwai = (LPWININETAPPINFOA)hInternet;
|
|
|
|
|
|
|
|
TRACE("0x%08lx\n", (ULONG)hInternet);
|
|
|
|
if (lpwai->hdr.htype != WH_HINIT)
|
2002-06-01 01:06:46 +02:00
|
|
|
return INTERNET_INVALID_STATUS_CALLBACK;
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
retVal = lpwai->lpfnStatusCB;
|
|
|
|
lpwai->lpfnStatusCB = lpfnIntCB;
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetWriteFile (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Write data to an open internet file
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2000-04-15 22:44:21 +02:00
|
|
|
BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
|
2000-04-11 22:07:00 +02:00
|
|
|
DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
|
|
|
|
{
|
|
|
|
BOOL retval = FALSE;
|
2001-08-24 21:13:36 +02:00
|
|
|
int nSocket = -1;
|
2000-04-11 22:07:00 +02:00
|
|
|
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
if (NULL == lpwh)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (lpwh->htype)
|
|
|
|
{
|
|
|
|
case WH_HHTTPREQ:
|
2002-06-01 01:06:46 +02:00
|
|
|
nSocket = ((LPWININETHTTPREQA)hFile)->nSocketFD;
|
2000-04-11 22:07:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WH_HFILE:
|
|
|
|
nSocket = ((LPWININETFILE)hFile)->nDataSocket;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-08-24 21:13:36 +02:00
|
|
|
if (nSocket != -1)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2002-06-22 01:59:49 +02:00
|
|
|
int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0);
|
|
|
|
retval = (res >= 0);
|
|
|
|
*lpdwNumOfBytesWritten = retval ? res : 0;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetReadFile (WININET.@)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Read data from an open internet file
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
|
2000-04-11 22:07:00 +02:00
|
|
|
DWORD dwNumOfBytesToRead, LPDWORD dwNumOfBytesRead)
|
|
|
|
{
|
|
|
|
BOOL retval = FALSE;
|
2001-08-24 21:13:36 +02:00
|
|
|
int nSocket = -1;
|
2000-04-11 22:07:00 +02:00
|
|
|
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
|
|
|
|
|
|
|
|
TRACE("\n");
|
2002-06-22 01:59:49 +02:00
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
if (NULL == lpwh)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
switch (lpwh->htype)
|
|
|
|
{
|
|
|
|
case WH_HHTTPREQ:
|
2002-06-01 01:06:46 +02:00
|
|
|
nSocket = ((LPWININETHTTPREQA)hFile)->nSocketFD;
|
2000-04-11 22:07:00 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WH_HFILE:
|
|
|
|
nSocket = ((LPWININETFILE)hFile)->nDataSocket;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2001-08-24 21:13:36 +02:00
|
|
|
if (nSocket != -1)
|
2000-04-11 22:07:00 +02:00
|
|
|
{
|
2002-06-22 01:59:49 +02:00
|
|
|
int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, 0);
|
|
|
|
retval = (res >= 0);
|
|
|
|
*dwNumOfBytesRead = retval ? res : 0;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2002-09-28 00:05:23 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetReadFileExA (WININET.@)
|
|
|
|
*
|
|
|
|
* Read data from an open internet file
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetReadFileExA(HINTERNET hFile, LPINTERNET_BUFFERSA lpBuffer,
|
|
|
|
DWORD dwFlags, DWORD dwContext)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetReadFileExW (WININET.@)
|
|
|
|
*
|
|
|
|
* Read data from an open internet file
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetReadFileExW(HINTERNET hFile, LPINTERNET_BUFFERSW lpBuffer,
|
|
|
|
DWORD dwFlags, DWORD dwContext)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
|
|
|
|
INTERNET_SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
|
2000-06-11 22:04:44 +02:00
|
|
|
/***********************************************************************
|
2002-12-05 20:54:40 +01:00
|
|
|
* INET_QueryOptionHelper (internal)
|
2000-06-11 22:04:44 +02:00
|
|
|
*/
|
2002-12-05 20:54:40 +01:00
|
|
|
static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD dwOption,
|
|
|
|
LPVOID lpBuffer, LPDWORD lpdwBufferLength)
|
2000-06-11 22:04:44 +02:00
|
|
|
{
|
|
|
|
LPWININETHANDLEHEADER lpwhh;
|
|
|
|
BOOL bSuccess = FALSE;
|
|
|
|
|
|
|
|
TRACE("0x%08lx\n", dwOption);
|
|
|
|
|
|
|
|
if (NULL == hInternet)
|
|
|
|
{
|
|
|
|
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
lpwhh = (LPWININETHANDLEHEADER) hInternet;
|
|
|
|
|
|
|
|
switch (dwOption)
|
|
|
|
{
|
2002-06-22 01:59:49 +02:00
|
|
|
case INTERNET_OPTION_HANDLE_TYPE:
|
|
|
|
{
|
|
|
|
ULONG type = lpwhh->htype;
|
|
|
|
TRACE("INTERNET_OPTION_HANDLE_TYPE: %ld\n", type);
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
if (*lpdwBufferLength < sizeof(ULONG))
|
|
|
|
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(lpBuffer, &type, sizeof(ULONG));
|
|
|
|
*lpdwBufferLength = sizeof(ULONG);
|
|
|
|
bSuccess = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case INTERNET_OPTION_REQUEST_FLAGS:
|
|
|
|
{
|
|
|
|
ULONG flags = 4;
|
|
|
|
TRACE("INTERNET_OPTION_REQUEST_FLAGS: %ld\n", flags);
|
|
|
|
if (*lpdwBufferLength < sizeof(ULONG))
|
|
|
|
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(lpBuffer, &flags, sizeof(ULONG));
|
|
|
|
*lpdwBufferLength = sizeof(ULONG);
|
|
|
|
bSuccess = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case INTERNET_OPTION_URL:
|
|
|
|
case INTERNET_OPTION_DATAFILE_NAME:
|
|
|
|
{
|
|
|
|
ULONG type = lpwhh->htype;
|
|
|
|
if (type == WH_HHTTPREQ)
|
|
|
|
{
|
|
|
|
LPWININETHTTPREQA lpreq = hInternet;
|
|
|
|
char url[1023];
|
|
|
|
|
|
|
|
sprintf(url,"http://%s%s",lpreq->lpszHostName,lpreq->lpszPath);
|
|
|
|
TRACE("INTERNET_OPTION_URL: %s\n",url);
|
|
|
|
if (*lpdwBufferLength < strlen(url)+1)
|
|
|
|
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
|
|
|
|
else
|
|
|
|
{
|
2002-12-05 20:54:40 +01:00
|
|
|
if(bIsUnicode)
|
|
|
|
{
|
|
|
|
*lpdwBufferLength=MultiByteToWideChar(CP_ACP,0,url,-1,lpBuffer,*lpdwBufferLength);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(lpBuffer, url, strlen(url)+1);
|
2002-06-22 01:59:49 +02:00
|
|
|
*lpdwBufferLength = strlen(url)+1;
|
2002-12-05 20:54:40 +01:00
|
|
|
}
|
2002-06-22 01:59:49 +02:00
|
|
|
bSuccess = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INTERNET_OPTION_HTTP_VERSION:
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Presently hardcoded to 1.1
|
|
|
|
*/
|
|
|
|
((HTTP_VERSION_INFO*)lpBuffer)->dwMajorVersion = 1;
|
|
|
|
((HTTP_VERSION_INFO*)lpBuffer)->dwMinorVersion = 1;
|
|
|
|
bSuccess = TRUE;
|
|
|
|
break;
|
2000-06-11 22:04:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2002-06-22 01:59:49 +02:00
|
|
|
FIXME("Stub! %ld \n",dwOption);
|
2000-06-11 22:04:44 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
2002-12-05 20:54:40 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetQueryOptionW (WININET.@)
|
|
|
|
*
|
|
|
|
* Queries an options on the specified handle
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetQueryOptionW(HINTERNET hInternet, DWORD dwOption,
|
|
|
|
LPVOID lpBuffer, LPDWORD lpdwBufferLength)
|
|
|
|
{
|
|
|
|
return INET_QueryOptionHelper(TRUE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetQueryOptionA (WININET.@)
|
|
|
|
*
|
|
|
|
* Queries an options on the specified handle
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetQueryOptionA(HINTERNET hInternet, DWORD dwOption,
|
|
|
|
LPVOID lpBuffer, LPDWORD lpdwBufferLength)
|
|
|
|
{
|
|
|
|
return INET_QueryOptionHelper(FALSE, hInternet, dwOption, lpBuffer, lpdwBufferLength);
|
|
|
|
}
|
|
|
|
|
2000-06-11 22:04:44 +02:00
|
|
|
|
2002-03-11 02:09:25 +01:00
|
|
|
/***********************************************************************
|
2002-03-23 22:39:05 +01:00
|
|
|
* InternetSetOptionW (WININET.@)
|
2002-03-11 02:09:25 +01:00
|
|
|
*
|
|
|
|
* Sets an options on the specified handle
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-03-23 22:39:05 +01:00
|
|
|
BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
|
2002-03-11 02:09:25 +01:00
|
|
|
LPVOID lpBuffer, DWORD dwBufferLength)
|
|
|
|
{
|
|
|
|
LPWININETHANDLEHEADER lpwhh;
|
|
|
|
|
|
|
|
TRACE("0x%08lx\n", dwOption);
|
|
|
|
|
|
|
|
if (NULL == hInternet)
|
|
|
|
{
|
|
|
|
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
|
2002-12-05 20:54:40 +01:00
|
|
|
return FALSE;
|
2002-03-11 02:09:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
lpwhh = (LPWININETHANDLEHEADER) hInternet;
|
|
|
|
|
|
|
|
switch (dwOption)
|
|
|
|
{
|
2002-12-05 20:54:40 +01:00
|
|
|
case INTERNET_OPTION_HTTP_VERSION:
|
|
|
|
{
|
|
|
|
HTTP_VERSION_INFO* pVersion=(HTTP_VERSION_INFO*)lpBuffer;
|
|
|
|
FIXME("Option INTERNET_OPTION_HTTP_VERSION(%ld,%ld): STUB\n",pVersion->dwMajorVersion,pVersion->dwMinorVersion);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INTERNET_OPTION_ERROR_MASK:
|
|
|
|
{
|
|
|
|
unsigned long flags=*(unsigned long*)lpBuffer;
|
|
|
|
FIXME("Option INTERNET_OPTION_ERROR_MASK(%ld): STUB\n",flags);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INTERNET_OPTION_CODEPAGE:
|
|
|
|
{
|
|
|
|
unsigned long codepage=*(unsigned long*)lpBuffer;
|
|
|
|
FIXME("Option INTERNET_OPTION_CODEPAGE (%ld): STUB\n",codepage);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INTERNET_OPTION_REQUEST_PRIORITY:
|
|
|
|
{
|
|
|
|
unsigned long priority=*(unsigned long*)lpBuffer;
|
|
|
|
FIXME("Option INTERNET_OPTION_REQUEST_PRIORITY (%ld): STUB\n",priority);
|
|
|
|
}
|
|
|
|
break;
|
2002-03-11 02:09:25 +01:00
|
|
|
default:
|
2002-12-05 20:54:40 +01:00
|
|
|
FIXME("Option %ld STUB\n",dwOption);
|
2002-03-11 02:09:25 +01:00
|
|
|
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
|
2002-12-05 20:54:40 +01:00
|
|
|
return FALSE;
|
2002-03-11 02:09:25 +01:00
|
|
|
}
|
|
|
|
|
2002-12-05 20:54:40 +01:00
|
|
|
return TRUE;
|
2002-03-11 02:09:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2002-03-23 22:39:05 +01:00
|
|
|
* InternetSetOptionA (WININET.@)
|
2002-03-11 02:09:25 +01:00
|
|
|
*
|
|
|
|
* Sets an options on the specified handle.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-03-23 22:39:05 +01:00
|
|
|
BOOL WINAPI InternetSetOptionA(HINTERNET hInternet, DWORD dwOption,
|
2002-03-11 02:09:25 +01:00
|
|
|
LPVOID lpBuffer, DWORD dwBufferLength)
|
|
|
|
{
|
|
|
|
/* FIXME!!! implement if lpBuffer is a string, dwBufferLength is
|
|
|
|
in TCHARs */
|
|
|
|
return InternetSetOptionW(hInternet,dwOption, lpBuffer,
|
|
|
|
dwBufferLength);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-14 21:24:50 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetGetCookieA (WININET.@)
|
2001-06-14 21:24:50 +02:00
|
|
|
*
|
|
|
|
* Retrieve cookie from the specified url
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
2002-10-28 19:48:24 +01:00
|
|
|
LPSTR lpCookieData, LPDWORD lpdwSize)
|
2001-06-14 21:24:50 +02:00
|
|
|
{
|
2002-10-28 19:48:24 +01:00
|
|
|
FIXME("STUB\n");
|
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_a(lpszUrl),debugstr_a(lpszCookieName),
|
|
|
|
lpCookieData);
|
2001-09-11 01:12:42 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2002-10-28 19:48:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetGetCookieW (WININET.@)
|
|
|
|
*
|
|
|
|
* Retrieve cookie from the specified url
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetGetCookieW(LPCSTR lpszUrl, LPCWSTR lpszCookieName,
|
|
|
|
LPWSTR lpCookieData, LPDWORD lpdwSize)
|
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
TRACE("(%s,%s,%p)\n", debugstr_a(lpszUrl), debugstr_w(lpszCookieName),
|
|
|
|
lpCookieData);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-11 01:12:42 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* InternetSetCookieA (WININET.@)
|
|
|
|
*
|
|
|
|
* Sets cookie for the specified url
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-10-28 19:48:24 +01:00
|
|
|
BOOL WINAPI InternetSetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
|
|
|
|
LPCSTR lpCookieData)
|
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl),
|
|
|
|
debugstr_a(lpszCookieName), debugstr_a(lpCookieData));
|
2001-09-11 01:12:42 +02:00
|
|
|
return FALSE;
|
2001-06-14 21:24:50 +02:00
|
|
|
}
|
|
|
|
|
2002-10-28 19:48:24 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetSetCookieW (WININET.@)
|
|
|
|
*
|
|
|
|
* Sets cookie for the specified url
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetSetCookieW(LPCSTR lpszUrl, LPCWSTR lpszCookieName,
|
|
|
|
LPCWSTR lpCookieData)
|
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
TRACE("(%s,%s,%s)\n", debugstr_a(lpszUrl),
|
|
|
|
debugstr_w(lpszCookieName), debugstr_w(lpCookieData));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-08-01 22:53:42 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* InternetCheckConnectionA (WININET.@)
|
2000-08-01 22:53:42 +02:00
|
|
|
*
|
|
|
|
* Pings a requested host to check internet connection
|
|
|
|
*
|
|
|
|
* RETURNS
|
2002-10-28 19:48:24 +01:00
|
|
|
* TRUE on success and FALSE on failure. If a failure then
|
|
|
|
* ERROR_NOT_CONNECTED is placesd into GetLastError
|
2000-08-01 22:53:42 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* this is a kludge which runs the resident ping program and reads the output.
|
|
|
|
*
|
|
|
|
* Anyone have a better idea?
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL rc = FALSE;
|
|
|
|
char command[1024];
|
|
|
|
char host[1024];
|
|
|
|
int status = -1;
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
FIXME("\n");
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
2000-08-01 22:53:42 +02:00
|
|
|
* Crack or set the Address
|
|
|
|
*/
|
|
|
|
if (lpszUrl == NULL)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
2000-08-01 22:53:42 +02:00
|
|
|
* According to the doc we are supost to use the ip for the next
|
2002-06-01 01:06:46 +02:00
|
|
|
* server in the WnInet internal server database. I have
|
2000-08-01 22:53:42 +02:00
|
|
|
* no idea what that is or how to get it.
|
|
|
|
*
|
|
|
|
* So someone needs to implement this.
|
|
|
|
*/
|
2001-05-09 19:31:31 +02:00
|
|
|
FIXME("Unimplemented with URL of NULL\n");
|
2000-08-01 22:53:42 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
URL_COMPONENTSA componets;
|
|
|
|
|
|
|
|
ZeroMemory(&componets,sizeof(URL_COMPONENTSA));
|
|
|
|
componets.lpszHostName = (LPSTR)&host;
|
|
|
|
componets.dwHostNameLength = 1024;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-01 22:53:42 +02:00
|
|
|
if (!InternetCrackUrlA(lpszUrl,0,0,&componets))
|
|
|
|
goto End;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-01 22:53:42 +02:00
|
|
|
TRACE("host name : %s\n",componets.lpszHostName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Build our ping command
|
|
|
|
*/
|
|
|
|
strcpy(command,"ping -w 1 ");
|
|
|
|
strcat(command,host);
|
|
|
|
strcat(command," >/dev/null 2>/dev/null");
|
|
|
|
|
|
|
|
TRACE("Ping command is : %s\n",command);
|
|
|
|
|
|
|
|
status = system(command);
|
|
|
|
|
|
|
|
TRACE("Ping returned a code of %i \n",status);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
/* Ping return code of 0 indicates success */
|
2000-08-01 22:53:42 +02:00
|
|
|
if (status == 0)
|
|
|
|
rc = TRUE;
|
|
|
|
|
|
|
|
End:
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-08-01 22:53:42 +02:00
|
|
|
if (rc == FALSE)
|
|
|
|
SetLastError(ERROR_NOT_CONNECTED);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-10-28 19:48:24 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetCheckConnectionW (WININET.@)
|
|
|
|
*
|
|
|
|
* Pings a requested host to check internet connection
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success and FALSE on failure. If a failure then
|
|
|
|
* ERROR_NOT_CONNECTED is placed into GetLastError
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetCheckConnectionW(LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
|
|
|
|
{
|
|
|
|
CHAR *szUrl;
|
|
|
|
INT len;
|
|
|
|
BOOL rc;
|
|
|
|
|
|
|
|
len = lstrlenW(lpszUrl)+1;
|
|
|
|
if (!(szUrl = (CHAR *)malloc(len*sizeof(CHAR))))
|
|
|
|
return FALSE;
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszUrl, -1, szUrl, len, NULL, NULL);
|
|
|
|
rc = InternetCheckConnectionA((LPCSTR)szUrl, dwFlags, dwReserved);
|
|
|
|
free(szUrl);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-20 01:56:49 +01:00
|
|
|
/**********************************************************
|
|
|
|
* InternetOpenUrlA (WININET.@)
|
|
|
|
*
|
|
|
|
* Opens an URL
|
2002-06-01 01:06:46 +02:00
|
|
|
*
|
2002-03-20 01:56:49 +01:00
|
|
|
* RETURNS
|
|
|
|
* handle of connection or NULL on failure
|
|
|
|
*/
|
2002-10-28 19:48:24 +01:00
|
|
|
HINTERNET WINAPI InternetOpenUrlA(HINTERNET hInternet, LPCSTR lpszUrl,
|
|
|
|
LPCSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
|
2002-03-20 01:56:49 +01:00
|
|
|
{
|
|
|
|
URL_COMPONENTSA urlComponents;
|
2002-10-28 19:48:24 +01:00
|
|
|
char protocol[32], hostName[MAXHOSTNAME], userName[1024];
|
|
|
|
char password[1024], path[2048], extra[1024];
|
2002-03-20 01:56:49 +01:00
|
|
|
HINTERNET client = NULL, client1 = NULL;
|
|
|
|
urlComponents.dwStructSize = sizeof(URL_COMPONENTSA);
|
|
|
|
urlComponents.lpszScheme = protocol;
|
|
|
|
urlComponents.dwSchemeLength = 32;
|
|
|
|
urlComponents.lpszHostName = hostName;
|
|
|
|
urlComponents.dwHostNameLength = MAXHOSTNAME;
|
|
|
|
urlComponents.lpszUserName = userName;
|
|
|
|
urlComponents.dwUserNameLength = 1024;
|
|
|
|
urlComponents.lpszPassword = password;
|
|
|
|
urlComponents.dwPasswordLength = 1024;
|
|
|
|
urlComponents.lpszUrlPath = path;
|
|
|
|
urlComponents.dwUrlPathLength = 2048;
|
|
|
|
urlComponents.lpszExtraInfo = extra;
|
|
|
|
urlComponents.dwExtraInfoLength = 1024;
|
|
|
|
if(!InternetCrackUrlA(lpszUrl, strlen(lpszUrl), 0, &urlComponents))
|
|
|
|
return NULL;
|
|
|
|
switch(urlComponents.nScheme) {
|
|
|
|
case INTERNET_SCHEME_FTP:
|
|
|
|
if(urlComponents.nPort == 0)
|
|
|
|
urlComponents.nPort = INTERNET_DEFAULT_FTP_PORT;
|
2002-10-28 19:48:24 +01:00
|
|
|
client = InternetConnectA(hInternet, hostName, urlComponents.nPort,
|
|
|
|
userName, password, INTERNET_SERVICE_FTP, dwFlags, dwContext);
|
2002-03-20 01:56:49 +01:00
|
|
|
return FtpOpenFileA(client, path, GENERIC_READ, dwFlags, dwContext);
|
|
|
|
break;
|
|
|
|
case INTERNET_SCHEME_HTTP:
|
|
|
|
case INTERNET_SCHEME_HTTPS:
|
|
|
|
{
|
|
|
|
LPCSTR accept[2] = { "*/*", NULL };
|
|
|
|
char *hostreq=(char*)malloc(strlen(hostName)+9);
|
|
|
|
sprintf(hostreq, "Host: %s\r\n", hostName);
|
|
|
|
if(urlComponents.nPort == 0) {
|
|
|
|
if(urlComponents.nScheme == INTERNET_SCHEME_HTTP)
|
|
|
|
urlComponents.nPort = INTERNET_DEFAULT_HTTP_PORT;
|
|
|
|
else
|
|
|
|
urlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
|
|
|
|
}
|
2002-10-28 19:48:24 +01:00
|
|
|
client = InternetConnectA(hInternet, hostName, urlComponents.nPort, userName,
|
|
|
|
password, INTERNET_SERVICE_HTTP, dwFlags, dwContext);
|
2002-03-20 01:56:49 +01:00
|
|
|
if(client == NULL)
|
|
|
|
return NULL;
|
|
|
|
client1 = HttpOpenRequestA(hInternet, NULL, path, NULL, NULL, accept, dwFlags, dwContext);
|
|
|
|
if(client1 == NULL) {
|
|
|
|
InternetCloseHandle(client);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
HttpAddRequestHeadersA(client1, lpszHeaders, dwHeadersLength, HTTP_ADDREQ_FLAG_ADD);
|
|
|
|
HttpAddRequestHeadersA(client1, hostreq, -1L, HTTP_ADDREQ_FLAG_ADD_IF_NEW);
|
|
|
|
if(!HttpSendRequestA(client1, NULL, 0, NULL, 0)) {
|
|
|
|
InternetCloseHandle(client1);
|
|
|
|
InternetCloseHandle(client);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return client1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case INTERNET_SCHEME_GOPHER:
|
|
|
|
/* gopher doesn't seem to be implemented in wine, but it's supposed
|
|
|
|
* to be supported by InternetOpenUrlA. */
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if(client != NULL)
|
|
|
|
InternetCloseHandle(client);
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
|
|
|
|
|
2002-10-28 19:48:24 +01:00
|
|
|
/**********************************************************
|
|
|
|
* InternetOpenUrlW (WININET.@)
|
|
|
|
*
|
|
|
|
* Opens an URL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* handle of connection or NULL on failure
|
|
|
|
*/
|
|
|
|
HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl,
|
|
|
|
LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD dwContext)
|
|
|
|
{
|
|
|
|
HINTERNET rc = (HINTERNET)NULL;
|
|
|
|
|
|
|
|
INT lenUrl = lstrlenW(lpszUrl)+1;
|
|
|
|
INT lenHeaders = lstrlenW(lpszHeaders)+1;
|
|
|
|
CHAR *szUrl = (CHAR *)malloc(lenUrl*sizeof(CHAR));
|
|
|
|
CHAR *szHeaders = (CHAR *)malloc(lenHeaders*sizeof(CHAR));
|
|
|
|
|
|
|
|
if (!szUrl || !szHeaders)
|
|
|
|
{
|
|
|
|
if (szUrl)
|
|
|
|
free(szUrl);
|
|
|
|
if (szHeaders)
|
|
|
|
free(szHeaders);
|
|
|
|
return (HINTERNET)NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszUrl, -1, szUrl, lenUrl,
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, -1, lpszHeaders, -1, szHeaders, lenHeaders,
|
|
|
|
NULL, NULL);
|
|
|
|
|
|
|
|
rc = InternetOpenUrlA(hInternet, szUrl, szHeaders,
|
|
|
|
dwHeadersLength, dwFlags, dwContext);
|
|
|
|
|
|
|
|
free(szUrl);
|
|
|
|
free(szHeaders);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-04-11 22:07:00 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_SetLastError (internal)
|
|
|
|
*
|
|
|
|
* Set last thread specific error
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void INTERNET_SetLastError(DWORD dwError)
|
|
|
|
{
|
|
|
|
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
|
|
|
|
|
|
|
|
SetLastError(dwError);
|
2002-12-05 20:54:40 +01:00
|
|
|
if(lpwite)
|
|
|
|
lpwite->dwError = dwError;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_GetLastError (internal)
|
|
|
|
*
|
|
|
|
* Get last thread specific error
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD INTERNET_GetLastError()
|
|
|
|
{
|
|
|
|
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
|
|
|
|
return lpwite->dwError;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_WorkerThreadFunc (internal)
|
|
|
|
*
|
|
|
|
* Worker thread execution function
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD INTERNET_WorkerThreadFunc(LPVOID *lpvParam)
|
|
|
|
{
|
|
|
|
DWORD dwWaitRes;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2002-11-13 20:40:50 +01:00
|
|
|
if(dwNumJobs > 0) {
|
|
|
|
INTERNET_ExecuteWork();
|
|
|
|
continue;
|
|
|
|
}
|
2000-04-11 22:07:00 +02:00
|
|
|
dwWaitRes = WaitForMultipleObjects(2, hEventArray, FALSE, MAX_IDLE_WORKER);
|
|
|
|
|
|
|
|
if (dwWaitRes == WAIT_OBJECT_0 + 1)
|
|
|
|
INTERNET_ExecuteWork();
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
|
|
|
|
InterlockedIncrement(&dwNumIdleThreads);
|
|
|
|
}
|
|
|
|
|
|
|
|
InterlockedDecrement(&dwNumIdleThreads);
|
|
|
|
InterlockedDecrement(&dwNumThreads);
|
|
|
|
TRACE("Worker thread exiting\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_InsertWorkRequest (internal)
|
|
|
|
*
|
|
|
|
* Insert work request into queue
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL INTERNET_InsertWorkRequest(LPWORKREQUEST lpWorkRequest)
|
|
|
|
{
|
|
|
|
BOOL bSuccess = FALSE;
|
|
|
|
LPWORKREQUEST lpNewRequest;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
lpNewRequest = HeapAlloc(GetProcessHeap(), 0, sizeof(WORKREQUEST));
|
|
|
|
if (lpNewRequest)
|
|
|
|
{
|
|
|
|
memcpy(lpNewRequest, lpWorkRequest, sizeof(WORKREQUEST));
|
|
|
|
lpNewRequest->prev = NULL;
|
|
|
|
|
|
|
|
EnterCriticalSection(&csQueue);
|
|
|
|
|
|
|
|
lpNewRequest->next = lpWorkQueueTail;
|
|
|
|
if (lpWorkQueueTail)
|
|
|
|
lpWorkQueueTail->prev = lpNewRequest;
|
|
|
|
lpWorkQueueTail = lpNewRequest;
|
|
|
|
if (!lpHeadWorkQueue)
|
|
|
|
lpHeadWorkQueue = lpWorkQueueTail;
|
|
|
|
|
|
|
|
LeaveCriticalSection(&csQueue);
|
|
|
|
|
|
|
|
bSuccess = TRUE;
|
2002-11-13 20:40:50 +01:00
|
|
|
InterlockedIncrement(&dwNumJobs);
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-04-23 21:55:26 +02:00
|
|
|
* INTERNET_GetWorkRequest (internal)
|
2000-04-11 22:07:00 +02:00
|
|
|
*
|
|
|
|
* Retrieves work request from queue
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL INTERNET_GetWorkRequest(LPWORKREQUEST lpWorkRequest)
|
|
|
|
{
|
|
|
|
BOOL bSuccess = FALSE;
|
|
|
|
LPWORKREQUEST lpRequest = NULL;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
EnterCriticalSection(&csQueue);
|
|
|
|
|
|
|
|
if (lpHeadWorkQueue)
|
|
|
|
{
|
|
|
|
lpRequest = lpHeadWorkQueue;
|
|
|
|
lpHeadWorkQueue = lpHeadWorkQueue->prev;
|
|
|
|
if (lpRequest == lpWorkQueueTail)
|
|
|
|
lpWorkQueueTail = lpHeadWorkQueue;
|
|
|
|
}
|
|
|
|
|
|
|
|
LeaveCriticalSection(&csQueue);
|
|
|
|
|
|
|
|
if (lpRequest)
|
|
|
|
{
|
|
|
|
memcpy(lpWorkRequest, lpRequest, sizeof(WORKREQUEST));
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpRequest);
|
|
|
|
bSuccess = TRUE;
|
2002-11-13 20:40:50 +01:00
|
|
|
InterlockedDecrement(&dwNumJobs);
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_AsyncCall (internal)
|
|
|
|
*
|
|
|
|
* Retrieves work request from queue
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL INTERNET_AsyncCall(LPWORKREQUEST lpWorkRequest)
|
|
|
|
{
|
|
|
|
HANDLE hThread;
|
|
|
|
DWORD dwTID;
|
|
|
|
BOOL bSuccess = FALSE;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (InterlockedDecrement(&dwNumIdleThreads) < 0)
|
|
|
|
{
|
|
|
|
InterlockedIncrement(&dwNumIdleThreads);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (InterlockedIncrement(&dwNumThreads) > MAX_WORKER_THREADS ||
|
|
|
|
!(hThread = CreateThread(NULL, 0,
|
2000-04-11 22:07:00 +02:00
|
|
|
(LPTHREAD_START_ROUTINE)INTERNET_WorkerThreadFunc, NULL, 0, &dwTID)))
|
|
|
|
{
|
|
|
|
InterlockedDecrement(&dwNumThreads);
|
|
|
|
INTERNET_SetLastError(ERROR_INTERNET_ASYNC_THREAD_FAILED);
|
|
|
|
goto lerror;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created new thread\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
bSuccess = TRUE;
|
|
|
|
INTERNET_InsertWorkRequest(lpWorkRequest);
|
|
|
|
SetEvent(hWorkEvent);
|
|
|
|
|
|
|
|
lerror:
|
|
|
|
|
|
|
|
return bSuccess;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_ExecuteWork (internal)
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
VOID INTERNET_ExecuteWork()
|
|
|
|
{
|
|
|
|
WORKREQUEST workRequest;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
if (INTERNET_GetWorkRequest(&workRequest))
|
|
|
|
{
|
2002-11-13 20:40:50 +01:00
|
|
|
TRACE("Got work %d\n", workRequest.asyncall);
|
2000-04-11 22:07:00 +02:00
|
|
|
switch (workRequest.asyncall)
|
|
|
|
{
|
|
|
|
case FTPPUTFILEA:
|
|
|
|
FTP_FtpPutFileA((HINTERNET)workRequest.HFTPSESSION, (LPCSTR)workRequest.LPSZLOCALFILE,
|
|
|
|
(LPCSTR)workRequest.LPSZNEWREMOTEFILE, workRequest.DWFLAGS, workRequest.DWCONTEXT);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZLOCALFILE);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZNEWREMOTEFILE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPSETCURRENTDIRECTORYA:
|
2002-06-01 01:06:46 +02:00
|
|
|
FTP_FtpSetCurrentDirectoryA((HINTERNET)workRequest.HFTPSESSION,
|
2000-04-11 22:07:00 +02:00
|
|
|
(LPCSTR)workRequest.LPSZDIRECTORY);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDIRECTORY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPCREATEDIRECTORYA:
|
2002-06-01 01:06:46 +02:00
|
|
|
FTP_FtpCreateDirectoryA((HINTERNET)workRequest.HFTPSESSION,
|
2000-04-11 22:07:00 +02:00
|
|
|
(LPCSTR)workRequest.LPSZDIRECTORY);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDIRECTORY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPFINDFIRSTFILEA:
|
2002-06-01 01:06:46 +02:00
|
|
|
FTP_FtpFindFirstFileA((HINTERNET)workRequest.HFTPSESSION,
|
|
|
|
(LPCSTR)workRequest.LPSZSEARCHFILE,
|
|
|
|
(LPWIN32_FIND_DATAA)workRequest.LPFINDFILEDATA, workRequest.DWFLAGS,
|
2000-04-11 22:07:00 +02:00
|
|
|
workRequest.DWCONTEXT);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZSEARCHFILE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPGETCURRENTDIRECTORYA:
|
2002-06-01 01:06:46 +02:00
|
|
|
FTP_FtpGetCurrentDirectoryA((HINTERNET)workRequest.HFTPSESSION,
|
2000-04-11 22:07:00 +02:00
|
|
|
(LPSTR)workRequest.LPSZDIRECTORY, (LPDWORD)workRequest.LPDWDIRECTORY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPOPENFILEA:
|
|
|
|
FTP_FtpOpenFileA((HINTERNET)workRequest.HFTPSESSION,
|
|
|
|
(LPCSTR)workRequest.LPSZFILENAME,
|
|
|
|
workRequest.FDWACCESS,
|
|
|
|
workRequest.DWFLAGS,
|
|
|
|
workRequest.DWCONTEXT);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZFILENAME);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPGETFILEA:
|
|
|
|
FTP_FtpGetFileA((HINTERNET)workRequest.HFTPSESSION,
|
|
|
|
(LPCSTR)workRequest.LPSZREMOTEFILE,
|
|
|
|
(LPCSTR)workRequest.LPSZNEWFILE,
|
|
|
|
(BOOL)workRequest.FFAILIFEXISTS,
|
|
|
|
workRequest.DWLOCALFLAGSATTRIBUTE,
|
|
|
|
workRequest.DWFLAGS,
|
|
|
|
workRequest.DWCONTEXT);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZREMOTEFILE);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZNEWFILE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPDELETEFILEA:
|
|
|
|
FTP_FtpDeleteFileA((HINTERNET)workRequest.HFTPSESSION,
|
|
|
|
(LPCSTR)workRequest.LPSZFILENAME);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZFILENAME);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPREMOVEDIRECTORYA:
|
|
|
|
FTP_FtpRemoveDirectoryA((HINTERNET)workRequest.HFTPSESSION,
|
|
|
|
(LPCSTR)workRequest.LPSZDIRECTORY);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDIRECTORY);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FTPRENAMEFILEA:
|
|
|
|
FTP_FtpRenameFileA((HINTERNET)workRequest.HFTPSESSION,
|
|
|
|
(LPCSTR)workRequest.LPSZSRCFILE,
|
|
|
|
(LPCSTR)workRequest.LPSZDESTFILE);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZSRCFILE);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZDESTFILE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case INTERNETFINDNEXTA:
|
|
|
|
INTERNET_FindNextFileA((HINTERNET)workRequest.HFTPSESSION,
|
|
|
|
(LPWIN32_FIND_DATAA)workRequest.LPFINDFILEDATA);
|
|
|
|
break;
|
2000-06-11 22:04:44 +02:00
|
|
|
|
|
|
|
case HTTPSENDREQUESTA:
|
2002-06-01 01:06:46 +02:00
|
|
|
HTTP_HttpSendRequestA((HINTERNET)workRequest.HFTPSESSION,
|
2000-06-11 22:04:44 +02:00
|
|
|
(LPCSTR)workRequest.LPSZHEADER,
|
2002-06-01 01:06:46 +02:00
|
|
|
workRequest.DWHEADERLENGTH,
|
|
|
|
(LPVOID)workRequest.LPOPTIONAL,
|
2000-06-11 22:04:44 +02:00
|
|
|
workRequest.DWOPTIONALLENGTH);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZHEADER);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HTTPOPENREQUESTA:
|
2002-06-01 01:06:46 +02:00
|
|
|
HTTP_HttpOpenRequestA((HINTERNET)workRequest.HFTPSESSION,
|
2000-06-11 22:04:44 +02:00
|
|
|
(LPCSTR)workRequest.LPSZVERB,
|
2002-06-01 01:06:46 +02:00
|
|
|
(LPCSTR)workRequest.LPSZOBJECTNAME,
|
|
|
|
(LPCSTR)workRequest.LPSZVERSION,
|
|
|
|
(LPCSTR)workRequest.LPSZREFERRER,
|
|
|
|
(LPCSTR*)workRequest.LPSZACCEPTTYPES,
|
2000-06-11 22:04:44 +02:00
|
|
|
workRequest.DWFLAGS,
|
|
|
|
workRequest.DWCONTEXT);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZVERB);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZOBJECTNAME);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZVERSION);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (LPVOID)workRequest.LPSZREFERRER);
|
|
|
|
break;
|
|
|
|
|
2002-06-22 01:59:49 +02:00
|
|
|
case SENDCALLBACK:
|
|
|
|
SendAsyncCallbackInt((LPWININETAPPINFOA)workRequest.param1,
|
|
|
|
(HINTERNET)workRequest.param2, workRequest.param3,
|
|
|
|
workRequest.param4, (LPVOID)workRequest.param5,
|
|
|
|
workRequest.param6);
|
|
|
|
break;
|
2000-04-11 22:07:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_GetResponseBuffer
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
LPSTR INTERNET_GetResponseBuffer()
|
|
|
|
{
|
|
|
|
LPWITHREADERROR lpwite = (LPWITHREADERROR)TlsGetValue(g_dwTlsErrIndex);
|
2002-06-22 01:59:49 +02:00
|
|
|
TRACE("\n");
|
2000-04-11 22:07:00 +02:00
|
|
|
return lpwite->response;
|
|
|
|
}
|
2000-06-11 22:04:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* INTERNET_GetNextLine (internal)
|
|
|
|
*
|
|
|
|
* Parse next line in directory string listing
|
|
|
|
*
|
|
|
|
* RETURNS
|
2001-10-22 21:04:32 +02:00
|
|
|
* Pointer to beginning of next line
|
2000-06-11 22:04:44 +02:00
|
|
|
* NULL on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
LPSTR INTERNET_GetNextLine(INT nSocket, LPSTR lpszBuffer, LPDWORD dwBuffer)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
fd_set infd;
|
|
|
|
BOOL bSuccess = FALSE;
|
|
|
|
INT nRecv = 0;
|
|
|
|
|
|
|
|
TRACE("\n");
|
|
|
|
|
|
|
|
FD_ZERO(&infd);
|
|
|
|
FD_SET(nSocket, &infd);
|
|
|
|
tv.tv_sec=RESPONSE_TIMEOUT;
|
|
|
|
tv.tv_usec=0;
|
|
|
|
|
|
|
|
while (nRecv < *dwBuffer)
|
|
|
|
{
|
|
|
|
if (select(nSocket+1,&infd,NULL,NULL,&tv) > 0)
|
|
|
|
{
|
|
|
|
if (recv(nSocket, &lpszBuffer[nRecv], 1, 0) <= 0)
|
|
|
|
{
|
|
|
|
INTERNET_SetLastError(ERROR_FTP_TRANSFER_IN_PROGRESS);
|
|
|
|
goto lend;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpszBuffer[nRecv] == '\n')
|
|
|
|
{
|
|
|
|
bSuccess = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (lpszBuffer[nRecv] != '\r')
|
|
|
|
nRecv++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
INTERNET_SetLastError(ERROR_INTERNET_TIMEOUT);
|
|
|
|
goto lend;
|
2001-09-11 02:32:32 +02:00
|
|
|
}
|
2000-06-11 22:04:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
lend:
|
|
|
|
if (bSuccess)
|
|
|
|
{
|
|
|
|
lpszBuffer[nRecv] = '\0';
|
|
|
|
*dwBuffer = nRecv - 1;
|
|
|
|
TRACE(":%d %s\n", nRecv, lpszBuffer);
|
|
|
|
return lpszBuffer;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2002-06-22 01:59:49 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
|
|
|
|
LPDWORD lpdwNumberOfBytesAvailble,
|
|
|
|
DWORD dwFlags, DWORD dwConext)
|
|
|
|
{
|
|
|
|
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hFile;
|
|
|
|
INT retval = -1;
|
|
|
|
int nSocket = -1;
|
|
|
|
|
|
|
|
|
|
|
|
if (NULL == lpwhr)
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NO_MORE_FILES);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("--> %p %i %i\n",lpwhr,lpwhr->hdr.htype,lpwhr->nSocketFD);
|
|
|
|
|
|
|
|
switch (lpwhr->hdr.htype)
|
|
|
|
{
|
|
|
|
case WH_HHTTPREQ:
|
|
|
|
nSocket = lpwhr->nSocketFD;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nSocket != -1)
|
|
|
|
{
|
|
|
|
char buffer[4048];
|
|
|
|
|
|
|
|
retval = recv(nSocket,buffer,4048,MSG_PEEK);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_NO_MORE_FILES);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpdwNumberOfBytesAvailble)
|
|
|
|
{
|
|
|
|
(*lpdwNumberOfBytesAvailble) = retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("<-- %i\n",retval);
|
|
|
|
return (retval+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetLockRequestFile( HINTERNET hInternet, HANDLE
|
|
|
|
*lphLockReqHandle)
|
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL WINAPI InternetUnlockRequestFile( HANDLE hLockHandle)
|
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-07-22 22:34:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetAutoDial
|
|
|
|
*
|
|
|
|
* On windows this function is supposed to dial the default internet
|
|
|
|
* connection. We don't want to have Wine dial out to the internet so
|
|
|
|
* we return TRUE by default. It might be nice to check if we are connected.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
2002-08-09 03:07:29 +02:00
|
|
|
BOOL WINAPI InternetAutoDial(DWORD dwFlags, HWND hwndParent)
|
2002-07-22 22:34:41 +02:00
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
|
|
|
|
/* Tell that we are connected to the internet. */
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-10-28 19:48:24 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* InternetAutoDialHangup
|
|
|
|
*
|
|
|
|
* Hangs up an connection made with InternetAutoDial
|
|
|
|
*
|
|
|
|
* PARAM
|
|
|
|
* dwReserved
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InternetAutodialHangup(DWORD dwReserved)
|
|
|
|
{
|
|
|
|
FIXME("STUB\n");
|
|
|
|
|
|
|
|
/* we didn't dial, we don't disconnect */
|
|
|
|
return TRUE;
|
|
|
|
}
|
2002-12-05 20:54:40 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* InternetCombineUrlA
|
|
|
|
*
|
|
|
|
* Combine a base URL with a relative URL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL WINAPI InternetCombineUrlA(LPCSTR lpszBaseUrl, LPCSTR lpszRelativeUrl,
|
|
|
|
LPSTR lpszBuffer, LPDWORD lpdwBufferLength,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
HRESULT hr=S_OK;
|
|
|
|
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
|
|
|
|
dwFlags ^= ICU_NO_ENCODE;
|
|
|
|
hr=UrlCombineA(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
|
|
|
|
|
|
|
|
return (hr==S_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*
|
|
|
|
* InternetCombineUrlW
|
|
|
|
*
|
|
|
|
* Combine a base URL with a relative URL
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE on success
|
|
|
|
* FALSE on failure
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
BOOL WINAPI InternetCombineUrlW(LPCWSTR lpszBaseUrl, LPCWSTR lpszRelativeUrl,
|
|
|
|
LPWSTR lpszBuffer, LPDWORD lpdwBufferLength,
|
|
|
|
DWORD dwFlags)
|
|
|
|
{
|
|
|
|
HRESULT hr=S_OK;
|
|
|
|
/* Flip this bit to correspond to URL_ESCAPE_UNSAFE */
|
|
|
|
dwFlags ^= ICU_NO_ENCODE;
|
|
|
|
hr=UrlCombineW(lpszBaseUrl,lpszRelativeUrl,lpszBuffer,lpdwBufferLength,dwFlags);
|
|
|
|
|
|
|
|
return (hr==S_OK);
|
|
|
|
}
|