Commit 1ee3ad47 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

wininet: Directly return error status from WriteFile implementations.

parent b77868cb
......@@ -1156,7 +1156,7 @@ static DWORD FTPFILE_ReadFileExW(object_header_t *hdr, INTERNET_BUFFERSW *buffer
return FTPFILE_ReadFile(hdr, buffers->lpvBuffer, buffers->dwBufferLength, &buffers->dwBufferLength);
}
static BOOL FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
static DWORD FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
{
ftp_file_t *lpwh = (ftp_file_t*) hdr;
int res;
......@@ -1164,7 +1164,7 @@ static BOOL FTPFILE_WriteFile(object_header_t *hdr, const void *buffer, DWORD si
res = send(lpwh->nDataSocket, buffer, size, 0);
*written = res>0 ? res : 0;
return res >= 0;
return res >= 0 ? ERROR_SUCCESS : sock_get_error(errno);
}
static void FTP_ReceiveRequestData(ftp_file_t *file, BOOL first_notif)
......
......@@ -2489,7 +2489,7 @@ done:
return res;
}
static BOOL HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
static DWORD HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD size, DWORD *written)
{
DWORD res;
http_request_t *lpwhr = (http_request_t*)hdr;
......@@ -2500,11 +2500,9 @@ static BOOL HTTPREQ_WriteFile(object_header_t *hdr, const void *buffer, DWORD si
res = NETCON_send(&lpwhr->netConnection, buffer, size, 0, (LPINT)written);
if (res == ERROR_SUCCESS)
lpwhr->dwBytesWritten += *written;
else
SetLastError(res);
INTERNET_SendCallback(&lpwhr->hdr, lpwhr->hdr.dwContext, INTERNET_STATUS_REQUEST_SENT, written, sizeof(DWORD));
return res == ERROR_SUCCESS;
return res;
}
static void HTTPREQ_AsyncQueryDataAvailableProc(WORKREQUEST *workRequest)
......
......@@ -1862,7 +1862,7 @@ BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer,
DWORD dwNumOfBytesToWrite, LPDWORD lpdwNumOfBytesWritten)
{
object_header_t *lpwh;
BOOL retval = FALSE;
BOOL res;
TRACE("(%p %p %d %p)\n", hFile, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
......@@ -1874,16 +1874,17 @@ BOOL WINAPI InternetWriteFile(HINTERNET hFile, LPCVOID lpBuffer,
}
if(lpwh->vtbl->WriteFile) {
retval = lpwh->vtbl->WriteFile(lpwh, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
res = lpwh->vtbl->WriteFile(lpwh, lpBuffer, dwNumOfBytesToWrite, lpdwNumOfBytesWritten);
}else {
WARN("No Writefile method.\n");
SetLastError(ERROR_INVALID_HANDLE);
retval = FALSE;
res = ERROR_INVALID_HANDLE;
}
WININET_Release( lpwh );
return retval;
if(res != ERROR_SUCCESS)
SetLastError(res);
return res == ERROR_SUCCESS;
}
......
......@@ -143,7 +143,7 @@ typedef struct {
DWORD (*ReadFile)(object_header_t*,void*,DWORD,DWORD*);
DWORD (*ReadFileExA)(object_header_t*,INTERNET_BUFFERSA*,DWORD,DWORD_PTR);
DWORD (*ReadFileExW)(object_header_t*,INTERNET_BUFFERSW*,DWORD,DWORD_PTR);
BOOL (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*);
DWORD (*WriteFile)(object_header_t*,const void*,DWORD,DWORD*);
DWORD (*QueryDataAvailable)(object_header_t*,DWORD*,DWORD,DWORD_PTR);
DWORD (*FindNextFileW)(object_header_t*,void*);
} object_vtbl_t;
......@@ -443,6 +443,7 @@ BOOL NETCON_recv(WININET_NETCONNECTION *connection, void *buf, size_t len, int f
BOOL NETCON_query_data_available(WININET_NETCONNECTION *connection, DWORD *available);
LPCVOID NETCON_GetCert(WININET_NETCONNECTION *connection);
DWORD NETCON_set_timeout(WININET_NETCONNECTION *connection, BOOL send, int value);
int sock_get_error(int);
extern void URLCacheContainers_CreateDefaults(void);
extern void URLCacheContainers_DeleteAll(void);
......
......@@ -315,7 +315,7 @@ BOOL NETCON_connected(WININET_NETCONNECTION *connection)
}
/* translate a unix error code into a winsock one */
static int sock_get_error( int err )
int sock_get_error( int err )
{
#if !defined(__MINGW32__) && !defined (_MSC_VER)
switch (err)
......
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