Commit 7cc70c0a authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Implement proper HINTERNET handles.

parent 39081ddc
......@@ -2,6 +2,7 @@
* WININET - Ftp implementation
*
* Copyright 1999 Corel Corporation
* Copyright 2004 Mike McCormack for Codeweavers
*
* Ulrich Czekalla
* Noureddine Jemmali
......@@ -156,9 +157,10 @@ inline static LPSTR FTP_strdup( LPCSTR str )
BOOL WINAPI FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile,
LPCSTR lpszNewRemoteFile, DWORD dwFlags, DWORD dwContext)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -203,10 +205,12 @@ BOOL WINAPI FTP_FtpPutFileA(HINTERNET hConnect, LPCSTR lpszLocalFile,
HANDLE hFile = NULL;
BOOL bSuccess = FALSE;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFTPSESSIONA lpwfs;
INT nResCode;
TRACE(" lpszLocalFile(%s) lpszNewRemoteFile(%s)\n", lpszLocalFile, lpszNewRemoteFile);
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -282,9 +286,10 @@ lend:
*/
BOOL WINAPI FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -354,12 +359,13 @@ BOOL WINAPI FtpSetCurrentDirectoryW(HINTERNET hConnect, LPCWSTR lpszDirectory)
BOOL WINAPI FTP_FtpSetCurrentDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
{
INT nResCode;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
DWORD bSuccess = FALSE;
TRACE("lpszDirectory(%s)\n", lpszDirectory);
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -411,9 +417,10 @@ lend:
*/
BOOL WINAPI FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -483,9 +490,11 @@ BOOL WINAPI FTP_FtpCreateDirectoryA(HINTERNET hConnect, LPCSTR lpszDirectory)
INT nResCode;
BOOL bSuccess = FALSE;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFTPSESSIONA lpwfs;
TRACE("\n");
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -537,9 +546,10 @@ lend:
HINTERNET WINAPI FtpFindFirstFileA(HINTERNET hConnect,
LPCSTR lpszSearchFile, LPWIN32_FIND_DATAA lpFindFileData, DWORD dwFlags, DWORD dwContext)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -604,11 +614,12 @@ HINTERNET WINAPI FTP_FtpFindFirstFileA(HINTERNET hConnect,
{
INT nResCode;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hConnect;
LPWININETFINDNEXTA hFindNext = NULL;
LPWININETFTPSESSIONA lpwfs;
HINTERNET hFindNext = NULL;
TRACE("\n");
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hConnect );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -679,7 +690,7 @@ lend:
&iar, sizeof(INTERNET_ASYNC_RESULT));
}
return (HINTERNET)hFindNext;
return hFindNext;
}
......@@ -696,11 +707,12 @@ lend:
BOOL WINAPI FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrentDirectory,
LPDWORD lpdwCurrentDirectory)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
TRACE("len(%ld)\n", *lpdwCurrentDirectory);
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -761,12 +773,13 @@ BOOL WINAPI FTP_FtpGetCurrentDirectoryA(HINTERNET hFtpSession, LPSTR lpszCurrent
LPDWORD lpdwCurrentDirectory)
{
INT nResCode;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
DWORD bSuccess = FALSE;
TRACE("len(%ld)\n", *lpdwCurrentDirectory);
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -841,9 +854,10 @@ HINTERNET WINAPI FtpOpenFileA(HINTERNET hFtpSession,
LPCSTR lpszFileName, DWORD fdwAccess, DWORD dwFlags,
DWORD dwContext)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -914,12 +928,14 @@ HINTERNET FTP_FtpOpenFileA(HINTERNET hFtpSession,
{
INT nDataSocket;
BOOL bSuccess = FALSE;
LPWININETFILE hFile = NULL;
LPWININETFILE lpwh = NULL;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
HINTERNET handle = NULL;
TRACE("\n");
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -943,16 +959,17 @@ HINTERNET FTP_FtpOpenFileA(HINTERNET hFtpSession,
/* Get data socket to server */
if (bSuccess && FTP_GetDataSocket(lpwfs, &nDataSocket))
{
hFile = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETFILE));
hFile->hdr.htype = WH_HFILE;
hFile->hdr.dwFlags = dwFlags;
hFile->hdr.dwContext = dwContext;
hFile->hdr.lpwhparent = hFtpSession;
hFile->nDataSocket = nDataSocket;
hFile->session_deleted = FALSE;
lpwh = HeapAlloc(GetProcessHeap(), 0, sizeof(WININETFILE));
handle = WININET_AllocHandle( &lpwh->hdr );
lpwh->hdr.htype = WH_HFILE;
lpwh->hdr.dwFlags = dwFlags;
lpwh->hdr.dwContext = dwContext;
lpwh->hdr.lpwhparent = &lpwfs->hdr;
lpwh->nDataSocket = nDataSocket;
lpwh->session_deleted = FALSE;
/* Indicate that a download is currently in progress */
lpwfs->download_in_progress = hFile;
lpwfs->download_in_progress = lpwh;
}
if (lpwfs->lstnSocket != -1)
......@@ -963,9 +980,9 @@ HINTERNET FTP_FtpOpenFileA(HINTERNET hFtpSession,
{
INTERNET_ASYNC_RESULT iar;
if (hFile)
if (lpwh)
{
iar.dwResult = (DWORD)hFile;
iar.dwResult = (DWORD)lpwh;
iar.dwError = ERROR_SUCCESS;
hIC->lpfnStatusCB(hFtpSession, lpwfs->hdr.dwContext, INTERNET_STATUS_HANDLE_CREATED,
&iar, sizeof(INTERNET_ASYNC_RESULT));
......@@ -977,7 +994,7 @@ HINTERNET FTP_FtpOpenFileA(HINTERNET hFtpSession,
&iar, sizeof(INTERNET_ASYNC_RESULT));
}
return (HINTERNET)hFile;
return handle;
}
......@@ -995,9 +1012,10 @@ BOOL WINAPI FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR lpszN
BOOL fFailIfExists, DWORD dwLocalFlagsAttribute, DWORD dwInternetFlags,
DWORD dwContext)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hInternet;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hInternet );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1072,9 +1090,11 @@ BOOL WINAPI FTP_FtpGetFileA(HINTERNET hInternet, LPCSTR lpszRemoteFile, LPCSTR l
BOOL bSuccess = FALSE;
HANDLE hFile;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hInternet;
LPWININETFTPSESSIONA lpwfs;
TRACE("lpszRemoteFile(%s) lpszNewFile(%s)\n", lpszRemoteFile, lpszNewFile);
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hInternet );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1151,9 +1171,10 @@ lend:
*/
BOOL WINAPI FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1195,9 +1216,11 @@ BOOL FTP_FtpDeleteFileA(HINTERNET hFtpSession, LPCSTR lpszFileName)
INT nResCode;
BOOL bSuccess = FALSE;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
TRACE("0x%08lx\n", (ULONG) hFtpSession);
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1247,9 +1270,10 @@ lend:
*/
BOOL WINAPI FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1291,9 +1315,11 @@ BOOL FTP_FtpRemoveDirectoryA(HINTERNET hFtpSession, LPCSTR lpszDirectory)
INT nResCode;
BOOL bSuccess = FALSE;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
TRACE("\n");
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1344,9 +1370,10 @@ lend:
*/
BOOL WINAPI FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDest)
{
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
LPWININETAPPINFOA hIC = NULL;
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1388,9 +1415,11 @@ BOOL FTP_FtpRenameFileA(HINTERNET hFtpSession, LPCSTR lpszSrc, LPCSTR lpszDest)
INT nResCode;
BOOL bSuccess = FALSE;
LPWININETAPPINFOA hIC = NULL;
LPWININETFTPSESSIONA lpwfs = (LPWININETFTPSESSIONA) hFtpSession;
LPWININETFTPSESSIONA lpwfs;
TRACE("\n");
lpwfs = (LPWININETFTPSESSIONA) WININET_GetObject( hFtpSession );
if (NULL == lpwfs || WH_HFTPSESSION != lpwfs->hdr.htype)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1456,16 +1485,16 @@ HINTERNET FTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
LPWININETAPPINFOA hIC = NULL;
BOOL bSuccess = FALSE;
LPWININETFTPSESSIONA lpwfs = NULL;
HINTERNET handle = NULL;
TRACE("0x%08lx Server(%s) Port(%d) User(%s) Paswd(%s)\n",
(ULONG) hInternet, lpszServerName,
nServerPort, lpszUserName, lpszPassword);
if (((LPWININETHANDLEHEADER)hInternet)->htype != WH_HINIT)
hIC = (LPWININETAPPINFOA) WININET_GetObject( hInternet );
if ( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
goto lerror;
hIC = (LPWININETAPPINFOA) hInternet;
if (NULL == lpszUserName && NULL != lpszPassword)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_USER_NAME);
......@@ -1519,6 +1548,13 @@ HINTERNET FTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
goto lerror;
}
handle = WININET_AllocHandle( &lpwfs->hdr );
if( !handle )
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
goto lerror;
}
lpwfs->hdr.htype = WH_HFTPSESSION;
lpwfs->hdr.dwFlags = dwFlags;
lpwfs->hdr.dwContext = dwContext;
......@@ -1564,6 +1600,7 @@ lerror:
if (!bSuccess && lpwfs)
{
HeapFree(GetProcessHeap(), 0, lpwfs);
WININET_FreeHandle( handle );
lpwfs = NULL;
}
......@@ -1577,7 +1614,7 @@ lerror:
&iar, sizeof(INTERNET_ASYNC_RESULT));
}
return (HINTERNET) lpwfs;
return handle;
}
......@@ -2491,6 +2528,7 @@ HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONA lpwfs, INT nSocket,
DWORD dwSize = 0;
LPFILEPROPERTIESA lpafp = NULL;
LPWININETFINDNEXTA lpwfn = NULL;
HINTERNET handle = 0;
TRACE("\n");
......@@ -2499,19 +2537,25 @@ HINTERNET FTP_ReceiveFileList(LPWININETFTPSESSIONA lpwfs, INT nSocket,
FTP_ConvertFileProp(lpafp, lpFindFileData);
lpwfn = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETFINDNEXTA));
if (NULL != lpwfn)
if (lpwfn)
{
lpwfn->hdr.htype = WH_HFINDNEXT;
lpwfn->hdr.lpwhparent = (LPWININETHANDLEHEADER)lpwfs;
lpwfn->hdr.dwContext = dwContext;
lpwfn->index = 1; /* Next index is 1 since we return index 0 */
lpwfn->size = dwSize;
lpwfn->lpafp = lpafp;
handle = WININET_AllocHandle( &lpwfn->hdr );
if( handle )
{
lpwfn->hdr.htype = WH_HFINDNEXT;
lpwfn->hdr.lpwhparent = (LPWININETHANDLEHEADER)lpwfs;
lpwfn->hdr.dwContext = dwContext;
lpwfn->index = 1; /* Next index is 1 since we return index 0 */
lpwfn->size = dwSize;
lpwfn->lpafp = lpafp;
}
else
HeapFree( GetProcessHeap(), 0, lpwfn );
}
}
TRACE("Matched %ld files\n", dwSize);
return (HINTERNET)lpwfn;
return handle;
}
......
......@@ -4,6 +4,7 @@
* Copyright 1999 Corel Corporation
* Copyright 2002 CodeWeavers Inc.
* Copyright 2002 TransGaming Technologies Inc.
* Copyright 2004 Mike McCormack for Codeweavers
*
* Ulrich Czekalla
* Aric Stewart
......@@ -113,11 +114,12 @@ BOOL WINAPI HttpAddRequestHeadersA(HINTERNET hHttpRequest,
LPSTR buffer;
CHAR value[MAX_FIELD_VALUE_LEN], field[MAX_FIELD_LEN];
BOOL bSuccess = FALSE;
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest;
LPWININETHTTPREQA lpwhr;
TRACE("%p, %s, %li, %li\n", hHttpRequest, lpszHeader, dwHeaderLength,
dwModifier);
lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
{
......@@ -209,8 +211,9 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
LPCSTR lpszReferrer , LPCSTR *lpszAcceptTypes,
DWORD dwFlags, DWORD dwContext)
{
LPWININETHTTPSESSIONA lpwhs = (LPWININETHTTPSESSIONA) hHttpSession;
LPWININETHTTPSESSIONA lpwhs;
LPWININETAPPINFOA hIC = NULL;
HINTERNET handle = NULL;
TRACE("(%p, %s, %s, %s, %s, %p, %08lx, %08lx)\n", hHttpSession,
debugstr_a(lpszVerb), lpszObjectName,
......@@ -223,10 +226,11 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
TRACE("\taccept type: %s\n",lpszAcceptTypes[i]);
}
lpwhs = (LPWININETHTTPSESSIONA) WININET_GetObject( hHttpSession );
if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
return NULL;
}
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
......@@ -263,17 +267,15 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
req->dwContext = dwContext;
INTERNET_AsyncCall(&workRequest);
TRACE ("returning NULL\n");
return NULL;
}
else
{
HINTERNET rec = HTTP_HttpOpenRequestA(hHttpSession, lpszVerb, lpszObjectName,
handle = HTTP_HttpOpenRequestA(hHttpSession, lpszVerb, lpszObjectName,
lpszVersion, lpszReferrer, lpszAcceptTypes,
dwFlags, dwContext);
TRACE("returning %p\n", rec);
return rec;
}
TRACE("returning %p\n", handle);
return handle;
}
......@@ -554,19 +556,21 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
LPCSTR lpszReferrer , LPCSTR *lpszAcceptTypes,
DWORD dwFlags, DWORD dwContext)
{
LPWININETHTTPSESSIONA lpwhs = (LPWININETHTTPSESSIONA) hHttpSession;
LPWININETHTTPSESSIONA lpwhs;
LPWININETAPPINFOA hIC = NULL;
LPWININETHTTPREQA lpwhr;
LPSTR lpszCookies;
LPSTR lpszUrl = NULL;
DWORD nCookieSize;
HINTERNET handle;
TRACE("--> \n");
lpwhs = (LPWININETHTTPSESSIONA) WININET_GetObject( hHttpSession );
if (NULL == lpwhs || lpwhs->hdr.htype != WH_HHTTPSESSION)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
return FALSE;
return NULL;
}
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
......@@ -575,11 +579,18 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
if (NULL == lpwhr)
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
return (HINTERNET) NULL;
return NULL;
}
handle = WININET_AllocHandle( &lpwhr->hdr );
if (NULL == handle)
{
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
HeapFree( GetProcessHeap(), 0, lpwhr );
return NULL;
}
lpwhr->hdr.htype = WH_HHTTPREQ;
lpwhr->hdr.lpwhparent = hHttpSession;
lpwhr->hdr.lpwhparent = &lpwhs->hdr;
lpwhr->hdr.dwFlags = dwFlags;
lpwhr->hdr.dwContext = dwContext;
NETCON_init(&lpwhr->netConnection, dwFlags & INTERNET_FLAG_SECURE);
......@@ -638,7 +649,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
{
char *agent_header = HeapAlloc(GetProcessHeap(), 0, strlen(hIC->lpszAgent) + 1 + 14);
sprintf(agent_header, "User-Agent: %s\r\n", hIC->lpszAgent);
HttpAddRequestHeadersA((HINTERNET)lpwhr, agent_header, strlen(agent_header),
HttpAddRequestHeadersA(handle, agent_header, strlen(agent_header),
HTTP_ADDREQ_FLAG_ADD);
HeapFree(GetProcessHeap(), 0, agent_header);
}
......@@ -656,7 +667,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
cnt += nCookieSize - 1;
sprintf(lpszCookies + cnt, "\r\n");
HttpAddRequestHeadersA((HINTERNET)lpwhr, lpszCookies, strlen(lpszCookies),
HttpAddRequestHeadersA(handle, lpszCookies, strlen(lpszCookies),
HTTP_ADDREQ_FLAG_ADD);
HeapFree(GetProcessHeap(), 0, lpszCookies);
}
......@@ -691,7 +702,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
&lpwhs->phostent, &lpwhs->socketAddress))
{
INTERNET_SetLastError(ERROR_INTERNET_NAME_NOT_RESOLVED);
return FALSE;
return NULL;
}
SendAsyncCallback(hIC, hHttpSession, lpwhr->hdr.dwContext,
......@@ -699,8 +710,8 @@ HINTERNET WINAPI HTTP_HttpOpenRequestA(HINTERNET hHttpSession,
&(lpwhs->socketAddress),
sizeof(struct sockaddr_in));
TRACE("<--\n");
return (HINTERNET) lpwhr;
TRACE("<-- %p\n", handle);
return handle;
}
......@@ -719,10 +730,11 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
{
LPHTTPHEADERA lphttpHdr = NULL;
BOOL bSuccess = FALSE;
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest;
LPWININETHTTPREQA lpwhr;
TRACE("(0x%08lx)--> %ld\n", dwInfoLevel, dwInfoLevel);
lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -947,13 +959,14 @@ BOOL WINAPI HttpSendRequestExA(HINTERNET hRequest,
BOOL WINAPI HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
DWORD dwHeaderLength, LPVOID lpOptional ,DWORD dwOptionalLength)
{
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest;
LPWININETHTTPREQA lpwhr;
LPWININETHTTPSESSIONA lpwhs = NULL;
LPWININETAPPINFOA hIC = NULL;
TRACE("(0x%08lx, %p (%s), %li, %p, %li)\n", (unsigned long)hHttpRequest,
TRACE("%p, %p (%s), %li, %p, %li)\n", hHttpRequest,
lpszHeaders, debugstr_a(lpszHeaders), dwHeaderLength, lpOptional, dwOptionalLength);
lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1041,6 +1054,8 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQA lpwhr, LPCSTR lpszUrl, LPCSTR
LPWININETHTTPSESSIONA lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
LPWININETAPPINFOA hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
char path[2048];
HINTERNET handle;
if(lpszUrl[0]=='/')
{
/* if it's an absolute path, keep the same session info */
......@@ -1143,7 +1158,8 @@ static BOOL HTTP_HandleRedirect(LPWININETHTTPREQA lpwhr, LPCSTR lpszUrl, LPCSTR
}
}
return HttpSendRequestA((HINTERNET)lpwhr, lpszHeaders, dwHeaderLength, lpOptional, dwOptionalLength);
handle = WININET_FindHandle( &lpwhr->hdr );
return HttpSendRequestA(handle, lpszHeaders, dwHeaderLength, lpOptional, dwOptionalLength);
}
/***********************************************************************
......@@ -1167,7 +1183,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
INT requestStringLen;
INT responseLen;
INT headerLength = 0;
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hHttpRequest;
LPWININETHTTPREQA lpwhr;
LPWININETHTTPSESSIONA lpwhs = NULL;
LPWININETAPPINFOA hIC = NULL;
BOOL loop_next = FALSE;
......@@ -1176,6 +1192,7 @@ BOOL WINAPI HTTP_HttpSendRequestA(HINTERNET hHttpRequest, LPCSTR lpszHeaders,
TRACE("--> 0x%08lx\n", (ULONG)hHttpRequest);
/* Verify our tree of internet handles */
lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hHttpRequest );
if (NULL == lpwhr || lpwhr->hdr.htype != WH_HHTTPREQ)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -1557,13 +1574,14 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
BOOL bSuccess = FALSE;
LPWININETAPPINFOA hIC = NULL;
LPWININETHTTPSESSIONA lpwhs = NULL;
HINTERNET handle = NULL;
TRACE("-->\n");
if (((LPWININETHANDLEHEADER)hInternet)->htype != WH_HINIT)
hIC = (LPWININETAPPINFOA) WININET_GetObject( hInternet );
if( (hIC == NULL) || (hIC->hdr.htype != WH_HINIT) )
goto lerror;
hIC = (LPWININETAPPINFOA) hInternet;
hIC->hdr.dwContext = dwContext;
lpwhs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WININETHTTPSESSIONA));
......@@ -1573,6 +1591,14 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
goto lerror;
}
handle = WININET_AllocHandle( &lpwhs->hdr );
if (NULL == handle)
{
ERR("Failed to alloc handle\n");
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
goto lerror;
}
/*
* According to my tests. The name is not resolved until a request is sent
*/
......@@ -1581,7 +1607,7 @@ HINTERNET HTTP_Connect(HINTERNET hInternet, LPCSTR lpszServerName,
nServerPort = INTERNET_DEFAULT_HTTP_PORT;
lpwhs->hdr.htype = WH_HHTTPSESSION;
lpwhs->hdr.lpwhparent = (LPWININETHANDLEHEADER)hInternet;
lpwhs->hdr.lpwhparent = &hIC->hdr;
lpwhs->hdr.dwFlags = dwFlags;
lpwhs->hdr.dwContext = dwContext;
if(hIC->lpszProxy && hIC->dwAccessType == INTERNET_OPEN_TYPE_PROXY) {
......@@ -1614,6 +1640,7 @@ lerror:
if (!bSuccess && lpwhs)
{
HeapFree(GetProcessHeap(), 0, lpwhs);
WININET_FreeHandle( handle );
lpwhs = NULL;
}
......@@ -1622,8 +1649,8 @@ lerror:
* windows
*/
TRACE("%p -->\n", hInternet);
return (HINTERNET)lpwhs;
TRACE("%p --> %p\n", hInternet, handle);
return handle;
}
......@@ -2058,9 +2085,11 @@ VOID HTTP_CloseConnection(LPWININETHTTPREQA lpwhr)
LPWININETHTTPSESSIONA lpwhs = NULL;
LPWININETAPPINFOA hIC = NULL;
HINTERNET handle;
TRACE("%p\n",lpwhr);
handle = WININET_FindHandle( &lpwhr->hdr );
lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
......@@ -2088,16 +2117,18 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr)
int i;
LPWININETHTTPSESSIONA lpwhs = NULL;
LPWININETAPPINFOA hIC = NULL;
HINTERNET handle;
TRACE("\n");
if (NETCON_connected(&lpwhr->netConnection))
HTTP_CloseConnection(lpwhr);
handle = WININET_FindHandle( &lpwhr->hdr );
lpwhs = (LPWININETHTTPSESSIONA) lpwhr->hdr.lpwhparent;
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
SendAsyncCallback(hIC, lpwhr, lpwhr->hdr.dwContext,
SendAsyncCallback(hIC, handle, lpwhr->hdr.dwContext,
INTERNET_STATUS_HANDLE_CLOSING, lpwhr,
sizeof(HINTERNET));
......@@ -2138,11 +2169,14 @@ void HTTP_CloseHTTPRequestHandle(LPWININETHTTPREQA lpwhr)
void HTTP_CloseHTTPSessionHandle(LPWININETHTTPSESSIONA lpwhs)
{
LPWININETAPPINFOA hIC = NULL;
HINTERNET handle;
TRACE("%p\n", lpwhs);
hIC = (LPWININETAPPINFOA) lpwhs->hdr.lpwhparent;
SendAsyncCallback(hIC, lpwhs, lpwhs->hdr.dwContext,
handle = WININET_FindHandle( &lpwhs->hdr );
SendAsyncCallback(hIC, handle, lpwhs->hdr.dwContext,
INTERNET_STATUS_HANDLE_CLOSING, lpwhs,
sizeof(HINTERNET));
......
......@@ -5,6 +5,7 @@
* Copyright 2002 CodeWeavers Inc.
* Copyright 2002 Jaco Greeff
* Copyright 2002 TransGaming Technologies Inc.
* Copyright 2004 Mike McCormack for Codeweavers
*
* Ulrich Czekalla
* Aric Stewart
......@@ -73,14 +74,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(wininet);
#define GET_HWININET_FROM_LPWININETFINDNEXT(lpwh) \
(LPWININETAPPINFOA)(((LPWININETFTPSESSIONA)(lpwh->hdr.lpwhparent))->hdr.lpwhparent)
/* 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;
}
typedef struct
{
......@@ -105,6 +98,122 @@ LPWORKREQUEST lpWorkQueueTail;
extern void URLCacheContainers_CreateDefaults();
extern void URLCacheContainers_DeleteAll();
#define HANDLE_CHUNK_SIZE 0x10
static CRITICAL_SECTION WININET_cs;
static CRITICAL_SECTION_DEBUG WININET_cs_debug =
{
0, 0, &WININET_cs,
{ &WININET_cs_debug.ProcessLocksList, &WININET_cs_debug.ProcessLocksList },
0, 0, { 0, (DWORD)(__FILE__ ": WININET_cs") }
};
static CRITICAL_SECTION WININET_cs = { &WININET_cs_debug, -1, 0, 0, 0, 0 };
static LPWININETHANDLEHEADER *WININET_Handles;
static UINT WININET_dwNextHandle;
static UINT WININET_dwMaxHandles;
HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info )
{
LPWININETHANDLEHEADER *p;
UINT handle = 0, num;
EnterCriticalSection( &WININET_cs );
if( !WININET_dwMaxHandles )
{
num = HANDLE_CHUNK_SIZE;
p = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof (UINT)* num);
if( !p )
goto end;
WININET_Handles = p;
WININET_dwMaxHandles = num;
}
if( WININET_dwMaxHandles == WININET_dwNextHandle )
{
num = WININET_dwMaxHandles + HANDLE_CHUNK_SIZE;
p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
WININET_Handles, sizeof (UINT)* num);
if( !p )
goto end;
WININET_Handles = p;
WININET_dwMaxHandles = num;
}
handle = WININET_dwNextHandle;
if( WININET_Handles[handle] )
ERR("handle isn't free but should be\n");
WININET_Handles[handle] = info;
while( WININET_Handles[WININET_dwNextHandle] &&
(WININET_dwNextHandle < WININET_dwMaxHandles ) )
WININET_dwNextHandle++;
end:
LeaveCriticalSection( &WININET_cs );
return (HINTERNET) (handle+1);
}
HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info )
{
UINT i, handle = 0;
EnterCriticalSection( &WININET_cs );
for( i=0; i<WININET_dwMaxHandles; i++ )
{
if( info == WININET_Handles[i] )
{
handle = i+1;
break;
}
}
LeaveCriticalSection( &WININET_cs );
return (HINTERNET) handle;
}
LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet )
{
LPWININETHANDLEHEADER info = NULL;
UINT handle = (UINT) hinternet;
EnterCriticalSection( &WININET_cs );
if( (handle > 0) && ( handle <= WININET_dwNextHandle ) )
info = WININET_Handles[handle-1];
LeaveCriticalSection( &WININET_cs );
TRACE("handle %d -> %p\n", handle, info);
return info;
}
BOOL WININET_FreeHandle( HINTERNET hinternet )
{
BOOL ret = FALSE;
UINT handle = (UINT) hinternet;
EnterCriticalSection( &WININET_cs );
if( (handle > 1) && ( handle < WININET_dwNextHandle ) )
{
handle--;
if( WININET_Handles[handle] )
{
WININET_Handles[handle] = NULL;
ret = TRUE;
if( WININET_dwNextHandle > handle )
WININET_dwNextHandle = handle;
}
}
LeaveCriticalSection( &WININET_cs );
return ret;
}
/***********************************************************************
* DllMain [Internal] Initializes the internal 'WININET.DLL'.
*
......@@ -294,6 +403,7 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
LPCSTR lpszProxy, LPCSTR lpszProxyBypass, DWORD dwFlags)
{
LPWININETAPPINFOA lpwai = NULL;
HINTERNET handle;
TRACE("(%s, %li, %s, %s, %li)\n", debugstr_a(lpszAgent), dwAccessType,
debugstr_a(lpszProxy), debugstr_a(lpszProxyBypass), dwFlags);
......@@ -316,6 +426,14 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
lpwai->lpszProxyUsername = NULL;
lpwai->lpszProxyPassword = NULL;
handle = WININET_AllocHandle( &lpwai->hdr );
if( !handle )
{
HeapFree( GetProcessHeap(), 0, lpwai );
INTERNET_SetLastError(ERROR_OUTOFMEMORY);
return NULL;
}
if (NULL != lpszAgent)
{
lpwai->lpszAgent = HeapAlloc( GetProcessHeap(),0,
......@@ -342,7 +460,8 @@ HINTERNET WINAPI InternetOpenA(LPCSTR lpszAgent, DWORD dwAccessType,
}
TRACE("returning %p\n", (HINTERNET)lpwai);
return (HINTERNET)lpwai;
return handle;
}
......@@ -593,10 +712,12 @@ HINTERNET WINAPI InternetConnectW(HINTERNET hInternet,
BOOL WINAPI InternetFindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
{
LPWININETAPPINFOA hIC = NULL;
LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
LPWININETFINDNEXTA lpwh;
TRACE("\n");
lpwh = (LPWININETFINDNEXTA) WININET_GetObject( hFind );
if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -637,10 +758,11 @@ BOOL WINAPI INTERNET_FindNextFileA(HINTERNET hFind, LPVOID lpvFindData)
BOOL bSuccess = TRUE;
LPWININETAPPINFOA hIC = NULL;
LPWIN32_FIND_DATAA lpFindFileData;
LPWININETFINDNEXTA lpwh = (LPWININETFINDNEXTA) hFind;
LPWININETFINDNEXTA lpwh;
TRACE("\n");
lpwh = (LPWININETFINDNEXTA) WININET_GetObject( hFind );
if (NULL == lpwh || lpwh->hdr.htype != WH_HFINDNEXT)
{
INTERNET_SetLastError(ERROR_INTERNET_INCORRECT_HANDLE_TYPE);
......@@ -743,13 +865,17 @@ VOID INTERNET_CloseHandle(LPWININETAPPINFOA lpwai)
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
{
BOOL retval;
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hInternet;
LPWININETHANDLEHEADER lpwh;
TRACE("%p\n",hInternet);
lpwh = WININET_GetObject( hInternet );
if (NULL == lpwh)
{
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
__TRY {
/* Clear any error information */
INTERNET_SetLastError(0);
retval = FALSE;
......@@ -786,11 +912,8 @@ BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
default:
break;
}
} __EXCEPT(page_fault) {
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
__ENDTRY
if( retval )
WININET_FreeHandle( hInternet );
return retval;
}
......@@ -1300,7 +1423,11 @@ INTERNET_STATUS_CALLBACK WINAPI InternetSetStatusCallbackA(
HINTERNET hInternet ,INTERNET_STATUS_CALLBACK lpfnIntCB)
{
INTERNET_STATUS_CALLBACK retVal;
LPWININETAPPINFOA lpwai = (LPWININETAPPINFOA)hInternet;
LPWININETAPPINFOA lpwai;
lpwai = (LPWININETAPPINFOA)WININET_GetObject(hInternet);
if (!lpwai)
return NULL;
TRACE("0x%08lx\n", (ULONG)hInternet);
if (lpwai->hdr.htype != WH_HINIT)
......@@ -1336,9 +1463,10 @@ BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
{
BOOL retval = FALSE;
int nSocket = -1;
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
LPWININETHANDLEHEADER lpwh;
TRACE("\n");
lpwh = (LPWININETHANDLEHEADER) WININET_GetObject( hFile );
if (NULL == lpwh)
return FALSE;
......@@ -1348,11 +1476,11 @@ BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer ,
FIXME("This shouldn't be here! We don't support this kind"
" of connection anymore. Must use NETCON functions,"
" especially if using SSL\n");
nSocket = ((LPWININETHTTPREQA)hFile)->netConnection.socketFD;
nSocket = ((LPWININETHTTPREQA)lpwh)->netConnection.socketFD;
break;
case WH_HFILE:
nSocket = ((LPWININETFILE)hFile)->nDataSocket;
nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
break;
default:
......@@ -1385,10 +1513,11 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
{
BOOL retval = FALSE;
int nSocket = -1;
LPWININETHANDLEHEADER lpwh = (LPWININETHANDLEHEADER) hFile;
LPWININETHANDLEHEADER lpwh;
TRACE("\n");
lpwh = (LPWININETHANDLEHEADER) WININET_GetObject( hFile );
if (NULL == lpwh)
return FALSE;
......@@ -1396,7 +1525,7 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
switch (lpwh->htype)
{
case WH_HHTTPREQ:
if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, lpBuffer,
if (!NETCON_recv(&((LPWININETHTTPREQA)lpwh)->netConnection, lpBuffer,
dwNumOfBytesToRead, 0, (int *)dwNumOfBytesRead))
{
*dwNumOfBytesRead = 0;
......@@ -1408,7 +1537,7 @@ BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer,
case WH_HFILE:
/* FIXME: FTP should use NETCON_ stuff */
nSocket = ((LPWININETFILE)hFile)->nDataSocket;
nSocket = ((LPWININETFILE)lpwh)->nDataSocket;
if (nSocket != -1)
{
int res = recv(nSocket, lpBuffer, dwNumOfBytesToRead, 0);
......@@ -1471,7 +1600,9 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
TRACE("(%p, 0x%08lx, %p, %p)\n", hInternet, dwOption, lpBuffer, lpdwBufferLength);
lpwhh = (LPWININETHANDLEHEADER) hInternet;
lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
if( !lpwhh )
return FALSE;
switch (dwOption)
{
......@@ -1512,7 +1643,7 @@ static BOOL INET_QueryOptionHelper(BOOL bIsUnicode, HINTERNET hInternet, DWORD d
ULONG type = lpwhh->htype;
if (type == WH_HHTTPREQ)
{
LPWININETHTTPREQA lpreq = hInternet;
LPWININETHTTPREQA lpreq = (LPWININETHTTPREQA) lpwhh;
char url[1023];
sprintf(url,"http://%s%s",lpreq->lpszHostName,lpreq->lpszPath);
......@@ -1607,7 +1738,9 @@ BOOL WINAPI InternetSetOptionW(HINTERNET hInternet, DWORD dwOption,
TRACE("0x%08lx\n", dwOption);
lpwhh = (LPWININETHANDLEHEADER) hInternet;
lpwhh = (LPWININETHANDLEHEADER) WININET_GetObject( hInternet );
if( !lpwhh )
return FALSE;
switch (dwOption)
{
......@@ -2425,11 +2558,12 @@ BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
LPDWORD lpdwNumberOfBytesAvailble,
DWORD dwFlags, DWORD dwConext)
{
LPWININETHTTPREQA lpwhr = (LPWININETHTTPREQA) hFile;
LPWININETHTTPREQA lpwhr;
INT retval = -1;
char buffer[4048];
lpwhr = (LPWININETHTTPREQA) WININET_GetObject( hFile );
if (NULL == lpwhr)
{
SetLastError(ERROR_NO_MORE_FILES);
......@@ -2441,7 +2575,7 @@ BOOL WINAPI InternetQueryDataAvailable( HINTERNET hFile,
switch (lpwhr->hdr.htype)
{
case WH_HHTTPREQ:
if (!NETCON_recv(&((LPWININETHTTPREQA)hFile)->netConnection, buffer,
if (!NETCON_recv(&lpwhr->netConnection, buffer,
4048, MSG_PEEK, (int *)lpdwNumberOfBytesAvailble))
{
SetLastError(ERROR_NO_MORE_FILES);
......
......@@ -309,6 +309,10 @@ typedef struct WORKREQ
} WORKREQUEST, *LPWORKREQUEST;
HINTERNET WININET_AllocHandle( LPWININETHANDLEHEADER info );
LPWININETHANDLEHEADER WININET_GetObject( HINTERNET hinternet );
BOOL WININET_FreeHandle( HINTERNET hinternet );
HINTERNET WININET_FindHandle( LPWININETHANDLEHEADER info );
time_t ConvertTimeString(LPCSTR asctime);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment