1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-29 13:01:14 +03:00

build fixes and improvements (mostly for Windows)

- in `hostkey.c` check the result of `libssh2_sha256_init()` and
  `libssh2_sha512_init()` calls. This avoid the warning that we're
  ignoring the return values.

- fix code using `int` (or `SOCKET`) for sockets. Use libssh2's
  dedicated `libssh2_socket_t` and `LIBSSH2_INVALID_SOCKET` instead.

- fix compiler warnings due to `STATUS_*` macro redefinitions between
  `ntstatus.h` / `winnt.h`. Solve it by manually defining the single
  `STATUS` value we need from `ntstatus.h` and stop including the whole
  header.
  Fixes #733

- improve Windows UWP/WinRT builds by detecting it with code copied
  from the curl project. Then excluding problematic libssh2 parts
  according to PR by Dmitry Kostjučenko.
  Fixes #734

- always use `SecureZeroMemory()` on Windows.

  We can tweak this if not found or not inlined by a C compiler which
  we otherwise support. Same if it causes issues with UWP apps.

  Ref: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa366877(v=vs.85)
  Ref: https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/wdm/nf-wdm-rtlsecurezeromemory

- always enable `LIBSSH2_CLEAR_MEMORY` on Windows. CMake and
  curl-for-win builds already did that. Delete `SecureZeroMemory()`
  detection from autotools' WinCNG backend logic, that this
  setting used to depend on.

  TODO: Enable it for all platforms in a separate PR.
  TODO: For clearing buffers in WinCNG, call `_libssh2_explicit_zero()`,
        insead of a local function or explicit `SecureZeroMemory()`.

- Makefile.inc: move `os400qc3.h` to `HEADERS`. This fixes
  compilation on non-unixy platforms. Recent regression.

- `libssh2.rc`: replace copyright with plain ASCII, as in curl.

  Ref: curl/curl@1ca62bb
  Ref: curl/curl#7765
  Ref: curl/curl#7776

- CMake fixes and improvements:

  - enable warnings with llvm/clang.
  - enable more comprehensive warnings with gcc and llvm/clang.
    Logic copied from curl:
    233810bb5f/CMakeLists.txt (L131-L148)
  - fix `Policy CMP0080` CMake warning by deleting that reference.
  - add `ENABLE_WERROR` (default: `OFF`) option. Ported from curl.
  - add `PICKY_COMPILER` (default: `ON`) option, as known from curl.

    It controls both the newly added picky warnings for llvm/clang and
    gcc, and also the pre-existing ones for MSVC.

- `win32/GNUmakefile` fixes and improvements:

  - delete `_AMD64_` and add missing `-m64` for x64 builds under test.
  - add support for `ARCH=custom`.
    It disables hardcoded Intel 64-bit and Intel 32-bit options,
    allowing ARM64 builds.
  - add support for `LIBSSH2_RCFLAG_EXTRAS`.
    To pass custom options to windres, e.g. in ARM64 builds.
  - add support for `LIBSSH2_RC`. To override `windres`.
  - delete support for Metrowerks C. Last released in 2004.

- `win32/libssh2_config.h`: delete unnecessary socket #includes

  `src/libssh2_priv.h` includes `winsock2.h` and `ws2tcpip.h` further
   down the line, triggered by `HAVE_WINSOCK2_H`.

  `mswsock.h` does not seem to be necessary anymore.

  Double-including these (before `windows.h`) caused compiler failures
  when building against BoringSSL and warnings with LibreSSL. We could
  work this around by passing `-DNOCRYPT`. Deleting the duplicates
  fixes these issues.

  Timeline:
  2013: c910cd382d deleted `mswsock.h` from `src/libssh2_priv.h`
  2008: 8c43bc52b1 added `winsock2.h` and `ws2tcpip.h` to `src/libssh2_priv.h`
  2005: dc4bb1af96 added the now deleted #includes

- delete or replace `LIBSSH2_WIN32` with `WIN32`.

- replace hand-rolled `HAVE_WINDOWS_H` macro with `WIN32`. Also delete
  its detections/definitions.

- delete unused `LIBSSH2_DARWIN` macro.

- delete unused `writev()` Windows implementation

  There is no reference to `writev()` since 2007-02-02, commit
  9d55db6501.

- fix a bunch of MSVC / llvm/clang / gcc compiler warnings:

  - `warning C4100: '...': unreferenced formal parameter`
  - using value of undefined PP macro `LIBSSH2DEBUG`
  - missing void from function definition
  - `if()` block missing in non-debug builds
  - unreferenced variable in non-debug builds
  - `warning: must specify at least one argument for '...' parameter of variadic macro [-Wgnu-zero-variadic-macro-arguments]`
    in `_libssh2_debug()`
  - `warning C4295: 'ciphertext' : array is too small to include a terminating null character`
  - `warning C4706: assignment within conditional expression`
  - `warning C4996: 'inet_addr': Use inet_pton() or InetPton() instead or
      define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings`
    By suppressning it. Would be best to use inet_pton() as suggested.
    On Windows this needs Vista though.
  - `warning C4152: nonstandard extension, function/data pointer conversion in expression`
    (silenced locally)
  - `warning C4068: unknown pragma`

  Ref: https://ci.appveyor.com/project/libssh2org/libssh2/builds/46354480/job/j7d0m34qgq8rag5w

Closes #808
This commit is contained in:
Viktor Szakats
2023-03-03 13:30:03 +00:00
parent 7487dcf4b4
commit 2addafb77b
58 changed files with 396 additions and 267 deletions

View File

@ -2,8 +2,8 @@ CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
userauth_kbd_packet.c \
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.c \
blowfish.c bcrypt_pbkdf.c agent_win.c os400qc3.c os400qc3.h
blowfish.c bcrypt_pbkdf.c agent_win.c os400qc3.c
HHEADERS = libssh2_priv.h $(CRYPTO_HHEADERS) transport.h channel.h comp.h \
mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h blf.h agent.h \
userauth_kbd_packet.h
userauth_kbd_packet.h os400qc3.h

View File

@ -464,7 +464,6 @@ m4_case([$1],
# Look for Windows Cryptography API: Next Generation
AC_CHECK_HEADERS([ntdef.h ntstatus.h], [], [], [#include <windows.h>])
AC_CHECK_DECLS([SecureZeroMemory], [], [], [#include <windows.h>])
LIBSSH2_LIB_HAVE_LINKFLAGS([crypt32], [], [
#include <windows.h>
@ -477,7 +476,6 @@ m4_case([$1],
AC_DEFINE(LIBSSH2_WINCNG, 1, [Use $1])
found_crypto="$1"
found_crypto_str="Windows Cryptography API: Next Generation"
support_clear_memory="$ac_cv_have_decl_SecureZeroMemory"
])
],
)

View File

@ -1,23 +1,61 @@
include(CheckCCompilerFlag)
option(ENABLE_WERROR "Turn compiler warnings into errors" OFF)
option(PICKY_COMPILER "Enable picky compiler options" ON)
if(ENABLE_WERROR)
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
else() # llvm/clang and gcc style options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
endif()
endif()
if(MSVC)
# Use the highest warning level for visual studio.
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
if(PICKY_COMPILER)
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
endif()
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif()
endif()
# Disable broken warnings
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
if(NOT CMAKE_C_FLAGS MATCHES "-Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
endif()
if(PICKY_COMPILER)
foreach(_CCOPT -pedantic -W -Wpointer-arith -Wwrite-strings -Wunused -Wshadow -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wfloat-equal -Wsign-compare -Wundef -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wstrict-aliasing=3 -Wcast-align -Wtype-limits -Wold-style-declaration -Wmissing-parameter-type -Wempty-body -Wclobbered -Wignored-qualifiers -Wconversion -Wvla -Wdouble-promotion -Wenum-conversion -Warith-conversion)
# surprisingly, CHECK_C_COMPILER_FLAG needs a new variable to store each new
# test result in.
string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname)
check_c_compiler_flag(${_CCOPT} ${_optvarname})
if(${_optvarname})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_CCOPT}")
endif()
endforeach()
foreach(_CCOPT long-long multichar format-nonliteral sign-conversion system-headers pedantic-ms-format)
# GCC only warns about unknown -Wno- options if there are also other diagnostic messages,
# so test for the positive form instead
string(MAKE_C_IDENTIFIER "OPT${_CCOPT}" _optvarname)
check_c_compiler_flag("-W${_CCOPT}" ${_optvarname})
if(${_optvarname})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-${_CCOPT}")
endif()
endforeach()
endif()
endif()

View File

@ -33,11 +33,9 @@ AB_INIT
AC_CANONICAL_HOST
case "$host" in
*-mingw*)
CFLAGS="$CFLAGS -DLIBSSH2_WIN32"
LIBS="$LIBS -lws2_32"
;;
*darwin*)
CFLAGS="$CFLAGS -DLIBSSH2_DARWIN"
;;
*hpux*)
;;

View File

@ -1,3 +1,9 @@
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -64,11 +70,12 @@ int main(int argc, char *argv[])
struct timeval tv;
ssize_t len, wr;
char buf[16384];
libssh2_socket_t sock = LIBSSH2_INVALID_SOCKET;
libssh2_socket_t listensock = LIBSSH2_INVALID_SOCKET;
libssh2_socket_t forwardsock = LIBSSH2_INVALID_SOCKET;
#ifdef WIN32
char sockopt;
SOCKET sock = INVALID_SOCKET;
SOCKET listensock = INVALID_SOCKET, forwardsock = INVALID_SOCKET;
WSADATA wsadata;
int err;
@ -78,8 +85,7 @@ int main(int argc, char *argv[])
return 1;
}
#else
int sockopt, sock = -1;
int listensock = -1, forwardsock = -1;
int sockopt;
#endif
if(argc > 1)
@ -105,17 +111,14 @@ int main(int argc, char *argv[])
/* Connect to SSH server */
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sock == LIBSSH2_INVALID_SOCKET) {
#ifdef WIN32
if(sock == INVALID_SOCKET) {
fprintf(stderr, "failed to open socket!\n");
return -1;
}
#else
if(sock == -1) {
perror("socket");
#endif
return -1;
}
#endif
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(server_ip);
@ -193,17 +196,14 @@ int main(int argc, char *argv[])
}
listensock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if(listensock == LIBSSH2_INVALID_SOCKET) {
#ifdef WIN32
if(listensock == INVALID_SOCKET) {
fprintf(stderr, "failed to open listen socket!\n");
return -1;
}
#else
if(listensock == -1) {
perror("socket");
#endif
return -1;
}
#endif
sin.sin_family = AF_INET;
sin.sin_port = htons(local_listenport);
@ -229,17 +229,14 @@ int main(int argc, char *argv[])
inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
forwardsock = accept(listensock, (struct sockaddr *)&sin, &sinlen);
if(forwardsock == LIBSSH2_INVALID_SOCKET) {
#ifdef WIN32
if(forwardsock == INVALID_SOCKET) {
fprintf(stderr, "failed to accept forward socket!\n");
goto shutdown;
}
#else
if(forwardsock == -1) {
perror("accept");
#endif
goto shutdown;
}
#endif
shost = inet_ntoa(sin.sin_addr);
sport = ntohs(sin.sin_port);

View File

@ -2,6 +2,12 @@
* Sample showing how to do a simple SCP transfer.
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -33,7 +39,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "scp_nonblock 192.168.0.1 user password /tmp/secrets"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -47,7 +53,7 @@ static long tvdiff(struct timeval newer, struct timeval older)
}
#endif
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -80,7 +86,8 @@ static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -2,6 +2,12 @@
* Sample showing how to do an SCP upload.
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -33,7 +39,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session = NULL;
@ -98,7 +105,7 @@ int main(int argc, char *argv[])
* connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
if(-1 == sock) {
if(sock == LIBSSH2_INVALID_SOCKET) {
fprintf(stderr, "failed to create socket!\n");
return -1;
}

View File

@ -2,8 +2,13 @@
* Sample showing how to do an SCP non-blocking upload transfer.
*/
#include "libssh2_config.h"
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#ifdef HAVE_WINSOCK2_H
@ -35,7 +40,7 @@
#include <ctype.h>
#include <time.h>
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -68,7 +73,8 @@ static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session = NULL;

View File

@ -7,6 +7,12 @@
* "sftp 192.168.0.1 user password /tmp/secrets -p|-i|-k"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -96,7 +102,8 @@ static void kbd_callback(const char *name, int name_len,
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 0;
libssh2_socket_t sock;
int i, auth_pw = 0;
struct sockaddr_in sin;
const char *fingerprint;
char *userauthlist;

View File

@ -43,7 +43,7 @@
example uses to store the downloaded
file in */
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -75,7 +75,8 @@ static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
int main(int argc, char *argv[])
{
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* sftp_append 192.168.0.1 user password localfile /tmp/remotefile
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -36,7 +42,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "sftp 192.168.0.1 user password /tmp/sftp_mkdir"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -36,7 +42,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "sftp 192.168.0.1 user password /tmp/sftp_write_nonblock.c"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -36,7 +42,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "sftp_nonblock 192.168.0.1 user password /tmp/secrets"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -48,7 +54,7 @@ static long tvdiff(struct timeval newer, struct timeval older)
}
#endif
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -81,7 +87,8 @@ static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "sftp 192.168.0.1 user password sftp_write.c /tmp/secrets"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -36,7 +42,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "sftp 192.168.0.1 user password thisfile /tmp/storehere"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -40,7 +46,7 @@
#include <ctype.h>
#include <time.h>
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -73,7 +79,8 @@ static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "sftp 192.168.0.1 user password file /tmp/storehere"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -40,7 +46,7 @@
#include <ctype.h>
#include <time.h>
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -73,7 +79,8 @@ static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -7,6 +7,12 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -69,7 +75,8 @@ static void kbd_callback(const char *name, int name_len,
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int rc, sock, i, auth_pw = 0;
libssh2_socket_t sock;
int rc, i, auth_pw = 0;
struct sockaddr_in sin;
const char *fingerprint;
char *userauthlist;

View File

@ -7,6 +7,12 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
@ -45,7 +51,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
libssh2_socket_t sock;
int i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -11,11 +11,17 @@
* command executes on the remote machine
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#ifdef HAVE_WINDOWS_H
#ifdef WIN32
# include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H
@ -74,7 +80,8 @@ static void kbd_callback(const char *name, int name_len,
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int rc, sock, i, auth_pw = 0;
libssh2_socket_t sock;
int rc, i, auth_pw = 0;
struct sockaddr_in sin;
const char *fingerprint;
char *userauthlist;

View File

@ -6,11 +6,17 @@
* "ssh2_agent host user"
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#ifdef HAVE_WINDOWS_H
#ifdef WIN32
# include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H
@ -41,7 +47,8 @@ const char *username = "username";
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock = -1, i, rc;
libssh2_socket_t sock = LIBSSH2_INVALID_SOCKET;
int i, rc;
struct sockaddr_in sin;
const char *fingerprint;
char *userauthlist;
@ -82,7 +89,7 @@ int main(int argc, char *argv[])
* responsible for creating the socket establishing the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
if(sock == -1) {
if(sock == LIBSSH2_INVALID_SOCKET) {
fprintf(stderr, "failed to create socket!\n");
rc = 1;
goto shutdown;
@ -237,7 +244,7 @@ int main(int argc, char *argv[])
libssh2_session_free(session);
}
if(sock != -1) {
if(sock != LIBSSH2_INVALID_SOCKET) {
#ifdef WIN32
closesocket(sock);
#else

View File

@ -13,6 +13,12 @@
*
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -45,7 +51,7 @@
#include <stdio.h>
#include <ctype.h>
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -81,7 +87,7 @@ int main(int argc, char *argv[])
const char *commandline = "uptime";
const char *username = NULL;
unsigned long hostaddr;
int sock;
libssh2_socket_t sock;
struct sockaddr_in sin;
LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel;

View File

@ -8,6 +8,12 @@
*
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -41,7 +47,7 @@
#include <stdio.h>
#include <ctype.h>
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -80,7 +86,7 @@ int main(int argc, char *argv[])
const char *username = "user";
const char *password = "password";
unsigned long hostaddr;
int sock;
libssh2_socket_t sock;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
@ -231,7 +237,6 @@ int main(int argc, char *argv[])
int totsize = 1500000;
int totwritten = 0;
int totread = 0;
int partials = 0;
int rereads = 0;
int rewrites = 0;
int i;
@ -297,7 +302,6 @@ int main(int argc, char *argv[])
fprintf(stderr, "wrote %d bytes (%d in total)",
n, totwritten);
if(left >= bufsize && n != bufsize) {
partials++;
fprintf(stderr, " PARTIAL");
}
fprintf(stderr, "\n");

View File

@ -10,6 +10,12 @@
*
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -43,7 +49,7 @@
#include <stdio.h>
#include <ctype.h>
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
@ -80,7 +86,7 @@ int main(int argc, char *argv[])
const char *username = "user";
const char *password = "password";
unsigned long hostaddr;
int sock;
libssh2_socket_t sock;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;

View File

@ -1,3 +1,9 @@
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -120,9 +126,9 @@ int main(int argc, char *argv[])
LIBSSH2_CHANNEL *channel = NULL;
char buf[1048576]; /* avoid any buffer reallocation for simplicity */
ssize_t len;
libssh2_socket_t sock = LIBSSH2_INVALID_SOCKET;
#ifdef WIN32
SOCKET sock = INVALID_SOCKET;
WSADATA wsadata;
int err;
@ -131,8 +137,6 @@ int main(int argc, char *argv[])
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
return 1;
}
#else
int sock = -1;
#endif
if(argc > 1)
@ -150,17 +154,14 @@ int main(int argc, char *argv[])
/* Connect to SSH server */
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sock == LIBSSH2_INVALID_SOCKET) {
#ifdef WIN32
if(sock == INVALID_SOCKET) {
fprintf(stderr, "failed to open socket!\n");
return -1;
}
#else
if(sock == -1) {
perror("socket");
#endif
return -1;
}
#endif
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(server_ip);

View File

@ -1,3 +1,9 @@
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "libssh2_config.h"
#include <libssh2.h>
@ -64,9 +70,10 @@ int main(int argc, char *argv[])
struct timeval tv;
ssize_t len, wr;
char buf[16384];
libssh2_socket_t sock = LIBSSH2_INVALID_SOCKET;
libssh2_socket_t forwardsock = LIBSSH2_INVALID_SOCKET;
#ifdef WIN32
SOCKET sock = INVALID_SOCKET, forwardsock = INVALID_SOCKET;
WSADATA wsadata;
int err;
@ -75,8 +82,6 @@ int main(int argc, char *argv[])
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
return 1;
}
#else
int sock = -1, forwardsock = -1;
#endif
if(argc > 1)
@ -102,17 +107,14 @@ int main(int argc, char *argv[])
/* Connect to SSH server */
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if(sock == LIBSSH2_INVALID_SOCKET) {
#ifdef WIN32
if(sock == INVALID_SOCKET) {
fprintf(stderr, "failed to open socket!\n");
return -1;
}
#else
if(sock == -1) {
perror("socket");
#endif
return -1;
}
#endif
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr(server_ip);
@ -217,17 +219,14 @@ int main(int argc, char *argv[])
"Accepted remote connection. Connecting to local server %s:%d\n",
local_destip, local_destport);
forwardsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if(forwardsock == LIBSSH2_INVALID_SOCKET) {
#ifdef WIN32
if(forwardsock == INVALID_SOCKET) {
fprintf(stderr, "failed to open forward socket!\n");
goto shutdown;
}
#else
if(forwardsock == -1) {
perror("socket");
#endif
goto shutdown;
}
#endif
sin.sin_family = AF_INET;
sin.sin_port = htons(local_destport);

View File

@ -99,7 +99,7 @@ extern "C" {
/* Allow alternate API prefix from CFLAGS or calling app */
#ifndef LIBSSH2_API
# ifdef LIBSSH2_WIN32
# ifdef WIN32
# if defined(_WINDLL) || defined(libssh2_EXPORTS)
# ifdef LIBSSH2_LIBRARY
# define LIBSSH2_API __declspec(dllexport)
@ -109,9 +109,9 @@ extern "C" {
# else
# define LIBSSH2_API
# endif
# else /* !LIBSSH2_WIN32 */
# else /* !WIN32 */
# define LIBSSH2_API
# endif /* LIBSSH2_WIN32 */
# endif /* WIN32 */
#endif /* LIBSSH2_API */
#ifdef HAVE_SYS_UIO_H

View File

@ -59,10 +59,6 @@
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define to 1 if you have the declaration of `SecureZeroMemory', and to 0 if
you don't. */
#undef HAVE_DECL_SECUREZEROMEMORY
/* disabled non-blocking sockets */
#undef HAVE_DISABLED_NONBLOCKING
@ -180,9 +176,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
/* Define to 1 if you have the <winsock2.h> header file. */
#undef HAVE_WINSOCK2_H

View File

@ -298,7 +298,6 @@ check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(sys/un.h HAVE_SYS_UN_H)
check_include_files(windows.h HAVE_WINDOWS_H)
check_include_files(ws2tcpip.h HAVE_WS2TCPIP_H)
check_include_files(winsock2.h HAVE_WINSOCK2_H)
@ -354,15 +353,6 @@ configure_file(
# to find generated header
target_include_directories(libssh2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
# Check for the OS.
# Daniel's note: this should not be necessary and we need to work to
# get this removed.
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
target_compile_definitions(libssh2 PRIVATE LIBSSH2_WIN32)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
target_compile_definitions(libssh2 PRIVATE LIBSSH2_DARWIN)
endif()
if(MSVC)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /DEBUG")

View File

@ -249,7 +249,7 @@ struct agent_ops agent_ops_unix = {
};
#endif /* PF_UNIX */
#ifdef WIN32
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP)
/* Code to talk to Pageant was taken from PuTTY.
*
* Portions copyright Robert de Bath, Joris van Rantwijk, Delian
@ -352,16 +352,16 @@ struct agent_ops agent_ops_pageant = {
agent_transact_pageant,
agent_disconnect_pageant
};
#endif /* WIN32 */
#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) */
static struct {
const char *name;
struct agent_ops *ops;
} supported_backends[] = {
#ifdef WIN32
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP)
{"Pageant", &agent_ops_pageant},
{"OpenSSH", &agent_ops_openssh},
#endif /* WIN32 */
#endif
#ifdef PF_UNIX
{"Unix", &agent_ops_unix},
#endif /* PF_UNIX */

View File

@ -55,7 +55,7 @@
#include <stdlib.h>
#endif
#ifdef WIN32
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP)
/* Code to talk to OpenSSH was taken and modified from the Win32 port of
* Portable OpenSSH by the PowerShell team. Commit
* 8ab565c53f3619d6a1f5ac229e212cad8a52852c of
@ -358,4 +358,4 @@ struct agent_ops agent_ops_openssh = {
agent_transact_openssh,
agent_disconnect_openssh
};
#endif /* WIN32 */
#endif /* defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) */

View File

@ -60,8 +60,11 @@ static void
bcrypt_hash(uint8_t *sha2pass, uint8_t *sha2salt, uint8_t *out)
{
blf_ctx state;
uint8_t ciphertext[BCRYPT_HASHSIZE] =
"OxychromaticBlowfishSwatDynamite";
uint8_t ciphertext[BCRYPT_HASHSIZE] = {
'O', 'x', 'y', 'c', 'h', 'r', 'o', 'm', 'a', 't', 'i', 'c',
'B', 'l', 'o', 'w', 'f', 'i', 's', 'h',
'S', 'w', 'a', 't',
'D', 'y', 'n', 'a', 'm', 'i', 't', 'e' };
uint32_t cdata[BCRYPT_BLOCKS];
int i;
uint16_t j;

View File

@ -302,7 +302,9 @@ hostkey_method_ssh_rsa_sha2_256_signv(LIBSSH2_SESSION * session,
unsigned char hash[SHA256_DIGEST_LENGTH];
libssh2_sha256_ctx ctx;
libssh2_sha256_init(&ctx);
if(!libssh2_sha256_init(&ctx)) {
return -1;
}
for(i = 0; i < veccount; i++) {
libssh2_sha256_update(ctx, datavec[i].iov_base, datavec[i].iov_len);
}
@ -370,7 +372,9 @@ hostkey_method_ssh_rsa_sha2_512_signv(LIBSSH2_SESSION * session,
unsigned char hash[SHA512_DIGEST_LENGTH];
libssh2_sha512_ctx ctx;
libssh2_sha512_init(&ctx);
if(!libssh2_sha512_init(&ctx)) {
return -1;
}
for(i = 0; i < veccount; i++) {
libssh2_sha512_update(ctx, datavec[i].iov_base, datavec[i].iov_len);
}

View File

@ -144,7 +144,7 @@ static void _libssh2_sha_algo_ctx_update(int sha_algo, void *ctx,
libssh2_sha1_update(*_ctx, data, len);
}
else {
#if LIBSSH2DEBUG
#ifdef LIBSSH2DEBUG
assert(0);
#endif
}
@ -170,7 +170,7 @@ static void _libssh2_sha_algo_ctx_final(int sha_algo, void *ctx,
libssh2_sha1_final(*_ctx, hash);
}
else {
#if LIBSSH2DEBUG
#ifdef LIBSSH2DEBUG
assert(0);
#endif
}
@ -195,7 +195,7 @@ static void _libssh2_sha_algo_value_hash(int sha_algo,
LIBSSH2_KEX_METHOD_SHA_VALUE_HASH(1, *data, data_len, version);
}
else {
#if LIBSSH2DEBUG
#ifdef LIBSSH2DEBUG
assert(0);
#endif
}
@ -3326,7 +3326,7 @@ kex_agree_instr(unsigned char *haystack, unsigned long haystack_len,
/* Search until we run out of comas or we run out of haystack,
whichever comes first */
while((s = (unsigned char *) memchr((char *) s, ',', left))) {
while((s = (unsigned char *) memchr((char *) s, ',', left)) != NULL) {
/* Advance buffer past coma if we can */
left = end_haystack - s;
if((left >= 1) && (left <= haystack_len) && (left > needle_len)) {

View File

@ -45,7 +45,6 @@
#cmakedefine HAVE_SYS_IOCTL_H
#cmakedefine HAVE_SYS_TIME_H
#cmakedefine HAVE_SYS_UN_H
#cmakedefine HAVE_WINDOWS_H
#cmakedefine HAVE_WS2TCPIP_H
#cmakedefine HAVE_WINSOCK2_H
#cmakedefine HAVE_NTDEF_H

View File

@ -42,12 +42,34 @@
#define LIBSSH2_LIBRARY
#include "libssh2_config.h"
#ifdef HAVE_WINDOWS_H
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
/* Detect Windows App environment which has a restricted access
to the Win32 APIs. */
# if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
defined(WINAPI_FAMILY)
# include <winapifamily.h>
# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
# define LIBSSH2_WINDOWS_APP
# endif
# endif
/* TODO: Enable this unconditionally for all platforms.
Also delete autotools logic that enables it only for mbedTLS.
And CMake logic which already enabled it unconditionally.
The actual memory clearing logic uses SecureZeroMemory(),
memset_s() or plain memset(), whichever is available, and
does not depend on any crypto backend function. */
#ifndef LIBSSH2_CLEAR_MEMORY
#define LIBSSH2_CLEAR_MEMORY
#endif
#endif
#ifdef HAVE_WS2TCPIP_H
@ -119,20 +141,6 @@ struct iovec {
#endif
/* Provide iovec / writev on WIN32 platform. */
#ifdef WIN32
static inline int writev(int sock, struct iovec *iov, int nvecs)
{
DWORD ret;
if(WSASend(sock, (LPWSABUF)iov, nvecs, &ret, 0, NULL, NULL) == 0) {
return ret;
}
return -1;
}
#endif /* WIN32 */
#ifdef __OS400__
/* Force parameter type. */
#define send(s, b, l, f) send((s), (unsigned char *) (b), (l), (f))
@ -976,7 +984,7 @@ void _libssh2_debug(LIBSSH2_SESSION * session, int context, const char *format,
#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \
defined(__GNUC__)
/* C99 supported and also by older GCC */
#define _libssh2_debug(x,y,z,...) do {} while (0)
#define _libssh2_debug(x,y,...) do {} while (0)
#else
/* no gcc and not C99, do static and hopefully inline */
static inline void

View File

@ -93,16 +93,14 @@ _libssh2_mbedtls_random(unsigned char *buf, int len)
static void
_libssh2_mbedtls_safe_free(void *buf, int len)
{
#ifndef LIBSSH2_CLEAR_MEMORY
(void)len;
#endif
if(!buf)
return;
#ifdef LIBSSH2_CLEAR_MEMORY
if(len > 0)
_libssh2_explicit_zero(buf, len);
#else
(void)len;
#endif
mbedtls_free(buf);

View File

@ -53,11 +53,9 @@
#include <sys/time.h>
#endif
#if defined(HAVE_DECL_SECUREZEROMEMORY) && HAVE_DECL_SECUREZEROMEMORY
#ifdef HAVE_WINDOWS_H
#ifdef WIN32
#include <windows.h>
#endif
#endif
#include <stdio.h>
#include <errno.h>
@ -717,21 +715,16 @@ void _libssh2_aes_ctr_increment(unsigned char *ctr,
}
}
#ifdef WIN32
static void * (__cdecl * const volatile memset_libssh)(void *, int, size_t) =
memset;
#else
#if !defined(WIN32) && !defined(HAVE_MEMSET_S)
static void * (* const volatile memset_libssh)(void *, int, size_t) = memset;
#endif
void _libssh2_explicit_zero(void *buf, size_t size)
{
#if defined(HAVE_DECL_SECUREZEROMEMORY) && HAVE_DECL_SECUREZEROMEMORY
#ifdef WIN32
SecureZeroMemory(buf, size);
(void)memset_libssh; /* Silence unused variable warning */
#elif defined(HAVE_MEMSET_S)
(void)memset_s(buf, size, 0, size);
(void)memset_libssh; /* Silence unused variable warning */
#else
memset_libssh(buf, 0, size);
#endif

View File

@ -108,7 +108,7 @@ int _libssh2_get_bignum_bytes(struct string_buf *buf, unsigned char **outbuf,
int _libssh2_check_length(struct string_buf *buf, size_t requested_len);
int _libssh2_eob(struct string_buf *buf);
#if defined(LIBSSH2_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
#if defined(WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__)
/* provide a private one */
#undef HAVE_GETTIMEOFDAY
int __cdecl _libssh2_gettimeofday(struct timeval *tp, void *tzp);

View File

@ -141,7 +141,7 @@ _libssh2_pem_parse(LIBSSH2_SESSION * session,
}
all_methods = libssh2_crypt_methods();
while((cur_method = *all_methods++)) {
while((cur_method = *all_methods++) != NULL) {
if(*cur_method->pem_annotation &&
memcmp(line, cur_method->pem_annotation,
strlen(cur_method->pem_annotation)) == 0) {
@ -490,7 +490,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
const LIBSSH2_CRYPT_METHOD **all_methods, *cur_method;
all_methods = libssh2_crypt_methods();
while((cur_method = *all_methods++)) {
while((cur_method = *all_methods++) != NULL) {
if(*cur_method->name &&
memcmp(ciphername, cur_method->name,
strlen(cur_method->name)) == 0) {

View File

@ -347,7 +347,7 @@ session_nonblock(libssh2_socket_t sockfd, /* operate on this */
* gets the given blocking or non-blocking state of the socket.
*/
static int
get_socket_nonblocking(int sockfd)
get_socket_nonblocking(libssh2_socket_t sockfd)
{ /* operate on this */
#undef GETBLOCK
#define GETBLOCK 0
@ -520,8 +520,14 @@ libssh2_session_init_ex(LIBSSH2_ALLOC_FUNC((*my_alloc)),
* ALERT: this function relies on that we can typecast function pointers
* to void pointers, which isn't allowed in ISO C!
*/
#ifdef _MSC_VER
#pragma warning(push)
/* nonstandard extension, function/data pointer conversion in expression */
#pragma warning(disable:4152)
#else
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
LIBSSH2_API void *
libssh2_session_callback_set(LIBSSH2_SESSION * session,
int cbtype, void *callback)
@ -569,7 +575,11 @@ libssh2_session_callback_set(LIBSSH2_SESSION * session,
return NULL;
}
#ifdef _MSC_VER
#pragma warning(pop)
#else
#pragma GCC diagnostic pop
#endif
/*
* _libssh2_wait_socket()
@ -876,7 +886,7 @@ session_free(LIBSSH2_SESSION *session)
}
if(session->free_state == libssh2_NB_state_created) {
while((ch = _libssh2_list_first(&session->channels))) {
while((ch = _libssh2_list_first(&session->channels)) != NULL) {
rc = _libssh2_channel_free(ch);
if(rc == LIBSSH2_ERROR_EAGAIN)
@ -887,7 +897,7 @@ session_free(LIBSSH2_SESSION *session)
}
if(session->free_state == libssh2_NB_state_sent) {
while((l = _libssh2_list_first(&session->listeners))) {
while((l = _libssh2_list_first(&session->listeners)) != NULL) {
rc = _libssh2_channel_forward_cancel(l);
if(rc == LIBSSH2_ERROR_EAGAIN)
return rc;
@ -1073,7 +1083,7 @@ session_free(LIBSSH2_SESSION *session)
}
/* Cleanup all remaining packets */
while((pkg = _libssh2_list_first(&session->packets))) {
while((pkg = _libssh2_list_first(&session->packets)) != NULL) {
packets_left++;
_libssh2_debug(session, LIBSSH2_TRACE_TRANS,
"packet left with id %d", pkg->data[0]);
@ -1084,6 +1094,7 @@ session_free(LIBSSH2_SESSION *session)
LIBSSH2_FREE(session, pkg->data);
LIBSSH2_FREE(session, pkg);
}
(void)packets_left;
_libssh2_debug(session, LIBSSH2_TRACE_TRANS,
"Extra packets left %d", packets_left);

View File

@ -118,7 +118,7 @@ debugdump(LIBSSH2_SESSION * session,
}
}
#else
#define debugdump(a,x,y,z)
#define debugdump(a,x,y,z) do {} while(0)
#endif

View File

@ -54,7 +54,7 @@ const char *libssh2_version(int req_version_num)
}
LIBSSH2_API
libssh2_crypto_engine_t libssh2_crypto_engine()
libssh2_crypto_engine_t libssh2_crypto_engine(void)
{
#if defined LIBSSH2_OPENSSL
return libssh2_openssl;

View File

@ -58,7 +58,6 @@
#include <windows.h>
#include <bcrypt.h>
#include <ntstatus.h>
#include <math.h>
#include "misc.h"
@ -75,6 +74,12 @@
#define PEM_DSA_FOOTER "-----END DSA PRIVATE KEY-----"
/* Define this manually to avoid including <ntstatus.h> and thus
clashing with <windows.h> symbols. */
#ifndef STATUS_NOT_SUPPORTED
#define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BB)
#endif
/*******************************************************************/
/*
* Windows CNG backend: Missing definitions (for MinGW[-w64])
@ -427,16 +432,14 @@ _libssh2_wincng_random(void *buf, int len)
static void
_libssh2_wincng_safe_free(void *buf, int len)
{
#ifndef LIBSSH2_CLEAR_MEMORY
(void)len;
#endif
if(!buf)
return;
#ifdef LIBSSH2_CLEAR_MEMORY
if(len > 0)
SecureZeroMemory(buf, len);
#else
(void)len;
#endif
free(buf);
@ -1849,6 +1852,19 @@ _libssh2_wincng_sk_pub_keyfilememory(LIBSSH2_SESSION *session,
size_t privatekeydata_len,
const char *passphrase)
{
(void)method;
(void)method_len;
(void)pubkeydata;
(void)pubkeydata_len;
(void)algorithm;
(void)flags;
(void)application;
(void)key_handle;
(void)handle_len;
(void)privatekeydata;
(void)privatekeydata_len;
(void)passphrase;
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
"Unable to extract public SK key from private key file: "
"Method unimplemented in Windows CNG backend");

View File

@ -36,7 +36,6 @@
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckSymbolExists)
include(BundleUtilities)
include(CopyRuntimeDependencies)
include(SocketLibraries)
@ -46,7 +45,6 @@ check_include_files(unistd.h HAVE_UNISTD_H)
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
check_include_files(windows.h HAVE_WINDOWS_H)
check_include_files(winsock2.h HAVE_WINSOCK2_H)
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
configure_file(

View File

@ -41,7 +41,6 @@
#cmakedefine HAVE_SYS_SOCKET_H
#cmakedefine HAVE_ARPA_INET_H
#cmakedefine HAVE_NETINET_IN_H
#cmakedefine HAVE_WINDOWS_H
#cmakedefine HAVE_WINSOCK2_H
#cmakedefine HAVE_SNPRINTF

View File

@ -35,6 +35,12 @@
* OF SUCH DAMAGE.
*/
#ifdef WIN32
#ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
#define _WINSOCK_DEPRECATED_NO_WARNINGS
#endif
#endif
#include "openssh_fixture.h"
#include "session_fixture.h"
#include "libssh2_config.h"
@ -326,7 +332,7 @@ static int open_socket_to_container(char *container_id)
char *ip_address = NULL;
char *port_string = NULL;
unsigned long hostaddr;
int sock;
libssh2_socket_t sock;
struct sockaddr_in sin;
int counter = 0;
int ret;

View File

@ -45,7 +45,7 @@
#include <unistd.h>
#endif
#ifdef HAVE_WINDOWS_H
#ifdef WIN32
#include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H

View File

@ -4,7 +4,7 @@
#include <libssh2.h>
#include <libssh2_sftp.h>
#ifdef HAVE_WINDOWS_H
#ifdef WIN32
# include <windows.h>
#endif
#ifdef HAVE_WINSOCK2_H
@ -33,7 +33,8 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 0;
libssh2_socket_t sock;
int i, auth_pw = 0;
struct sockaddr_in sin;
const char *fingerprint;
char *userauthlist;

View File

@ -86,6 +86,9 @@ CAT = type
ECHONL = $(ComSpec) /c echo.
endif
ifeq ($(LIBSSH2_RC),)
LIBSSH2_RC := $(CROSSPREFIX)windres
endif
ifeq ($(LIBSSH2_CC),)
LIBSSH2_CC := $(CROSSPREFIX)gcc
endif
@ -101,12 +104,7 @@ endif
libssh2_dll_LIBRARY = $(TARGET)$(LIBSSH2_DLL_SUFFIX).dll
# The following line defines your compiler.
ifdef METROWERKS
CC = mwcc
else
CC = $(LIBSSH2_CC)
endif
CC = $(LIBSSH2_CC)
# Set environment var ARCH to your architecture to override autodetection.
ifndef ARCH
@ -125,27 +123,12 @@ endif
-include $(OBJDIR)/version.inc
# Global flags for all compilers
CFLAGS = $(LIBSSH2_CFLAG_EXTRAS) $(OPT) -D$(DB) -DLIBSSH2_WIN32 -DHAVE_WINDOWS_H # -DHAVE_CONFIG_H
CFLAGS = $(LIBSSH2_CFLAG_EXTRAS) $(OPT) -D$(DB)
LDFLAGS = $(LIBSSH2_LDFLAG_EXTRAS)
ifeq ($(CC),mwcc)
LD = mwld
RC = mwwinrc
LDFLAGS += -nostdlib
AR = $(LD)
ARFLAGS = -nostdlib -library -o
LIBEXT = lib
#RANLIB =
LIBPATH += -lr "$(METROWERKS)/MSL" -lr "$(METROWERKS)/Win32-x86 Support"
LDLIBS += -lMSL_Runtime_x86.lib -lMSL_C_x86.lib -lMSL_Extras_x86.lib
RCFLAGS =
CFLAGS += -nostdinc -gccinc -msgstyle gcc -inline off -opt nointrinsics -proc 586
CFLAGS += -ir "$(METROWERKS)/MSL" -ir "$(METROWERKS)/Win32-x86 Support"
CFLAGS += -w on,nounused,nounusedexpr # -ansi strict
else
LIBEXT = a
LD = $(LIBSSH2_CC)
RC = $(CROSSPREFIX)windres
RC = $(LIBSSH2_RC)
LDFLAGS += -s -shared -Wl,--output-def,$(libssh2_dll_LIBRARY:.dll=.def),--out-implib,$(TARGET)$(LIBSSH2_DLL_A_SUFFIX).$(LIBEXT)
AR = $(LIBSSH2_AR)
ARFLAGS = cru
@ -155,10 +138,11 @@ CFLAGS += -fno-builtin
CFLAGS += -fno-strict-aliasing
CFLAGS += -Wall # -pedantic
ifeq ($(ARCH),w64)
CFLAGS += -m64 -D_AMD64_
CFLAGS += -m64
LDFLAGS += -m64
RCFLAGS += -F pe-x86-64
else
ifeq ($(ARCH),w32)
CFLAGS += -m32
LDFLAGS += -m32
RCFLAGS += -F pe-i386
@ -208,12 +192,7 @@ else
endif
endif
endif
ifeq ($(CC),mwcc)
LDLIBS += -lkernel32.lib -luser32.lib -lwsock32.lib
else
#LDLIBS += -lwsock32
LDLIBS += -lws2_32
endif
ifdef WITH_ZLIB
CFLAGS += -DLIBSSH2_HAVE_ZLIB
@ -338,7 +317,7 @@ $(libssh2_dll_LIBRARY) $(TARGET)$(LIBSSH2_DLL_A_SUFFIX).$(LIBEXT): $(OBJL)
$(OBJDIR)/%.res: %.rc
@echo Creating $@
@$(RC) $(RCFLAGS) -i $< -o $@
@$(RC) $(RCFLAGS) $(LIBSSH2_RCFLAG_EXTRAS) -i $< -o $@
$(DISTDIR)/readme.txt: GNUmakefile

View File

@ -44,7 +44,7 @@ RD = rmdir /q /s 2>NUL
CP = copy
CFLAGS = -3r -mf -hc -zff -zgf -zq -zm -zc -s -fr=nul -w2 -fpi -oilrtfm &
-wcd=201 -bt=nt -d+ -dWIN32 -DLIBSSH2_WIN32 &
-wcd=201 -bt=nt -d+ -dWIN32 &
-I. -I..\include $(SYS_INCL)
!ifdef %debug

View File

@ -1,4 +1,3 @@
# Tweak these for your system
!if "$(OPENSSLINC)" == ""
OPENSSLINC=..\openssl-0.9.8zc\inc32
@ -50,5 +49,3 @@ DLLFLAGS=$(CFLAGS) $(DLLFLAGS)
LIBS=$(LIBS) ws2_32.lib user32.lib advapi32.lib gdi32.lib
INTDIR=$(TARGET)\$(SUBDIR)

View File

@ -33,7 +33,7 @@ BEGIN
VALUE "OriginalFilename", "libssh2.dll\0"
VALUE "ProductName", "The libssh2 library\0"
VALUE "ProductVersion", LIBSSH2_VERSION "\0"
VALUE "LegalCopyright", "<EFBFBD> " LIBSSH2_COPYRIGHT "\0"
VALUE "LegalCopyright", "Copyright (C) " LIBSSH2_COPYRIGHT "\0"
VALUE "License", "https://www.libssh2.org/license.html\0"
END
END

View File

@ -7,9 +7,6 @@
#ifndef _CRT_SECURE_NO_DEPRECATE
#define _CRT_SECURE_NO_DEPRECATE 1
#endif /* _CRT_SECURE_NO_DEPRECATE */
#include <winsock2.h>
#include <mswsock.h>
#include <ws2tcpip.h>
#ifdef __MINGW32__
#define HAVE_UNISTD_H
@ -44,4 +41,3 @@
#define LIBSSH2_DH_GEX_NEW 1
#endif /* LIBSSH2_CONFIG_H */

View File

@ -50,8 +50,8 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release_dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -77,8 +77,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug_dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# SUBTRACT CPP /WX /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -104,8 +104,8 @@ LINK32=link.exe
# PROP Output_Dir "Release_lib"
# PROP Intermediate_Dir "Release_lib"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@ -128,8 +128,8 @@ LIB32=link.exe -lib
# PROP Output_Dir "Debug_lib"
# PROP Intermediate_Dir "Debug_lib"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_OPENSSL" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
@ -152,8 +152,8 @@ LIB32=link.exe -lib
# PROP Intermediate_Dir "Release_dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@ -179,8 +179,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug_dll"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# SUBTRACT CPP /WX /YX
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
@ -206,8 +206,8 @@ LINK32=link.exe
# PROP Output_Dir "Release_lib"
# PROP Intermediate_Dir "Release_lib"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\win32" /I "..\include" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@ -230,8 +230,8 @@ LIB32=link.exe -lib
# PROP Output_Dir "Debug_lib"
# PROP Intermediate_Dir "Debug_lib"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /nologo /MD /W3 /Gm /GX /ZI /Od /I "..\win32" /I "..\include" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WINCNG" /D "_MBCS" /D "_LIB" /D "LIBSSH2DEBUG" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe

View File

@ -77,12 +77,7 @@ CAT = type
ECHONL = $(ComSpec) /c echo.
endif
# The following line defines your compiler.
ifdef METROWERKS
CC = mwcc
else
CC = $(CROSSPREFIX)gcc
endif
CC = $(CROSSPREFIX)gcc
# Set environment var ARCH to your architecture to override autodetection.
ifndef ARCH
@ -101,23 +96,8 @@ endif
-include $(OBJDIR)/version.inc
# Global flags for all compilers
CFLAGS = $(OPT) -D$(DB) -DLIBSSH2_WIN32 # -DHAVE_CONFIG_H
CFLAGS = $(OPT) -D$(DB)
ifeq ($(CC),mwcc)
LD = mwld
RC = mwwinrc
LDFLAGS = -nostdlib
AR = $(LD)
ARFLAGS = -nostdlib -library -o
LIBEXT = lib
LIBPATH += -lr "$(METROWERKS)/MSL" -lr "$(METROWERKS)/Win32-x86 Support"
LDLIBS += -lMSL_Runtime_x86.lib -lMSL_C_x86.lib -lMSL_Extras_x86.lib
LDLIBS += -lkernel32.lib -luser32.lib -lwsock32.lib
RCFLAGS =
CFLAGS += -nostdinc -gccinc -msgstyle gcc -inline off -opt nointrinsics -proc 586
CFLAGS += -ir "$(METROWERKS)/MSL" -ir "$(METROWERKS)/Win32-x86 Support"
CFLAGS += -w on,nounused,nounusedexpr # -ansi strict
else
LD = $(CROSSPREFIX)gcc
RC = $(CROSSPREFIX)windres
LDFLAGS = -s
@ -131,9 +111,10 @@ CFLAGS += -fno-builtin
CFLAGS += -fno-strict-aliasing
CFLAGS += -Wall #-Wno-unused #-pedantic
ifeq ($(ARCH),w64)
CFLAGS += -D_AMD64_
CFLAGS += -m64
RCFLAGS += -F pe-x86-64
else
ifeq ($(ARCH),w32)
CFLAGS += -m32
RCFLAGS += -F pe-i386
endif
@ -230,7 +211,7 @@ $(OBJDIR):
$(OBJDIR)/%.res: $(OBJDIR)/%.rc
@echo Creating $@
@$(RC) $(RCFLAGS) -i $< -o $@
@$(RC) $(RCFLAGS) $(LIBSSH2_RCFLAG_EXTRAS) -i $< -o $@
$(OBJDIR)/%.rc: GNUmakefile $(OBJDIR)/version.inc
@echo $(DL)1 VERSIONINFO$(DL) > $@
@ -279,5 +260,3 @@ help: $(OBJDIR)/version.inc
@echo $(DL)$(MAKE) clean$(DL)
@echo $(DL)$(MAKE) objclean$(DL)
@echo $(DL)===========================================================$(DL)

View File

@ -41,8 +41,8 @@ RSC=rc.exe
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\include" /I "..\win32" /D "WIN32" /D "NDEBUG" /D "LIBSSH2_WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\include" /I "..\win32" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
@ -65,8 +65,8 @@ LINK32=link.exe
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\win32" /D "WIN32" /D "_DEBUG" /D "LIBSSH2_WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\include" /I "..\win32" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe