1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-07-28 01:41:49 +03:00

build: hand-crafted config rework & header tidy-up

- introduce the concept of a project level setup header
  `src/libssh2_setup.h`, that is used by `src`, `example` and `tests`
  alike. Move there all common platform/compiler configuration from
  `src/libssh2_priv.h`, individual sources and `CMakeFiles.txt` files.
  Also move there our hand-crafted (= not auto-generated by CMake or
  autotools) configuration `win32/libssh2-config.h`.

- `win32` directory is empty now, delete it.

- `Makefile.mk`: adapt to the above. Build-directory is the target
  triplet, or any custom name set via `BLD_DIR`.

- sync header path order between build systems:
  build/src -> source/src -> source/include

- delete redundant references to `windows.h`, `winsock2.h`,
  `ws2tcpip.h`.

- delete unnecessary #includes, update order (`libssh2_setup.h` first,
  `winsock2.h` first), simplify where possible.

  This makes the code warning-free without `WIN32_LEAN_AND_MEAN`.
  At the same time this patch applies this macro globally, to avoid
  header bloat.

- example: add missing *nix header guards.

- example: fix misindented `HAVE_UNISTD_H` `#ifdef`s.

- set `WIN32` with all build-tools.

- set `HAVE_SYS_PARAM_H` in the hand-crafted config for MinGW.
  To match auto-detection.

- move a source-specific macro to `misc.c` from `libssh2_priv.h`.

See the PR's individual commits for step-by-step updates.

Closes #932
This commit is contained in:
Viktor Szakats
2023-04-07 23:32:42 +00:00
parent 8774f4973f
commit 59666e03f0
77 changed files with 250 additions and 466 deletions

3
.gitignore vendored
View File

@ -8,10 +8,9 @@
*.exe *.exe
*.obj *.obj
.*.swp .*.swp
*-*-*
Debug Debug
Release Release
debug-*
release-*
*.exp *.exp
Makefile Makefile
Makefile.in Makefile.in

View File

@ -127,9 +127,9 @@ check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(sys/ioctl.h HAVE_SYS_IOCTL_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/time.h HAVE_SYS_TIME_H)
check_include_files(sys/un.h HAVE_SYS_UN_H) check_include_files(sys/un.h HAVE_SYS_UN_H)
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
# for example and tests # for example and tests
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
check_include_files(arpa/inet.h HAVE_ARPA_INET_H) check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
check_include_files(netinet/in.h HAVE_NETINET_IN_H) check_include_files(netinet/in.h HAVE_NETINET_IN_H)
@ -330,6 +330,7 @@ endif()
if(CRYPTO_BACKEND STREQUAL "WinCNG" OR NOT CRYPTO_BACKEND) if(CRYPTO_BACKEND STREQUAL "WinCNG" OR NOT CRYPTO_BACKEND)
# The check actually compiles the header. This requires windows.h. # The check actually compiles the header. This requires windows.h.
# Check necessary for old-MinGW
check_include_files("windows.h;bcrypt.h" HAVE_BCRYPT_H) check_include_files("windows.h;bcrypt.h" HAVE_BCRYPT_H)
if(HAVE_BCRYPT_H) if(HAVE_BCRYPT_H)

View File

@ -23,7 +23,6 @@ VMSFILES = vms/libssh2_make_example.dcl vms/libssh2_make_help.dcl \
vms/readme.vms vms/libssh2_config.h vms/readme.vms vms/libssh2_config.h
WIN32FILES = NMakefile \ WIN32FILES = NMakefile \
win32/libssh2_config.h \
src/libssh2.rc src/libssh2.rc
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \ OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \

View File

@ -4,6 +4,6 @@ CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.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 blowfish.c bcrypt_pbkdf.c agent_win.c os400qc3.c
HHEADERS = libssh2_priv.h $(CRYPTO_HHEADERS) transport.h channel.h comp.h \ HHEADERS = libssh2_priv.h libssh2_setup.h $(CRYPTO_HHEADERS) transport.h \
mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h blf.h agent.h \ channel.h comp.h mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h \
userauth_kbd_packet.h os400qc3.h blf.h agent.h userauth_kbd_packet.h os400qc3.h

View File

@ -47,18 +47,17 @@ else
TRIPLET ?= $(shell $(CC) -dumpmachine) TRIPLET ?= $(shell $(CC) -dumpmachine)
endif endif
BLD_DIR ?= $(PROOT)/$(TRIPLET)
ifneq ($(findstring -w,$(TRIPLET)),) ifneq ($(findstring -w,$(TRIPLET)),)
WIN32 := 1 WIN32 := 1
BIN_EXT := .exe BIN_EXT := .exe
DYN_EXT := .dll DYN_EXT := .dll
BLD_DIR ?= $(PROOT)/win32
CONFIG_H_DIR ?= $(PROOT)/win32
else else
BLD_DIR ?= $(PROOT) CPPFLAGS += -I$(BLD_DIR) -DHAVE_CONFIG_H
CONFIG_H_DIR ?= $(PROOT)
endif endif
CPPFLAGS += -I$(CONFIG_H_DIR) -I$(PROOT)/include CPPFLAGS += -I$(PROOT)/src -I$(PROOT)/include
RCFLAGS += -I$(PROOT)/include RCFLAGS += -I$(PROOT)/include
# examples, tests # examples, tests
@ -87,9 +86,9 @@ endif
DB ?= NDEBUG DB ?= NDEBUG
CPPFLAGS += -D$(DB) CPPFLAGS += -D$(DB)
ifeq ($(DB),NDEBUG) ifeq ($(DB),NDEBUG)
OBJ_DIR := release-$(TRIPLET) OBJ_DIR := release
else else
OBJ_DIR := debug-$(TRIPLET) OBJ_DIR := debug
CFLAGS += -g CFLAGS += -g
CPPFLAGS += -DLIBSSH2DEBUG CPPFLAGS += -DLIBSSH2DEBUG
endif endif
@ -264,7 +263,6 @@ dist: all $(DISTDIR) $(DISTDIR)/readme.txt
@$(call COPY, $(PROOT)/README, $(DISTDIR)) @$(call COPY, $(PROOT)/README, $(DISTDIR))
@$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR)) @$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR))
@$(call COPY, $(PROOT)/include/*.h, $(DISTDIR)/include) @$(call COPY, $(PROOT)/include/*.h, $(DISTDIR)/include)
@$(call COPY, $(CONFIG_H_DIR)/libssh2_config.h, $(DISTDIR)/include)
@$(call COPY, $(TARGET).a, $(DISTDIR)/lib) @$(call COPY, $(TARGET).a, $(DISTDIR)/lib)
ifdef WIN32 ifdef WIN32
@$(call COPY, $(libssh2_def_LIBRARY), $(DISTDIR)/bin) @$(call COPY, $(libssh2_def_LIBRARY), $(DISTDIR)/bin)

View File

@ -11,7 +11,7 @@ CFLAGS=/Oi /O2 /Oy /GF /Y- /MD /DNDEBUG
DLLFLAGS=/LD DLLFLAGS=/LD
!endif !endif
CFLAGS=/nologo /GL /Zi /EHsc $(CFLAGS) /Iwin32 /Iinclude CFLAGS=/nologo /GL /Zi /EHsc $(CFLAGS) /Iinclude
!if "$(OPENSSL_PATH)" != "" !if "$(OPENSSL_PATH)" != ""
CFLAGS=$(CFLAGS) /DLIBSSH2_OPENSSL /I$(OPENSSL_PATH)\include CFLAGS=$(CFLAGS) /DLIBSSH2_OPENSSL /I$(OPENSSL_PATH)\include

View File

@ -217,7 +217,6 @@ dnl the code was bad, try a different program now, test 3
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif #endif
#include <windows.h>
#include <winsock2.h> #include <winsock2.h>
#endif #endif
],[ ],[
@ -451,6 +450,7 @@ m4_case([$1],
LIBS="$LIBS -lcrypt32" LIBS="$LIBS -lcrypt32"
# Check necessary for old-MinGW
LIBSSH2_LIB_HAVE_LINKFLAGS([bcrypt], [], [ LIBSSH2_LIB_HAVE_LINKFLAGS([bcrypt], [], [
#include <windows.h> #include <windows.h>
#include <bcrypt.h> #include <bcrypt.h>

View File

@ -74,7 +74,6 @@ int main(void)
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#endif #endif
#include <windows.h>
#include <winsock2.h> #include <winsock2.h>
int main(void) int main(void)

View File

@ -27,8 +27,6 @@ if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
endif() endif()
endif() endif()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang") elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR CMAKE_C_COMPILER_ID MATCHES "Clang")
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall") if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")

View File

@ -39,11 +39,6 @@ list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
if(MSVC)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
endif()
set(EXAMPLES set(EXAMPLES
direct_tcpip direct_tcpip
scp scp
@ -74,7 +69,7 @@ foreach(example ${EXAMPLES})
add_executable(example-${example} ${example}.c) add_executable(example-${example} ${example}.c)
list(APPEND EXAMPLE_TARGETS example-${example}) list(APPEND EXAMPLE_TARGETS example-${example})
# to find generated header # to find generated header
target_include_directories(example-${example} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../src) target_include_directories(example-${example} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../src ../src)
target_link_libraries(example-${example} ${LIB_STATIC} ${LIBRARIES}) target_link_libraries(example-${example} ${LIB_STATIC} ${LIBRARIES})
endforeach() endforeach()

View File

@ -29,5 +29,5 @@ noinst_PROGRAMS = \
tcpip-forward \ tcpip-forward \
x11 x11
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/example -I../src AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_srcdir)/include
LDADD = $(top_builddir)/src/libssh2.la LDADD = $(top_builddir)/src/libssh2.la

View File

@ -1,16 +1,22 @@
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <ws2tcpip.h> /* for socklen_t */
#include <winsock2.h>
#include <ws2tcpip.h>
#define recv(s, b, l, f) recv((s), (b), (int)(l), (f)) #define recv(s, b, l, f) recv((s), (b), (int)(l), (f))
#define send(s, b, l, f) send((s), (b), (int)(l), (f)) #define send(s, b, l, f) send((s), (b), (int)(l), (f))
#else #endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif #endif
@ -30,10 +36,6 @@
#define INADDR_NONE (in_addr_t)-1 #define INADDR_NONE (in_addr_t)-1
#endif #endif
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub"; const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
const char *keyfile2 = "/home/username/.ssh/id_rsa"; const char *keyfile2 = "/home/username/.ssh/id_rsa";
const char *username = "username"; const char *username = "username";

View File

@ -2,11 +2,10 @@
* Sample showing how to do a simple SCP transfer. * Sample showing how to do a simple SCP transfer.
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32 #ifdef WIN32
# include <winsock2.h>
# define write(f, b, c) write((f), (b), (unsigned int)(c)) # define write(f, b, c) write((f), (b), (unsigned int)(c))
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
@ -15,8 +14,8 @@
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>

View File

@ -7,11 +7,10 @@
* "scp_nonblock 192.168.0.1 user password /tmp/secrets" * "scp_nonblock 192.168.0.1 user password /tmp/secrets"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32 #ifdef WIN32
# include <winsock2.h>
# define write(f, b, c) write((f), (b), (unsigned int)(c)) # define write(f, b, c) write((f), (b), (unsigned int)(c))
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
@ -23,8 +22,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -39,10 +38,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
/* diff in ms */ /* diff in ms */
static long tvdiff(struct timeval newer, struct timeval older) static long tvdiff(struct timeval newer, struct timeval older)

View File

@ -2,20 +2,17 @@
* Sample showing how to do an SCP upload. * Sample showing how to do an SCP upload.
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -30,10 +27,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(disable:4127)
#endif
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
uint32_t hostaddr; uint32_t hostaddr;

View File

@ -2,12 +2,9 @@
* Sample showing how to do an SCP non-blocking upload transfer. * Sample showing how to do an SCP non-blocking upload transfer.
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -17,8 +14,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -34,10 +31,6 @@
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{ {
struct timeval timeout; struct timeval timeout;

View File

@ -7,12 +7,11 @@
* "sftp 192.168.0.1 user password /tmp/secrets -p|-i|-k" * "sftp 192.168.0.1 user password /tmp/secrets -p|-i|-k"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32 #ifdef WIN32
# include <winsock2.h>
# define write(f, b, c) write((f), (b), (unsigned int)(c)) # define write(f, b, c) write((f), (b), (unsigned int)(c))
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
@ -21,8 +20,8 @@
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -37,10 +36,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(disable:4127)
#endif
const char *keyfile1 = "~/.ssh/id_rsa.pub"; const char *keyfile1 = "~/.ssh/id_rsa.pub";
const char *keyfile2 = "~/.ssh/id_rsa"; const char *keyfile2 = "~/.ssh/id_rsa";
const char *username = "username"; const char *username = "username";

View File

@ -7,12 +7,11 @@
* Using the SFTP server running on 127.0.0.1 * Using the SFTP server running on 127.0.0.1
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32 #ifdef WIN32
# include <winsock2.h>
# define write(f, b, c) write((f), (b), (unsigned int)(c)) # define write(f, b, c) write((f), (b), (unsigned int)(c))
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
@ -24,8 +23,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -40,10 +39,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(disable:4127)
#endif
#define STORAGE "/tmp/sftp-storage" /* this is the local file name this #define STORAGE "/tmp/sftp-storage" /* this is the local file name this
example uses to store the downloaded example uses to store the downloaded
file in */ file in */

View File

@ -7,21 +7,18 @@
* sftp_append 192.168.0.1 user password localfile /tmp/remotefile * sftp_append 192.168.0.1 user password localfile /tmp/remotefile
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>

View File

@ -7,21 +7,18 @@
* "sftp 192.168.0.1 user password /tmp/sftp_mkdir" * "sftp 192.168.0.1 user password /tmp/sftp_mkdir"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>

View File

@ -7,21 +7,18 @@
* "sftp 192.168.0.1 user password /tmp/sftp_write_nonblock.c" * "sftp 192.168.0.1 user password /tmp/sftp_write_nonblock.c"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>

View File

@ -7,12 +7,11 @@
* "sftp_nonblock 192.168.0.1 user password /tmp/secrets" * "sftp_nonblock 192.168.0.1 user password /tmp/secrets"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32 #ifdef WIN32
# include <winsock2.h>
# define write(f, b, c) write((f), (b), (unsigned int)(c)) # define write(f, b, c) write((f), (b), (unsigned int)(c))
#endif #endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
@ -24,8 +23,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -40,10 +39,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(disable:4127)
#endif
#ifdef HAVE_GETTIMEOFDAY #ifdef HAVE_GETTIMEOFDAY
/* diff in ms */ /* diff in ms */
static long tvdiff(struct timeval newer, struct timeval older) static long tvdiff(struct timeval newer, struct timeval older)

View File

@ -7,21 +7,18 @@
* "sftp 192.168.0.1 user password sftp_write.c /tmp/secrets" * "sftp 192.168.0.1 user password sftp_write.c /tmp/secrets"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>

View File

@ -7,13 +7,10 @@
* "sftp 192.168.0.1 user password thisfile /tmp/storehere" * "sftp 192.168.0.1 user password thisfile /tmp/storehere"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -23,8 +20,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -40,10 +37,6 @@
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{ {
struct timeval timeout; struct timeval timeout;

View File

@ -7,13 +7,10 @@
* "sftp 192.168.0.1 user password file /tmp/storehere" * "sftp 192.168.0.1 user password file /tmp/storehere"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -23,8 +20,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -40,10 +37,6 @@
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{ {
struct timeval timeout; struct timeval timeout;

View File

@ -7,13 +7,10 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir" * "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -36,10 +33,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(disable:4127)
#endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define __FILESIZE "I64u" #define __FILESIZE "I64u"
#else #else

View File

@ -7,21 +7,18 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir" * "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -36,10 +33,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(disable:4127)
#endif
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define __FILESIZE "I64u" #define __FILESIZE "I64u"
#else #else

View File

@ -11,22 +11,18 @@
* command executes on the remote machine * command executes on the remote machine
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <windows.h>
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
# ifdef HAVE_ARPA_INET_H # ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>

View File

@ -6,22 +6,18 @@
* "ssh2_agent host user" * "ssh2_agent host user"
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <windows.h>
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
# ifdef HAVE_ARPA_INET_H # ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>

View File

@ -13,12 +13,9 @@
* *
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -28,8 +25,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -45,10 +42,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{ {
struct timeval timeout; struct timeval timeout;

View File

@ -8,12 +8,9 @@
* *
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -23,8 +20,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -39,10 +36,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{ {
struct timeval timeout; struct timeval timeout;

View File

@ -10,12 +10,9 @@
* *
*/ */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif
@ -25,8 +22,8 @@
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H
# include <sys/select.h> # include <sys/select.h>
#endif #endif
# ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> # include <unistd.h>
#endif #endif
#ifdef HAVE_ARPA_INET_H #ifdef HAVE_ARPA_INET_H
# include <arpa/inet.h> # include <arpa/inet.h>
@ -41,10 +38,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session) static int waitsocket(libssh2_socket_t socket_fd, LIBSSH2_SESSION *session)
{ {
struct timeval timeout; struct timeval timeout;

View File

@ -1,14 +1,16 @@
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32 #ifdef HAVE_SYS_SOCKET_H
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#else
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif #endif

View File

@ -1,16 +1,22 @@
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#ifdef WIN32 #ifdef WIN32
#include <windows.h> #include <ws2tcpip.h> /* for socklen_t */
#include <winsock2.h>
#include <ws2tcpip.h>
#define recv(s, b, l, f) recv((s), (b), (int)(l), (f)) #define recv(s, b, l, f) recv((s), (b), (int)(l), (f))
#define send(s, b, l, f) send((s), (b), (int)(l), (f)) #define send(s, b, l, f) send((s), (b), (int)(l), (f))
#else #endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h> #include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> #include <arpa/inet.h>
#endif
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h> #include <sys/time.h>
#endif #endif
@ -30,10 +36,6 @@
#define INADDR_NONE (in_addr_t)-1 #define INADDR_NONE (in_addr_t)-1
#endif #endif
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub"; const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
const char *keyfile2 = "/home/username/.ssh/id_rsa"; const char *keyfile2 = "/home/username/.ssh/id_rsa";
const char *username = "username"; const char *username = "username";

View File

@ -5,8 +5,8 @@
* "ssh2 host user password [DEBUG]" * "ssh2 host user password [DEBUG]"
*/ */
#include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include "libssh2_config.h"
#include <stdio.h> #include <stdio.h>
@ -42,10 +42,6 @@
#include <termios.h> #include <termios.h>
#if defined(_MSC_VER) && _MSC_VER < 1700
#pragma warning(disable:4127)
#endif
#define _PATH_UNIX_X "/tmp/.X11-unix/X%d" #define _PATH_UNIX_X "/tmp/.X11-unix/X%d"
/* /*

View File

@ -87,7 +87,12 @@
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef _WIN32
#if defined(_WIN32) || defined(WIN32)
#define _LIBSSH2_WIN32
#endif
#ifdef _LIBSSH2_WIN32
# include <basetsd.h> # include <basetsd.h>
# include <winsock2.h> # include <winsock2.h>
#endif #endif
@ -99,7 +104,7 @@ extern "C" {
/* Allow alternate API prefix from CFLAGS or calling app */ /* Allow alternate API prefix from CFLAGS or calling app */
#ifndef LIBSSH2_API #ifndef LIBSSH2_API
# ifdef WIN32 # ifdef _LIBSSH2_WIN32
# if defined(LIBSSH2_EXPORTS) || defined(DLL_EXPORT) || \ # if defined(LIBSSH2_EXPORTS) || defined(DLL_EXPORT) || \
defined(_WINDLL) || defined(libssh2_shared_EXPORTS) defined(_WINDLL) || defined(libssh2_shared_EXPORTS)
# ifdef LIBSSH2_LIBRARY # ifdef LIBSSH2_LIBRARY
@ -110,9 +115,9 @@ extern "C" {
# else # else
# define LIBSSH2_API # define LIBSSH2_API
# endif # endif
# else /* !WIN32 */ # else /* !_LIBSSH2_WIN32 */
# define LIBSSH2_API # define LIBSSH2_API
# endif /* WIN32 */ # endif /* _LIBSSH2_WIN32 */
#endif /* LIBSSH2_API */ #endif /* LIBSSH2_API */
#ifdef HAVE_SYS_UIO_H #ifdef HAVE_SYS_UIO_H
@ -138,13 +143,13 @@ typedef unsigned long long libssh2_uint64_t;
typedef long long libssh2_int64_t; typedef long long libssh2_int64_t;
#endif #endif
#ifdef WIN32 #ifdef _LIBSSH2_WIN32
typedef SOCKET libssh2_socket_t; typedef SOCKET libssh2_socket_t;
#define LIBSSH2_INVALID_SOCKET INVALID_SOCKET #define LIBSSH2_INVALID_SOCKET INVALID_SOCKET
#else /* !WIN32 */ #else /* !_LIBSSH2_WIN32 */
typedef int libssh2_socket_t; typedef int libssh2_socket_t;
#define LIBSSH2_INVALID_SOCKET -1 #define LIBSSH2_INVALID_SOCKET -1
#endif /* WIN32 */ #endif /* _LIBSSH2_WIN32 */
/* /*
* Determine whether there is small or large file support on windows. * Determine whether there is small or large file support on windows.
@ -170,7 +175,7 @@ typedef int libssh2_socket_t;
# undef LIBSSH2_USE_WIN32_LARGE_FILES # undef LIBSSH2_USE_WIN32_LARGE_FILES
#endif #endif
#if defined(_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \ #if defined(_LIBSSH2_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \
!defined(LIBSSH2_USE_WIN32_SMALL_FILES) !defined(LIBSSH2_USE_WIN32_SMALL_FILES)
# define LIBSSH2_USE_WIN32_SMALL_FILES # define LIBSSH2_USE_WIN32_SMALL_FILES
#endif #endif

View File

@ -40,7 +40,7 @@
#include "libssh2.h" #include "libssh2.h"
#ifndef WIN32 #ifndef _LIBSSH2_WIN32
#include <unistd.h> #include <unistd.h>
#endif #endif

View File

@ -31,7 +31,7 @@ lib_LTLIBRARIES = libssh2.la
# srcdir/include for the shipped headers # srcdir/include for the shipped headers
# builddir/src for the generated config header when building out of the source # builddir/src for the generated config header when building out of the source
# tree # tree
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_builddir)/src AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/include
VERSION=-version-info 1:1:0 VERSION=-version-info 1:1:0

View File

@ -50,9 +50,6 @@
#endif #endif
#include "userauth.h" #include "userauth.h"
#include "session.h" #include "session.h"
#ifdef WIN32
#include <stdlib.h>
#endif
/* Requests from client to agent for protocol 1 key operations */ /* Requests from client to agent for protocol 1 key operations */
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1 #define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1

View File

@ -41,9 +41,6 @@
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include "session.h" #include "session.h"
#ifdef WIN32
#include <stdlib.h>
#endif
/* non-blocking mode on agent connection is not yet implemented, but /* non-blocking mode on agent connection is not yet implemented, but
for future use. */ for future use. */

View File

@ -40,21 +40,11 @@
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include "agent.h" #include "agent.h"
#include <errno.h> #include <errno.h>
#ifdef HAVE_SYS_UN_H
#include <sys/un.h>
#else
/* Use the existence of sys/un.h as a test if Unix domain socket is
supported. winsock*.h define PF_UNIX/AF_UNIX but do not actually
support them. */
#undef PF_UNIX
#endif
#include "userauth.h"
#include "session.h"
#ifdef WIN32
#include <stdlib.h>
#endif
#if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP) #if defined(WIN32) && !defined(LIBSSH2_WINDOWS_APP)
#include <stdlib.h> /* for getenv() */
/* Code to talk to OpenSSH was taken and modified from the Win32 port of /* Code to talk to OpenSSH was taken and modified from the Win32 port of
* Portable OpenSSH by the PowerShell team. Commit * Portable OpenSSH by the PowerShell team. Commit
* 8ab565c53f3619d6a1f5ac229e212cad8a52852c of * 8ab565c53f3619d6a1f5ac229e212cad8a52852c of

View File

@ -39,50 +39,12 @@
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
*/ */
/* Disable warnings: C4127: conditional expression is constant */ /* Header used by 'src' */
#if defined(_MSC_VER) && _MSC_VER < 1900
#pragma warning(disable:4127)
#endif
/* Define mingw-w64 version macros, eg __MINGW{32,64}_{MINOR,MAJOR}_VERSION */
#ifdef __MINGW32__
#include <_mingw.h>
#endif
#define LIBSSH2_LIBRARY #define LIBSSH2_LIBRARY
#include "libssh2_config.h"
/* Number of bits in a file offset, on hosts where this is settable. */ /* platform/compiler-specific setup */
#if defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR) #include "libssh2_setup.h"
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
# endif
#endif
#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
#include <winsock2.h>
#include <ws2tcpip.h>
/* Force parameter type. */
#define recv(s, b, l, f) recv((s), (b), (int)(l), (f))
#define send(s, b, l, f) send((s), (b), (int)(l), (f))
#endif
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
@ -128,6 +90,19 @@
#include "libssh2_sftp.h" #include "libssh2_sftp.h"
#include "misc.h" #include "misc.h"
#ifdef WIN32
/* 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
#endif
#ifndef FALSE #ifndef FALSE
#define FALSE 0 #define FALSE 0
#endif #endif

90
src/libssh2_setup.h Normal file
View File

@ -0,0 +1,90 @@
#ifndef LIBSSH2_SETUP_H
#define LIBSSH2_SETUP_H
/* Header for platform/compiler-specific initialization.
Used by 'src', 'example', 'tests' */
#if defined(_WIN32) && !defined(WIN32)
#define WIN32
#endif
/* Define mingw-w64 version macros, eg __MINGW{32,64}_{MINOR,MAJOR}_VERSION */
#ifdef __MINGW32__
#include <_mingw.h>
#endif
/* Configuration provided by build tools (autotools and CMake),
and via platform-specific directories for os400 and vms */
#if defined(HAVE_CONFIG_H) || defined(__OS400__) || defined(__VMS)
#include "libssh2_config.h"
/* Hand-crafted configuration for platforms which lack config tool. */
#elif defined(WIN32)
#define HAVE_IOCTLSOCKET
#define HAVE_SELECT
#define HAVE_SNPRINTF
#ifdef __MINGW32__
# define HAVE_UNISTD_H
# define HAVE_INTTYPES_H
# define HAVE_SYS_TIME_H
# define HAVE_SYS_PARAM_H
# define HAVE_GETTIMEOFDAY
# define HAVE_LONGLONG
# define HAVE_STRTOLL
#elif defined(_MSC_VER)
# if _MSC_VER >= 1310
# define HAVE_LONGLONG
# endif
# if _MSC_VER >= 1800
# define HAVE_STRTOLL
# endif
# if _MSC_VER < 1900
# undef HAVE_SNPRINTF
# endif
#endif
#endif /* defined(HAVE_CONFIG_H) */
/* Below applies to both auto-detected and hand-crafted configs */
#ifdef WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifdef __MINGW32__
# ifdef __MINGW64_VERSION_MAJOR
/* Number of bits in a file offset, on hosts where this is settable. */
# ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
# endif
# endif
#elif defined(_MSC_VER)
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS /* for fopen(), getenv() */
# endif
# ifndef LIBSSH2_LIBRARY /* apply to examples and tests only */
# ifndef _CRT_NONSTDC_NO_DEPRECATE
# define _CRT_NONSTDC_NO_DEPRECATE /* for strdup(), write() */
# endif
# ifndef _WINSOCK_DEPRECATED_NO_WARNINGS
# define _WINSOCK_DEPRECATED_NO_WARNINGS /* for inet_addr() */
# endif
# endif
# if _MSC_VER < 1500
# define vsnprintf _vsnprintf
# endif
# if _MSC_VER < 1900
# define strdup _strdup
/* Silence bogus warning C4127: conditional expression is constant */
# pragma warning(disable:4127)
# endif
#endif
#endif /* WIN32 */
#endif /* LIBSSH2_SETUP_H */

View File

@ -51,7 +51,9 @@
#endif #endif
#ifdef WIN32 #ifdef WIN32
#include <windows.h> /* Force parameter type. */
#define recv(s, b, l, f) recv((s), (b), (int)(l), (f))
#define send(s, b, l, f) send((s), (b), (int)(l), (f))
#endif #endif
#include <stdio.h> #include <stdio.h>

View File

@ -38,6 +38,11 @@
*/ */
#include "libssh2_priv.h" #include "libssh2_priv.h"
#ifdef WIN32
#include <ws2tcpip.h> /* for socklen_t */
#endif
#include <errno.h> #include <errno.h>
#ifdef HAVE_UNISTD_H #ifdef HAVE_UNISTD_H
#include <unistd.h> #include <unistd.h>

View File

@ -39,11 +39,6 @@ list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
add_definitions(-DHAVE_CONFIG_H) add_definitions(-DHAVE_CONFIG_H)
if(MSVC)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
endif()
set(TESTS set(TESTS
warmup warmup
hostkey hostkey
@ -83,21 +78,21 @@ if(NOT CRYPTO_BACKEND STREQUAL "mbedTLS")
endif() endif()
add_library(runner STATIC runner.h runner.c openssh_fixture.h openssh_fixture.c session_fixture.h session_fixture.c) add_library(runner STATIC runner.h runner.c openssh_fixture.h openssh_fixture.c session_fixture.h session_fixture.c)
target_include_directories(runner PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" ../include) target_include_directories(runner PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" ../src ../include)
target_compile_definitions(runner PRIVATE FIXTURE_WORKDIR="${CMAKE_CURRENT_SOURCE_DIR}") target_compile_definitions(runner PRIVATE FIXTURE_WORKDIR="${CMAKE_CURRENT_SOURCE_DIR}")
# test building against shared libssh2 lib # test building against shared libssh2 lib
if(BUILD_SHARED_LIBS) if(BUILD_SHARED_LIBS)
set(test warmup) # any test will do set(test warmup) # any test will do
add_executable(test_${test}_shared test_${test}.c) add_executable(test_${test}_shared test_${test}.c)
target_include_directories(test_${test}_shared PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src") target_include_directories(test_${test}_shared PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" ../src)
target_link_libraries(test_${test}_shared runner ${LIB_SHARED} ${LIBRARIES}) target_link_libraries(test_${test}_shared runner ${LIB_SHARED} ${LIBRARIES})
endif() endif()
foreach(test ${TESTS}) foreach(test ${TESTS})
add_executable(test_${test} test_${test}.c) add_executable(test_${test} test_${test}.c)
list(APPEND TEST_TARGETS test_${test}) list(APPEND TEST_TARGETS test_${test})
target_include_directories(test_${test} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src") target_include_directories(test_${test} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" ../src)
target_link_libraries(test_${test} runner ${LIB_STATIC} ${LIBRARIES}) target_link_libraries(test_${test} runner ${LIB_STATIC} ${LIBRARIES})
add_test( add_test(
@ -143,7 +138,7 @@ endforeach()
add_executable(test_keyboard_interactive_auth_info_request test_keyboard_interactive_auth_info_request.c ../src/userauth_kbd_packet.c) add_executable(test_keyboard_interactive_auth_info_request test_keyboard_interactive_auth_info_request.c ../src/userauth_kbd_packet.c)
target_compile_definitions(test_keyboard_interactive_auth_info_request PRIVATE "${CRYPTO_BACKEND_DEFINE}") target_compile_definitions(test_keyboard_interactive_auth_info_request PRIVATE "${CRYPTO_BACKEND_DEFINE}")
target_include_directories(test_keyboard_interactive_auth_info_request PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" "../src/" "${CRYPTO_BACKEND_INCLUDE_DIR}") target_include_directories(test_keyboard_interactive_auth_info_request PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/../src" ../src "${CRYPTO_BACKEND_INCLUDE_DIR}")
find_program(GCOV_PATH gcov) find_program(GCOV_PATH gcov)
set(TGT_OPTIONS -g --coverage -fprofile-abs-path) set(TGT_OPTIONS -g --coverage -fprofile-abs-path)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)

View File

@ -1,6 +1,6 @@
SUBDIRS = ossfuzz SUBDIRS = ossfuzz
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -I$(top_builddir)/src AM_CPPFLAGS = -I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_srcdir)/include
ctests = simple$(EXEEXT) ctests = simple$(EXEEXT)
TESTS = $(ctests) mansyntax.sh TESTS = $(ctests) mansyntax.sh

View File

@ -37,11 +37,7 @@
#include "session_fixture.h" #include "session_fixture.h"
#include "openssh_fixture.h" #include "openssh_fixture.h"
#include "libssh2_config.h"
#ifdef WIN32
#include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>
#endif #endif

View File

@ -35,7 +35,6 @@
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
*/ */
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
int main(void) int main(void)

View File

@ -38,6 +38,10 @@
#ifndef LIBSSH2_TESTS_RUNNER_H #ifndef LIBSSH2_TESTS_RUNNER_H
#define LIBSSH2_TESTS_RUNNER_H #define LIBSSH2_TESTS_RUNNER_H
/* Most tests need these */
#include "session_fixture.h"
#include <stdio.h>
int test(LIBSSH2_SESSION *session); int test(LIBSSH2_SESSION *session);
#endif #endif

View File

@ -36,7 +36,6 @@
*/ */
#include "session_fixture.h" #include "session_fixture.h"
#include "libssh2_config.h"
#include "openssh_fixture.h" #include "openssh_fixture.h"
#include <stdio.h> #include <stdio.h>
@ -45,15 +44,11 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef WIN32
#include <windows.h>
#include <winsock2.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#include <direct.h> #include <direct.h>
#define getcwd _getcwd #define getcwd _getcwd
#define chdir _chdir #define chdir _chdir
#endif #endif
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h> #include <sys/socket.h>

View File

@ -38,6 +38,7 @@
#ifndef LIBSSH2_TESTS_SESSION_FIXTURE_H #ifndef LIBSSH2_TESTS_SESSION_FIXTURE_H
#define LIBSSH2_TESTS_SESSION_FIXTURE_H #define LIBSSH2_TESTS_SESSION_FIXTURE_H
#include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#if defined(_MSC_VER) && _MSC_VER < 1900 #if defined(_MSC_VER) && _MSC_VER < 1900

View File

@ -1,13 +1,9 @@
/* Self test, based on examples/ssh2.c. */ /* Self test, based on examples/ssh2.c. */
#include "libssh2_config.h" #include "libssh2_setup.h"
#include <libssh2.h> #include <libssh2.h>
#include <libssh2_sftp.h> #include <libssh2_sftp.h>
#ifdef WIN32
# include <windows.h>
# include <winsock2.h>
#endif
#ifdef HAVE_SYS_SOCKET_H #ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h> # include <sys/socket.h>
#endif #endif

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
const char *USERNAME = "libssh2"; /* set in Dockerfile */ const char *USERNAME = "libssh2"; /* set in Dockerfile */
const char *KEY_FILE_PRIVATE = "key_rsa"; const char *KEY_FILE_PRIVATE = "key_rsa";
const char *KEY_FILE_PUBLIC = "key_rsa.pub"; /* set in Dockerfile */ const char *KEY_FILE_PUBLIC = "key_rsa.pub"; /* set in Dockerfile */

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
static const char *EXPECTED_RSA_HOSTKEY = static const char *EXPECTED_RSA_HOSTKEY =
"AAAAB3NzaC1yc2EAAAABIwAAAQEArrr/JuJmaZligyfS8vcNur+mWR2ddDQtVdhHzdKU" "AAAAB3NzaC1yc2EAAAABIwAAAQEArrr/JuJmaZligyfS8vcNur+mWR2ddDQtVdhHzdKU"
"UoR6/Om6cvxpe61H1YZO1xCpLUBXmkki4HoNtYOpPB2W4V+8U4BDeVBD5crypEOE1+7B" "UoR6/Om6cvxpe61H1YZO1xCpLUBXmkki4HoNtYOpPB2W4V+8U4BDeVBD5crypEOE1+7B"

View File

@ -1,10 +1,4 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include "libssh2_config.h"
#include <libssh2.h>
#include <stdio.h>
static const char *EXPECTED_RSA_HOSTKEY = static const char *EXPECTED_RSA_HOSTKEY =
"AAAAB3NzaC1yc2EAAAABIwAAAQEArrr/JuJmaZligyfS8vcNur+mWR2ddDQtVdhHzdKU" "AAAAB3NzaC1yc2EAAAABIwAAAQEArrr/JuJmaZligyfS8vcNur+mWR2ddDQtVdhHzdKU"

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
static const char *USERNAME = "libssh2"; /* set in Dockerfile */ static const char *USERNAME = "libssh2"; /* set in Dockerfile */
static const char *WRONG_PASSWORD = "i'm not the password"; static const char *WRONG_PASSWORD = "i'm not the password";

View File

@ -35,11 +35,11 @@
* OF SUCH DAMAGE. * OF SUCH DAMAGE.
*/ */
#include <stdlib.h>
#include "libssh2_priv.h" #include "libssh2_priv.h"
#include "userauth_kbd_packet.h" #include "userauth_kbd_packet.h"
#include <stdlib.h>
#define PASS 0 #define PASS 0
#define FAIL -1 #define FAIL -1

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *PASSWORD = "my test password"; static const char *PASSWORD = "my test password";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
static const char *USERNAME = "libssh2"; /* set in Dockerfile */ static const char *USERNAME = "libssh2"; /* set in Dockerfile */
static const char *WRONG_PASSWORD = "i'm not the password"; static const char *WRONG_PASSWORD = "i'm not the password";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *PASSWORD = "my test password"; static const char *PASSWORD = "my test password";
static const char *WRONG_USERNAME = "i dont exist"; static const char *WRONG_USERNAME = "i dont exist";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *PASSWORD = "my test password"; static const char *PASSWORD = "my test password";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
static const char *USERNAME = "libssh2"; /* set in Dockerfile */ static const char *USERNAME = "libssh2"; /* set in Dockerfile */
static const char *KEY_FILE_PRIVATE = "key_dsa_wrong"; static const char *KEY_FILE_PRIVATE = "key_dsa_wrong";
static const char *KEY_FILE_PUBLIC = "key_dsa_wrong.pub"; static const char *KEY_FILE_PUBLIC = "key_dsa_wrong.pub";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_dsa"; static const char *KEY_FILE_PRIVATE = "key_dsa";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_ecdsa"; static const char *KEY_FILE_PRIVATE = "key_ecdsa";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_ed25519"; static const char *KEY_FILE_PRIVATE = "key_ed25519";

View File

@ -1,9 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
static const char *USERNAME = "libssh2"; /* set in Dockerfile */ static const char *USERNAME = "libssh2"; /* set in Dockerfile */

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *PASSWORD = "libssh2"; static const char *PASSWORD = "libssh2";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *PASSWORD = "libssh2"; static const char *PASSWORD = "libssh2";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_rsa"; static const char *KEY_FILE_PRIVATE = "key_rsa";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_rsa_openssh"; static const char *KEY_FILE_PRIVATE = "key_rsa_openssh";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "signed_key_ecdsa"; static const char *KEY_FILE_PRIVATE = "signed_key_ecdsa";

View File

@ -1,10 +1,5 @@
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "signed_key_rsa"; static const char *KEY_FILE_PRIVATE = "signed_key_rsa";

View File

@ -1,12 +1,7 @@
/* libssh2 test receiving large amounts of data through a channel */ /* libssh2 test receiving large amounts of data through a channel */
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
/* configured in Dockerfile */ /* configured in Dockerfile */
static const char *USERNAME = "libssh2"; static const char *USERNAME = "libssh2";
static const char *KEY_FILE_PRIVATE = "key_rsa"; static const char *KEY_FILE_PRIVATE = "key_rsa";

View File

@ -1,13 +1,8 @@
/* Warm-up test. Always return success. /* Warm-up test. Always return success.
Workaround for CI/docker/etc flakiness on the first run. */ Workaround for CI/docker/etc flakiness on the first run. */
#include "session_fixture.h"
#include "runner.h" #include "runner.h"
#include <libssh2.h>
#include <stdio.h>
int test(LIBSSH2_SESSION *session) int test(LIBSSH2_SESSION *session)
{ {
size_t len = 0; size_t len = 0;

7
win32/.gitignore vendored
View File

@ -1,7 +0,0 @@
*.a
*.dll
*.def
*.exe
debug-*
release-*
libssh2-*.zip

View File

@ -1,38 +0,0 @@
#ifndef LIBSSH2_CONFIG_H
#define LIBSSH2_CONFIG_H
#ifndef WIN32
#define WIN32
#endif
#define HAVE_IOCTLSOCKET
#define HAVE_SELECT
#define HAVE_SNPRINTF
#ifdef __MINGW32__
# define HAVE_UNISTD_H
# define HAVE_INTTYPES_H
# define HAVE_SYS_TIME_H
# define HAVE_GETTIMEOFDAY
# define HAVE_LONGLONG
# define HAVE_STRTOLL
#elif defined(_MSC_VER)
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
# if _MSC_VER >= 1310
# define HAVE_LONGLONG
# endif
# if _MSC_VER >= 1800
# define HAVE_STRTOLL
# endif
# if _MSC_VER < 1900
# undef HAVE_SNPRINTF
# if _MSC_VER < 1500
# define vsnprintf _vsnprintf
# endif
# define strdup _strdup
# endif
#endif
#endif /* LIBSSH2_CONFIG_H */