From 39ab2abf660e12585ce5c2da8b660903fe40fd04 Mon Sep 17 00:00:00 2001 From: Jacob Barthelmeh Date: Mon, 26 Nov 2018 16:17:04 -0700 Subject: [PATCH] add sftp client VS project --- ide/winvs/include.am | 2 + .../wolfsftp-client/wolfsftp-client.vcxproj | 335 ++++++++++++++++++ .../wolfsftp-client.vcxproj.user | 19 + ide/winvs/wolfssh.sln | 21 ++ src/port.c | 8 +- wolfsftp/client/sftpclient.c | 10 + wolfssh/port.h | 2 +- 7 files changed, 392 insertions(+), 5 deletions(-) create mode 100644 ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj create mode 100644 ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user diff --git a/ide/winvs/include.am b/ide/winvs/include.am index 8da37685..647adaf6 100644 --- a/ide/winvs/include.am +++ b/ide/winvs/include.am @@ -16,3 +16,5 @@ EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj EXTRA_DIST+= ide/winvs/echoserver/echoserver.vcxproj.user EXTRA_DIST+= ide/winvs/testsuite/testsuite.vcxproj EXTRA_DIST+= ide/winvs/testsuite/testsuite.vcxproj.user +EXTRA_DIST+= ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj +EXTRA_DIST+= ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user diff --git a/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj b/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj new file mode 100644 index 00000000..61a15b74 --- /dev/null +++ b/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj @@ -0,0 +1,335 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + DLL Debug + Win32 + + + DLL Debug + x64 + + + DLL Release + Win32 + + + DLL Release + x64 + + + Release + Win32 + + + Release + x64 + + + + + + + + {7c2ccf0d-a155-4914-bd1c-9a47c0530e65} + + + + {8DD810D6-159B-4C40-B682-FCA11F9B3680} + Win32Proj + wolfsftp-client + 10.0.17134.0 + + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + true + v141 + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + Application + false + v141 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + $(Configuration)\$(Platform)\obj\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\$(Platform)\obj\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\$(Platform)\obj\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(Configuration)\$(Platform)\obj\ + $(SolutionDir)$(Configuration)\$(Platform)\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\obj\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\obj\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\obj\ + + + false + $(SolutionDir)$(Configuration)\$(Platform)\ + $(Configuration)\$(Platform)\obj\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + ProgramDatabase + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + msvcrt.lib + $(wolfCryptDebug32) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + ProgramDatabase + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + msvcrt.lib + $(wolfCryptDllDebug32) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + ProgramDatabase + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + msvcrt.lib + $(wolfCryptDebug64) + + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + ProgramDatabase + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + msvcrt.lib + $(wolfCryptDllDebug64) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + true + true + $(wolfCryptRelease32) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + true + true + $(wolfCryptDllRelease32) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + true + true + $(wolfCryptRelease64) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;WOLFSSL_USER_SETTINGS;%(PreprocessorDefinitions) + ..;..\..\..;$(wolfCryptDir);%(AdditionalIncludeDirectories) + + + Console + true + wolfssl.lib;ws2_32.lib;%(AdditionalDependencies) + true + true + $(wolfCryptDllRelease64) + + + + + + diff --git a/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user b/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user new file mode 100644 index 00000000..ee6c1e37 --- /dev/null +++ b/ide/winvs/wolfsftp-client/wolfsftp-client.vcxproj.user @@ -0,0 +1,19 @@ + + + + WindowsLocalDebugger + PATH=$(wolfCryptDllDebug32);%PATH% + + + WindowsLocalDebugger + PATH=$(wolfCryptDllDebug64);%PATH% + + + WindowsLocalDebugger + PATH=$(wolfCryptDllRelease32);%PATH% + + + WindowsLocalDebugger + PATH=$(wolfCryptDllRelease64);%PATH% + + diff --git a/ide/winvs/wolfssh.sln b/ide/winvs/wolfssh.sln index 34958361..efdae948 100644 --- a/ide/winvs/wolfssh.sln +++ b/ide/winvs/wolfssh.sln @@ -19,6 +19,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "client", "client\client.vcx EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testsuite", "testsuite\testsuite.vcxproj", "{BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wolfsftp-client", "wolfsftp-client\wolfsftp-client.vcxproj", "{8DD810D6-159B-4C40-B682-FCA11F9B3680}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -123,8 +125,27 @@ Global {BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Release|Win32.ActiveCfg = Release|Win32 {BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Release|Win32.Build.0 = Release|Win32 {BD09DA06-6D2E-4FB0-AE39-1BAE9FDAA9DD}.Release|x64.ActiveCfg = Release|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Debug|Win32.ActiveCfg = Debug|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Debug|Win32.Build.0 = Debug|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Debug|x64.ActiveCfg = Debug|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Debug|x64.Build.0 = Debug|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Debug|Win32.ActiveCfg = DLL Debug|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Debug|Win32.Build.0 = DLL Debug|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Debug|x64.ActiveCfg = Debug|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Debug|x64.Build.0 = Debug|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Release|Win32.ActiveCfg = DLL Release|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Release|Win32.Build.0 = DLL Release|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Release|x64.ActiveCfg = Release|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.DLL Release|x64.Build.0 = Release|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Release|Win32.ActiveCfg = Release|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Release|Win32.Build.0 = Release|Win32 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Release|x64.ActiveCfg = Release|x64 + {8DD810D6-159B-4C40-B682-FCA11F9B3680}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A0B37101-A4ED-4067-8240-E824A04F25C7} + EndGlobalSection EndGlobal diff --git a/src/port.c b/src/port.c index 0b2342d7..6496af23 100644 --- a/src/port.c +++ b/src/port.c @@ -79,8 +79,8 @@ int wfopen(WFILE** f, const char* filename, const char* mode) #endif } -#ifdef USE_WINDOWS_API - +#if defined(USE_WINDOWS_API) && (defined(WOLFSSH_SFTP) || \ + defined(WOLFSSH_SCP)) && !defined(NO_WOLFSSH_SERVER) int wPwrite(WFD fd, unsigned char* buf, unsigned int sz, long ofst) { OVERLAPPED offset; @@ -90,7 +90,7 @@ int wPwrite(WFD fd, unsigned char* buf, unsigned int sz, long ofst) WMEMSET(&offset, 0, sizeof(OVERLAPPED)); offset.Offset = (DWORD)(ofst & 0xFFFFFFFF); offset.OffsetHigh = (DWORD)((ofst & 0xFFFFFFFF00000000) >> 32); - if (WriteFile(fd, buf, sz, &bytesWritten, &offset) != 0) + if (WriteFile((HANDLE)_get_osfhandle(fd), buf, sz, &bytesWritten, &offset) != 0) ret = -1; else ret = (int)bytesWritten; @@ -108,7 +108,7 @@ int wPread(WFD fd, unsigned char* buf, unsigned int sz, long ofst) WMEMSET(&offset, 0, sizeof(OVERLAPPED)); offset.Offset = (DWORD)(ofst & 0xFFFFFFFF); offset.OffsetHigh = (DWORD)((ofst & 0xFFFFFFFF00000000) >> 32); - if (ReadFile(fd, buf, sz, &bytesRead, &offset) != 0) + if (ReadFile((HANDLE)_get_osfhandle(fd), buf, sz, &bytesRead, &offset) != 0) ret = -1; else ret = (int)bytesRead; diff --git a/wolfsftp/client/sftpclient.c b/wolfsftp/client/sftpclient.c index 8b8adf58..9b5a8715 100644 --- a/wolfsftp/client/sftpclient.c +++ b/wolfsftp/client/sftpclient.c @@ -29,6 +29,8 @@ #include #endif +#ifdef WOLFSSH_SFTP + int doCmds(void); @@ -904,6 +906,14 @@ THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args) return 0; } +#else + +THREAD_RETURN WOLFSSH_THREAD sftpclient_test(void* args) +{ + printf("Not compiled in!\nPlease recompile with WOLFSSH_SFTP or --enable-sftp"); + return -1; +} +#endif /* WOLFSSH_SFTP */ #ifndef NO_MAIN_DRIVER diff --git a/wolfssh/port.h b/wolfssh/port.h index ed733af3..5b834dbf 100644 --- a/wolfssh/port.h +++ b/wolfssh/port.h @@ -440,7 +440,7 @@ extern "C" { #define WOPEN(f,m,p) _open((f),(m),(p)) #define WCLOSE(fd) _close((fd)) - #define WFD HANDLE + #define WFD int int wPwrite(WFD, unsigned char*, unsigned int, long); int wPread(WFD, unsigned char*, unsigned int, long); #define WPWRITE(fd,b,s,o) wPwrite((fd),(b),(s),(o))