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:
3
.gitignore
vendored
3
.gitignore
vendored
@ -8,10 +8,9 @@
|
||||
*.exe
|
||||
*.obj
|
||||
.*.swp
|
||||
*-*-*
|
||||
Debug
|
||||
Release
|
||||
debug-*
|
||||
release-*
|
||||
*.exp
|
||||
Makefile
|
||||
Makefile.in
|
||||
|
@ -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/time.h HAVE_SYS_TIME_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
|
||||
check_include_files(sys/param.h HAVE_SYS_PARAM_H)
|
||||
check_include_files(arpa/inet.h HAVE_ARPA_INET_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)
|
||||
|
||||
# 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)
|
||||
|
||||
if(HAVE_BCRYPT_H)
|
||||
|
@ -23,7 +23,6 @@ VMSFILES = vms/libssh2_make_example.dcl vms/libssh2_make_help.dcl \
|
||||
vms/readme.vms vms/libssh2_config.h
|
||||
|
||||
WIN32FILES = NMakefile \
|
||||
win32/libssh2_config.h \
|
||||
src/libssh2.rc
|
||||
|
||||
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
|
||||
|
@ -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 \
|
||||
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 os400qc3.h
|
||||
HHEADERS = libssh2_priv.h libssh2_setup.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 os400qc3.h
|
||||
|
14
Makefile.mk
14
Makefile.mk
@ -47,18 +47,17 @@ else
|
||||
TRIPLET ?= $(shell $(CC) -dumpmachine)
|
||||
endif
|
||||
|
||||
BLD_DIR ?= $(PROOT)/$(TRIPLET)
|
||||
|
||||
ifneq ($(findstring -w,$(TRIPLET)),)
|
||||
WIN32 := 1
|
||||
BIN_EXT := .exe
|
||||
DYN_EXT := .dll
|
||||
BLD_DIR ?= $(PROOT)/win32
|
||||
CONFIG_H_DIR ?= $(PROOT)/win32
|
||||
else
|
||||
BLD_DIR ?= $(PROOT)
|
||||
CONFIG_H_DIR ?= $(PROOT)
|
||||
CPPFLAGS += -I$(BLD_DIR) -DHAVE_CONFIG_H
|
||||
endif
|
||||
|
||||
CPPFLAGS += -I$(CONFIG_H_DIR) -I$(PROOT)/include
|
||||
CPPFLAGS += -I$(PROOT)/src -I$(PROOT)/include
|
||||
RCFLAGS += -I$(PROOT)/include
|
||||
|
||||
# examples, tests
|
||||
@ -87,9 +86,9 @@ endif
|
||||
DB ?= NDEBUG
|
||||
CPPFLAGS += -D$(DB)
|
||||
ifeq ($(DB),NDEBUG)
|
||||
OBJ_DIR := release-$(TRIPLET)
|
||||
OBJ_DIR := release
|
||||
else
|
||||
OBJ_DIR := debug-$(TRIPLET)
|
||||
OBJ_DIR := debug
|
||||
CFLAGS += -g
|
||||
CPPFLAGS += -DLIBSSH2DEBUG
|
||||
endif
|
||||
@ -264,7 +263,6 @@ dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||
@$(call COPY, $(PROOT)/README, $(DISTDIR))
|
||||
@$(call COPY, $(PROOT)/RELEASE-NOTES, $(DISTDIR))
|
||||
@$(call COPY, $(PROOT)/include/*.h, $(DISTDIR)/include)
|
||||
@$(call COPY, $(CONFIG_H_DIR)/libssh2_config.h, $(DISTDIR)/include)
|
||||
@$(call COPY, $(TARGET).a, $(DISTDIR)/lib)
|
||||
ifdef WIN32
|
||||
@$(call COPY, $(libssh2_def_LIBRARY), $(DISTDIR)/bin)
|
||||
|
@ -11,7 +11,7 @@ CFLAGS=/Oi /O2 /Oy /GF /Y- /MD /DNDEBUG
|
||||
DLLFLAGS=/LD
|
||||
!endif
|
||||
|
||||
CFLAGS=/nologo /GL /Zi /EHsc $(CFLAGS) /Iwin32 /Iinclude
|
||||
CFLAGS=/nologo /GL /Zi /EHsc $(CFLAGS) /Iinclude
|
||||
|
||||
!if "$(OPENSSL_PATH)" != ""
|
||||
CFLAGS=$(CFLAGS) /DLIBSSH2_OPENSSL /I$(OPENSSL_PATH)\include
|
||||
|
@ -217,7 +217,6 @@ dnl the code was bad, try a different program now, test 3
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
],[
|
||||
@ -451,6 +450,7 @@ m4_case([$1],
|
||||
|
||||
LIBS="$LIBS -lcrypt32"
|
||||
|
||||
# Check necessary for old-MinGW
|
||||
LIBSSH2_LIB_HAVE_LINKFLAGS([bcrypt], [], [
|
||||
#include <windows.h>
|
||||
#include <bcrypt.h>
|
||||
|
@ -74,7 +74,6 @@ int main(void)
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
int main(void)
|
||||
|
@ -27,8 +27,6 @@ if(MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||
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")
|
||||
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
|
@ -39,11 +39,6 @@ list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
|
||||
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
set(EXAMPLES
|
||||
direct_tcpip
|
||||
scp
|
||||
@ -74,7 +69,7 @@ foreach(example ${EXAMPLES})
|
||||
add_executable(example-${example} ${example}.c)
|
||||
list(APPEND EXAMPLE_TARGETS example-${example})
|
||||
# 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})
|
||||
endforeach()
|
||||
|
||||
|
@ -29,5 +29,5 @@ noinst_PROGRAMS = \
|
||||
tcpip-forward \
|
||||
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
|
||||
|
@ -1,16 +1,22 @@
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <ws2tcpip.h> /* for socklen_t */
|
||||
#define recv(s, b, l, f) recv((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>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
@ -30,10 +36,6 @@
|
||||
#define INADDR_NONE (in_addr_t)-1
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1700
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "/home/username/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
|
@ -2,11 +2,10 @@
|
||||
* Sample showing how to do a simple SCP transfer.
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# define write(f, b, c) write((f), (b), (unsigned int)(c))
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
@ -15,8 +14,8 @@
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
|
@ -7,11 +7,10 @@
|
||||
* "scp_nonblock 192.168.0.1 user password /tmp/secrets"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# define write(f, b, c) write((f), (b), (unsigned int)(c))
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
@ -23,8 +22,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -39,10 +38,6 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1700
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* diff in ms */
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
|
@ -2,20 +2,17 @@
|
||||
* Sample showing how to do an SCP upload.
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -30,10 +27,6 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
uint32_t hostaddr;
|
||||
|
@ -2,12 +2,9 @@
|
||||
* Sample showing how to do an SCP non-blocking upload transfer.
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
@ -17,8 +14,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -34,10 +31,6 @@
|
||||
#include <ctype.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)
|
||||
{
|
||||
struct timeval timeout;
|
||||
|
@ -7,12 +7,11 @@
|
||||
* "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_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# define write(f, b, c) write((f), (b), (unsigned int)(c))
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
@ -21,8 +20,8 @@
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -37,10 +36,6 @@
|
||||
#include <stdio.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 *keyfile2 = "~/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
|
@ -7,12 +7,11 @@
|
||||
* Using the SFTP server running on 127.0.0.1
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# define write(f, b, c) write((f), (b), (unsigned int)(c))
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
@ -24,8 +23,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -40,10 +39,6 @@
|
||||
#include <stdio.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
|
||||
example uses to store the downloaded
|
||||
file in */
|
||||
|
@ -7,21 +7,18 @@
|
||||
* sftp_append 192.168.0.1 user password localfile /tmp/remotefile
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
|
@ -7,21 +7,18 @@
|
||||
* "sftp 192.168.0.1 user password /tmp/sftp_mkdir"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
|
@ -7,21 +7,18 @@
|
||||
* "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_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
|
@ -7,12 +7,11 @@
|
||||
* "sftp_nonblock 192.168.0.1 user password /tmp/secrets"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
# define write(f, b, c) write((f), (b), (unsigned int)(c))
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
@ -24,8 +23,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -40,10 +39,6 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* diff in ms */
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
|
@ -7,21 +7,18 @@
|
||||
* "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_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
|
@ -7,13 +7,10 @@
|
||||
* "sftp 192.168.0.1 user password thisfile /tmp/storehere"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
@ -23,8 +20,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -40,10 +37,6 @@
|
||||
#include <ctype.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)
|
||||
{
|
||||
struct timeval timeout;
|
||||
|
@ -7,13 +7,10 @@
|
||||
* "sftp 192.168.0.1 user password file /tmp/storehere"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
@ -23,8 +20,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -40,10 +37,6 @@
|
||||
#include <ctype.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)
|
||||
{
|
||||
struct timeval timeout;
|
||||
|
@ -7,13 +7,10 @@
|
||||
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
@ -36,10 +33,6 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define __FILESIZE "I64u"
|
||||
#else
|
||||
|
@ -7,21 +7,18 @@
|
||||
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -36,10 +33,6 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#define __FILESIZE "I64u"
|
||||
#else
|
||||
|
@ -11,22 +11,18 @@
|
||||
* command executes on the remote machine
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
# ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
|
@ -6,22 +6,18 @@
|
||||
* "ssh2_agent host user"
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
# include <netinet/in.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
# ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
|
@ -13,12 +13,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
@ -28,8 +25,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -45,10 +42,6 @@
|
||||
#include <stdio.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)
|
||||
{
|
||||
struct timeval timeout;
|
||||
|
@ -8,12 +8,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
@ -23,8 +20,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -39,10 +36,6 @@
|
||||
#include <stdio.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)
|
||||
{
|
||||
struct timeval timeout;
|
||||
|
@ -10,12 +10,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
@ -25,8 +22,8 @@
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
# ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
@ -41,10 +38,6 @@
|
||||
#include <stdio.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)
|
||||
{
|
||||
struct timeval timeout;
|
||||
|
@ -1,14 +1,16 @@
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
|
@ -1,16 +1,22 @@
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <ws2tcpip.h> /* for socklen_t */
|
||||
#define recv(s, b, l, f) recv((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>
|
||||
#endif
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
@ -30,10 +36,6 @@
|
||||
#define INADDR_NONE (in_addr_t)-1
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1700
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "/home/username/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
|
@ -5,8 +5,8 @@
|
||||
* "ssh2 host user password [DEBUG]"
|
||||
*/
|
||||
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include "libssh2_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -42,10 +42,6 @@
|
||||
|
||||
#include <termios.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1700
|
||||
#pragma warning(disable:4127)
|
||||
#endif
|
||||
|
||||
#define _PATH_UNIX_X "/tmp/.X11-unix/X%d"
|
||||
|
||||
/*
|
||||
|
@ -87,7 +87,12 @@
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
|
||||
#if defined(_WIN32) || defined(WIN32)
|
||||
#define _LIBSSH2_WIN32
|
||||
#endif
|
||||
|
||||
#ifdef _LIBSSH2_WIN32
|
||||
# include <basetsd.h>
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
@ -99,7 +104,7 @@ extern "C" {
|
||||
|
||||
/* Allow alternate API prefix from CFLAGS or calling app */
|
||||
#ifndef LIBSSH2_API
|
||||
# ifdef WIN32
|
||||
# ifdef _LIBSSH2_WIN32
|
||||
# if defined(LIBSSH2_EXPORTS) || defined(DLL_EXPORT) || \
|
||||
defined(_WINDLL) || defined(libssh2_shared_EXPORTS)
|
||||
# ifdef LIBSSH2_LIBRARY
|
||||
@ -110,9 +115,9 @@ extern "C" {
|
||||
# else
|
||||
# define LIBSSH2_API
|
||||
# endif
|
||||
# else /* !WIN32 */
|
||||
# else /* !_LIBSSH2_WIN32 */
|
||||
# define LIBSSH2_API
|
||||
# endif /* WIN32 */
|
||||
# endif /* _LIBSSH2_WIN32 */
|
||||
#endif /* LIBSSH2_API */
|
||||
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
@ -138,13 +143,13 @@ typedef unsigned long long libssh2_uint64_t;
|
||||
typedef long long libssh2_int64_t;
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _LIBSSH2_WIN32
|
||||
typedef SOCKET libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET INVALID_SOCKET
|
||||
#else /* !WIN32 */
|
||||
#else /* !_LIBSSH2_WIN32 */
|
||||
typedef int libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET -1
|
||||
#endif /* WIN32 */
|
||||
#endif /* _LIBSSH2_WIN32 */
|
||||
|
||||
/*
|
||||
* 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
|
||||
#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)
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
#endif
|
||||
|
@ -40,7 +40,7 @@
|
||||
|
||||
#include "libssh2.h"
|
||||
|
||||
#ifndef WIN32
|
||||
#ifndef _LIBSSH2_WIN32
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
@ -31,7 +31,7 @@ lib_LTLIBRARIES = libssh2.la
|
||||
# srcdir/include for the shipped headers
|
||||
# builddir/src for the generated config header when building out of the source
|
||||
# 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
|
||||
|
||||
|
@ -50,9 +50,6 @@
|
||||
#endif
|
||||
#include "userauth.h"
|
||||
#include "session.h"
|
||||
#ifdef WIN32
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* Requests from client to agent for protocol 1 key operations */
|
||||
#define SSH_AGENTC_REQUEST_RSA_IDENTITIES 1
|
||||
|
@ -41,9 +41,6 @@
|
||||
|
||||
#include "libssh2_priv.h"
|
||||
#include "session.h"
|
||||
#ifdef WIN32
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
/* non-blocking mode on agent connection is not yet implemented, but
|
||||
for future use. */
|
||||
|
@ -40,21 +40,11 @@
|
||||
#include "libssh2_priv.h"
|
||||
#include "agent.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)
|
||||
|
||||
#include <stdlib.h> /* for getenv() */
|
||||
|
||||
/* Code to talk to OpenSSH was taken and modified from the Win32 port of
|
||||
* Portable OpenSSH by the PowerShell team. Commit
|
||||
* 8ab565c53f3619d6a1f5ac229e212cad8a52852c of
|
||||
|
@ -39,50 +39,12 @@
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Disable warnings: C4127: conditional expression is constant */
|
||||
#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
|
||||
/* Header used by 'src' */
|
||||
|
||||
#define LIBSSH2_LIBRARY
|
||||
#include "libssh2_config.h"
|
||||
|
||||
/* Number of bits in a file offset, on hosts where this is settable. */
|
||||
#if defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR)
|
||||
# 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
|
||||
/* platform/compiler-specific setup */
|
||||
#include "libssh2_setup.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
@ -128,6 +90,19 @@
|
||||
#include "libssh2_sftp.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
|
||||
#define FALSE 0
|
||||
#endif
|
||||
|
90
src/libssh2_setup.h
Normal file
90
src/libssh2_setup.h
Normal 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 */
|
@ -51,7 +51,9 @@
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -38,6 +38,11 @@
|
||||
*/
|
||||
|
||||
#include "libssh2_priv.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <ws2tcpip.h> /* for socklen_t */
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
|
@ -39,11 +39,6 @@ list(APPEND LIBRARIES ${SOCKET_LIBRARIES})
|
||||
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
||||
endif()
|
||||
|
||||
set(TESTS
|
||||
warmup
|
||||
hostkey
|
||||
@ -83,21 +78,21 @@ if(NOT CRYPTO_BACKEND STREQUAL "mbedTLS")
|
||||
endif()
|
||||
|
||||
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}")
|
||||
|
||||
# test building against shared libssh2 lib
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(test warmup) # any test will do
|
||||
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})
|
||||
endif()
|
||||
|
||||
foreach(test ${TESTS})
|
||||
add_executable(test_${test} test_${test}.c)
|
||||
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})
|
||||
|
||||
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)
|
||||
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)
|
||||
set(TGT_OPTIONS -g --coverage -fprofile-abs-path)
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
|
||||
|
@ -1,6 +1,6 @@
|
||||
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)
|
||||
TESTS = $(ctests) mansyntax.sh
|
||||
|
@ -37,11 +37,7 @@
|
||||
|
||||
#include "session_fixture.h"
|
||||
#include "openssh_fixture.h"
|
||||
#include "libssh2_config.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
@ -35,7 +35,6 @@
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
int main(void)
|
||||
|
@ -38,6 +38,10 @@
|
||||
#ifndef 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);
|
||||
|
||||
#endif
|
||||
|
@ -36,7 +36,6 @@
|
||||
*/
|
||||
|
||||
#include "session_fixture.h"
|
||||
#include "libssh2_config.h"
|
||||
#include "openssh_fixture.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -45,15 +44,11 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <direct.h>
|
||||
#define getcwd _getcwd
|
||||
#define chdir _chdir
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
#include <sys/socket.h>
|
||||
|
@ -38,6 +38,7 @@
|
||||
#ifndef LIBSSH2_TESTS_SESSION_FIXTURE_H
|
||||
#define LIBSSH2_TESTS_SESSION_FIXTURE_H
|
||||
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
|
@ -1,13 +1,9 @@
|
||||
/* Self test, based on examples/ssh2.c. */
|
||||
|
||||
#include "libssh2_config.h"
|
||||
#include "libssh2_setup.h"
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
#ifdef WIN32
|
||||
# include <windows.h>
|
||||
# include <winsock2.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_SOCKET_H
|
||||
# include <sys/socket.h>
|
||||
#endif
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const char *USERNAME = "libssh2"; /* set in Dockerfile */
|
||||
const char *KEY_FILE_PRIVATE = "key_rsa";
|
||||
const char *KEY_FILE_PUBLIC = "key_rsa.pub"; /* set in Dockerfile */
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static const char *EXPECTED_RSA_HOSTKEY =
|
||||
"AAAAB3NzaC1yc2EAAAABIwAAAQEArrr/JuJmaZligyfS8vcNur+mWR2ddDQtVdhHzdKU"
|
||||
"UoR6/Om6cvxpe61H1YZO1xCpLUBXmkki4HoNtYOpPB2W4V+8U4BDeVBD5crypEOE1+7B"
|
||||
|
@ -1,10 +1,4 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
#include "libssh2_config.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static const char *EXPECTED_RSA_HOSTKEY =
|
||||
"AAAAB3NzaC1yc2EAAAABIwAAAQEArrr/JuJmaZligyfS8vcNur+mWR2ddDQtVdhHzdKU"
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static const char *USERNAME = "libssh2"; /* set in Dockerfile */
|
||||
static const char *WRONG_PASSWORD = "i'm not the password";
|
||||
|
||||
|
@ -35,11 +35,11 @@
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "libssh2_priv.h"
|
||||
#include "userauth_kbd_packet.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define PASS 0
|
||||
#define FAIL -1
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *PASSWORD = "my test password";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static const char *USERNAME = "libssh2"; /* set in Dockerfile */
|
||||
static const char *WRONG_PASSWORD = "i'm not the password";
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *PASSWORD = "my test password";
|
||||
static const char *WRONG_USERNAME = "i dont exist";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *PASSWORD = "my test password";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
static const char *USERNAME = "libssh2"; /* set in Dockerfile */
|
||||
static const char *KEY_FILE_PRIVATE = "key_dsa_wrong";
|
||||
static const char *KEY_FILE_PUBLIC = "key_dsa_wrong.pub";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "key_dsa";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "key_ecdsa";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "key_ed25519";
|
||||
|
@ -1,9 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static const char *USERNAME = "libssh2"; /* set in Dockerfile */
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *PASSWORD = "libssh2";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *PASSWORD = "libssh2";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "key_rsa";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "key_rsa_openssh";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "signed_key_ecdsa";
|
||||
|
@ -1,10 +1,5 @@
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "signed_key_rsa";
|
||||
|
@ -1,12 +1,7 @@
|
||||
/* libssh2 test receiving large amounts of data through a channel */
|
||||
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* configured in Dockerfile */
|
||||
static const char *USERNAME = "libssh2";
|
||||
static const char *KEY_FILE_PRIVATE = "key_rsa";
|
||||
|
@ -1,13 +1,8 @@
|
||||
/* Warm-up test. Always return success.
|
||||
Workaround for CI/docker/etc flakiness on the first run. */
|
||||
|
||||
#include "session_fixture.h"
|
||||
#include "runner.h"
|
||||
|
||||
#include <libssh2.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int test(LIBSSH2_SESSION *session)
|
||||
{
|
||||
size_t len = 0;
|
||||
|
7
win32/.gitignore
vendored
7
win32/.gitignore
vendored
@ -1,7 +0,0 @@
|
||||
*.a
|
||||
*.dll
|
||||
*.def
|
||||
*.exe
|
||||
debug-*
|
||||
release-*
|
||||
libssh2-*.zip
|
@ -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 */
|
Reference in New Issue
Block a user