mirror of https://github.com/wolfSSL/wolfssh.git
wolfSFTP for Windows
1. Clean up some type size warnings. 2. Fix the wrappers for FileRead() and FileWrite(). The Overlapped struct is a little funky to use.pull/122/head
parent
8f87568a91
commit
b57e825381
16
src/port.c
16
src/port.c
|
@ -88,11 +88,9 @@ int wPwrite(WFD fd, unsigned char* buf, unsigned int sz, long ofst)
|
|||
int ret;
|
||||
|
||||
WMEMSET(&offset, 0, sizeof(OVERLAPPED));
|
||||
offset.DUMMYUNIONNAME.DUMMYSTRUCTNAME.Offset =
|
||||
(DWORD)(ofst & 0xFFFFFFFF);
|
||||
offset.DUMMYUNIONNAME.DUMMYSTRUCTNAME.OffsetHigh =
|
||||
(DWORD)((ofst 0xFFFFFFFF00000000) >> 32);
|
||||
if (WriteFile(XXX, data, sz, &bytesWritten, &offset) != 0)
|
||||
offset.Offset = (DWORD)(ofst & 0xFFFFFFFF);
|
||||
offset.OffsetHigh = (DWORD)((ofst & 0xFFFFFFFF00000000) >> 32);
|
||||
if (WriteFile(fd, buf, sz, &bytesWritten, &offset) != 0)
|
||||
ret = -1;
|
||||
else
|
||||
ret = (int)bytesWritten;
|
||||
|
@ -108,11 +106,9 @@ int wPread(WFD fd, unsigned char* buf, unsigned int sz, long ofst)
|
|||
int ret;
|
||||
|
||||
WMEMSET(&offset, 0, sizeof(OVERLAPPED));
|
||||
offset.DUMMYUNIONNAME.DUMMYSTRUCTNAME.Offset =
|
||||
(DWORD)(ofst & 0xFFFFFFFF);
|
||||
offset.DUMMYUNIONNAME.DUMMYSTRUCTNAME.OffsetHigh =
|
||||
(DWORD)((ofst 0xFFFFFFFF00000000) >> 32);
|
||||
if (ReadFile(XXX, data, sz, &bytesRead, &offset) != 0)
|
||||
offset.Offset = (DWORD)(ofst & 0xFFFFFFFF);
|
||||
offset.OffsetHigh = (DWORD)((ofst & 0xFFFFFFFF00000000) >> 32);
|
||||
if (ReadFile(fd, buf, sz, &bytesRead, &offset) != 0)
|
||||
ret = -1;
|
||||
else
|
||||
ret = (int)bytesRead;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#include <wolfssh/wolfsftp.h>
|
||||
|
||||
#ifdef WOLFSSH_SFTP
|
||||
|
@ -1588,7 +1588,7 @@ int wolfSSH_SFTP_RecvWrite(WOLFSSH* ssh, int reqId, word32 maxSz)
|
|||
/* get length to be written */
|
||||
ato32(data + idx, &sz); idx += UINT32_SZ;
|
||||
|
||||
ret = (int)WPWRITE(fd, data + idx, sz, ofst);
|
||||
ret = (int)WPWRITE(fd, data + idx, sz, (long)ofst);
|
||||
WFREE(data, ssh->ctx->heap, DYNTYPE_BUFFER);
|
||||
if (ret < 0) {
|
||||
#if defined(WOLFSSL_NUCLEUS) && defined(DEBUG_WOLFSSH)
|
||||
|
@ -1662,7 +1662,7 @@ int wolfSSH_SFTP_RecvRead(WOLFSSH* ssh, int reqId, word32 maxSz)
|
|||
return WS_MEMORY_E;
|
||||
}
|
||||
|
||||
ret = (int)WPREAD(fd, data, sz, ofst);
|
||||
ret = (int)WPREAD(fd, data, sz, (long)ofst);
|
||||
if (ret < 0) {
|
||||
WLOG(WS_LOG_SFTP, "Error reading from file");
|
||||
WFREE(data, ssh->ctx->heap, DYNTYPE_BUFFER);
|
||||
|
|
|
@ -423,6 +423,7 @@ extern "C" {
|
|||
#endif /* NO_WOLFSSH_DIR */
|
||||
#elif defined(USE_WINDOWS_API)
|
||||
|
||||
#include <windows.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <io.h>
|
||||
|
@ -442,7 +443,7 @@ extern "C" {
|
|||
#define WFD HANDLE
|
||||
int wPwrite(WFD, unsigned char*, unsigned int, long);
|
||||
int wPread(WFD, unsigned char*, unsigned int, long);
|
||||
#define WPWRITE(fd,b,s,o) wPwrite((fs),(b),(s),(o))
|
||||
#define WPWRITE(fd,b,s,o) wPwrite((fd),(b),(s),(o))
|
||||
#define WPREAD(fd,b,s,o) wPread((fd),(b),(s),(o))
|
||||
#define WS_DELIM '\\'
|
||||
|
||||
|
|
Loading…
Reference in New Issue