From 1ffcfbce85cf89d364b99a2594661cc40850cf9c Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 26 Feb 2008 20:21:34 +0100 Subject: [PATCH] wininet: Use vtbl in InternetWriteFile implementation. --- dlls/wininet/ftp.c | 18 ++++++++++++++++-- dlls/wininet/http.c | 11 ++++++++++- dlls/wininet/internet.c | 45 +++++++++++---------------------------------- dlls/wininet/internet.h | 4 +--- 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/dlls/wininet/ftp.c b/dlls/wininet/ftp.c index d56b732d4ba..0714777aad5 100644 --- a/dlls/wininet/ftp.c +++ b/dlls/wininet/ftp.c @@ -1155,9 +1155,21 @@ static void FTPFILE_Destroy(WININETHANDLEHEADER *hdr) HeapFree(GetProcessHeap(), 0, lpwh); } +static BOOL FTPFILE_WriteFile(WININETHANDLEHEADER *hdr, const void *buffer, DWORD size, DWORD *written) +{ + LPWININETFTPFILE lpwh = (LPWININETFTPFILE) hdr; + int res; + + res = send(lpwh->nDataSocket, buffer, size, 0); + + *written = res>0 ? res : 0; + return res >= 0; +} + static const HANDLEHEADERVtbl FTPFILEVtbl = { FTPFILE_Destroy, - NULL + NULL, + FTPFILE_WriteFile }; /*********************************************************************** @@ -2073,7 +2085,8 @@ static void FTPSESSION_CloseConnection(WININETHANDLEHEADER *hdr) static const HANDLEHEADERVtbl FTPSESSIONVtbl = { FTPSESSION_Destroy, - FTPSESSION_CloseConnection + FTPSESSION_CloseConnection, + NULL }; @@ -3150,6 +3163,7 @@ static void FTPFINDNEXT_Destroy(WININETHANDLEHEADER *hdr) static const HANDLEHEADERVtbl FTPFINDNEXTVtbl = { FTPFINDNEXT_Destroy, + NULL, NULL }; diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 87194c4d440..bd219e64423 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -1392,9 +1392,17 @@ static void HTTPREQ_CloseConnection(WININETHANDLEHEADER *hdr) INTERNET_STATUS_CONNECTION_CLOSED, 0, 0); } +static BOOL HTTPREQ_WriteFile(WININETHANDLEHEADER *hdr, const void *buffer, DWORD size, DWORD *written) +{ + LPWININETHTTPREQW lpwhr = (LPWININETHTTPREQW)hdr; + + return NETCON_send(&lpwhr->netConnection, buffer, size, 0, (LPINT)written); +} + static const HANDLEHEADERVtbl HTTPREQVtbl = { HTTPREQ_Destroy, - HTTPREQ_CloseConnection + HTTPREQ_CloseConnection, + HTTPREQ_WriteFile }; /*********************************************************************** @@ -2916,6 +2924,7 @@ static void HTTPSESSION_Destroy(WININETHANDLEHEADER *hdr) static const HANDLEHEADERVtbl HTTPSESSIONVtbl = { HTTPSESSION_Destroy, + NULL, NULL }; diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 2554a31a441..472c183d579 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -473,6 +473,7 @@ static VOID APPINFO_Destroy(WININETHANDLEHEADER *hdr) static const HANDLEHEADERVtbl APPINFOVtbl = { APPINFO_Destroy, + NULL, NULL }; @@ -1692,48 +1693,24 @@ DWORD WINAPI InternetSetFilePointer(HINTERNET hFile, LONG lDistanceToMove, * FALSE on failure * */ -BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer , +BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer, DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten) { - BOOL retval = FALSE; - int nSocket = -1; LPWININETHANDLEHEADER lpwh; + BOOL retval = FALSE; - TRACE("\n"); - lpwh = WININET_GetObject( hFile ); - if (NULL == lpwh) - return FALSE; - - switch (lpwh->htype) - { - case WH_HHTTPREQ: - { - LPWININETHTTPREQW lpwhr; - lpwhr = (LPWININETHTTPREQW)lpwh; - - TRACE("HTTPREQ %i\n",dwNumOfBytesToWrite); - retval = NETCON_send(&lpwhr->netConnection, lpBuffer, - dwNumOfBytesToWrite, 0, (LPINT)lpdwNumOfBytesWritten); + TRACE("(%p %p %d %p)\n", hFile, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten); - WININET_Release( lpwh ); - return retval; - } - break; - - case WH_HFILE: - nSocket = ((LPWININETFTPFILE)lpwh)->nDataSocket; - break; + lpwh = WININET_GetObject( hFile ); - default: - break; + if(lpwh && lpwh->vtbl->WriteFile) { + retval = lpwh->vtbl->WriteFile(lpwh, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten); + }else { + WARN("Invalid handle\n"); + SetLastError(ERROR_INVALID_HANDLE); + retval = FALSE; } - if (nSocket != -1) - { - int res = send(nSocket, lpBuffer, dwNumOfBytesToWrite, 0); - retval = (res >= 0); - *lpdwNumOfBytesWritten = retval ? res : 0; - } WININET_Release( lpwh ); return retval; diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 5cf0b286361..2389fe51b65 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -133,14 +133,12 @@ typedef enum #define INET_OPENURL 0x0001 #define INET_CALLBACKW 0x0002 -struct _WININETHANDLEHEADER; typedef struct _WININETHANDLEHEADER WININETHANDLEHEADER, *LPWININETHANDLEHEADER; -typedef void (*WININET_object_function)( LPWININETHANDLEHEADER ); - typedef struct { void (*Destroy)(WININETHANDLEHEADER*); void (*CloseConnection)(WININETHANDLEHEADER*); + BOOL (*WriteFile)(WININETHANDLEHEADER*,const void*,DWORD,DWORD*); } HANDLEHEADERVtbl; struct _WININETHANDLEHEADER -- 2.11.4.GIT