Compare commits
280 Commits
libssh2-1.
...
libssh2-1.
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6d553a7bb9 | ||
![]() |
da6676483b | ||
![]() |
ca5222ea81 | ||
![]() |
d453f4ce3c | ||
![]() |
1fcf849e15 | ||
![]() |
65a4528d17 | ||
![]() |
0ffb3bfafe | ||
![]() |
30221cfe5d | ||
![]() |
fb2840bc9c | ||
![]() |
78043ff25d | ||
![]() |
5eac3edda5 | ||
![]() |
298f056fd6 | ||
![]() |
652ae4d134 | ||
![]() |
996b04ecec | ||
![]() |
8d568d6c3b | ||
![]() |
ae484b426c | ||
![]() |
85dbd4c136 | ||
![]() |
d7e25b4729 | ||
![]() |
e12fe71462 | ||
![]() |
992de2fbfa | ||
![]() |
77c48d4e26 | ||
![]() |
0d60964632 | ||
![]() |
60874670ef | ||
![]() |
77d825ac93 | ||
![]() |
b60fb64b17 | ||
![]() |
0de1cba671 | ||
![]() |
2ddcaf2db8 | ||
![]() |
0f15724e72 | ||
![]() |
57692b6b10 | ||
![]() |
92a3ac4673 | ||
![]() |
72453b7367 | ||
![]() |
8b720f342f | ||
![]() |
e2985f0a67 | ||
![]() |
002db176b7 | ||
![]() |
7a37c33264 | ||
![]() |
914157804f | ||
![]() |
4c4d6a8da4 | ||
![]() |
c367e61294 | ||
![]() |
d900984b0a | ||
![]() |
4bd6d7ebf6 | ||
![]() |
dac4b3bac3 | ||
![]() |
7dcf5ed6fb | ||
![]() |
8ba6bf2aef | ||
![]() |
0fba5cfda6 | ||
![]() |
72bedfe761 | ||
![]() |
f915a31a4d | ||
![]() |
0fbf8f3c7e | ||
![]() |
e64260a117 | ||
![]() |
ed2c3c8d28 | ||
![]() |
73930e6577 | ||
![]() |
cf544d0f4c | ||
![]() |
d0ffeba72e | ||
![]() |
9bf32da607 | ||
![]() |
95dc2a6a52 | ||
![]() |
036196b0b0 | ||
![]() |
51dcded3eb | ||
![]() |
b83c3e056e | ||
![]() |
ad23faaae6 | ||
![]() |
d441da3086 | ||
![]() |
ad26fd92cf | ||
![]() |
4d97ed92b2 | ||
![]() |
fb432f3f78 | ||
![]() |
fc4a969a05 | ||
![]() |
92fff06e27 | ||
![]() |
a49f479b4c | ||
![]() |
6c84a426be | ||
![]() |
4961014033 | ||
![]() |
a53cebba34 | ||
![]() |
3768f8aeef | ||
![]() |
3acca4ad15 | ||
![]() |
026ec0e881 | ||
![]() |
a4d995af0d | ||
![]() |
9af7eb48dc | ||
![]() |
f4b5947d6d | ||
![]() |
36f6d23572 | ||
![]() |
af14462d53 | ||
![]() |
d48d7c3a87 | ||
![]() |
13f8addd1b | ||
![]() |
418be878ad | ||
![]() |
e9536edede | ||
![]() |
d754fee2f2 | ||
![]() |
6c14cc003a | ||
![]() |
cbd5f72339 | ||
![]() |
858930cae5 | ||
![]() |
08fa27b628 | ||
![]() |
4383a39d83 | ||
![]() |
09c5e59933 | ||
![]() |
5a88a86fef | ||
![]() |
0340d4586e | ||
![]() |
2d2744efdd | ||
![]() |
e113202098 | ||
![]() |
983ceafe58 | ||
![]() |
e160ba448e | ||
![]() |
b8289b625e | ||
![]() |
5f4c249e42 | ||
![]() |
6f95c2efd3 | ||
![]() |
31a5986c6d | ||
![]() |
22bd8d81d8 | ||
![]() |
3d3347c062 | ||
![]() |
2d59b41daa | ||
![]() |
1e7988cb0d | ||
![]() |
b99204f289 | ||
![]() |
7ca44fbd94 | ||
![]() |
41b1cb6751 | ||
![]() |
84590bc78f | ||
![]() |
864950cf16 | ||
![]() |
09a559433e | ||
![]() |
57dea4df6d | ||
![]() |
77020c7961 | ||
![]() |
e52f35d9f4 | ||
![]() |
a8d14c5dcf | ||
![]() |
0c90b8bd9b | ||
![]() |
3fc17cd69f | ||
![]() |
aa4e649d94 | ||
![]() |
49ea2be885 | ||
![]() |
247dfce5fb | ||
![]() |
71d45d3df1 | ||
![]() |
daa2dfa2db | ||
![]() |
1429ad749d | ||
![]() |
4078da8d81 | ||
![]() |
0930928810 | ||
![]() |
55d030089b | ||
![]() |
260410edf3 | ||
![]() |
1de36eb5b4 | ||
![]() |
aa7f9a85f7 | ||
![]() |
41d22ccf26 | ||
![]() |
56f7c0e2a4 | ||
![]() |
1329dc5155 | ||
![]() |
a1e744bb5e | ||
![]() |
14d9ee01bc | ||
![]() |
fed47c34e4 | ||
![]() |
18cfec8336 | ||
![]() |
74624c8ddf | ||
![]() |
bbbdf946a7 | ||
![]() |
042993b8eb | ||
![]() |
41ed2b71a2 | ||
![]() |
6bf8983368 | ||
![]() |
523a552258 | ||
![]() |
d73e0ec260 | ||
![]() |
1fa5fe6059 | ||
![]() |
8f00a7471d | ||
![]() |
fe3e23022b | ||
![]() |
33e1013d7b | ||
![]() |
20eb836f4e | ||
![]() |
6ada234c62 | ||
![]() |
e16f638dca | ||
![]() |
7d94b69b80 | ||
![]() |
8bb6cf7f95 | ||
![]() |
5fcbb168b8 | ||
![]() |
d811750645 | ||
![]() |
cfe94c715e | ||
![]() |
a8473c819b | ||
![]() |
c71889017f | ||
![]() |
253d5922f2 | ||
![]() |
79d63df12d | ||
![]() |
86552bf2bb | ||
![]() |
477e609a84 | ||
![]() |
3e47ca8a32 | ||
![]() |
6af0ee567b | ||
![]() |
c6d99bd3a4 | ||
![]() |
d1eccb487a | ||
![]() |
22204c4e2e | ||
![]() |
8670f5da24 | ||
![]() |
3835655f09 | ||
![]() |
dc199ed03a | ||
![]() |
8f799f98d9 | ||
![]() |
637c90959b | ||
![]() |
8a731d6217 | ||
![]() |
d85f9a689f | ||
![]() |
031566f9cc | ||
![]() |
977a3b6a76 | ||
![]() |
34dc1d61b4 | ||
![]() |
be95032e29 | ||
![]() |
c0bface8a7 | ||
![]() |
f31c9fb221 | ||
![]() |
f89bed9571 | ||
![]() |
bc9d735664 | ||
![]() |
06ff22f1a6 | ||
![]() |
e57f29f8f6 | ||
![]() |
1c1699545b | ||
![]() |
abcc0d370f | ||
![]() |
977dbb7511 | ||
![]() |
aedfba25b8 | ||
![]() |
19f1402f1d | ||
![]() |
df5c61dbca | ||
![]() |
1689315fce | ||
![]() |
7f7e65c54b | ||
![]() |
751e0087a8 | ||
![]() |
600f26ce6e | ||
![]() |
3260beb07a | ||
![]() |
01a6210ab7 | ||
![]() |
6a3b5487cb | ||
![]() |
e4ba5fabec | ||
![]() |
46f017e751 | ||
![]() |
12adbc28b8 | ||
![]() |
424a27e007 | ||
![]() |
1e4fb7ee9f | ||
![]() |
7b80a188dd | ||
![]() |
9d50d43a83 | ||
![]() |
c355d31ff9 | ||
![]() |
18fe507324 | ||
![]() |
d63e32dd30 | ||
![]() |
c32e82e97b | ||
![]() |
7d4b5a8e07 | ||
![]() |
200784c4e7 | ||
![]() |
b22b23703c | ||
![]() |
0e4e14109a | ||
![]() |
5bcc2d4629 | ||
![]() |
33df559967 | ||
![]() |
26f6d71885 | ||
![]() |
62c91e2cd4 | ||
![]() |
b9dc6112d7 | ||
![]() |
106bacdebc | ||
![]() |
23dec383f7 | ||
![]() |
fc94046e6e | ||
![]() |
ee547fe90d | ||
![]() |
a58b0dacb4 | ||
![]() |
6e710d7fb6 | ||
![]() |
b20bfeb3e5 | ||
![]() |
aba11380a1 | ||
![]() |
2c46c4bf95 | ||
![]() |
160776d218 | ||
![]() |
ee2d61a48b | ||
![]() |
fcb601da7b | ||
![]() |
55bae8dd07 | ||
![]() |
4440e05d48 | ||
![]() |
378d0a6676 | ||
![]() |
21cb7bfb36 | ||
![]() |
e1a5d1bc77 | ||
![]() |
189cf86df0 | ||
![]() |
30e376773a | ||
![]() |
38e210af0e | ||
![]() |
d145e04443 | ||
![]() |
feab568a7a | ||
![]() |
08973a00a1 | ||
![]() |
c00efa5f93 | ||
![]() |
adc5db29e3 | ||
![]() |
92d686fe19 | ||
![]() |
5559ad8fe1 | ||
![]() |
88366b5ec2 | ||
![]() |
61df22c460 | ||
![]() |
d808080daf | ||
![]() |
f5c1a0d98b | ||
![]() |
85a827d1bc | ||
![]() |
1b3307dda0 | ||
![]() |
85c6627c86 | ||
![]() |
c49cc8411f | ||
![]() |
fa15fded72 | ||
![]() |
c2329aa09e | ||
![]() |
94077f7a58 | ||
![]() |
55a8b10ad9 | ||
![]() |
27f9ac2549 | ||
![]() |
cdeef54967 | ||
![]() |
42aefdba79 | ||
![]() |
d41f5e40aa | ||
![]() |
2df6cd6606 | ||
![]() |
d512b25f69 | ||
![]() |
b4f71fd25a | ||
![]() |
a5bf809b80 | ||
![]() |
2157e178a3 | ||
![]() |
d385230e15 | ||
![]() |
61e40a32ff | ||
![]() |
e6c46cc249 | ||
![]() |
9f1b89e99b | ||
![]() |
8da30ea4d4 | ||
![]() |
ff6c01e959 | ||
![]() |
c910cd382d | ||
![]() |
edd42304a2 | ||
![]() |
1ad20ac7d3 | ||
![]() |
d7f9cd57c5 | ||
![]() |
16ef83dd81 | ||
![]() |
951904418b | ||
![]() |
80e5e20b00 | ||
![]() |
6e0d757f24 | ||
![]() |
a12f3ffab5 | ||
![]() |
486bb37621 | ||
![]() |
fe347a702f | ||
![]() |
07615610ba | ||
![]() |
5aa7b29758 | ||
![]() |
a67ff056e6 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -24,7 +24,6 @@ ltmain.sh
|
||||
missing
|
||||
ssh2_sample
|
||||
libssh2-*.tar.gz
|
||||
INSTALL
|
||||
install-sh
|
||||
*.o
|
||||
*.lo
|
||||
@@ -33,3 +32,4 @@ mkinstalldirs
|
||||
tags
|
||||
libssh2.pc
|
||||
TAGS
|
||||
*~
|
||||
|
75
.travis.yml
Normal file
75
.travis.yml
Normal file
@@ -0,0 +1,75 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
language: c
|
||||
|
||||
compiler:
|
||||
- gcc
|
||||
- clang
|
||||
|
||||
env:
|
||||
matrix:
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
|
||||
- ADDRESS_SIZE=64 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=OpenSSL BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=OFF
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=OFF ENABLE_ZLIB_COMPRESSION=ON
|
||||
- ADDRESS_SIZE=32 CRYPTO_BACKEND=Libgcrypt BUILD_SHARED_LIBS=ON ENABLE_ZLIB_COMPRESSION=ON
|
||||
|
||||
before_install:
|
||||
- sudo add-apt-repository --yes ppa:kalakris/cmake
|
||||
- sudo apt-get update
|
||||
- sudo apt-get -y install cmake
|
||||
- if [ $ADDRESS_SIZE = '64' ]; then sudo apt-get install -y libgcrypt11-dev libssl-dev zlib1g-dev; fi
|
||||
- if [ $ADDRESS_SIZE = '32' ]; then sudo apt-get install -y linux-libc-dev linux-libc-dev:i386; fi
|
||||
- if [ $ADDRESS_SIZE = '32' ]; then sudo apt-get install -y gcc-multilib libgcrypt11-dev:i386 libssl-dev:i386 zlib1g-dev:i386; fi
|
||||
- if [ $ADDRESS_SIZE = '32' ]; then export TOOLCHAIN_OPTION="-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-Linux-32.cmake"; fi
|
||||
|
||||
install:
|
||||
- mkdir bin
|
||||
- cd bin
|
||||
|
||||
script:
|
||||
- cmake $TOOLCHAIN_OPTION -DCRYPTO_BACKEND=$CRYPTO_BACKEND -DBUILD_SHARED_LIBS=$BUILD_SHARED_LIBS -DENABLE_ZLIB_COMPRESSION=$ENABLE_ZLIB_COMPRESSION .. && cmake --build . && CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --target test && cmake --build . --target package
|
101
CMakeLists.txt
Normal file
101
CMakeLists.txt
Normal file
@@ -0,0 +1,101 @@
|
||||
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
|
||||
project(libssh2 C)
|
||||
set(PROJECT_URL "https://www.libssh2.org/")
|
||||
set(PROJECT_DESCRIPTION "The SSH library")
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
|
||||
|
||||
# Parse version
|
||||
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h _HEADER_CONTENTS)
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
|
||||
LIBSSH2_VERSION "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_MAJOR "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_MINOR[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_MINOR "${_HEADER_CONTENTS}")
|
||||
string(
|
||||
REGEX REPLACE ".*#define LIBSSH2_VERSION_PATCH[ \t]+([0-9]+).*" "\\1"
|
||||
LIBSSH2_VERSION_PATCH "${_HEADER_CONTENTS}")
|
||||
|
||||
if(NOT LIBSSH2_VERSION OR
|
||||
NOT LIBSSH2_VERSION_MAJOR MATCHES "^[0-9]+$" OR
|
||||
NOT LIBSSH2_VERSION_MINOR MATCHES "^[0-9]+$" OR
|
||||
NOT LIBSSH2_VERSION_PATCH MATCHES "^[0-9]+$")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Unable to parse version from"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/include/libssh2.h")
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(
|
||||
FILES docs/AUTHORS COPYING docs/HACKING README RELEASE-NOTES NEWS
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR})
|
||||
|
||||
include(max_warnings)
|
||||
include(FeatureSummary)
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
option(BUILD_EXAMPLES "Build libssh2 examples" ON)
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(example)
|
||||
endif()
|
||||
|
||||
option(BUILD_TESTING "Build libssh2 test suite" ON)
|
||||
if(BUILD_TESTING)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
add_subdirectory(docs)
|
||||
|
||||
feature_summary(WHAT ALL)
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR ${LIBSSH2_VERSION_MAJOR})
|
||||
set(CPACK_PACKAGE_VERSION_MINOR ${LIBSSH2_VERSION_MINOR})
|
||||
set(CPACK_PACKAGE_VERSION_PATCH ${LIBSSH2_VERSION_PATCH})
|
||||
set(CPACK_PACKAGE_VERSION ${LIBSSH2_VERSION})
|
||||
include(CPack)
|
2
COPYING
2
COPYING
@@ -2,7 +2,7 @@
|
||||
* Copyright (c) 2005,2006 Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||
* Copyright (c) 2006-2007 The Written Word, Inc.
|
||||
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
|
||||
* Copyright (c) 2009 Daniel Stenberg
|
||||
* Copyright (c) 2009-2014 Daniel Stenberg
|
||||
* Copyright (C) 2008, 2009 Simon Josefsson
|
||||
* All rights reserved.
|
||||
*
|
||||
|
2
Makefile.OpenSSL.inc
Normal file
2
Makefile.OpenSSL.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
CRYPTO_CSOURCES = openssl.c
|
||||
CRYPTO_HHEADERS = openssl.h
|
2
Makefile.WinCNG.inc
Normal file
2
Makefile.WinCNG.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
CRYPTO_CSOURCES = wincng.c
|
||||
CRYPTO_HHEADERS = wincng.h
|
19
Makefile.am
19
Makefile.am
@@ -32,8 +32,20 @@ win32/libssh2_config.h win32/config.mk win32/rules.mk \
|
||||
win32/Makefile.Watcom win32/libssh2.dsw win32/tests.dsp $(DSP) \
|
||||
win32/msvcproj.head win32/msvcproj.foot win32/libssh2.rc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk HACKING \
|
||||
maketgz NMakefile TODO RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath
|
||||
OS400FILES = os400/README400 os400/initscript.sh os400/make.sh \
|
||||
os400/make-src.sh os400/make-rpg.sh os400/make-include.sh \
|
||||
os400/os400sys.c os400/ccsid.c \
|
||||
os400/libssh2_config.h os400/macros.h os400/libssh2_ccsid.h \
|
||||
os400/include/alloca.h os400/include/sys/socket.h os400/include/stdio.h \
|
||||
os400/libssh2rpg/libssh2.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_ccsid.rpgle.in \
|
||||
os400/libssh2rpg/libssh2_publickey.rpgle \
|
||||
os400/libssh2rpg/libssh2_sftp.rpgle \
|
||||
Makefile.os400qc3.inc
|
||||
|
||||
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk \
|
||||
maketgz NMakefile RELEASE-NOTES libssh2.pc.in $(VMSFILES) config.rpath \
|
||||
CMakeLists.txt cmake $(OS400FILES)
|
||||
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
|
||||
@@ -75,6 +87,9 @@ gen-coverage:
|
||||
coverage: init-coverage build-coverage gen-coverage
|
||||
|
||||
# DSP/VCPROJ generation adapted from libcurl
|
||||
# only OpenSSL and WinCNG are supported with this build system
|
||||
CRYPTO_CSOURCES = openssl.c wincng.c
|
||||
CRYPTO_HHEADERS = openssl.h wincng.h
|
||||
# Makefile.inc provides the CSOURCES and HHEADERS defines
|
||||
include Makefile.inc
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
CSOURCES = channel.c comp.c crypt.c hostkey.c kex.c mac.c misc.c \
|
||||
packet.c publickey.c scp.c session.c sftp.c userauth.c transport.c \
|
||||
version.c knownhost.c agent.c openssl.c libgcrypt.c pem.c keepalive.c \
|
||||
global.c
|
||||
version.c knownhost.c agent.c $(CRYPTO_CSOURCES) pem.c keepalive.c global.c
|
||||
|
||||
HHEADERS = libssh2_priv.h openssl.h libgcrypt.h transport.h channel.h \
|
||||
comp.h mac.h misc.h packet.h userauth.h session.h sftp.h crypto.h
|
||||
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
|
||||
|
2
Makefile.libgcrypt.inc
Normal file
2
Makefile.libgcrypt.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
CRYPTO_CSOURCES = libgcrypt.c
|
||||
CRYPTO_HHEADERS = libgcrypt.h
|
2
Makefile.os400qc3.inc
Normal file
2
Makefile.os400qc3.inc
Normal file
@@ -0,0 +1,2 @@
|
||||
CRYPTO_CSOURCES = os400qc3.c
|
||||
CRYPTO_HHEADERS = os400qc3.h
|
@@ -1,5 +1,10 @@
|
||||
!include "win32/config.mk"
|
||||
|
||||
!if "$(WITH_WINCNG)" == "1"
|
||||
!include "Makefile.WinCNG.inc"
|
||||
!else
|
||||
!include "Makefile.OpenSSL.inc"
|
||||
!endif
|
||||
!include "Makefile.inc"
|
||||
|
||||
OBJECTS=$(CSOURCES:.c=.obj)
|
||||
@@ -12,6 +17,7 @@ all-sub: win32\objects.mk
|
||||
|
||||
clean:
|
||||
-rmdir 2>NUL /s/q $(TARGET)
|
||||
-del 2>NUL win32\objects.mk
|
||||
|
||||
real-clean vclean: clean
|
||||
-del 2>NUL libssh2.dll
|
||||
@@ -19,7 +25,6 @@ real-clean vclean: clean
|
||||
-del 2>NUL libssh2.ilk
|
||||
-del 2>NUL libssh2.lib
|
||||
-del 2>NUL *.pdb
|
||||
-del 2>NUL win32\objects.mk
|
||||
|
||||
win32\objects.mk: Makefile.inc
|
||||
@echo OBJECTS = \>$@
|
||||
|
90
README
90
README
@@ -8,90 +8,12 @@ Web site: http://www.libssh2.org/
|
||||
|
||||
Mailing list: http://cool.haxx.se/mailman/listinfo/libssh2-devel
|
||||
|
||||
Generic installation instructions are in INSTALL. Some ./configure
|
||||
options deserve additional comments:
|
||||
License: see COPYING
|
||||
|
||||
* --enable-crypt-none
|
||||
Source code: https://github.com/libssh2/libssh2
|
||||
|
||||
The SSH2 Transport allows for unencrypted data
|
||||
transmission using the "none" cipher. Because this is
|
||||
such a huge security hole, it is typically disabled on
|
||||
SSH2 implementations and is disabled in libssh2 by
|
||||
default as well.
|
||||
Web site source code: https://github.com/libssh2/www
|
||||
|
||||
Enabling this option will allow for "none" as a
|
||||
negotiable method, however it still requires that the
|
||||
method be advertized by the remote end and that no
|
||||
more-preferable methods are available.
|
||||
|
||||
* --enable-mac-none
|
||||
|
||||
The SSH2 Transport also allows implementations to
|
||||
forego a message authentication code. While this is
|
||||
less of a security risk than using a "none" cipher, it
|
||||
is still not recommended as disabling MAC hashes
|
||||
removes a layer of security.
|
||||
|
||||
Enabling this option will allow for "none" as a
|
||||
negotiable method, however it still requires that the
|
||||
method be advertized by the remote end and that no
|
||||
more-preferable methods are available.
|
||||
|
||||
* --disable-gex-new
|
||||
|
||||
The diffie-hellman-group-exchange-sha1 (dh-gex) key
|
||||
exchange method originally defined an exchange
|
||||
negotiation using packet type 30 to request a
|
||||
generation pair based on a single target value. Later
|
||||
refinement of dh-gex provided for range and target
|
||||
values. By default libssh2 will use the newer range
|
||||
method.
|
||||
|
||||
If you experience trouble connecting to an old SSH
|
||||
server using dh-gex, try this option to fallback on
|
||||
the older more reliable method.
|
||||
|
||||
* --with-libgcrypt
|
||||
* --without-libgcrypt
|
||||
* --with-libgcrypt-prefix=DIR
|
||||
|
||||
libssh2 can use the Libgcrypt library
|
||||
(http://www.gnupg.org/) for cryptographic operations.
|
||||
Either Libgcrypt or OpenSSL is required.
|
||||
|
||||
Configure will attempt to locate Libgcrypt
|
||||
automatically.
|
||||
|
||||
If your installation of Libgcrypt is in another
|
||||
location, specify it using --with-libgcrypt-prefix.
|
||||
|
||||
* --with-openssl
|
||||
* --without-openssl
|
||||
* --with-libssl-prefix=[DIR]
|
||||
|
||||
libssh2 can use the OpenSSL library
|
||||
(http://www.openssl.org) for cryptographic operations.
|
||||
Either Libgcrypt or OpenSSL is required.
|
||||
|
||||
Configure will attempt to locate OpenSSL in the
|
||||
default location.
|
||||
|
||||
If your installation of OpenSSL is in another
|
||||
location, specify it using --with-libssl-prefix.
|
||||
|
||||
* --with-libz
|
||||
* --without-libz
|
||||
* --with-libz-prefix=[DIR]
|
||||
|
||||
If present, libssh2 will attempt to use the zlib
|
||||
(http://www.zlib.org) for payload compression, however
|
||||
zlib is not required.
|
||||
|
||||
If your installation of Libz is in another location,
|
||||
specify it using --with-libz-prefix.
|
||||
|
||||
* --enable-debug
|
||||
|
||||
Will make the build use more pedantic and strict compiler
|
||||
options as well as enable the libssh2_trace() function (for
|
||||
showing debug traces).
|
||||
Installation instructions are in:
|
||||
- docs/INSTALL_CMAKE for CMake
|
||||
- docs/INSTALL_AUTOTOOLS for Autotools
|
||||
|
@@ -1,28 +1,56 @@
|
||||
libssh2 1.4.3
|
||||
libssh2 1.7.0
|
||||
|
||||
This release includes the following changes:
|
||||
|
||||
o compression: add support for zlib@openssh.com
|
||||
o libssh2_session_set_last_error: Add function
|
||||
o mac: Add support for HMAC-SHA-256 and HMAC-SHA-512
|
||||
o WinCNG: support for SHA256/512 HMAC
|
||||
o kex: Added diffie-hellman-group-exchange-sha256 support
|
||||
o OS/400 crypto library QC3 support
|
||||
|
||||
This release includes the following security advisory:
|
||||
|
||||
o diffie_hellman_sha256: convert bytes to bits
|
||||
CVE-2016-0787: http://www.libssh2.org/adv_20160223.html
|
||||
|
||||
This release includes the following bugfixes:
|
||||
|
||||
o sftp_read: return error if a too large package arrives
|
||||
o libssh2_hostkey_hash.3: update the description of return value
|
||||
o Fixed MSVC NMakefile
|
||||
o examples: use stderr for messages, stdout for data
|
||||
o openssl: do not leak memory when handling errors
|
||||
o improved handling of disabled MD5 algorithm in OpenSSL
|
||||
o known_hosts: Fail when parsing unknown keys in known_hosts file
|
||||
o configure: gcrypt doesn't come with pkg-config support
|
||||
o session_free: wrong variable used for keeping state
|
||||
o libssh2_userauth_publickey_fromfile_ex.3: mention publickey == NULL
|
||||
o comp_method_zlib_decomp: handle Z_BUF_ERROR when inflating
|
||||
|
||||
o SFTP: Increase speed and datasize in SFTP read
|
||||
o openssl: make libssh2_sha1 return error code
|
||||
o openssl: fix memleak in _libssh2_dsa_sha1_verify()
|
||||
o cmake: include CMake files in the release tarballs
|
||||
o Fix builds with Visual Studio 2015
|
||||
o hostkey.c: Fix compiling error when OPENSSL_NO_MD5 is defined
|
||||
o GNUmakefile: add support for LIBSSH2_LDFLAG_EXTRAS
|
||||
o GNUmakefile: add -m64 CFLAGS when targeting mingw64
|
||||
o kex: free server host key before allocating it (again)
|
||||
o SCP: add libssh2_scp_recv2 to support large (> 2GB) files on windows
|
||||
o channel: Detect bad usage of libssh2_channel_process_startup
|
||||
o userauth: Fix off by one error when reading public key file
|
||||
o kex: removed dupe entry from libssh2_kex_methods
|
||||
o _libssh2_error: Support allocating the error message
|
||||
o hostkey: fix invalid memory access if libssh2_dsa_new fails
|
||||
o hostkey: align code path of ssh_rsa_init to ssh_dss_init
|
||||
o libssh2.pc.in: fix the output of pkg-config --libs
|
||||
o wincng: fixed possible memory leak in _libssh2_wincng_hash
|
||||
o wincng: fixed _libssh2_wincng_hash_final return value
|
||||
o add OpenSSL 1.1.0-pre2 compatibility
|
||||
o agent_disconnect_unix: unset the agent fd after closing it
|
||||
o sftp: stop reading when buffer is full
|
||||
o sftp: Send at least one read request before reading
|
||||
o sftp: Don't return EAGAIN if data was written to buffer
|
||||
o sftp: Check read packet file offset
|
||||
o configure: build "silent" if possible
|
||||
o openssl: add OpenSSL 1.1.0-pre3-dev compatibility
|
||||
o GNUmakefile: list system libs after user libs
|
||||
|
||||
This release would not have looked like this without help, code, reports and
|
||||
advice from friends like these:
|
||||
|
||||
Guenter Knauf, Peter Stuge, TJ Saunders, Mike Abdullah, Maxime Larocque,
|
||||
Dmitry Smirnov, Dave Hayden, Peter Krempa, Kamil Dudka
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
Alexander Lamaison, Andreas Schneider, brian m. carlson, Daniel Stenberg,
|
||||
David Byron, Jakob Egger, Kamil Dudka, Marc Hoersken, Mizunashi Mana,
|
||||
Patrick Monnerat, Paul Howarth, Salvador Fandino, Salvador Fandiño,
|
||||
Salvador Fandiño, Viktor Szakats, Will Cosgrove,
|
||||
(16 contributors)
|
||||
|
||||
Thanks! (and sorry if I forgot to mention someone)
|
||||
|
84
appveyor.yml
Normal file
84
appveyor.yml
Normal file
@@ -0,0 +1,84 @@
|
||||
# Copyright (c) 2014, Ruslan Baratov
|
||||
# Copyright (c) 2014, 2016 Alexander Lamaison
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
os: Visual Studio 2015
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- GENERATOR: "Visual Studio 14 2015"
|
||||
BUILD_SHARED_LIBS: ON
|
||||
|
||||
- GENERATOR: "Visual Studio 14 2015"
|
||||
BUILD_SHARED_LIBS: OFF
|
||||
|
||||
- GENERATOR: "Visual Studio 12 2013"
|
||||
BUILD_SHARED_LIBS: ON
|
||||
|
||||
- GENERATOR: "Visual Studio 12 2013"
|
||||
BUILD_SHARED_LIBS: OFF
|
||||
|
||||
- GENERATOR: "Visual Studio 11 2012"
|
||||
BUILD_SHARED_LIBS: ON
|
||||
|
||||
- GENERATOR: "Visual Studio 11 2012"
|
||||
BUILD_SHARED_LIBS: OFF
|
||||
|
||||
- GENERATOR: "Visual Studio 10 2010"
|
||||
BUILD_SHARED_LIBS: ON
|
||||
|
||||
- GENERATOR: "Visual Studio 10 2010"
|
||||
BUILD_SHARED_LIBS: OFF
|
||||
|
||||
- GENERATOR: "Visual Studio 9 2008"
|
||||
BUILD_SHARED_LIBS: ON
|
||||
|
||||
- GENERATOR: "Visual Studio 9 2008"
|
||||
BUILD_SHARED_LIBS: OFF
|
||||
|
||||
platform:
|
||||
- x86
|
||||
- x64
|
||||
|
||||
configuration:
|
||||
# - Debug
|
||||
- Release
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- GENERATOR: "Visual Studio 9 2008"
|
||||
platform: x64
|
||||
|
||||
build_script:
|
||||
- ps: if($env:PLATFORM -eq "x64") { $env:CMAKE_GEN_SUFFIX=" Win64" }
|
||||
- cmake "-G%GENERATOR%%CMAKE_GEN_SUFFIX%" -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% -H. -B_builds
|
||||
- cmake --build _builds --config "%CONFIGURATION%"
|
||||
|
||||
test_script:
|
||||
- ps: cd _builds
|
||||
- ctest -VV -C "%CONFIGURATION%" -E ssh2 --output-on-failure
|
||||
|
||||
on_failure:
|
||||
- ps: if (Test-Path _builds/CMakeFiles/CMakeOutput.log) { cat _builds/CMakeFiles/CMakeOutput.log }
|
||||
- ps: if (Test-Path _builds/CMakeFiles/CMakeError.log) { cat _builds/CMakeFiles/CMakeError.log }
|
81
cmake/CheckFunctionExistsMayNeedLibrary.cmake
Normal file
81
cmake/CheckFunctionExistsMayNeedLibrary.cmake
Normal file
@@ -0,0 +1,81 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
|
||||
# - check_function_exists_maybe_need_library(<function> <var> [lib1 ... libn])
|
||||
#
|
||||
# Check if function is available for linking, first without extra libraries, and
|
||||
# then, if not found that way, linking in each optional library as well. This
|
||||
# function is similar to autotools AC_SEARCH_LIBS.
|
||||
#
|
||||
# If the function if found, this will define <var>.
|
||||
#
|
||||
# If the function was only found by linking in an additional library, this
|
||||
# will define NEED_LIB_LIBX, where LIBX is the one of lib1 to libn that
|
||||
# makes the function available, in uppercase.
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
#
|
||||
|
||||
include(CheckFunctionExists)
|
||||
include(CheckLibraryExists)
|
||||
|
||||
function(check_function_exists_may_need_library function variable)
|
||||
|
||||
check_function_exists(${function} ${variable})
|
||||
|
||||
if(NOT ${variable})
|
||||
foreach(lib ${ARGN})
|
||||
string(TOUPPER ${lib} UP_LIB)
|
||||
# Use new variable to prevent cache from previous step shortcircuiting
|
||||
# new test
|
||||
check_library_exists(${lib} ${function} "" HAVE_${function}_IN_${lib})
|
||||
if(HAVE_${function}_IN_${lib})
|
||||
set(${variable} 1 CACHE INTERNAL
|
||||
"Function ${function} found in library ${lib}")
|
||||
set(NEED_LIB_${UP_LIB} 1 CACHE INTERNAL
|
||||
"Need to link ${lib}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
endfunction()
|
119
cmake/CheckNonblockingSocketSupport.cmake
Normal file
119
cmake/CheckNonblockingSocketSupport.cmake
Normal file
@@ -0,0 +1,119 @@
|
||||
include(CheckCSourceCompiles)
|
||||
|
||||
# - check_nonblocking_socket_support()
|
||||
#
|
||||
# Check for how to set a socket to non-blocking state. There seems to exist
|
||||
# four known different ways, with the one used almost everywhere being POSIX
|
||||
# and XPG3, while the other different ways for different systems (old BSD,
|
||||
# Windows and Amiga).
|
||||
#
|
||||
# One of the following variables will be set indicating the supported
|
||||
# method (if any):
|
||||
# HAVE_O_NONBLOCK
|
||||
# HAVE_FIONBIO
|
||||
# HAVE_IOCTLSOCKET
|
||||
# HAVE_IOCTLSOCKET_CASE
|
||||
# HAVE_SO_NONBLOCK
|
||||
# HAVE_DISABLED_NONBLOCKING
|
||||
#
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
#
|
||||
macro(check_nonblocking_socket_support)
|
||||
# There are two known platforms (AIX 3.x and SunOS 4.1.x) where the
|
||||
# O_NONBLOCK define is found but does not work.
|
||||
check_c_source_compiles("
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(sun) || defined(__sun__) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
|
||||
# if defined(__SVR4) || defined(__srv4__)
|
||||
# define PLATFORM_SOLARIS
|
||||
# else
|
||||
# define PLATFORM_SUNOS4
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
|
||||
# define PLATFORM_AIX_V3
|
||||
#endif
|
||||
|
||||
#if defined(PLATFORM_SUNOS4) || defined(PLATFORM_AIX_V3) || defined(__BEOS__)
|
||||
#error \"O_NONBLOCK does not work on this platform\"
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = fcntl(socket, F_SETFL, flags | O_NONBLOCK);
|
||||
}"
|
||||
HAVE_O_NONBLOCK)
|
||||
|
||||
if(NOT HAVE_O_NONBLOCK)
|
||||
check_c_source_compiles("/* FIONBIO test (old-style unix) */
|
||||
#include <unistd.h>
|
||||
#include <stropts.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = ioctl(socket, FIONBIO, &flags);
|
||||
}"
|
||||
HAVE_FIONBIO)
|
||||
|
||||
if(NOT HAVE_FIONBIO)
|
||||
check_c_source_compiles("/* ioctlsocket test (Windows) */
|
||||
#undef inline
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
SOCKET sd;
|
||||
unsigned long flags = 0;
|
||||
sd = socket(0, 0, 0);
|
||||
ioctlsocket(sd, FIONBIO, &flags);
|
||||
}"
|
||||
HAVE_IOCTLSOCKET)
|
||||
|
||||
if(NOT HAVE_IOCTLSOCKET)
|
||||
check_c_source_compiles("/* IoctlSocket test (Amiga?) */
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
int socket;
|
||||
int flags = IoctlSocket(socket, FIONBIO, (long)1);
|
||||
}"
|
||||
HAVE_IOCTLSOCKET_CASE)
|
||||
|
||||
if(NOT HAVE_IOCTLSOCKET_CASE)
|
||||
check_c_source_compiles("/* SO_NONBLOCK test (BeOS) */
|
||||
#include <socket.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
long b = 1;
|
||||
int socket;
|
||||
int flags = setsockopt(socket, SOL_SOCKET, SO_NONBLOCK, &b, sizeof(b));
|
||||
}"
|
||||
HAVE_SO_NONBLOCK)
|
||||
|
||||
if(NOT HAVE_SO_NONBLOCK)
|
||||
# No non-blocking socket method found
|
||||
set(HAVE_DISABLED_NONBLOCKING 1)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
72
cmake/CopyRuntimeDependencies.cmake
Normal file
72
cmake/CopyRuntimeDependencies.cmake
Normal file
@@ -0,0 +1,72 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(ADD_TARGET_TO_COPY_DEPENDENCIES)
|
||||
set(options)
|
||||
set(oneValueArgs TARGET)
|
||||
set(multiValueArgs DEPENDENCIES BEFORE_TARGETS)
|
||||
cmake_parse_arguments(COPY
|
||||
"${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(NOT COPY_DEPENDENCIES)
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Using a custom target to drive custom commands stops multiple
|
||||
# parallel builds trying to kick off the commands at the same time
|
||||
add_custom_target(${COPY_TARGET})
|
||||
|
||||
foreach(target ${COPY_BEFORE_TARGETS})
|
||||
add_dependencies(${target} ${COPY_TARGET})
|
||||
endforeach()
|
||||
|
||||
foreach(dependency ${COPY_DEPENDENCIES})
|
||||
|
||||
add_custom_command(
|
||||
TARGET ${COPY_TARGET}
|
||||
DEPENDS ${dependency}
|
||||
# Make directory first otherwise file is copied in place of
|
||||
# directory instead of into it
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
ARGS -E copy ${dependency} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
||||
VERBATIM)
|
||||
|
||||
endforeach()
|
||||
|
||||
endfunction()
|
53
cmake/FindLibgcrypt.cmake
Normal file
53
cmake/FindLibgcrypt.cmake
Normal file
@@ -0,0 +1,53 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
# - Try to find Libgcrypt
|
||||
# This will define all or none of:
|
||||
# LIBGCRYPT_FOUND - if Libgcrypt headers and library was found
|
||||
# LIBGCRYPT_INCLUDE_DIRS - The Libgcrypt include directories
|
||||
# LIBGCRYPT_LIBRARIES - The libraries needed to use Libgcrypt
|
||||
|
||||
find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h)
|
||||
|
||||
find_library(LIBGCRYPT_LIBRARY NAMES gcrypt libgcrypt)
|
||||
|
||||
set(LIBGCRYPT_LIBRARIES ${LIBGCRYPT_LIBRARY})
|
||||
set(LIBGCRYPT_INCLUDE_DIRS ${LIBGCRYPT_INCLUDE_DIR})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Libgcrypt DEFAULT_MSG
|
||||
LIBGCRYPT_LIBRARY LIBGCRYPT_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LIBGCRYPT_INCLUDE_DIR LIBGCRYPT_LIBRARY)
|
64
cmake/SocketLibraries.cmake
Normal file
64
cmake/SocketLibraries.cmake
Normal file
@@ -0,0 +1,64 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
# Some systems have their socket functions in a library.
|
||||
# (Solaris -lsocket/-lnsl, Windows -lws2_32). This macro appends those
|
||||
# libraries to the given list
|
||||
macro(append_needed_socket_libraries LIBRARIES_LIST)
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
# x86 Windows uses STDCALL for these functions, so their names are mangled,
|
||||
# meaning the platform checks don't work. Hardcoding these until we get
|
||||
# a better solution.
|
||||
set(HAVE_SOCKET 1)
|
||||
set(HAVE_SELECT 1)
|
||||
set(HAVE_INET_ADDR 1)
|
||||
set(NEED_LIB_WS2_32 1)
|
||||
else()
|
||||
check_function_exists_may_need_library(socket HAVE_SOCKET socket ws2_32)
|
||||
check_function_exists_may_need_library(select HAVE_SELECT ws2_32)
|
||||
check_function_exists_may_need_library(inet_addr HAVE_INET_ADDR nsl ws2_32)
|
||||
endif()
|
||||
|
||||
if(NEED_LIB_SOCKET)
|
||||
list(APPEND ${LIBRARIES_LIST} socket)
|
||||
endif()
|
||||
if(NEED_LIB_NSL)
|
||||
list(APPEND ${LIBRARIES_LIST} nsl)
|
||||
endif()
|
||||
if(NEED_LIB_WS2_32)
|
||||
list(APPEND ${LIBRARIES_LIST} ws2_32)
|
||||
endif()
|
||||
|
||||
endmacro()
|
42
cmake/Toolchain-Linux-32.cmake
Normal file
42
cmake/Toolchain-Linux-32.cmake
Normal file
@@ -0,0 +1,42 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
# Cross-compile 32-bit binary on 64-bit linux host
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_VERSION 1)
|
||||
set(CMAKE_SYSTEM_PROCESSOR "i386")
|
||||
|
||||
set(CMAKE_CXX_COMPILER_ARG1 "-m32")
|
||||
set(CMAKE_C_COMPILER_ARG1 "-m32")
|
23
cmake/max_warnings.cmake
Normal file
23
cmake/max_warnings.cmake
Normal file
@@ -0,0 +1,23 @@
|
||||
if(MSVC)
|
||||
# Use the highest warning level for visual studio.
|
||||
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
|
||||
endif()
|
||||
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
|
||||
string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
else()
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
|
||||
endif()
|
||||
|
||||
# Disable broken warnings
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(NOT CMAKE_CXX_FLAGS MATCHES "-Wall")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||
endif()
|
||||
if(NOT CMAKE_C_FLAGS MATCHES "-Wall")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
|
||||
endif()
|
||||
endif()
|
132
configure.ac
132
configure.ac
@@ -2,8 +2,9 @@
|
||||
AC_INIT(libssh2, [-], libssh2-devel@cool.haxx.se)
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
AC_CONFIG_SRCDIR([src])
|
||||
AM_CONFIG_HEADER([src/libssh2_config.h example/libssh2_config.h])
|
||||
AC_CONFIG_HEADERS([src/libssh2_config.h example/libssh2_config.h])
|
||||
AM_MAINTAINER_MODE
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
dnl SED is needed by some of the tools
|
||||
AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
|
||||
@@ -83,59 +84,111 @@ dnl check for how to do large files
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
# Configure parameters
|
||||
AC_ARG_WITH(libgcrypt,
|
||||
AC_HELP_STRING([--with-libgcrypt],[Use Libgcrypt for crypto]),
|
||||
use_libgcrypt=$withval,use_libgcrypt=auto)
|
||||
AC_ARG_WITH(openssl,
|
||||
AC_HELP_STRING([--with-openssl],[Use OpenSSL for crypto]),
|
||||
use_openssl=$withval,use_openssl=auto)
|
||||
AC_ARG_WITH(libgcrypt,
|
||||
AC_HELP_STRING([--with-libgcrypt],[Use libgcrypt for crypto]),
|
||||
use_libgcrypt=$withval,use_libgcrypt=auto)
|
||||
AC_ARG_WITH(wincng,
|
||||
AC_HELP_STRING([--with-wincng],[Use Windows CNG for crypto]),
|
||||
use_wincng=$withval,use_wincng=auto)
|
||||
AC_ARG_WITH(libz,
|
||||
AC_HELP_STRING([--with-libz],[Use Libz for compression]),
|
||||
AC_HELP_STRING([--with-libz],[Use zlib for compression]),
|
||||
use_libz=$withval,use_libz=auto)
|
||||
|
||||
# Look for OpenSSL (default)
|
||||
if test "$use_openssl" != "no" && test "$use_libgcrypt" != "yes"; then
|
||||
found_crypto=none
|
||||
support_clear_memory=no
|
||||
|
||||
# Look for OpenSSL
|
||||
if test "$found_crypto" = "none" && test "$use_openssl" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>])
|
||||
LIBSREQUIRED=libssl,libcrypto
|
||||
fi
|
||||
if test "$ac_cv_libssl" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_OPENSSL, 1, [Use OpenSSL])
|
||||
LIBSREQUIRED=libssl,libcrypto
|
||||
|
||||
# Not all OpenSSL have AES-CTR functions.
|
||||
save_LIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBSSL"
|
||||
AC_CHECK_FUNCS(EVP_aes_128_ctr)
|
||||
LIBS="$save_LIBS"
|
||||
|
||||
found_crypto="OpenSSL (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A})"
|
||||
fi
|
||||
AM_CONDITIONAL(OPENSSL, test "$ac_cv_libssl" = "yes")
|
||||
|
||||
# Look for libgcrypt
|
||||
if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
|
||||
if test "$found_crypto" = "none" && test "$use_libgcrypt" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
|
||||
LIBS="$LIBS -lgcrypt"
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBSREQUIRED)
|
||||
|
||||
if test "$ac_cv_libssl" != "yes" && test "$ac_cv_libgcrypt" != "yes"; then
|
||||
AC_MSG_ERROR([cannot find OpenSSL or Libgcrypt,
|
||||
try --with-libssl-prefix=PATH or --with-libgcrypt-prefix=PATH])
|
||||
fi
|
||||
|
||||
if test "$ac_cv_libgcrypt" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_LIBGCRYPT, 1, [Use libgcrypt])
|
||||
LIBSREQUIRED= # libgcrypt doesn't provide a .pc file. sad face.
|
||||
LIBS="$LIBS -lgcrypt"
|
||||
found_crypto=libgcrypt
|
||||
fi
|
||||
AM_CONDITIONAL(LIBGCRYPT, test "$ac_cv_libgcrypt" = "yes")
|
||||
|
||||
# Not all OpenSSL have AES-CTR functions.
|
||||
if test "$ac_cv_libssl" = "yes"; then
|
||||
save_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $LIBSSL"
|
||||
AC_CHECK_FUNCS(EVP_aes_128_ctr)
|
||||
LDFLAGS="$save_LDFLAGS"
|
||||
# Look for Windows Cryptography API: Next Generation
|
||||
if test "$found_crypto" = "none" && test "$use_wincng" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([bcrypt], [], [
|
||||
#include <windows.h>
|
||||
#include <bcrypt.h>
|
||||
])
|
||||
AC_LIB_HAVE_LINKFLAGS([crypt32], [], [
|
||||
#include <windows.h>
|
||||
#include <wincrypt.h>
|
||||
])
|
||||
AC_CHECK_HEADERS([ntdef.h ntstatus.h], [], [], [
|
||||
#include <windows.h>
|
||||
])
|
||||
AC_CHECK_DECLS([SecureZeroMemory], [], [], [
|
||||
#include <windows.h>
|
||||
])
|
||||
fi
|
||||
if test "$ac_cv_libbcrypt" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_WINCNG, 1, [Use Windows CNG])
|
||||
LIBSREQUIRED= # wincng doesn't provide a .pc file. sad face.
|
||||
LIBS="$LIBS -lbcrypt"
|
||||
if test "$ac_cv_libcrypt32" = "yes"; then
|
||||
LIBS="$LIBS -lcrypt32"
|
||||
fi
|
||||
found_crypto="Windows Cryptography API: Next Generation"
|
||||
if test "$ac_cv_have_decl_SecureZeroMemory" = "yes"; then
|
||||
support_clear_memory=yes
|
||||
fi
|
||||
fi
|
||||
AM_CONDITIONAL(WINCNG, test "$ac_cv_libbcrypt" = "yes")
|
||||
|
||||
AM_CONDITIONAL(OS400QC3, false)
|
||||
|
||||
# Check if crypto library was found
|
||||
if test "$found_crypto" = "none"; then
|
||||
AC_MSG_ERROR([No crypto library found!
|
||||
Try --with-libssl-prefix=PATH
|
||||
or --with-libgcrypt-prefix=PATH
|
||||
or --with-wincng on Windows\
|
||||
])
|
||||
fi
|
||||
|
||||
# Look for Libz
|
||||
if test "$use_libz" != "no"; then
|
||||
AC_LIB_HAVE_LINKFLAGS([z], [], [#include <zlib.h>])
|
||||
if test "$ac_cv_libz" != yes; then
|
||||
AC_MSG_NOTICE([Cannot find libz, disabling compression])
|
||||
AC_MSG_NOTICE([Cannot find zlib, disabling compression])
|
||||
AC_MSG_NOTICE([Try --with-libz-prefix=PATH if you know you have it])
|
||||
else
|
||||
AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support])
|
||||
if test "${LIBSREQUIRED}" != ""; then
|
||||
LIBSREQUIRED="${LIBSREQUIRED},"
|
||||
fi
|
||||
LIBSREQUIRED="${LIBSREQUIRED}zlib"
|
||||
fi
|
||||
fi
|
||||
|
||||
AC_SUBST(LIBSREQUIRED)
|
||||
|
||||
#
|
||||
# Optional Settings
|
||||
#
|
||||
@@ -154,6 +207,30 @@ if test "$GEX_NEW" != "no"; then
|
||||
AC_DEFINE(LIBSSH2_DH_GEX_NEW, 1, [Enable newer diffie-hellman-group-exchange-sha1 syntax])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(clear-memory,
|
||||
AC_HELP_STRING([--disable-clear-memory],[Disable clearing of memory before being freed]),
|
||||
[CLEAR_MEMORY=$enableval])
|
||||
if test "$CLEAR_MEMORY" != "no"; then
|
||||
if test "$support_clear_memory" = "yes"; then
|
||||
AC_DEFINE(LIBSSH2_CLEAR_MEMORY, 1, [Enable clearing of memory before being freed])
|
||||
enable_clear_memory=yes
|
||||
else
|
||||
if test "$CLEAR_MEMORY" = "yes"; then
|
||||
AC_MSG_ERROR([secure clearing/zeroing of memory is not supported by the selected crypto backend])
|
||||
else
|
||||
AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend])
|
||||
fi
|
||||
enable_clear_memory=unsupported
|
||||
fi
|
||||
else
|
||||
if test "$support_clear_memory" = "yes"; then
|
||||
enable_clear_memory=no
|
||||
else
|
||||
AC_MSG_WARN([secure clearing/zeroing of memory is not supported by the selected crypto backend])
|
||||
enable_clear_memory=unsupported
|
||||
fi
|
||||
fi
|
||||
|
||||
dnl ************************************************************
|
||||
dnl option to switch on compiler debug options
|
||||
dnl
|
||||
@@ -318,9 +395,10 @@ AC_MSG_NOTICE([summary of build options:
|
||||
Compiler: ${CC}
|
||||
Compiler flags: ${CFLAGS}
|
||||
Library types: Shared=${enable_shared}, Static=${enable_static}
|
||||
Crypto library: openssl: ${ac_cv_libssl:-no} (AES-CTR: ${ac_cv_func_EVP_aes_128_ctr:-N/A}) libgcrypt: ${ac_cv_libgcrypt:-no}
|
||||
Crypto library: ${found_crypto}
|
||||
Clear memory: $enable_clear_memory
|
||||
Debug build: $enable_debug
|
||||
Build examples: $build_examples
|
||||
Path to sshd: $ac_cv_path_SSHD (only for self-tests)
|
||||
libz compression: $ac_cv_libz
|
||||
zlib compression: $ac_cv_libz
|
||||
])
|
||||
|
206
docs/CMakeLists.txt
Normal file
206
docs/CMakeLists.txt
Normal file
@@ -0,0 +1,206 @@
|
||||
# Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
set(MAN_PAGES
|
||||
libssh2_agent_connect.3
|
||||
libssh2_agent_disconnect.3
|
||||
libssh2_agent_free.3
|
||||
libssh2_agent_get_identity.3
|
||||
libssh2_agent_init.3
|
||||
libssh2_agent_list_identities.3
|
||||
libssh2_agent_userauth.3
|
||||
libssh2_banner_set.3
|
||||
libssh2_base64_decode.3
|
||||
libssh2_channel_close.3
|
||||
libssh2_channel_direct_tcpip.3
|
||||
libssh2_channel_direct_tcpip_ex.3
|
||||
libssh2_channel_eof.3
|
||||
libssh2_channel_exec.3
|
||||
libssh2_channel_flush.3
|
||||
libssh2_channel_flush_ex.3
|
||||
libssh2_channel_flush_stderr.3
|
||||
libssh2_channel_forward_accept.3
|
||||
libssh2_channel_forward_cancel.3
|
||||
libssh2_channel_forward_listen.3
|
||||
libssh2_channel_forward_listen_ex.3
|
||||
libssh2_channel_free.3
|
||||
libssh2_channel_get_exit_signal.3
|
||||
libssh2_channel_get_exit_status.3
|
||||
libssh2_channel_handle_extended_data.3
|
||||
libssh2_channel_handle_extended_data2.3
|
||||
libssh2_channel_ignore_extended_data.3
|
||||
libssh2_channel_open_ex.3
|
||||
libssh2_channel_open_session.3
|
||||
libssh2_channel_process_startup.3
|
||||
libssh2_channel_read.3
|
||||
libssh2_channel_read_ex.3
|
||||
libssh2_channel_read_stderr.3
|
||||
libssh2_channel_receive_window_adjust.3
|
||||
libssh2_channel_receive_window_adjust2.3
|
||||
libssh2_channel_request_pty.3
|
||||
libssh2_channel_request_pty_ex.3
|
||||
libssh2_channel_request_pty_size.3
|
||||
libssh2_channel_request_pty_size_ex.3
|
||||
libssh2_channel_send_eof.3
|
||||
libssh2_channel_set_blocking.3
|
||||
libssh2_channel_setenv.3
|
||||
libssh2_channel_setenv_ex.3
|
||||
libssh2_channel_shell.3
|
||||
libssh2_channel_subsystem.3
|
||||
libssh2_channel_wait_closed.3
|
||||
libssh2_channel_wait_eof.3
|
||||
libssh2_channel_window_read.3
|
||||
libssh2_channel_window_read_ex.3
|
||||
libssh2_channel_window_write.3
|
||||
libssh2_channel_window_write_ex.3
|
||||
libssh2_channel_write.3
|
||||
libssh2_channel_write_ex.3
|
||||
libssh2_channel_write_stderr.3
|
||||
libssh2_channel_x11_req.3
|
||||
libssh2_channel_x11_req_ex.3
|
||||
libssh2_exit.3
|
||||
libssh2_free.3
|
||||
libssh2_hostkey_hash.3
|
||||
libssh2_init.3
|
||||
libssh2_keepalive_config.3
|
||||
libssh2_keepalive_send.3
|
||||
libssh2_knownhost_add.3
|
||||
libssh2_knownhost_addc.3
|
||||
libssh2_knownhost_check.3
|
||||
libssh2_knownhost_checkp.3
|
||||
libssh2_knownhost_del.3
|
||||
libssh2_knownhost_free.3
|
||||
libssh2_knownhost_get.3
|
||||
libssh2_knownhost_init.3
|
||||
libssh2_knownhost_readfile.3
|
||||
libssh2_knownhost_readline.3
|
||||
libssh2_knownhost_writefile.3
|
||||
libssh2_knownhost_writeline.3
|
||||
libssh2_poll.3
|
||||
libssh2_poll_channel_read.3
|
||||
libssh2_publickey_add.3
|
||||
libssh2_publickey_add_ex.3
|
||||
libssh2_publickey_init.3
|
||||
libssh2_publickey_list_fetch.3
|
||||
libssh2_publickey_list_free.3
|
||||
libssh2_publickey_remove.3
|
||||
libssh2_publickey_remove_ex.3
|
||||
libssh2_publickey_shutdown.3
|
||||
libssh2_scp_recv.3
|
||||
libssh2_scp_recv2.3
|
||||
libssh2_scp_send.3
|
||||
libssh2_scp_send64.3
|
||||
libssh2_scp_send_ex.3
|
||||
libssh2_session_abstract.3
|
||||
libssh2_session_banner_get.3
|
||||
libssh2_session_banner_set.3
|
||||
libssh2_session_block_directions.3
|
||||
libssh2_session_callback_set.3
|
||||
libssh2_session_disconnect.3
|
||||
libssh2_session_disconnect_ex.3
|
||||
libssh2_session_flag.3
|
||||
libssh2_session_free.3
|
||||
libssh2_session_get_blocking.3
|
||||
libssh2_session_get_timeout.3
|
||||
libssh2_session_hostkey.3
|
||||
libssh2_session_init.3
|
||||
libssh2_session_init_ex.3
|
||||
libssh2_session_last_errno.3
|
||||
libssh2_session_last_error.3
|
||||
libssh2_session_set_last_error.3
|
||||
libssh2_session_method_pref.3
|
||||
libssh2_session_methods.3
|
||||
libssh2_session_set_blocking.3
|
||||
libssh2_session_set_timeout.3
|
||||
libssh2_session_startup.3
|
||||
libssh2_session_supported_algs.3
|
||||
libssh2_sftp_close.3
|
||||
libssh2_sftp_close_handle.3
|
||||
libssh2_sftp_closedir.3
|
||||
libssh2_sftp_fsetstat.3
|
||||
libssh2_sftp_fstat.3
|
||||
libssh2_sftp_fstat_ex.3
|
||||
libssh2_sftp_fstatvfs.3
|
||||
libssh2_sftp_fsync.3
|
||||
libssh2_sftp_get_channel.3
|
||||
libssh2_sftp_init.3
|
||||
libssh2_sftp_last_error.3
|
||||
libssh2_sftp_lstat.3
|
||||
libssh2_sftp_mkdir.3
|
||||
libssh2_sftp_mkdir_ex.3
|
||||
libssh2_sftp_open.3
|
||||
libssh2_sftp_open_ex.3
|
||||
libssh2_sftp_opendir.3
|
||||
libssh2_sftp_read.3
|
||||
libssh2_sftp_readdir.3
|
||||
libssh2_sftp_readdir_ex.3
|
||||
libssh2_sftp_readlink.3
|
||||
libssh2_sftp_realpath.3
|
||||
libssh2_sftp_rename.3
|
||||
libssh2_sftp_rename_ex.3
|
||||
libssh2_sftp_rewind.3
|
||||
libssh2_sftp_rmdir.3
|
||||
libssh2_sftp_rmdir_ex.3
|
||||
libssh2_sftp_seek.3
|
||||
libssh2_sftp_seek64.3
|
||||
libssh2_sftp_setstat.3
|
||||
libssh2_sftp_shutdown.3
|
||||
libssh2_sftp_stat.3
|
||||
libssh2_sftp_stat_ex.3
|
||||
libssh2_sftp_statvfs.3
|
||||
libssh2_sftp_symlink.3
|
||||
libssh2_sftp_symlink_ex.3
|
||||
libssh2_sftp_tell.3
|
||||
libssh2_sftp_tell64.3
|
||||
libssh2_sftp_unlink.3
|
||||
libssh2_sftp_unlink_ex.3
|
||||
libssh2_sftp_write.3
|
||||
libssh2_trace.3
|
||||
libssh2_trace_sethandler.3
|
||||
libssh2_userauth_authenticated.3
|
||||
libssh2_userauth_hostbased_fromfile.3
|
||||
libssh2_userauth_hostbased_fromfile_ex.3
|
||||
libssh2_userauth_keyboard_interactive.3
|
||||
libssh2_userauth_keyboard_interactive_ex.3
|
||||
libssh2_userauth_list.3
|
||||
libssh2_userauth_password.3
|
||||
libssh2_userauth_password_ex.3
|
||||
libssh2_userauth_publickey.3
|
||||
libssh2_userauth_publickey_fromfile.3
|
||||
libssh2_userauth_publickey_fromfile_ex.3
|
||||
libssh2_version.3)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
install(FILES ${MAN_PAGES} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
|
593
docs/HACKING.CRYPTO
Normal file
593
docs/HACKING.CRYPTO
Normal file
@@ -0,0 +1,593 @@
|
||||
Definitions needed to implement a specific crypto library
|
||||
|
||||
This document offers some hints about implementing a new crypto library
|
||||
interface.
|
||||
|
||||
A crypto library interface consists of at least a header file, defining
|
||||
entities referenced from the libssh2 core modules.
|
||||
Real code implementation (if needed), is left at the implementor's choice.
|
||||
|
||||
This document lists the entities that must/may be defined in the header file.
|
||||
|
||||
Procedures listed as "void" may indeed have a result type: the void indication
|
||||
indicates the libssh2 core modules never use the function result.
|
||||
|
||||
|
||||
1) Crypto library initialization/termination.
|
||||
|
||||
void libssh2_crypto_init(void);
|
||||
Initializes the crypto library. May be an empty macro if not needed.
|
||||
|
||||
void libssh2_crypto_exit(void);
|
||||
Terminates the crypto library use. May be an empty macro if not needed.
|
||||
|
||||
|
||||
2) HMAC
|
||||
|
||||
libssh2_hmac_ctx
|
||||
Type of an HMAC computation context. Generally a struct.
|
||||
Used for all hash algorithms.
|
||||
|
||||
void libssh2_hmac_ctx_init(libssh2_hmac_ctx ctx);
|
||||
Initializes the HMAC computation context ctx.
|
||||
Called before setting-up the hash algorithm.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_update(libssh2_hmac_ctx ctx,
|
||||
const unsigned char *data,
|
||||
int datalen);
|
||||
Continue computation of an HMAC on datalen bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_final(libssh2_hmac_ctx ctx,
|
||||
unsigned char output[]);
|
||||
Get the computed HMAC from context ctx into the output buffer. The
|
||||
minimum data buffer size depends on the HMAC hash algorithm.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_cleanup(libssh2_hmac_ctx *ctx);
|
||||
Releases the HMAC computation context at ctx.
|
||||
|
||||
|
||||
3) Hash algorithms.
|
||||
|
||||
3.1) SHA-1
|
||||
Must always be implemented.
|
||||
|
||||
SHA_DIGEST_LENGTH
|
||||
#define to 20, the SHA-1 digest length.
|
||||
|
||||
libssh2_sha1_ctx
|
||||
Type of an SHA1 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha1_init(libssh2_sha1_ctx *x);
|
||||
Initializes the SHA-1 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha1_update(libssh2_sha1_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-1 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha1_final(libssh2_sha1_ctx ctx,
|
||||
unsigned char output[SHA1_DIGEST_LEN]);
|
||||
Get the computed SHA-1 signature from context ctx and store it into the
|
||||
output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_sha1_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-SHA-1 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.2) SHA-256
|
||||
Must always be implemented.
|
||||
|
||||
SHA256_DIGEST_LENGTH
|
||||
#define to 32, the SHA-256 digest length.
|
||||
|
||||
libssh2_sha256_ctx
|
||||
Type of an SHA-256 computation context. Generally a struct.
|
||||
|
||||
int libssh2_sha256_init(libssh2_sha256_ctx *x);
|
||||
Initializes the SHA-256 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_sha256_update(libssh2_sha256_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continue computation of SHA-256 on len bytes at data using context ctx.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_sha256_final(libssh2_sha256_ctx ctx,
|
||||
unsigned char output[SHA256_DIGEST_LENGTH]);
|
||||
Gets the computed SHA-256 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
int libssh2_sha256(const unsigned char *message,
|
||||
unsigned long len,
|
||||
unsigned char output[SHA256_DIGEST_LENGTH]);
|
||||
Computes the SHA-256 signature over the given message of length len and
|
||||
store the result into the output buffer.
|
||||
Return 1 if error, else 0.
|
||||
Note: Seems unused in current code, but defined in each crypto library backend.
|
||||
|
||||
LIBSSH2_HMAC_SHA256
|
||||
#define as 1 if the crypto library supports HMAC-SHA-256, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void libssh2_hmac_sha256_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-256 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.3) SHA-512
|
||||
LIBSSH2_HMAC_SHA512
|
||||
#define as 1 if the crypto library supports HMAC-SHA-512, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
SHA512_DIGEST_LENGTH
|
||||
#define to 64, the SHA-512 digest length.
|
||||
|
||||
void libssh2_hmac_sha512_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-512 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.4) MD5
|
||||
LIBSSH2_MD5
|
||||
#define to 1 if the crypto library supports MD5, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
MD5_DIGEST_LENGTH
|
||||
#define to 16, the MD5 digest length.
|
||||
|
||||
libssh2_md5_ctx
|
||||
Type of an MD5 computation context. Generally a struct.
|
||||
|
||||
int libssh2_md5_init(libssh2_md5_ctx *x);
|
||||
Initializes the MD5 computation context at x.
|
||||
Returns 1 for success and 0 for failure
|
||||
|
||||
void libssh2_md5_update(libssh2_md5_ctx ctx,
|
||||
const unsigned char *data,
|
||||
size_t len);
|
||||
Continues computation of MD5 on len bytes at data using context ctx.
|
||||
Returns 1 for success and 0 for failure.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_md5_final(libssh2_md5_ctx ctx,
|
||||
unsigned char output[MD5_DIGEST_LENGTH]);
|
||||
Gets the computed MD5 signature from context ctx into the output buffer.
|
||||
Release the context.
|
||||
Note: if the ctx parameter is modified by the underlying code,
|
||||
this procedure must be implemented as a macro to map ctx --> &ctx.
|
||||
|
||||
void libssh2_hmac_md5_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-MD5 computation using the
|
||||
keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
|
||||
3.5) RIPEMD-160
|
||||
LIBSSH2_HMAC_RIPEMD
|
||||
#define as 1 if the crypto library supports HMAC-RIPEMD-160, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void libssh2_hmac_ripemd160_init(libssh2_hmac_ctx *ctx,
|
||||
const void *key,
|
||||
int keylen);
|
||||
Setup the HMAC computation context ctx for an HMAC-RIPEMD-160 computation using
|
||||
the keylen-byte key. Is invoked just after libssh2_hmac_ctx_init().
|
||||
Returns 1 for success and 0 for failure.
|
||||
|
||||
|
||||
4) Bidirectional Key ciphers.
|
||||
|
||||
_libssh2_cipher_ctx
|
||||
Type of a cipher computation context.
|
||||
|
||||
_libssh2_cipher_type(name);
|
||||
Macro defining name as storage identifying a cipher algorithm for
|
||||
the crypto library interface. No trailing semicolon.
|
||||
|
||||
int _libssh2_cipher_init(_libssh2_cipher_ctx *h,
|
||||
_libssh2_cipher_type(algo),
|
||||
unsigned char *iv,
|
||||
unsigned char *secret,
|
||||
int encrypt);
|
||||
Creates a cipher context for the given algorithm with the initialization vector
|
||||
iv and the secret key secret. Prepare for encryption or decryption depending on
|
||||
encrypt.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_cipher_crypt(_libssh2_cipher_ctx *ctx,
|
||||
_libssh2_cipher_type(algo),
|
||||
int encrypt,
|
||||
unsigned char *block,
|
||||
size_t blocksize);
|
||||
Encrypt or decrypt in-place data at (block, blocksize) using the given
|
||||
context and/or algorithm.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_cipher_dtor(_libssh2_cipher_ctx *ctx);
|
||||
Release cipher context at ctx.
|
||||
|
||||
4.1) AES
|
||||
4.1.1) AES in CBC block mode.
|
||||
LIBSSH2_AES
|
||||
#define as 1 if the crypto library supports AES in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_aes128
|
||||
AES-128-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes192
|
||||
AES-192-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes256
|
||||
AES-256-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.1.2) AES in CTR block mode.
|
||||
LIBSSH2_AES_CTR
|
||||
#define as 1 if the crypto library supports AES in CTR mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
void _libssh2_init_aes_ctr(void);
|
||||
Initialize static AES CTR ciphers.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
_libssh2_cipher_aes128ctr
|
||||
AES-128-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes192ctr
|
||||
AES-192-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
_libssh2_cipher_aes256ctr
|
||||
AES-256-CTR algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.2) Blowfish in CBC block mode.
|
||||
LIBSSH2_BLOWFISH
|
||||
#define as 1 if the crypto library supports blowfish in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_blowfish
|
||||
Blowfish-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.3) RC4.
|
||||
LIBSSH2_RC4
|
||||
#define as 1 if the crypto library supports RC4 (arcfour), else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_arcfour
|
||||
RC4 algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.4) CAST5 in CBC block mode.
|
||||
LIBSSH2_CAST
|
||||
#define 1 if the crypto library supports cast, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_cast5
|
||||
CAST5-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
4.5) Tripple DES in CBC block mode.
|
||||
LIBSSH2_3DES
|
||||
#define as 1 if the crypto library supports TripleDES in CBC mode, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
_libssh2_cipher_3des
|
||||
TripleDES-CBC algorithm identifier initializer.
|
||||
#define with constant value of type _libssh2_cipher_type().
|
||||
|
||||
|
||||
5) Big numbers.
|
||||
Positive multi-byte integers support is sufficient.
|
||||
|
||||
5.1) Computation contexts.
|
||||
This has a real meaning if the big numbers computations need some context
|
||||
storage. If not, use a dummy type and functions (macros).
|
||||
|
||||
_libssh2_bn_ctx
|
||||
Type of multiple precision computation context. May not be empty. if not used,
|
||||
#define as char, for example.
|
||||
|
||||
libssh2_bn_ctx _libssh2_bn_ctx_new(void);
|
||||
Returns a new multiple precision computation context.
|
||||
|
||||
void _libssh2_bn_ctx_free(_libssh2_bn_ctx ctx);
|
||||
Releases a multiple precision computation context.
|
||||
|
||||
5.2) Computation support.
|
||||
_libssh2_bn
|
||||
Type of multiple precision numbers (aka bignumbers or huge integers) for the
|
||||
crypto library.
|
||||
|
||||
_libssh2_bn * _libssh2_bn_init(void);
|
||||
Creates a multiple precision number (preset to zero).
|
||||
|
||||
_libssh2_bn * _libssh2_bn_init_from_bin(void);
|
||||
Create a multiple precision number intended to be set by the
|
||||
_libssh2_bn_from_bin() function (see below). Unlike _libssh2_bn_init(), this
|
||||
code may be a dummy initializer if the _libssh2_bn_from_bin() actually
|
||||
allocates the number. Returns a value of type _libssh2_bn *.
|
||||
|
||||
void _libssh2_bn_free(_libssh2_bn *bn);
|
||||
Destroys the multiple precision number at bn.
|
||||
|
||||
unsigned long _libssh2_bn_bytes(libssh2_bn *bn);
|
||||
Get the number of bytes needed to store the bits of the multiple precision
|
||||
number at bn.
|
||||
|
||||
unsigned long _libssh2_bn_bits(_libssh2_bn *bn);
|
||||
Returns the number of bits of multiple precision number at bn.
|
||||
|
||||
int _libssh2_bn_set_word(_libssh2_bn *bn, unsigned long val);
|
||||
Sets the value of bn to val.
|
||||
Returns 1 on success, 0 otherwise.
|
||||
|
||||
_libssh2_bn * _libssh2_bn_from_bin(_libssh2_bn *bn, int len,
|
||||
const unsigned char *val);
|
||||
Converts the positive integer in big-endian form of length len at val
|
||||
into a _libssh2_bn and place it in bn. If bn is NULL, a new _libssh2_bn is
|
||||
created.
|
||||
Returns a pointer to target _libssh2_bn or NULL if error.
|
||||
|
||||
int _libssh2_bn_to_bin(_libssh2_bn *bn, unsigned char *val);
|
||||
Converts the absolute value of bn into big-endian form and store it at
|
||||
val. val must point to _libssh2_bn_bytes(bn) bytes of memory.
|
||||
Returns the length of the big-endian number.
|
||||
|
||||
void _libssh2_bn_rand(_libssh2_bn *bn, int bits, int top, int bottom);
|
||||
Generates a cryptographically strong pseudo-random number of bits in
|
||||
length and stores it in bn. If top is -1, the most significant bit of the
|
||||
random number can be zero. If top is 0, it is set to 1, and if top is 1, the
|
||||
two most significant bits of the number will be set to 1, so that the product
|
||||
of two such random numbers will always have 2*bits length. If bottom is true,
|
||||
the number will be odd.
|
||||
|
||||
void _libssh2_bn_mod_exp(_libssh2_bn *r, _libssh2_bn *a,
|
||||
_libssh2_bn *p, _libssh2_bn *m,
|
||||
_libssh2_bn_ctx *ctx);
|
||||
Computes a to the p-th power modulo m and stores the result into r (r=a^p % m).
|
||||
May use the given context.
|
||||
|
||||
|
||||
6) Private key algorithms.
|
||||
Format of an RSA public key:
|
||||
a) "ssh-rsa".
|
||||
b) RSA exponent, MSB first, with high order bit = 0.
|
||||
c) RSA modulus, MSB first, with high order bit = 0.
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
Format of a DSA public key:
|
||||
a) "ssh-dss".
|
||||
b) p, MSB first, with high order bit = 0.
|
||||
c) q, MSB first, with high order bit = 0.
|
||||
d) g, MSB first, with high order bit = 0.
|
||||
e) pub_key, MSB first, with high order bit = 0.
|
||||
Each item is preceded by its 32-bit byte length, MSB first.
|
||||
|
||||
int _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
Reads a private key from file privatekey and extract the public key -->
|
||||
(pubkeydata, pubkeydata_len). Store the associated method (ssh-rsa or ssh-dss)
|
||||
into (method, method_len).
|
||||
Both buffers have to be allocated using LIBSSH2_ALLOC().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||
unsigned char **method,
|
||||
size_t *method_len,
|
||||
unsigned char **pubkeydata,
|
||||
size_t *pubkeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
Gets a private key from bytes at (privatekeydata, privatekeydata_len) and
|
||||
extract the public key --> (pubkeydata, pubkeydata_len). Store the associated
|
||||
method (ssh-rsa or ssh-dss) into (method, method_len).
|
||||
Both buffers have to be allocated using LIBSSH2_ALLOC().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
6.1) RSA
|
||||
LIBSSH2_RSA
|
||||
#define as 1 if the crypto library supports RSA, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
libssh2_rsa_ctx
|
||||
Type of an RSA computation context. Generally a struct.
|
||||
|
||||
int _libssh2_rsa_new(libssh2_rsa_ctx **rsa,
|
||||
const unsigned char *edata,
|
||||
unsigned long elen,
|
||||
const unsigned char *ndata,
|
||||
unsigned long nlen,
|
||||
const unsigned char *ddata,
|
||||
unsigned long dlen,
|
||||
const unsigned char *pdata,
|
||||
unsigned long plen,
|
||||
const unsigned char *qdata,
|
||||
unsigned long qlen,
|
||||
const unsigned char *e1data,
|
||||
unsigned long e1len,
|
||||
const unsigned char *e2data,
|
||||
unsigned long e2len,
|
||||
const unsigned char *coeffdata, unsigned long coefflen);
|
||||
Creates a new context for RSA computations from key source values:
|
||||
pdata, plen Prime number p. Only used if private key known (ddata).
|
||||
qdata, qlen Prime number q. Only used if private key known (ddata).
|
||||
ndata, nlen Modulus n.
|
||||
edata, elen Exponent e.
|
||||
ddata, dlen e^-1 % phi(n) = private key. May be NULL if unknown.
|
||||
e1data, e1len dp = d % (p-1). Only used if private key known (dtata).
|
||||
e2data, e2len dq = d % (q-1). Only used if private key known (dtata).
|
||||
coeffdata, coefflen q^-1 % p. Only used if private key known.
|
||||
Returns 0 if OK.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
Note: the current generic code only calls this function with e and n (public
|
||||
key parameters): unless used internally by the backend, it is not needed to
|
||||
support the private key and the other parameters here.
|
||||
|
||||
int _libssh2_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Reads an RSA private key from file filename into a new RSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *data,
|
||||
size_t data_len,
|
||||
unsigned const char *passphrase);
|
||||
Gets an RSA private key from data into a new RSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_sha1_verify(libssh2_rsa_ctx *rsa,
|
||||
const unsigned char *sig,
|
||||
unsigned long sig_len,
|
||||
const unsigned char *m, unsigned long m_len);
|
||||
Verify (sig, siglen) signature of (m, m_len) using an SHA-1 hash and the
|
||||
RSA context.
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_rsa_sha1_signv(LIBSSH2_SESSION *session,
|
||||
unsigned char **sig, size_t *siglen,
|
||||
int count, const struct iovec vector[],
|
||||
libssh2_rsa_ctx *ctx);
|
||||
RSA signs the SHA-1 hash computed over the count data chunks in vector.
|
||||
Signature is stored at (sig, siglen).
|
||||
Signature buffer must be allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
Note: this procedure is optional: if provided, it MUST be defined as a macro.
|
||||
|
||||
int _libssh2_rsa_sha1_sign(LIBSSH2_SESSION *session,
|
||||
libssh2_rsa_ctx *rsactx,
|
||||
const unsigned char *hash,
|
||||
size_t hash_len,
|
||||
unsigned char **signature,
|
||||
size_t *signature_len);
|
||||
RSA signs the (hash, hashlen) SHA-1 hash bytes and stores the allocated
|
||||
signature at (signature, signature_len).
|
||||
Signature buffer must be allocated from the given session.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
Note: this procedure is not used if macro _libssh2_rsa_sha1_signv() is defined.
|
||||
|
||||
void _libssh2_rsa_free(libssh2_rsa_ctx *rsactx);
|
||||
Releases the RSA computation context at rsactx.
|
||||
|
||||
|
||||
6.2) DSA
|
||||
LIBSSH2_DSA
|
||||
#define as 1 if the crypto library supports DSA, else 0.
|
||||
If defined as 0, the rest of this section can be omitted.
|
||||
|
||||
|
||||
libssh2_dsa_ctx
|
||||
Type of a DSA computation context. Generally a struct.
|
||||
|
||||
int _libssh2_dsa_new(libssh2_dsa_ctx **dsa,
|
||||
const unsigned char *pdata,
|
||||
unsigned long plen,
|
||||
const unsigned char *qdata,
|
||||
unsigned long qlen,
|
||||
const unsigned char *gdata,
|
||||
unsigned long glen,
|
||||
const unsigned char *ydata,
|
||||
unsigned long ylen,
|
||||
const unsigned char *x, unsigned long x_len);
|
||||
Creates a new context for DSA computations from source key values:
|
||||
pdata, plen Prime number p. Only used if private key known (ddata).
|
||||
qdata, qlen Prime number q. Only used if private key known (ddata).
|
||||
gdata, glen G number.
|
||||
ydata, ylen Public key.
|
||||
xdata, xlen Private key. Only taken if xlen non-zero.
|
||||
Returns 0 if OK.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_new_private(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *filename,
|
||||
unsigned const char *passphrase);
|
||||
Gets a DSA private key from file filename into a new DSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Return 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx **dsa,
|
||||
LIBSSH2_SESSION *session,
|
||||
const char *data,
|
||||
size_t data_len,
|
||||
unsigned const char *passphrase);
|
||||
Gets a DSA private key from the data_len-bytes data into a new DSA context.
|
||||
Must call _libssh2_init_if_needed().
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_sha1_verify(libssh2_dsa_ctx *dsactx,
|
||||
const unsigned char *sig,
|
||||
const unsigned char *m, unsigned long m_len);
|
||||
Verify (sig, siglen) signature of (m, m_len) using an SHA1 hash and the
|
||||
DSA context.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
int _libssh2_dsa_sha1_sign(libssh2_dsa_ctx *dsactx,
|
||||
const unsigned char *hash,
|
||||
unsigned long hash_len, unsigned char *sig);
|
||||
DSA signs the (hash, hash_len) data using SHA-1 and store the signature at sig.
|
||||
Returns 0 if OK, else -1.
|
||||
This procedure is already prototyped in crypto.h.
|
||||
|
||||
void _libssh2_dsa_free(libssh2_dsa_ctx *dsactx);
|
||||
Releases the DSA computation context at dsactx.
|
||||
|
||||
|
||||
7) Miscellaneous
|
||||
|
||||
void libssh2_prepare_iovec(struct iovec *vector, unsigned int len);
|
||||
Prepare len consecutive iovec slots before using them.
|
||||
In example, this is needed to preset unused structure slacks on platforms
|
||||
requiring it.
|
||||
If this is not needed, it should be defined as an empty macro.
|
||||
|
||||
void _libssh2_random(unsigned char *buf, int len);
|
||||
Store len random bytes at buf.
|
325
docs/INSTALL_AUTOTOOLS
Normal file
325
docs/INSTALL_AUTOTOOLS
Normal file
@@ -0,0 +1,325 @@
|
||||
Installation Instructions
|
||||
*************************
|
||||
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free
|
||||
Software Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that the
|
||||
`configure' script does not know about. Run `./configure --help' for
|
||||
details on some of the pertinent environment variables.
|
||||
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' installs the package's commands under
|
||||
`/usr/local/bin', include files under `/usr/local/include', etc. You
|
||||
can specify an installation prefix other than `/usr/local' by giving
|
||||
`configure' the option `--prefix=PREFIX'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
|
||||
PREFIX as the prefix for installing programs and libraries.
|
||||
Documentation and other data files still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=DIR' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' cannot figure out automatically,
|
||||
but needs to determine by the type of machine the package will run on.
|
||||
Usually, assuming the package is built to be run on the _same_
|
||||
architectures, `configure' can figure that out, but if it prints a
|
||||
message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the option `--target=TYPE' to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share, you
|
||||
can create a site shell script called `config.site' that gives default
|
||||
values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
causes the specified `gcc' to be used as the C compiler (unless it is
|
||||
overridden in the site shell script). Here is a another example:
|
||||
|
||||
/bin/bash ./configure CONFIG_SHELL=/bin/bash
|
||||
|
||||
Here the `CONFIG_SHELL=/bin/bash' operand causes subsequent
|
||||
configuration-related scripts to be executed by `/bin/bash'.
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it operates.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
More configure options
|
||||
======================
|
||||
|
||||
Some ./configure options deserve additional comments:
|
||||
|
||||
* --enable-crypt-none
|
||||
|
||||
The SSH2 Transport allows for unencrypted data
|
||||
transmission using the "none" cipher. Because this is
|
||||
such a huge security hole, it is typically disabled on
|
||||
SSH2 implementations and is disabled in libssh2 by
|
||||
default as well.
|
||||
|
||||
Enabling this option will allow for "none" as a
|
||||
negotiable method, however it still requires that the
|
||||
method be advertized by the remote end and that no
|
||||
more-preferable methods are available.
|
||||
|
||||
* --enable-mac-none
|
||||
|
||||
The SSH2 Transport also allows implementations to
|
||||
forego a message authentication code. While this is
|
||||
less of a security risk than using a "none" cipher, it
|
||||
is still not recommended as disabling MAC hashes
|
||||
removes a layer of security.
|
||||
|
||||
Enabling this option will allow for "none" as a
|
||||
negotiable method, however it still requires that the
|
||||
method be advertized by the remote end and that no
|
||||
more-preferable methods are available.
|
||||
|
||||
* --disable-gex-new
|
||||
|
||||
The diffie-hellman-group-exchange-sha1 (dh-gex) key
|
||||
exchange method originally defined an exchange
|
||||
negotiation using packet type 30 to request a
|
||||
generation pair based on a single target value. Later
|
||||
refinement of dh-gex provided for range and target
|
||||
values. By default libssh2 will use the newer range
|
||||
method.
|
||||
|
||||
If you experience trouble connecting to an old SSH
|
||||
server using dh-gex, try this option to fallback on
|
||||
the older more reliable method.
|
||||
|
||||
* --with-libgcrypt
|
||||
* --without-libgcrypt
|
||||
* --with-libgcrypt-prefix=DIR
|
||||
|
||||
libssh2 can use the Libgcrypt library
|
||||
(http://www.gnupg.org/) for cryptographic operations.
|
||||
Either Libgcrypt or OpenSSL is required.
|
||||
|
||||
Configure will attempt to locate Libgcrypt
|
||||
automatically.
|
||||
|
||||
If your installation of Libgcrypt is in another
|
||||
location, specify it using --with-libgcrypt-prefix.
|
||||
|
||||
* --with-openssl
|
||||
* --without-openssl
|
||||
* --with-libssl-prefix=[DIR]
|
||||
|
||||
libssh2 can use the OpenSSL library
|
||||
(http://www.openssl.org) for cryptographic operations.
|
||||
Either Libgcrypt or OpenSSL is required.
|
||||
|
||||
Configure will attempt to locate OpenSSL in the
|
||||
default location.
|
||||
|
||||
If your installation of OpenSSL is in another
|
||||
location, specify it using --with-libssl-prefix.
|
||||
|
||||
* --with-libz
|
||||
* --without-libz
|
||||
* --with-libz-prefix=[DIR]
|
||||
|
||||
If present, libssh2 will attempt to use the zlib
|
||||
(http://www.zlib.org) for payload compression, however
|
||||
zlib is not required.
|
||||
|
||||
If your installation of Libz is in another location,
|
||||
specify it using --with-libz-prefix.
|
||||
|
||||
* --enable-debug
|
||||
|
||||
Will make the build use more pedantic and strict compiler
|
||||
options as well as enable the libssh2_trace() function (for
|
||||
showing debug traces).
|
174
docs/INSTALL_CMAKE
Normal file
174
docs/INSTALL_CMAKE
Normal file
@@ -0,0 +1,174 @@
|
||||
License: see COPYING
|
||||
|
||||
Source code: https://github.com/libssh2/libssh2
|
||||
|
||||
Web site source code: https://github.com/libssh2/www
|
||||
|
||||
Installation instructions are in docs/INSTALL
|
||||
=======
|
||||
To build libssh2 you will need CMake v2.8 or later [1] and one of the
|
||||
following cryptography libraries:
|
||||
|
||||
* OpenSSL
|
||||
* Libgcrypt
|
||||
* WinCNG
|
||||
|
||||
Getting started
|
||||
---------------
|
||||
|
||||
If you are happy with the default options, make a new build directory,
|
||||
change to it, configure the build environment and build the project:
|
||||
|
||||
mkdir bin
|
||||
cd bin
|
||||
cmake ..
|
||||
cmake --build .
|
||||
|
||||
libssh2 will be built as a static library and will use any
|
||||
cryptography library available. The library binary will be put in
|
||||
`bin/src`, with the examples in `bin/example` and the tests in
|
||||
`bin/tests`.
|
||||
|
||||
Customising the build
|
||||
---------------------
|
||||
|
||||
Of course, you might want to customise the build options. You can
|
||||
pass the options to CMake on the command line:
|
||||
|
||||
cmake -D<option>=<value> ..
|
||||
|
||||
The following options are available:
|
||||
|
||||
* `BUILD_SHARED_LIBS=OFF`
|
||||
|
||||
Determines whether libssh2 is built as a static library or as a
|
||||
shared library (.dll/.so). Can be `ON` or `OFF`.
|
||||
|
||||
* `CRYPTO_BACKEND=`
|
||||
|
||||
Chooses a specific cryptography library to use for cryptographic
|
||||
operations. Can be `OpenSSL` (http://www.openssl.org),
|
||||
`Libgcrypt` (http://www.gnupg.org/), `WinCNG` (Windows Vista+) or
|
||||
blank to use any library available.
|
||||
|
||||
CMake will attempt to locate the libraries automatically. See [2]
|
||||
for more information.
|
||||
|
||||
* `ENABLE_ZLIB_COMPRESSION=OFF`
|
||||
|
||||
Will use zlib (http://www.zlib.org) for payload compression. Can
|
||||
be `ON` or `OFF`.
|
||||
|
||||
* `ENABLE_CRYPT_NONE=OFF`
|
||||
|
||||
The SSH2 Transport allows for unencrypted data transmission using
|
||||
the "none" cipher. Because this is such a huge security hole, it
|
||||
is typically disabled on SSH2 implementations and is disabled in
|
||||
libssh2 by default as well.
|
||||
|
||||
Enabling this option will allow for "none" as a negotiable method,
|
||||
however it still requires that the method be advertized by the
|
||||
remote end and that no more-preferable methods are available.
|
||||
|
||||
* `ENABLE_MAC_NONE=OFF`
|
||||
|
||||
The SSH2 Transport also allows implementations to forego a message
|
||||
authentication code. While this is less of a security risk than
|
||||
using a "none" cipher, it is still not recommended as disabling
|
||||
MAC hashes removes a layer of security.
|
||||
|
||||
Enabling this option will allow for "none" as a negotiable method,
|
||||
however it still requires that the method be advertized by the
|
||||
remote end and that no more-preferable methods are available.
|
||||
|
||||
* `ENABLE_GEX_NEW=ON`
|
||||
|
||||
The diffie-hellman-group-exchange-sha1 (dh-gex) key exchange
|
||||
method originally defined an exchange negotiation using packet
|
||||
type 30 to request a generation pair based on a single target
|
||||
value. Later refinement of dh-gex provided for range and target
|
||||
values. By default libssh2 will use the newer range method.
|
||||
|
||||
If you experience trouble connecting to an old SSH server using
|
||||
dh-gex, try this option to fallback on the older more reliable
|
||||
method.
|
||||
|
||||
* `ENABLE_DEBUG_LOGGING=ON` in Debug, `=OFF` in Release
|
||||
|
||||
Will enable the libssh2_trace() function for showing debug traces.
|
||||
|
||||
Build tools
|
||||
-----------
|
||||
|
||||
The previous examples used CMake to start the build using:
|
||||
|
||||
cmake --build .
|
||||
|
||||
Alternatively, once CMake has configured your project, you can just
|
||||
use your own build tool, e.g GNU make, Visual Studio, etc., from that
|
||||
point onwards.
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
To test the build, run the appropriate test target for your build
|
||||
system. For example:
|
||||
|
||||
cmake --build . --target test
|
||||
or
|
||||
cmake --build . --target RUN_TESTS
|
||||
|
||||
How do I use libssh2 in my project if my project doesn't use CMake?
|
||||
-------------------------------------------------------------------
|
||||
|
||||
If you are not using CMake for your own project, install libssh2
|
||||
|
||||
cmake <libssh2 source location>
|
||||
cmake --build .
|
||||
cmake --build . --target install
|
||||
or
|
||||
cmake --build . --target INSTALL
|
||||
|
||||
and then specify the install location to your project in the normal
|
||||
way for your build environment. If you don't like the default install
|
||||
location, add `-DCMAKE_INSTALL_PREFIX=<chosen prefix>` when initially
|
||||
configuring the project.
|
||||
|
||||
How can I use libssh2 in my project if it also uses CMake?
|
||||
----------------------------------------------------------
|
||||
|
||||
If your own project also uses CMake, you don't need to worry about
|
||||
setting it up with libssh2's location. Just add just the following
|
||||
lines and CMake will find libssh2 on your system, set up the necessary
|
||||
paths and link the library with your binary.
|
||||
|
||||
find_package(Libssh2 REQUIRED CONFIG)
|
||||
target_link_libraries(my_project_target Libssh2::libssh2)
|
||||
|
||||
Of course, you still have to make libssh2 available on your system
|
||||
first. You can install it in the traditional way shown above, but you
|
||||
don't have to. Instead you can just build it, which will export its
|
||||
location to the user package registry [3] where `find_package` will
|
||||
find it.
|
||||
|
||||
You can even combine the two steps using a so-called 'superbuild'
|
||||
project [4] that downloads, builds and exports libssh2, and then
|
||||
builds your project:
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
ExternalProject_Add(
|
||||
Libssh2
|
||||
URL <libssh2 download location>
|
||||
URL_HASH SHA1=<libssh2 archive SHA1>
|
||||
INSTALL_COMMAND "")
|
||||
|
||||
ExternalProject_Add(
|
||||
MyProject DEPENDS Libssh2
|
||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src
|
||||
INSTALL_COMMAND "")
|
||||
|
||||
[1] http://www.cmake.org/cmake/resources/software.html
|
||||
[2] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
|
||||
[3] http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#package-registry
|
||||
[4] http://www.kitware.com/media/html/BuildingExternalProjectsWithCMake2.8.html
|
@@ -1,6 +1,7 @@
|
||||
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
|
||||
|
||||
EXTRA_DIST = template.3 BINDINGS
|
||||
EXTRA_DIST = template.3 BINDINGS INSTALL_AUTOTOOLS INSTALL_CMAKE HACKING TODO \
|
||||
AUTHORS CMakeLists.txt HACKING.CRYPTO
|
||||
|
||||
dist_man_MANS = \
|
||||
libssh2_agent_connect.3 \
|
||||
@@ -88,6 +89,7 @@ dist_man_MANS = \
|
||||
libssh2_publickey_remove_ex.3 \
|
||||
libssh2_publickey_shutdown.3 \
|
||||
libssh2_scp_recv.3 \
|
||||
libssh2_scp_recv2.3 \
|
||||
libssh2_scp_send.3 \
|
||||
libssh2_scp_send64.3 \
|
||||
libssh2_scp_send_ex.3 \
|
||||
@@ -102,11 +104,13 @@ dist_man_MANS = \
|
||||
libssh2_session_free.3 \
|
||||
libssh2_session_get_blocking.3 \
|
||||
libssh2_session_get_timeout.3 \
|
||||
libssh2_session_handshake.3 \
|
||||
libssh2_session_hostkey.3 \
|
||||
libssh2_session_init.3 \
|
||||
libssh2_session_init_ex.3 \
|
||||
libssh2_session_last_errno.3 \
|
||||
libssh2_session_last_error.3 \
|
||||
libssh2_session_set_last_error.3 \
|
||||
libssh2_session_method_pref.3 \
|
||||
libssh2_session_methods.3 \
|
||||
libssh2_session_set_blocking.3 \
|
||||
@@ -120,6 +124,7 @@ dist_man_MANS = \
|
||||
libssh2_sftp_fstat.3 \
|
||||
libssh2_sftp_fstat_ex.3 \
|
||||
libssh2_sftp_fstatvfs.3 \
|
||||
libssh2_sftp_fsync.3 \
|
||||
libssh2_sftp_get_channel.3 \
|
||||
libssh2_sftp_init.3 \
|
||||
libssh2_sftp_last_error.3 \
|
||||
@@ -166,4 +171,5 @@ dist_man_MANS = \
|
||||
libssh2_userauth_publickey.3 \
|
||||
libssh2_userauth_publickey_fromfile.3 \
|
||||
libssh2_userauth_publickey_fromfile_ex.3 \
|
||||
libssh2_userauth_publickey_frommemory.3 \
|
||||
libssh2_version.3
|
||||
|
@@ -1,6 +1,6 @@
|
||||
.TH libssh2_banner_set 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_banner_set - set the SSH prococol banner for the local client
|
||||
libssh2_banner_set - set the SSH protocol banner for the local client
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
|
@@ -19,7 +19,7 @@ The returned buffer is allocated by this function, but it is not clear how to
|
||||
free that memory!
|
||||
.SH BUGS
|
||||
The memory that *dest points to is allocated by the malloc function libssh2
|
||||
uses, but there's no way for an appliction to free this data in a safe and
|
||||
uses, but there's no way for an application to free this data in a safe and
|
||||
reliable way!
|
||||
.SH RETURN VALUE
|
||||
0 if successful, \-1 if any error occurred.
|
||||
|
@@ -8,7 +8,7 @@ int
|
||||
libssh2_channel_get_exit_status(LIBSSH2_CHANNEL* channel)
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIchannel\fP - Closed channel stream to retreive exit status from.
|
||||
\fIchannel\fP - Closed channel stream to retrieve exit status from.
|
||||
|
||||
Returns the exit code raised by the process running on the remote host at
|
||||
the other end of the named channel. Note that the exit status may not be
|
||||
|
@@ -4,7 +4,7 @@ libssh2_channel_window_write - convenience macro for \fIlibssh2_channel_window_w
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
unsigend long libssh2_channel_window_write(LIBSSH2_CHANNEL *channel);
|
||||
unsigned long libssh2_channel_window_write(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
|
@@ -9,11 +9,11 @@ libssh2_channel_window_write_ex(LIBSSH2_CHANNEL *channel,
|
||||
unsigned long *window_size_initial)
|
||||
.SH DESCRIPTION
|
||||
Check the status of the write window Returns the number of bytes which may be
|
||||
safely writen on the channel without blocking. 'window_size_initial' (if
|
||||
safely written on the channel without blocking. 'window_size_initial' (if
|
||||
passed) will be populated with the size of the initial window as defined by
|
||||
the channel_open request
|
||||
.SH RETURN VALUE
|
||||
Number of bytes which may be safely writen on the channel without blocking.
|
||||
Number of bytes which may be safely written on the channel without blocking.
|
||||
.SH ERRORS
|
||||
|
||||
.SH SEE ALSO
|
||||
|
@@ -36,7 +36,7 @@ The salt has to be provided base64 encoded with a trailing zero byte.
|
||||
argument
|
||||
|
||||
\fItypemask\fP is a bitmask that specifies format and info about the data
|
||||
passed to this function. Specificly, it details what format the host name is,
|
||||
passed to this function. Specifically, it details what format the host name is,
|
||||
what format the key is and what key type it is.
|
||||
|
||||
The host name is given as one of the following types:
|
||||
|
@@ -40,7 +40,7 @@ argument
|
||||
\fIcommentlen\fP is the total size in bytes of the comment pointed to by the \fIcomment\fP argument
|
||||
|
||||
\fItypemask\fP is a bitmask that specifies format and info about the data
|
||||
passed to this function. Specificly, it details what format the host name is,
|
||||
passed to this function. Specifically, it details what format the host name is,
|
||||
what format the key is and what key type it is.
|
||||
|
||||
The host name is given as one of the following types:
|
||||
|
@@ -25,7 +25,7 @@ IP numerical address of the host or the full name.
|
||||
argument
|
||||
|
||||
\fItypemask\fP is a bitmask that specifies format and info about the data
|
||||
passed to this function. Specificly, it details what format the host name is,
|
||||
passed to this function. Specifically, it details what format the host name is,
|
||||
what format the key is and what key type it is.
|
||||
|
||||
The host name is given as one of the following types:
|
||||
|
@@ -30,7 +30,7 @@ addition to the plain host name only check.
|
||||
argument
|
||||
|
||||
\fItypemask\fP is a bitmask that specifies format and info about the data
|
||||
passed to this function. Specificly, it details what format the host name is,
|
||||
passed to this function. Specifically, it details what format the host name is,
|
||||
what format the key is and what key type it is.
|
||||
|
||||
The host name is given as one of the following types:
|
||||
|
@@ -8,7 +8,7 @@ int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds, long timeout);
|
||||
.SH DESCRIPTION
|
||||
This function is deprecated. Do note use. We encourage users to instead use
|
||||
the \fIpoll(3)\fP or \fIselect(3)\fP functions to check for socket activity or
|
||||
when specific sockets are ready to get recevied from or send to.
|
||||
when specific sockets are ready to get received from or send to.
|
||||
|
||||
Poll for activity on a socket, channel, listener, or any combination of these
|
||||
three types. The calling semantics for this function generally match
|
||||
|
@@ -8,6 +8,9 @@ LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat *sb);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This function is \fBDEPRECATED\fP. Use \fIlibssh2_scp_recv2(3)\fP
|
||||
instead!
|
||||
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
|
32
docs/libssh2_scp_recv2.3
Normal file
32
docs/libssh2_scp_recv2.3
Normal file
@@ -0,0 +1,32 @@
|
||||
.TH libssh2_scp_recv2 3 "29 Jun 2015" "libssh2 1.6.1" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_scp_recv2 - request a remote file via SCP
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
LIBSSH2_CHANNEL *
|
||||
libssh2_scp_recv2(LIBSSH2_SESSION *session, const char *path, struct_stat *sb);
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIpath\fP - Full path and filename of file to transfer. That is the remote
|
||||
file name.
|
||||
|
||||
\fIsb\fP - Populated with remote file's size, mode, mtime, and atime
|
||||
|
||||
Request a file from the remote host via SCP.
|
||||
.SH RETURN VALUE
|
||||
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
\fILIBSSH2_ERROR_SCP_PROTOCOL\fP -
|
||||
|
||||
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would
|
||||
block.
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_init_ex(3)
|
||||
.BR libssh2_channel_open_ex(3)
|
||||
|
@@ -17,7 +17,7 @@ de-referenced pointer, the internal storage of the session instance may be
|
||||
modified in place.
|
||||
|
||||
.SH RETURN VALUE
|
||||
A pointer to session internal storage whos contents point to previously
|
||||
A pointer to session internal storage who's contents point to previously
|
||||
provided abstract data.
|
||||
|
||||
.SH SEE ALSO
|
||||
|
@@ -1,6 +1,6 @@
|
||||
.TH libssh2_session_banner_set 3 "9 Sep 2011" "libssh2 1.4.0" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_session_banner_set - set the SSH prococol banner for the local client
|
||||
libssh2_session_banner_set - set the SSH protocol banner for the local client
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
|
@@ -18,7 +18,7 @@ libssh2_session_disconnect(LIBSSH2_SESSION *session, const char *description);
|
||||
|
||||
\fIdescription\fP - Human readable reason for disconnection.
|
||||
|
||||
\fIlang\fP - Localization string describing the langauge/encoding of the description provided.
|
||||
\fIlang\fP - Localization string describing the language/encoding of the description provided.
|
||||
|
||||
Send a disconnect message to the remote host associated with \fIsession\fP,
|
||||
along with a \fIreason\fP symbol and a verbose \fIdescription\fP.
|
||||
|
@@ -18,3 +18,4 @@ Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_error(3)
|
||||
.BR libssh2_session_set_last_error(3)
|
||||
|
@@ -29,3 +29,4 @@ Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_errno(3)
|
||||
.BR libssh2_session_set_last_error(3)
|
||||
|
@@ -19,7 +19,7 @@ If a method is listed which is not supported by libssh2 it will be
|
||||
ignored and not sent to the remote host during protocol negotiation.
|
||||
|
||||
Set preferred methods to be negotiated. These
|
||||
preferrences must be set prior to calling
|
||||
preferences must be set prior to calling
|
||||
.BR libssh2_session_handshake(3)
|
||||
as they are used during the protocol initiation phase.
|
||||
|
||||
|
33
docs/libssh2_session_set_last_error.3
Normal file
33
docs/libssh2_session_set_last_error.3
Normal file
@@ -0,0 +1,33 @@
|
||||
.TH libssh2_session_set_last_error 3 "26 Oct 2015" "libssh2 1.6.1" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_session_set_last_error - sets the internal error state
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
int
|
||||
libssh2_session_set_last_error(LIBSSH2_SESSION *session, int errcode, const char *errmsg)
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIerrcode\fP - One of the error codes as defined in the public
|
||||
libssh2 header file.
|
||||
|
||||
\fIerrmsg\fP - If not NULL, a copy of the given string is stored
|
||||
inside the session object as the error message.
|
||||
|
||||
This function is provided for high level language wrappers
|
||||
(i.e. Python or Perl) and other libraries that may extend libssh2 with
|
||||
additional features while still relying on its error reporting
|
||||
mechanism.
|
||||
|
||||
.SH RETURN VALUE
|
||||
Numeric error code corresponding to the the Error Code constants.
|
||||
|
||||
.SH AVAILABILITY
|
||||
Added in 1.6.1
|
||||
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_last_error(3)
|
||||
.BR libssh2_session_last_errno(3)
|
@@ -12,7 +12,7 @@ int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
|
||||
\fIsession\fP - An instance of initialized LIBSSH2_SESSION (the function will
|
||||
use its pointer to the memory allocation function). \fImethod_type\fP - Method
|
||||
type. See .BR \fIlibssh2_session_method_pref(3)\fP. \fIalgs\fP - Address of a
|
||||
pointer that will point to an array af returned algorithms
|
||||
pointer that will point to an array of returned algorithms
|
||||
|
||||
Get a list of supported algorithms for the given \fImethod_type\fP. The
|
||||
method_type parameter is equivalent to method_type in
|
||||
@@ -36,7 +36,7 @@ const char **algorithms;
|
||||
int rc, i;
|
||||
LIBSSH2_SESSION *session;
|
||||
|
||||
/* initilize session */
|
||||
/* initialize session */
|
||||
session = libssh2_session_init();
|
||||
rc = libssh2_session_supported_algs(session,
|
||||
LIBSSH2_METHOD_CRYPT_CS,
|
||||
|
@@ -20,7 +20,7 @@ or \fBlibssh2_sftp_opendir(3)\fP (which is a macro).
|
||||
|
||||
Close an active LIBSSH2_SFTP_HANDLE. Because files and directories share the
|
||||
same underlying storage mechanism these methods may be used
|
||||
interchangably. \fBlibssh2_sftp_close(3)\fP and \fBlibssh2_sftp_closedir(3)\fP
|
||||
interchangeably. \fBlibssh2_sftp_close(3)\fP and \fBlibssh2_sftp_closedir(3)\fP
|
||||
are macros for \fBlibssh2_sftp_close_handle(3)\fP.
|
||||
|
||||
.SH RETURN VALUE
|
||||
|
@@ -10,7 +10,7 @@ int
|
||||
libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *handle,
|
||||
LIBSSH2_SFTP_ATTRIBUTES *attrs, int setstat)
|
||||
|
||||
#define libbssh2_sftp_fstat(handle, attrs) \\
|
||||
#define libssh2_sftp_fstat(handle, attrs) \\
|
||||
libssh2_sftp_fstat_ex((handle), (attrs), 0)
|
||||
#define libssh2_sftp_fsetstat(handle, attrs) \\
|
||||
libssh2_sftp_fstat_ex((handle), (attrs), 1)
|
||||
@@ -60,7 +60,7 @@ most common ones are:
|
||||
|
||||
To check for specific user permissions, the set of defines are in the
|
||||
pattern LIBSSH2_SFTP_S_I<action><who> where <action> is R, W or X for
|
||||
read, write and excutable and <who> is USR, GRP and OTH for user,
|
||||
read, write and executable and <who> is USR, GRP and OTH for user,
|
||||
group and other. So, you check for a user readable file, use the bit
|
||||
\fILIBSSH2_SFTP_S_IRUSR\fP while you want to see if it is executable
|
||||
for other, you use \fILIBSSH2_SFTP_S_IXOTH\fP and so on.
|
||||
|
39
docs/libssh2_sftp_fsync.3
Normal file
39
docs/libssh2_sftp_fsync.3
Normal file
@@ -0,0 +1,39 @@
|
||||
.TH libssh2_sftp_fsync 3 "8 Apr 2013" "libssh2 1.4.4" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_sftp_fsync - synchronize file to disk
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
int
|
||||
libssh2_sftp_fsync(LIBSSH2_SFTP_HANDLE *handle)
|
||||
.fi
|
||||
.SH DESCRIPTION
|
||||
This function causes the remote server to synchronize the file
|
||||
data and metadata to disk (like fsync(2)).
|
||||
|
||||
For this to work requires fsync@openssh.com support on the server.
|
||||
|
||||
\fIhandle\fP - SFTP File Handle as returned by
|
||||
.BR libssh2_sftp_open_ex(3)
|
||||
|
||||
.SH RETURN VALUE
|
||||
Returns 0 on success or negative on failure. If used in non-blocking mode, it
|
||||
returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
|
||||
|
||||
\fILIBSSH2_ERROR_SFTP_PROTOCOL\fP - An invalid SFTP protocol response
|
||||
was received on the socket, or an SFTP operation caused an errorcode
|
||||
to be returned by the server. In particular, this can be returned if
|
||||
the SSH server does not support the fsync operation: the SFTP subcode
|
||||
\fILIBSSH2_FX_OP_UNSUPPORTED\fP will be returned in this case.
|
||||
|
||||
.SH AVAILABILITY
|
||||
Added in libssh2 1.4.4 and OpenSSH 6.3.
|
||||
.SH SEE ALSO
|
||||
.BR fsync(2)
|
@@ -15,7 +15,7 @@ libssh2_sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path, long mode);
|
||||
.BR libssh2_sftp_init(3)
|
||||
|
||||
\fIpath\fP - full path of the new directory to create. Note that the new
|
||||
directory's parents must all exist priot to making this call.
|
||||
directory's parents must all exist prior to making this call.
|
||||
|
||||
\fIpath_len\fP - length of the full path of the new directory to create.
|
||||
|
||||
|
@@ -29,7 +29,7 @@ filesystem entry
|
||||
Bitmask flags made up of LIBSSH2_SFTP_RENAME_* constants.
|
||||
|
||||
Rename a filesystem object on the remote filesystem. The semantics of
|
||||
this command typically include the ability to move a filsystem object
|
||||
this command typically include the ability to move a filesystem object
|
||||
between folders and/or filesystem mounts. If the LIBSSH2_SFTP_RENAME_OVERWRITE
|
||||
flag is not set and the destfile entry already exists, the operation
|
||||
will fail. Use of the other two flags indicate a preference (but not a
|
||||
|
@@ -4,7 +4,7 @@ libssh2_sftp_rewind - convenience macro for \fIlibssh2_sftp_seek64(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
int libssh2_sftp_rewind(LINBSSH2_SFTP_HANDLE *handle);
|
||||
int libssh2_sftp_rewind(LIBSSH2_SFTP_HANDLE *handle);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
|
@@ -4,7 +4,7 @@ libssh2_sftp_stat - convenience macro for \fIlibssh2_sftp_fstat_ex(3)\fP calls
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
int libssh2_sftp_stat(LIBSSH2_SFTP *sftp, const char *path, LIBSSH2_STFP_ATTRIBUTES *attrs);
|
||||
int libssh2_sftp_stat(LIBSSH2_SFTP *sftp, const char *path, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
|
||||
.SH DESCRIPTION
|
||||
This is a macro defined in a public libssh2 header file that is using the
|
||||
|
@@ -48,7 +48,7 @@ These are convenience macros:
|
||||
.BR libssh2_sftp_realpath(3)
|
||||
: Resolve a complex, relative, or symlinked filepath to its effective target.
|
||||
.SH RETURN VALUE
|
||||
When using LIBSSH2_SFTP_SYMLINK, this funtion returns 0 on success or negative
|
||||
When using LIBSSH2_SFTP_SYMLINK, this function returns 0 on success or negative
|
||||
on failure.
|
||||
|
||||
When using LIBSSH2_SFTP_READLINK or LIBSSH2_SFTP_REALPATH, it returns the
|
||||
|
@@ -28,7 +28,7 @@ distinguished from a failing case by examining
|
||||
\fIlibssh2_userauth_authenticated(3)\fP.
|
||||
.SH RETURN VALUE
|
||||
On success a comma delimited list of supported authentication schemes. This
|
||||
list is internally managed by libssh2. On failure ruturns NULL.
|
||||
list is internally managed by libssh2. On failure returns NULL.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
|
@@ -7,6 +7,7 @@ libssh2_userauth_publickey_fromfile - authenticate a session with a public key,
|
||||
.nf
|
||||
int libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
unsigned int ousername_len,
|
||||
const char *publickey,
|
||||
const char *privatekey,
|
||||
const char *passphrase);
|
||||
|
56
docs/libssh2_userauth_publickey_frommemory.3
Normal file
56
docs/libssh2_userauth_publickey_frommemory.3
Normal file
@@ -0,0 +1,56 @@
|
||||
.TH libssh2_userauth_publickey_frommemory 3 "1 Sep 2014" "libssh2 1.5" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_userauth_publickey_frommemory - authenticate a session with a public key, read from memory
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
|
||||
.nf
|
||||
int libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
size_t username_len,
|
||||
const char *publickeydata,
|
||||
size_t publickeydata_len,
|
||||
const char *privatekeydata,
|
||||
size_t privatekeydata_len,
|
||||
const char *passphrase);
|
||||
.SH DESCRIPTION
|
||||
This function allows to authenticate a session with a public key read from memory.
|
||||
It's only supported when libssh2 is backed by OpenSSL.
|
||||
\fIsession\fP - Session instance as returned by
|
||||
.BR libssh2_session_init_ex(3)
|
||||
|
||||
\fIusername\fP - Remote user name to authenticate as.
|
||||
|
||||
\fIusername_len\fP - Length of username.
|
||||
|
||||
\fIpublickeydata\fP - Buffer containing the contents of a public key file.
|
||||
|
||||
\fIpublickeydata_len\fP - Length of public key data.
|
||||
|
||||
\fIprivatekeydata\fP - Buffer containing the contents of a private key file.
|
||||
|
||||
\fIprivatekeydata_len\fP - Length of private key data.
|
||||
|
||||
\fIpassphrase\fP - Passphrase to use when decoding private key file.
|
||||
|
||||
Attempt public key authentication using a PEM encoded private key file stored in memory.
|
||||
.SH RETURN VALUE
|
||||
Return 0 on success or negative on failure. It returns
|
||||
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
.SH ERRORS
|
||||
\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
|
||||
|
||||
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
|
||||
|
||||
\fILIBSSH2_ERROR_SOCKET_TIMEOUT\fP -
|
||||
|
||||
\fILIBSSH2_ERROR_PUBLICKEY_UNVERIFIED\fP - The username/public key
|
||||
combination was invalid.
|
||||
|
||||
\fILIBSSH2_ERROR_AUTHENTICATION_FAILED\fP - Authentication using the supplied
|
||||
public key was not accepted.
|
||||
.SH AVAILABILITY
|
||||
libssh2_userauth_publickey_frommemory was added in libssh2 1.6.0
|
||||
.SH SEE ALSO
|
||||
.BR libssh2_session_init_ex(3)
|
100
example/CMakeLists.txt
Normal file
100
example/CMakeLists.txt
Normal file
@@ -0,0 +1,100 @@
|
||||
# Copyright (c) 2014, 2015 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms,
|
||||
# with or without modification, are permitted provided
|
||||
# that the following conditions are met:
|
||||
#
|
||||
# Redistributions of source code must retain the above
|
||||
# copyright notice, this list of conditions and the
|
||||
# following disclaimer.
|
||||
#
|
||||
# Redistributions in binary form must reproduce the above
|
||||
# copyright notice, this list of conditions and the following
|
||||
# disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# Neither the name of the copyright holder nor the names
|
||||
# of any other contributors may be used to endorse or
|
||||
# promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
# CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
# OF SUCH DAMAGE.
|
||||
|
||||
include(CheckIncludeFiles)
|
||||
include(CheckSymbolExists)
|
||||
include(CopyRuntimeDependencies)
|
||||
include(SocketLibraries)
|
||||
|
||||
set(EXAMPLES
|
||||
direct_tcpip
|
||||
ssh2
|
||||
scp
|
||||
scp_nonblock
|
||||
scp_write
|
||||
scp_write_nonblock
|
||||
sftp
|
||||
sftp_nonblock
|
||||
sftp_write
|
||||
sftp_write_nonblock
|
||||
sftp_mkdir
|
||||
sftp_mkdir_nonblock
|
||||
sftp_RW_nonblock
|
||||
sftp_write_sliding
|
||||
sftpdir
|
||||
sftpdir_nonblock
|
||||
ssh2_exec
|
||||
ssh2_agent
|
||||
ssh2_echo
|
||||
sftp_append
|
||||
subsystem_netconf
|
||||
tcpip-forward)
|
||||
|
||||
append_needed_socket_libraries(LIBRARIES)
|
||||
|
||||
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})
|
||||
target_link_libraries(example-${example} libssh2 ${LIBRARIES})
|
||||
endforeach()
|
||||
add_target_to_copy_dependencies(
|
||||
TARGET copy_example_dependencies
|
||||
DEPENDENCIES ${RUNTIME_DEPENDENCIES}
|
||||
BEFORE_TARGETS ${EXAMPLE_TARGETS})
|
||||
|
||||
## Platform checks
|
||||
check_include_files(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_files(unistd.h HAVE_UNISTD_H)
|
||||
check_include_files(stdlib.h HAVE_STDLIB_H)
|
||||
check_include_files(sys/select.h HAVE_SYS_SELECT_H)
|
||||
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
|
||||
check_include_files(sys/time.h HAVE_SYS_TIME_H)
|
||||
check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
|
||||
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
|
||||
check_include_files(winsock2.h HAVE_WINSOCK2_H)
|
||||
|
||||
check_symbol_exists(strcasecmp strings.h HAVE_STRCASECMP)
|
||||
check_symbol_exists(_stricmp string.h HAVE__STRICMP)
|
||||
check_symbol_exists(snprintf stdio.h HAVE_SNPRINTF)
|
||||
check_symbol_exists(_snprintf stdio.h HAVE__SNPRINTF)
|
||||
|
||||
check_symbol_exists(__func__ "" HAVE___FUNC__)
|
||||
check_symbol_exists(__FUNCTION__ "" HAVE___FUNCTION__)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libssh2_config_cmake.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libssh2_config.h)
|
@@ -1,6 +1,6 @@
|
||||
AUTOMAKE_OPTIONS = foreign nostdinc
|
||||
|
||||
EXTRA_DIST = libssh2_config.h.in
|
||||
EXTRA_DIST = libssh2_config.h.in libssh2_config_cmake.h.in CMakeLists.txt
|
||||
|
||||
# samples
|
||||
noinst_PROGRAMS = direct_tcpip ssh2 scp scp_nonblock scp_write \
|
||||
|
@@ -15,10 +15,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
@@ -48,7 +51,7 @@ enum {
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc, sock = -1, listensock = -1, forwardsock = -1, i, auth = AUTH_NONE;
|
||||
int rc, i, auth = AUTH_NONE;
|
||||
struct sockaddr_in sin;
|
||||
socklen_t sinlen;
|
||||
const char *fingerprint;
|
||||
@@ -64,11 +67,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
char sockopt;
|
||||
SOCKET sock = INVALID_SOCKET;
|
||||
SOCKET listensock = INVALID_SOCKET, forwardsock = INVALID_SOCKET;
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int sockopt;
|
||||
int sockopt, sock = -1;
|
||||
int listensock = -1, forwardsock = -1;
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
@@ -94,6 +105,18 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Connect to SSH server */
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (sock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
perror("inet_addr");
|
||||
@@ -167,6 +190,18 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
listensock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (listensock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open listen socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (listensock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(local_listenport);
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(local_listenip))) {
|
||||
@@ -189,10 +224,17 @@ int main(int argc, char *argv[])
|
||||
inet_ntoa(sin.sin_addr), ntohs(sin.sin_port));
|
||||
|
||||
forwardsock = accept(listensock, (struct sockaddr *)&sin, &sinlen);
|
||||
if (-1 == forwardsock) {
|
||||
#ifdef WIN32
|
||||
if (forwardsock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to accept forward socket!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
#else
|
||||
if (forwardsock == -1) {
|
||||
perror("accept");
|
||||
goto shutdown;
|
||||
}
|
||||
#endif
|
||||
|
||||
shost = inet_ntoa(sin.sin_addr);
|
||||
sport = ntohs(sin.sin_port);
|
||||
@@ -233,14 +275,17 @@ int main(int argc, char *argv[])
|
||||
goto shutdown;
|
||||
}
|
||||
wr = 0;
|
||||
do {
|
||||
i = libssh2_channel_write(channel, buf, len);
|
||||
while(wr < len) {
|
||||
i = libssh2_channel_write(channel, buf + wr, len - wr);
|
||||
if (LIBSSH2_ERROR_EAGAIN == i) {
|
||||
continue;
|
||||
}
|
||||
if (i < 0) {
|
||||
fprintf(stderr, "libssh2_channel_write: %d\n", i);
|
||||
goto shutdown;
|
||||
}
|
||||
wr += i;
|
||||
} while(i > 0 && wr < len);
|
||||
}
|
||||
}
|
||||
while (1) {
|
||||
len = libssh2_channel_read(channel, buf, sizeof(buf));
|
||||
|
72
example/libssh2_config_cmake.h.in
Normal file
72
example/libssh2_config_cmake.h.in
Normal file
@@ -0,0 +1,72 @@
|
||||
/* Copyright (c) 2014 Alexander Lamaison <alexander.lamaison@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Headers */
|
||||
#cmakedefine HAVE_UNISTD_H
|
||||
#cmakedefine HAVE_INTTYPES_H
|
||||
#cmakedefine HAVE_STDLIB_H
|
||||
#cmakedefine HAVE_SYS_SELECT_H
|
||||
#cmakedefine HAVE_SYS_SOCKET_H
|
||||
#cmakedefine HAVE_SYS_TIME_H
|
||||
#cmakedefine HAVE_ARPA_INET_H
|
||||
#cmakedefine HAVE_NETINET_IN_H
|
||||
#cmakedefine HAVE_WINSOCK2_H
|
||||
|
||||
/* Functions */
|
||||
#cmakedefine HAVE_STRCASECMP
|
||||
#cmakedefine HAVE__STRICMP
|
||||
#cmakedefine HAVE_SNPRINTF
|
||||
#cmakedefine HAVE__SNPRINTF
|
||||
|
||||
/* Workaround for platforms without POSIX strcasecmp (e.g. Windows) */
|
||||
#ifndef HAVE_STRCASECMP
|
||||
# ifdef HAVE__STRICMP
|
||||
# define strcasecmp _stricmp
|
||||
# define HAVE_STRCASECMP
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Symbols */
|
||||
#cmakedefine HAVE___FUNC__
|
||||
#cmakedefine HAVE___FUNCTION__
|
||||
|
||||
/* Workaround for platforms without C90 __func__ */
|
||||
#ifndef HAVE___FUNC__
|
||||
# ifdef HAVE___FUNCTION__
|
||||
# define __func__ __FUNCTION__
|
||||
# define HAVE___FUNC__
|
||||
# endif
|
||||
#endif
|
@@ -41,14 +41,19 @@ int main(int argc, char *argv[])
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *scppath="/tmp/TEST";
|
||||
struct stat fileinfo;
|
||||
libssh2_struct_stat fileinfo;
|
||||
int rc;
|
||||
off_t got=0;
|
||||
libssh2_struct_stat_size got = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
@@ -132,7 +137,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Request a file via SCP */
|
||||
channel = libssh2_scp_recv(session, scppath, &fileinfo);
|
||||
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
||||
|
||||
if (!channel) {
|
||||
fprintf(stderr, "Unable to open a session: %d\n",
|
||||
@@ -146,7 +151,7 @@ int main(int argc, char *argv[])
|
||||
int amount=sizeof(mem);
|
||||
|
||||
if((fileinfo.st_size -got) < amount) {
|
||||
amount = fileinfo.st_size -got;
|
||||
amount = (int)(fileinfo.st_size -got);
|
||||
}
|
||||
|
||||
rc = libssh2_channel_read(channel, mem, amount);
|
||||
|
@@ -38,12 +38,14 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* diff in ms */
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec-older.tv_sec)*1000+
|
||||
(newer.tv_usec-older.tv_usec)/1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
|
||||
{
|
||||
@@ -86,19 +88,26 @@ int main(int argc, char *argv[])
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *scppath="/tmp/TEST";
|
||||
struct stat fileinfo;
|
||||
libssh2_struct_stat fileinfo;
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
int rc;
|
||||
int total = 0;
|
||||
long time_ms;
|
||||
#endif
|
||||
int rc;
|
||||
int spin = 0;
|
||||
off_t got=0;
|
||||
libssh2_struct_stat_size got = 0;
|
||||
libssh2_struct_stat_size total = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
@@ -144,7 +153,9 @@ int main(int argc, char *argv[])
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&start, NULL);
|
||||
#endif
|
||||
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
@@ -196,9 +207,9 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
/* Request a file via SCP */
|
||||
fprintf(stderr, "libssh2_scp_recv()!\n");
|
||||
fprintf(stderr, "libssh2_scp_recv2()!\n");
|
||||
do {
|
||||
channel = libssh2_scp_recv(session, scppath, &fileinfo);
|
||||
channel = libssh2_scp_recv2(session, scppath, &fileinfo);
|
||||
|
||||
if (!channel) {
|
||||
if(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
|
||||
@@ -224,7 +235,7 @@ int main(int argc, char *argv[])
|
||||
int amount=sizeof(mem);
|
||||
|
||||
if ((fileinfo.st_size -got) < amount) {
|
||||
amount = fileinfo.st_size - got;
|
||||
amount = (int)(fileinfo.st_size - got);
|
||||
}
|
||||
|
||||
/* loop until we block */
|
||||
@@ -247,11 +258,15 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&end, NULL);
|
||||
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin);
|
||||
#else
|
||||
fprintf(stderr, "Got " LIBSSH2_STRUCT_STAT_SIZE_FORMAT " bytes spin: %d\n", total, spin);
|
||||
#endif
|
||||
|
||||
libssh2_channel_free(channel);
|
||||
channel = NULL;
|
||||
|
@@ -51,8 +51,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -90,8 +90,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -106,8 +106,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -93,8 +93,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = libssh2_init (0);
|
||||
|
@@ -55,8 +55,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -48,8 +48,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -48,8 +48,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -39,12 +39,14 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
/* diff in ms */
|
||||
static long tvdiff(struct timeval newer, struct timeval older)
|
||||
{
|
||||
return (newer.tv_sec-older.tv_sec)*1000+
|
||||
(newer.tv_usec-older.tv_usec)/1000;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
|
||||
{
|
||||
@@ -86,19 +88,26 @@ int main(int argc, char *argv[])
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/TEST";
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
struct timeval start;
|
||||
struct timeval end;
|
||||
long time_ms;
|
||||
#endif
|
||||
int rc;
|
||||
int total = 0;
|
||||
long time_ms;
|
||||
int spin = 0;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
@@ -146,7 +155,9 @@ int main(int argc, char *argv[])
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&start, NULL);
|
||||
#endif
|
||||
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
@@ -249,10 +260,14 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
} while (1);
|
||||
|
||||
#ifdef HAVE_GETTIMEOFDAY
|
||||
gettimeofday(&end, NULL);
|
||||
time_ms = tvdiff(end, start);
|
||||
fprintf(stderr, "Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
|
||||
time_ms, total/(time_ms/1000.0), spin );
|
||||
#else
|
||||
fprintf(stderr, "Got %d bytes spin: %d\n", total, spin);
|
||||
#endif
|
||||
|
||||
libssh2_sftp_close(sftp_handle);
|
||||
libssh2_sftp_shutdown(sftp_session);
|
||||
|
@@ -54,8 +54,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -94,8 +94,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -94,8 +94,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -52,24 +52,51 @@
|
||||
#define PRIu64 __PRI64_PREFIX "u"
|
||||
#endif /* PRIu64 */
|
||||
|
||||
const char *keyfile1="~/.ssh/id_rsa.pub";
|
||||
const char *keyfile2="~/.ssh/id_rsa";
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
|
||||
static void kbd_callback(const char *name, int name_len,
|
||||
const char *instruction, int instruction_len,
|
||||
int num_prompts,
|
||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
||||
void **abstract)
|
||||
{
|
||||
(void)name;
|
||||
(void)name_len;
|
||||
(void)instruction;
|
||||
(void)instruction_len;
|
||||
if (num_prompts == 1) {
|
||||
responses[0].text = strdup(password);
|
||||
responses[0].length = strlen(password);
|
||||
}
|
||||
(void)prompts;
|
||||
(void)abstract;
|
||||
} /* kbd_callback */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned long hostaddr;
|
||||
int sock, i, auth_pw = 1;
|
||||
int rc, sock, i, auth_pw = 0;
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
char *userauthlist;
|
||||
LIBSSH2_SESSION *session;
|
||||
const char *username="username";
|
||||
const char *password="password";
|
||||
const char *sftppath="/tmp/secretdir";
|
||||
int rc;
|
||||
LIBSSH2_SFTP *sftp_session;
|
||||
LIBSSH2_SFTP_HANDLE *sftp_handle;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
@@ -136,21 +163,63 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* check what authentication methods are available */
|
||||
userauthlist = libssh2_userauth_list(session, username, strlen(username));
|
||||
fprintf(stderr, "Authentication methods: %s\n", userauthlist);
|
||||
if (strstr(userauthlist, "password") != NULL) {
|
||||
auth_pw |= 1;
|
||||
}
|
||||
if (strstr(userauthlist, "keyboard-interactive") != NULL) {
|
||||
auth_pw |= 2;
|
||||
}
|
||||
if (strstr(userauthlist, "publickey") != NULL) {
|
||||
auth_pw |= 4;
|
||||
}
|
||||
|
||||
/* if we got an 5. argument we set this option if supported */
|
||||
if(argc > 5) {
|
||||
if ((auth_pw & 1) && !strcasecmp(argv[5], "-p")) {
|
||||
auth_pw = 1;
|
||||
}
|
||||
if ((auth_pw & 2) && !strcasecmp(argv[5], "-i")) {
|
||||
auth_pw = 2;
|
||||
}
|
||||
if ((auth_pw & 4) && !strcasecmp(argv[5], "-k")) {
|
||||
auth_pw = 4;
|
||||
}
|
||||
}
|
||||
|
||||
if (auth_pw & 1) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
fprintf(stderr, "\tAuthentication by password failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
fprintf(stderr, "\tAuthentication by password succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 2) {
|
||||
/* Or via keyboard-interactive */
|
||||
if (libssh2_userauth_keyboard_interactive(session, username,
|
||||
&kbd_callback) ) {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"\tAuthentication by keyboard-interactive succeeded.\n");
|
||||
}
|
||||
} else if (auth_pw & 4) {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username, keyfile1,
|
||||
keyfile2, password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed!\n");
|
||||
goto shutdown;
|
||||
} else {
|
||||
fprintf(stderr, "\tAuthentication by public key succeeded.\n");
|
||||
}
|
||||
} else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
fprintf(stderr, "No supported authentication methods found!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||
|
@@ -68,8 +68,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
|
@@ -72,10 +72,16 @@ int main(int argc, char *argv[])
|
||||
char *userauthlist;
|
||||
LIBSSH2_SESSION *session;
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
@@ -237,7 +243,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Other channel types are supported via:
|
||||
* libssh2_scp_send()
|
||||
* libssh2_scp_recv()
|
||||
* libssh2_scp_recv2()
|
||||
* libssh2_channel_direct_tcpip()
|
||||
*/
|
||||
|
||||
|
@@ -49,10 +49,16 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_CHANNEL *channel;
|
||||
LIBSSH2_AGENT *agent = NULL;
|
||||
struct libssh2_agent_publickey *identity, *prev_identity = NULL;
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1) {
|
||||
@@ -211,7 +217,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Other channel types are supported via:
|
||||
* libssh2_scp_send()
|
||||
* libssh2_scp_recv()
|
||||
* libssh2_scp_recv2()
|
||||
* libssh2_channel_direct_tcpip()
|
||||
*/
|
||||
|
||||
|
@@ -29,10 +29,13 @@
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -91,8 +94,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
/* must be ip address only */
|
||||
hostname = argv[1];
|
||||
|
@@ -31,10 +31,13 @@
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@@ -92,8 +95,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsadata;
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
int err;
|
||||
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
/* must be ip address only */
|
||||
hostname = argv[1];
|
||||
|
@@ -16,10 +16,13 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
@@ -28,6 +31,12 @@
|
||||
#define INADDR_NONE (in_addr_t)~0
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_SNPRINTF
|
||||
# ifdef HAVE__SNPRINTF
|
||||
# define snprintf _snprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
const char *keyfile1 = "/home/username/.ssh/id_rsa.pub";
|
||||
const char *keyfile2 = "/home/username/.ssh/id_rsa";
|
||||
const char *username = "username";
|
||||
@@ -102,7 +111,7 @@ static int netconf_read_until(LIBSSH2_CHANNEL *channel, const char *endtag,
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc, sock = -1, i, auth = AUTH_NONE;
|
||||
int rc, i, auth = AUTH_NONE;
|
||||
struct sockaddr_in sin;
|
||||
const char *fingerprint;
|
||||
char *userauthlist;
|
||||
@@ -112,9 +121,17 @@ int main(int argc, char *argv[])
|
||||
ssize_t len;
|
||||
|
||||
#ifdef WIN32
|
||||
SOCKET sock = INVALID_SOCKET;
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int sock = -1;
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
@@ -132,6 +149,18 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Connect to SSH server */
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (sock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
fprintf(stderr, "inet_addr: Invalid IP address \"%s\"\n", server_ip);
|
||||
|
@@ -15,10 +15,13 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_SYS_SELECT_H
|
||||
#include <sys/select.h>
|
||||
#endif
|
||||
@@ -35,11 +38,11 @@ const char *password = "";
|
||||
const char *server_ip = "127.0.0.1";
|
||||
|
||||
const char *remote_listenhost = "localhost"; /* resolved by the server */
|
||||
unsigned int remote_wantport = 2222;
|
||||
unsigned int remote_listenport;
|
||||
int remote_wantport = 2222;
|
||||
int remote_listenport;
|
||||
|
||||
const char *local_destip = "127.0.0.1";
|
||||
unsigned int local_destport = 22;
|
||||
int local_destport = 22;
|
||||
|
||||
enum {
|
||||
AUTH_NONE = 0,
|
||||
@@ -49,7 +52,7 @@ enum {
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int rc, sock = -1, forwardsock = -1, i, auth = AUTH_NONE;
|
||||
int rc, i, auth = AUTH_NONE;
|
||||
struct sockaddr_in sin;
|
||||
socklen_t sinlen = sizeof(sin);
|
||||
const char *fingerprint;
|
||||
@@ -57,20 +60,23 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_SESSION *session;
|
||||
LIBSSH2_LISTENER *listener = NULL;
|
||||
LIBSSH2_CHANNEL *channel = NULL;
|
||||
const char *shost;
|
||||
unsigned int sport;
|
||||
fd_set fds;
|
||||
struct timeval tv;
|
||||
ssize_t len, wr;
|
||||
char buf[16384];
|
||||
|
||||
#ifdef WIN32
|
||||
char sockopt;
|
||||
SOCKET sock = INVALID_SOCKET, forwardsock = INVALID_SOCKET;
|
||||
WSADATA wsadata;
|
||||
int err;
|
||||
|
||||
WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
err = WSAStartup(MAKEWORD(2,0), &wsadata);
|
||||
if (err != 0) {
|
||||
fprintf(stderr, "WSAStartup failed with error: %d\n", err);
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int sockopt;
|
||||
int sock = -1, forwardsock = -1;
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
@@ -96,6 +102,18 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Connect to SSH server */
|
||||
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (sock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open socket!\n");
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
if (sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(server_ip))) {
|
||||
perror("inet_addr");
|
||||
@@ -196,6 +214,18 @@ int main(int argc, char *argv[])
|
||||
"Accepted remote connection. Connecting to local server %s:%d\n",
|
||||
local_destip, local_destport);
|
||||
forwardsock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
|
||||
#ifdef WIN32
|
||||
if (forwardsock == INVALID_SOCKET) {
|
||||
fprintf(stderr, "failed to open forward socket!\n");
|
||||
goto shutdown;
|
||||
}
|
||||
#else
|
||||
if (forwardsock == -1) {
|
||||
perror("socket");
|
||||
goto shutdown;
|
||||
}
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons(local_destport);
|
||||
if (INADDR_NONE == (sin.sin_addr.s_addr = inet_addr(local_destip))) {
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/select.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
@@ -48,13 +49,13 @@ static void remove_node(struct chan_X11_list *elem)
|
||||
current_node = gp_x11_chan;
|
||||
|
||||
if (gp_x11_chan == elem) {
|
||||
/* Removing the only one element in the list */
|
||||
free(gp_x11_chan);
|
||||
gp_x11_chan = NULL;
|
||||
gp_x11_chan = gp_x11_chan->next;
|
||||
free(current_node);
|
||||
return;
|
||||
}
|
||||
|
||||
while( current_node->next != NULL) {
|
||||
if (current_node->next ==elem) {
|
||||
while (current_node->next != NULL) {
|
||||
if (current_node->next == elem) {
|
||||
current_node->next = current_node->next->next;
|
||||
current_node = current_node->next;
|
||||
free(current_node);
|
||||
@@ -209,24 +210,27 @@ static int x11_send_receive(LIBSSH2_CHANNEL *channel, int sock)
|
||||
rc = libssh2_poll(fds, nfds, 0);
|
||||
if (rc >0) {
|
||||
rc = libssh2_channel_read(channel, buf, bufsize);
|
||||
rc = write(sock, buf, rc);
|
||||
write(sock, buf, rc);
|
||||
}
|
||||
|
||||
rc = select(sock+1,&set,NULL,NULL,&timeval_out);
|
||||
rc = select(sock+1, &set, NULL, NULL, &timeval_out);
|
||||
if (rc > 0) {
|
||||
memset((void *)buf,0,bufsize);
|
||||
memset((void *)buf, 0, bufsize);
|
||||
|
||||
/* Data in sock*/
|
||||
rc = read(sock, buf, bufsize);
|
||||
if (rc > 0)
|
||||
rc = libssh2_channel_write(channel,buf, rc);
|
||||
else
|
||||
if (rc > 0) {
|
||||
libssh2_channel_write(channel, buf, rc);
|
||||
}
|
||||
else {
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
free(fds);
|
||||
free(buf);
|
||||
if (libssh2_channel_eof (channel) == 1) {
|
||||
if (libssh2_channel_eof(channel) == 1) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -289,6 +293,10 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
sock = socket (AF_INET, SOCK_STREAM, 0);
|
||||
if (sock == -1) {
|
||||
perror("socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_port = htons (22);
|
||||
@@ -369,6 +377,9 @@ main (int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(&w_size, 0, sizeof(struct winsize));
|
||||
memset(&w_size_bck, 0, sizeof(struct winsize));
|
||||
|
||||
while (1) {
|
||||
|
||||
FD_ZERO(&set);
|
||||
@@ -400,7 +411,7 @@ main (int argc, char *argv[])
|
||||
|
||||
rc = libssh2_poll(fds, nfds, 0);
|
||||
if (rc >0) {
|
||||
rc = libssh2_channel_read(channel, buf,sizeof(buf));
|
||||
libssh2_channel_read(channel, buf, sizeof(buf));
|
||||
fprintf(stdout, "%s", buf);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* Copyright (c) 2004-2009, Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2009-2012 Daniel Stenberg
|
||||
* Copyright (c) 2009-2015 Daniel Stenberg
|
||||
* Copyright (c) 2010 Simon Josefsson <simon@josefsson.org>
|
||||
* All rights reserved.
|
||||
*
|
||||
@@ -40,19 +40,19 @@
|
||||
#ifndef LIBSSH2_H
|
||||
#define LIBSSH2_H 1
|
||||
|
||||
#define LIBSSH2_COPYRIGHT "2004-2012 The libssh2 project and its contributors."
|
||||
#define LIBSSH2_COPYRIGHT "2004-2016 The libssh2 project and its contributors."
|
||||
|
||||
/* We use underscore instead of dash when appending DEV in dev versions just
|
||||
to make the BANNER define (used by src/session.c) be a valid SSH
|
||||
banner. Release versions have no appended strings and may of course not
|
||||
have dashes either. */
|
||||
#define LIBSSH2_VERSION "1.4.3_DEV"
|
||||
#define LIBSSH2_VERSION "1.7.0_DEV"
|
||||
|
||||
/* The numeric version number is also available "in parts" by using these
|
||||
defines: */
|
||||
#define LIBSSH2_VERSION_MAJOR 1
|
||||
#define LIBSSH2_VERSION_MINOR 4
|
||||
#define LIBSSH2_VERSION_PATCH 3
|
||||
#define LIBSSH2_VERSION_MINOR 7
|
||||
#define LIBSSH2_VERSION_PATCH 0
|
||||
|
||||
/* This is the numeric version of the libssh2 version number, meant for easier
|
||||
parsing and comparions by programs. The LIBSSH2_VERSION_NUM define will
|
||||
@@ -69,7 +69,7 @@
|
||||
and it is always a greater number in a more recent release. It makes
|
||||
comparisons with greater than and less than work.
|
||||
*/
|
||||
#define LIBSSH2_VERSION_NUM 0x010403
|
||||
#define LIBSSH2_VERSION_NUM 0x010700
|
||||
|
||||
/*
|
||||
* This is the date and time when the full source package was created. The
|
||||
@@ -100,17 +100,21 @@ extern "C" {
|
||||
/* Allow alternate API prefix from CFLAGS or calling app */
|
||||
#ifndef LIBSSH2_API
|
||||
# ifdef LIBSSH2_WIN32
|
||||
# ifdef LIBSSH2_LIBRARY
|
||||
# define LIBSSH2_API __declspec(dllexport)
|
||||
# ifdef _WINDLL
|
||||
# ifdef LIBSSH2_LIBRARY
|
||||
# define LIBSSH2_API __declspec(dllexport)
|
||||
# else
|
||||
# define LIBSSH2_API __declspec(dllimport)
|
||||
# endif /* LIBSSH2_LIBRARY */
|
||||
# else
|
||||
# define LIBSSH2_API __declspec(dllimport)
|
||||
# endif /* LIBSSH2_LIBRARY */
|
||||
# define LIBSSH2_API
|
||||
# endif
|
||||
# else /* !LIBSSH2_WIN32 */
|
||||
# define LIBSSH2_API
|
||||
# endif /* LIBSSH2_WIN32 */
|
||||
#endif /* LIBSSH2_API */
|
||||
|
||||
#if defined(LIBSSH2_DARWIN)
|
||||
#ifdef HAVE_SYS_UIO_H
|
||||
# include <sys/uio.h>
|
||||
#endif
|
||||
|
||||
@@ -141,6 +145,68 @@ typedef int libssh2_socket_t;
|
||||
#define LIBSSH2_INVALID_SOCKET -1
|
||||
#endif /* WIN32 */
|
||||
|
||||
/*
|
||||
* Determine whether there is small or large file support on windows.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER) && !defined(_WIN32_WCE)
|
||||
# if (_MSC_VER >= 900) && (_INTEGRAL_MAX_BITS >= 64)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
# else
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(__WATCOMC__) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES)
|
||||
# define LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(__POCC__)
|
||||
# undef LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) && !defined(LIBSSH2_USE_WIN32_LARGE_FILES) && \
|
||||
!defined(LIBSSH2_USE_WIN32_SMALL_FILES)
|
||||
# define LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Large file (>2Gb) support using WIN32 functions.
|
||||
*/
|
||||
|
||||
#ifdef LIBSSH2_USE_WIN32_LARGE_FILES
|
||||
# include <io.h>
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%I64d"
|
||||
typedef struct _stati64 libssh2_struct_stat;
|
||||
typedef __int64 libssh2_struct_stat_size;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Small file (<2Gb) support using WIN32 functions.
|
||||
*/
|
||||
|
||||
#ifdef LIBSSH2_USE_WIN32_SMALL_FILES
|
||||
# include <sys/types.h>
|
||||
# include <sys/stat.h>
|
||||
# ifndef _WIN32_WCE
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%d"
|
||||
typedef struct _stat libssh2_struct_stat;
|
||||
typedef off_t libssh2_struct_stat_size;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef LIBSSH2_STRUCT_STAT_SIZE_FORMAT
|
||||
# define LIBSSH2_STRUCT_STAT_SIZE_FORMAT "%zd"
|
||||
typedef struct stat libssh2_struct_stat;
|
||||
typedef off_t libssh2_struct_stat_size;
|
||||
#endif
|
||||
|
||||
/* Part of every banner, user specified or not */
|
||||
#define LIBSSH2_SSH_BANNER "SSH-2.0-libssh2_" LIBSSH2_VERSION
|
||||
|
||||
@@ -281,7 +347,8 @@ typedef struct _LIBSSH2_POLLFD {
|
||||
unsigned char type; /* LIBSSH2_POLLFD_* below */
|
||||
|
||||
union {
|
||||
int socket; /* File descriptors -- examined with system select() call */
|
||||
libssh2_socket_t socket; /* File descriptors -- examined with
|
||||
system select() call */
|
||||
LIBSSH2_CHANNEL *channel; /* Examined by checking internal state */
|
||||
LIBSSH2_LISTENER *listener; /* Read polls only -- are inbound
|
||||
connections waiting to be accepted? */
|
||||
@@ -501,6 +568,9 @@ LIBSSH2_API int libssh2_session_last_error(LIBSSH2_SESSION *session,
|
||||
char **errmsg,
|
||||
int *errmsg_len, int want_buf);
|
||||
LIBSSH2_API int libssh2_session_last_errno(LIBSSH2_SESSION *session);
|
||||
LIBSSH2_API int libssh2_session_set_last_error(LIBSSH2_SESSION* session,
|
||||
int errcode,
|
||||
const char* errmsg);
|
||||
LIBSSH2_API int libssh2_session_block_directions(LIBSSH2_SESSION *session);
|
||||
|
||||
LIBSSH2_API int libssh2_session_flag(LIBSSH2_SESSION *session, int flag,
|
||||
@@ -521,8 +591,9 @@ LIBSSH2_API int libssh2_userauth_password_ex(LIBSSH2_SESSION *session,
|
||||
LIBSSH2_PASSWD_CHANGEREQ_FUNC((*passwd_change_cb)));
|
||||
|
||||
#define libssh2_userauth_password(session, username, password) \
|
||||
libssh2_userauth_password_ex((session), (username), strlen(username), \
|
||||
(password), strlen(password), NULL)
|
||||
libssh2_userauth_password_ex((session), (username), \
|
||||
(unsigned int)strlen(username), \
|
||||
(password), (unsigned int)strlen(password), NULL)
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session,
|
||||
@@ -534,9 +605,10 @@ libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session,
|
||||
|
||||
#define libssh2_userauth_publickey_fromfile(session, username, publickey, \
|
||||
privatekey, passphrase) \
|
||||
libssh2_userauth_publickey_fromfile_ex((session), (username), \
|
||||
strlen(username), (publickey), \
|
||||
(privatekey), (passphrase))
|
||||
libssh2_userauth_publickey_fromfile_ex((session), (username), \
|
||||
(unsigned int)strlen(username), \
|
||||
(publickey), \
|
||||
(privatekey), (passphrase))
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
||||
@@ -561,10 +633,23 @@ libssh2_userauth_hostbased_fromfile_ex(LIBSSH2_SESSION *session,
|
||||
#define libssh2_userauth_hostbased_fromfile(session, username, publickey, \
|
||||
privatekey, passphrase, hostname) \
|
||||
libssh2_userauth_hostbased_fromfile_ex((session), (username), \
|
||||
strlen(username), (publickey), \
|
||||
(privatekey), (passphrase), \
|
||||
(hostname), strlen(hostname), \
|
||||
(username), strlen(username))
|
||||
(unsigned int)strlen(username), \
|
||||
(publickey), \
|
||||
(privatekey), (passphrase), \
|
||||
(hostname), \
|
||||
(unsigned int)strlen(hostname), \
|
||||
(username), \
|
||||
(unsigned int)strlen(username))
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
||||
const char *username,
|
||||
size_t username_len,
|
||||
const char *publickeyfiledata,
|
||||
size_t publickeyfiledata_len,
|
||||
const char *privatekeyfiledata,
|
||||
size_t privatekeyfiledata_len,
|
||||
const char *passphrase);
|
||||
|
||||
/*
|
||||
* response_callback is provided with filled by library prompts array,
|
||||
@@ -576,18 +661,20 @@ LIBSSH2_API int
|
||||
libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION* session,
|
||||
const char *username,
|
||||
unsigned int username_len,
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC((*response_callback)));
|
||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(
|
||||
(*response_callback)));
|
||||
|
||||
#define libssh2_userauth_keyboard_interactive(session, username, \
|
||||
response_callback) \
|
||||
libssh2_userauth_keyboard_interactive_ex((session), (username), \
|
||||
strlen(username), (response_callback))
|
||||
#define libssh2_userauth_keyboard_interactive(session, username, \
|
||||
response_callback) \
|
||||
libssh2_userauth_keyboard_interactive_ex((session), (username), \
|
||||
(unsigned int)strlen(username), \
|
||||
(response_callback))
|
||||
|
||||
LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds,
|
||||
long timeout);
|
||||
|
||||
/* Channel API */
|
||||
#define LIBSSH2_CHANNEL_WINDOW_DEFAULT (256*1024)
|
||||
#define LIBSSH2_CHANNEL_WINDOW_DEFAULT (2*1024*1024)
|
||||
#define LIBSSH2_CHANNEL_PACKET_DEFAULT 32768
|
||||
#define LIBSSH2_CHANNEL_MINADJUST 1024
|
||||
|
||||
@@ -635,9 +722,10 @@ LIBSSH2_API int libssh2_channel_setenv_ex(LIBSSH2_CHANNEL *channel,
|
||||
const char *value,
|
||||
unsigned int value_len);
|
||||
|
||||
#define libssh2_channel_setenv(channel, varname, value) \
|
||||
libssh2_channel_setenv_ex((channel), (varname), strlen(varname), (value), \
|
||||
strlen(value))
|
||||
#define libssh2_channel_setenv(channel, varname, value) \
|
||||
libssh2_channel_setenv_ex((channel), (varname), \
|
||||
(unsigned int)strlen(varname), (value), \
|
||||
(unsigned int)strlen(value))
|
||||
|
||||
LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel,
|
||||
const char *term,
|
||||
@@ -646,10 +734,12 @@ LIBSSH2_API int libssh2_channel_request_pty_ex(LIBSSH2_CHANNEL *channel,
|
||||
unsigned int modes_len,
|
||||
int width, int height,
|
||||
int width_px, int height_px);
|
||||
#define libssh2_channel_request_pty(channel, term) \
|
||||
libssh2_channel_request_pty_ex((channel), (term), strlen(term), NULL, 0, \
|
||||
LIBSSH2_TERM_WIDTH, LIBSSH2_TERM_HEIGHT, \
|
||||
LIBSSH2_TERM_WIDTH_PX, LIBSSH2_TERM_HEIGHT_PX)
|
||||
#define libssh2_channel_request_pty(channel, term) \
|
||||
libssh2_channel_request_pty_ex((channel), (term), \
|
||||
(unsigned int)strlen(term), \
|
||||
NULL, 0, \
|
||||
LIBSSH2_TERM_WIDTH, LIBSSH2_TERM_HEIGHT, \
|
||||
LIBSSH2_TERM_WIDTH_PX, LIBSSH2_TERM_HEIGHT_PX)
|
||||
|
||||
LIBSSH2_API int libssh2_channel_request_pty_size_ex(LIBSSH2_CHANNEL *channel,
|
||||
int width, int height,
|
||||
@@ -676,11 +766,11 @@ LIBSSH2_API int libssh2_channel_process_startup(LIBSSH2_CHANNEL *channel,
|
||||
NULL, 0)
|
||||
#define libssh2_channel_exec(channel, command) \
|
||||
libssh2_channel_process_startup((channel), "exec", sizeof("exec") - 1, \
|
||||
(command), strlen(command))
|
||||
(command), (unsigned int)strlen(command))
|
||||
#define libssh2_channel_subsystem(channel, subsystem) \
|
||||
libssh2_channel_process_startup((channel), "subsystem", \
|
||||
sizeof("subsystem") - 1, (subsystem), \
|
||||
strlen(subsystem))
|
||||
(unsigned int)strlen(subsystem))
|
||||
|
||||
LIBSSH2_API ssize_t libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel,
|
||||
int stream_id, char *buf,
|
||||
@@ -781,9 +871,14 @@ LIBSSH2_API int libssh2_channel_close(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API int libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel);
|
||||
LIBSSH2_API int libssh2_channel_free(LIBSSH2_CHANNEL *channel);
|
||||
|
||||
/* libssh2_scp_recv is DEPRECATED, do not use! */
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv(LIBSSH2_SESSION *session,
|
||||
const char *path,
|
||||
struct stat *sb);
|
||||
/* Use libssh2_scp_recv2 for large (> 2GB) file support on windows */
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_recv2(LIBSSH2_SESSION *session,
|
||||
const char *path,
|
||||
libssh2_struct_stat *sb);
|
||||
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_scp_send_ex(LIBSSH2_SESSION *session,
|
||||
const char *path, int mode,
|
||||
size_t size, long mtime,
|
||||
@@ -856,11 +951,12 @@ libssh2_knownhost_init(LIBSSH2_SESSION *session);
|
||||
#define LIBSSH2_KNOWNHOST_KEYENC_BASE64 (2<<16)
|
||||
|
||||
/* type of key (2 bits) */
|
||||
#define LIBSSH2_KNOWNHOST_KEY_MASK (3<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_MASK (7<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SHIFT 18
|
||||
#define LIBSSH2_KNOWNHOST_KEY_RSA1 (1<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SSHRSA (2<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_SSHDSS (3<<18)
|
||||
#define LIBSSH2_KNOWNHOST_KEY_UNKNOWN (7<<18)
|
||||
|
||||
LIBSSH2_API int
|
||||
libssh2_knownhost_add(LIBSSH2_KNOWNHOSTS *hosts,
|
||||
|
@@ -69,7 +69,8 @@ typedef struct _libssh2_publickey_list {
|
||||
libssh2_publickey_attribute *attrs; /* free me */
|
||||
} libssh2_publickey_list;
|
||||
|
||||
/* Generally use the first macro here, but if both name and value are string literals, you can use _fast() to take advantage of preprocessing */
|
||||
/* Generally use the first macro here, but if both name and value are string
|
||||
literals, you can use _fast() to take advantage of preprocessing */
|
||||
#define libssh2_publickey_attribute(name, value, mandatory) \
|
||||
{ (name), strlen(name), (value), strlen(value), (mandatory) },
|
||||
#define libssh2_publickey_attribute_fast(name, value, mandatory) \
|
||||
|
@@ -247,6 +247,7 @@ LIBSSH2_API int libssh2_sftp_readdir_ex(LIBSSH2_SFTP_HANDLE *handle, \
|
||||
|
||||
LIBSSH2_API ssize_t libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle,
|
||||
const char *buffer, size_t count);
|
||||
LIBSSH2_API int libssh2_sftp_fsync(LIBSSH2_SFTP_HANDLE *handle);
|
||||
|
||||
LIBSSH2_API int libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle);
|
||||
#define libssh2_sftp_close(handle) libssh2_sftp_close_handle(handle)
|
||||
|
@@ -12,6 +12,6 @@ URL: http://www.libssh2.org/
|
||||
Description: Library for SSH-based communication
|
||||
Version: @LIBSSH2VER@
|
||||
Requires.private: @LIBSREQUIRED@
|
||||
Libs: -L${libdir} -lssh2 @LDFLAGS@ @LIBS@
|
||||
Libs: -L${libdir} -lssh2 @LIBS@
|
||||
Libs.private: @LIBS@
|
||||
Cflags: -I${includedir}
|
||||
|
@@ -14,12 +14,12 @@ endif
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../zlib-1.2.7
|
||||
ZLIB_PATH = ../../zlib-1.2.8
|
||||
endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../openssl-0.9.8x
|
||||
OPENSSL_PATH = ../../openssl-0.9.8zc
|
||||
endif
|
||||
|
||||
# Edit the path below to point to your Distribution folder.
|
||||
@@ -37,7 +37,7 @@ DEVLARC = $(DEVLDIR).zip
|
||||
# Edit the vars below to change NLM target settings.
|
||||
TARGET = libssh2
|
||||
VERSION = $(LIBSSH2_VERSION)
|
||||
COPYR = Copyright (c) $(LIBSSH2_COPYRIGHT_STR)
|
||||
CPRIGHT = Copyright (c) $(LIBSSH2_COPYRIGHT_STR)
|
||||
WWWURL = http://www.libssh2.org/
|
||||
DESCR = libssh2 $(LIBSSH2_VERSION_STR) ($(LIBARCH)) - $(WWWURL)
|
||||
MTSAFE = YES
|
||||
@@ -213,6 +213,10 @@ endif
|
||||
|
||||
vpath %.c . ../src
|
||||
|
||||
# only OpenSSL is supported with this build system
|
||||
CFLAGS += -DLIBSSH2_OPENSSL
|
||||
include ../Makefile.OpenSSL.inc
|
||||
|
||||
# include Makefile.inc to get CSOURCES define
|
||||
include ../Makefile.inc
|
||||
|
||||
@@ -247,30 +251,30 @@ $(OBJDIR)/version.inc: ../get_ver.awk ../include/libssh2.h $(OBJDIR)
|
||||
@$(AWK) -f $^ > $@
|
||||
|
||||
dist: all $(DISTDIR) $(DISTDIR)/readme.txt
|
||||
@$(call MD, $(DISTDIR)/bin)
|
||||
@$(call CP, ../AUTHORS, $(DISTDIR))
|
||||
@$(call CP, ../COPYING, $(DISTDIR))
|
||||
@$(call CP, ../INSTALL, $(DISTDIR))
|
||||
@$(call CP, ../README, $(DISTDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DISTDIR))
|
||||
@$(call CP, $(TARGET).nlm, $(DISTDIR)/bin)
|
||||
@$(call MKDIR, $(DISTDIR)/bin)
|
||||
@$(call COPY, ../AUTHORS, $(DISTDIR))
|
||||
@$(call COPY, ../COPYING, $(DISTDIR))
|
||||
@$(call COPY, ../INSTALL, $(DISTDIR))
|
||||
@$(call COPY, ../README, $(DISTDIR))
|
||||
@$(call COPY, ../RELEASE-NOTES, $(DISTDIR))
|
||||
@$(call COPY, $(TARGET).nlm, $(DISTDIR)/bin)
|
||||
@echo Creating $(DISTARC)
|
||||
@$(ZIP) $(DISTARC) $(DISTDIR)/* < $(DISTDIR)/readme.txt
|
||||
|
||||
dev: all $(DEVLDIR) $(DEVLDIR)/readme.txt
|
||||
@$(call MD, $(DEVLDIR)/bin)
|
||||
@$(call MD, $(DEVLDIR)/include)
|
||||
@$(call MD, $(DEVLDIR)/nw)
|
||||
@$(call CP, ../AUTHORS, $(DEVLDIR))
|
||||
@$(call CP, ../COPYING, $(DEVLDIR))
|
||||
@$(call CP, ../INSTALL, $(DEVLDIR))
|
||||
@$(call CP, ../README, $(DEVLDIR))
|
||||
@$(call CP, ../RELEASE-NOTES, $(DEVLDIR))
|
||||
@$(call CP, ../include/*.h, $(DEVLDIR)/include)
|
||||
@$(call CP, libssh2_config.h, $(DEVLDIR)/include)
|
||||
@$(call CP, $(TARGET).nlm, $(DEVLDIR)/bin)
|
||||
@$(call CP, $(TARGET).imp, $(DEVLDIR)/nw)
|
||||
@$(call CP, $(TARGET).$(LIBEXT), $(DEVLDIR)/nw)
|
||||
@$(call MKDIR, $(DEVLDIR)/bin)
|
||||
@$(call MKDIR, $(DEVLDIR)/include)
|
||||
@$(call MKDIR, $(DEVLDIR)/nw)
|
||||
@$(call COPY, ../AUTHORS, $(DEVLDIR))
|
||||
@$(call COPY, ../COPYING, $(DEVLDIR))
|
||||
@$(call COPY, ../INSTALL, $(DEVLDIR))
|
||||
@$(call COPY, ../README, $(DEVLDIR))
|
||||
@$(call COPY, ../RELEASE-NOTES, $(DEVLDIR))
|
||||
@$(call COPY, ../include/*.h, $(DEVLDIR)/include)
|
||||
@$(call COPY, libssh2_config.h, $(DEVLDIR)/include)
|
||||
@$(call COPY, $(TARGET).nlm, $(DEVLDIR)/bin)
|
||||
@$(call COPY, $(TARGET).imp, $(DEVLDIR)/nw)
|
||||
@$(call COPY, $(TARGET).$(LIBEXT), $(DEVLDIR)/nw)
|
||||
@echo Creating $(DEVLARC)
|
||||
@$(ZIP) $(DEVLARC) $(DEVLDIR)/* < $(DEVLDIR)/readme.txt
|
||||
|
||||
@@ -323,7 +327,7 @@ $(OBJDIR)/%.def: GNUmakefile
|
||||
@echo $(DL)# Do not edit this file - it is created by make!$(DL) >> $@
|
||||
@echo $(DL)# All your changes will be lost!!$(DL) >> $@
|
||||
@echo $(DL)#$(DL) >> $@
|
||||
@echo $(DL)copyright "$(COPYR)"$(DL) >> $@
|
||||
@echo $(DL)copyright "$(CPRIGHT)"$(DL) >> $@
|
||||
@echo $(DL)description "$(DESCR)"$(DL) >> $@
|
||||
@echo $(DL)version $(VERSION)$(DL) >> $@
|
||||
ifdef NLMTYPE
|
||||
@@ -530,21 +534,26 @@ endif
|
||||
@echo $(DL) libssh2_channel_wait_closed,$(DL) >> $@
|
||||
@echo $(DL) libssh2_channel_wait_eof,$(DL) >> $@
|
||||
@echo $(DL) libssh2_channel_write_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_exit,$(DL) >> $@
|
||||
@echo $(DL) libssh2_hostkey_hash,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_recv,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send64,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_init,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_add,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_check,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_checkp,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_free,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_init,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_readfile,$(DL) >> $@
|
||||
@echo $(DL) libssh2_knownhost_writefile,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_recv,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_recv2,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send64,$(DL) >> $@
|
||||
@echo $(DL) libssh2_scp_send_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_abstract,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_block_directions,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_callback_set,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_disconnect_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_free,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_handshake,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_hostkey,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_init_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_session_last_errno,$(DL) >> $@
|
||||
@@ -576,7 +585,8 @@ endif
|
||||
@echo $(DL) libssh2_userauth_keyboard_interactive_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_userauth_list,$(DL) >> $@
|
||||
@echo $(DL) libssh2_userauth_password_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_userauth_publickey_fromfile_ex$(DL) >> $@
|
||||
@echo $(DL) libssh2_userauth_publickey_fromfile_ex,$(DL) >> $@
|
||||
@echo $(DL) libssh2_version$(DL) >> $@
|
||||
|
||||
$(DISTDIR)/readme.txt: GNUmakefile
|
||||
@echo Creating $@
|
||||
|
@@ -13,12 +13,12 @@ endif
|
||||
|
||||
# Edit the path below to point to the base of your Zlib sources.
|
||||
ifndef ZLIB_PATH
|
||||
ZLIB_PATH = ../../../zlib-1.2.7
|
||||
ZLIB_PATH = ../../../zlib-1.2.8
|
||||
endif
|
||||
|
||||
# Edit the path below to point to the base of your OpenSSL package.
|
||||
ifndef OPENSSL_PATH
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8x
|
||||
OPENSSL_PATH = ../../../openssl-0.9.8zc
|
||||
endif
|
||||
|
||||
# Edit the var below to enable static linking of libssh2 and libz
|
||||
|
169
os400/README400
Normal file
169
os400/README400
Normal file
@@ -0,0 +1,169 @@
|
||||
|
||||
Implementation notes:
|
||||
|
||||
This is a true OS/400 implementation, not a PASE implementation (for PASE,
|
||||
use AIX implementation).
|
||||
|
||||
It uses ASCII as internal character set. This has been accomplished using the
|
||||
QADRT library and include files, a C and system procedures ASCII wrapper
|
||||
library. See IBM QADRT description for more information.
|
||||
This results in libssh2 being an ASCII library: any function string
|
||||
argument is taken/returned in ASCII and a C/C++ calling program built around
|
||||
QADRT may use libssh2 functions as on any other platform.
|
||||
QADRT does not define ASCII wrappers for all C/system procedures: an
|
||||
additional module (os400sys.c) define some more of them, that are used by
|
||||
libssh2 and that QADRT left out.
|
||||
Since standard library entry points expect and return ASCII character strings,
|
||||
additional procedures are provided for string transcoding (see below). No
|
||||
wrappers to standard procedures are provided: however, nested calls to
|
||||
transcoding procedures may be used.
|
||||
|
||||
Crypto API is provided by the IBM QC3 API library. It supports RSA, but not DSA.
|
||||
|
||||
|
||||
Standard compilation environment does support neither autotools nor make;
|
||||
in fact, very few common utilities are available. As a consequence, the
|
||||
libssh2_config.h has been coded manually and the compilation scripts are
|
||||
a set of shell scripts stored in subdirectory os400.
|
||||
|
||||
The test environment is currently not supported on OS/400.
|
||||
|
||||
|
||||
|
||||
Compiling on OS/400:
|
||||
|
||||
These instructions target people who knows about OS/400, compiling, IFS and
|
||||
archive extraction. Do not ask questions about these subjects if you're not
|
||||
familiar with.
|
||||
|
||||
_ As a prerequisite, QADRT development environment must be installed.
|
||||
_ Install the libssh2 sources directory in IFS.
|
||||
_ Enter shell (QSH)
|
||||
_ Change current directory to the libssh2 sources installation directory
|
||||
_ Change current directory to os400
|
||||
_ Edit file iniscript.sh. You may want to change tunable configuration
|
||||
parameters, like debug info generation, optimisation level, listing option,
|
||||
target library, zlib availability and location, etc.
|
||||
_ Copy any file in the current directory to makelog (i.e.:
|
||||
cp initscript.sh makelog): this is intended to create the makelog file with
|
||||
an ASCII CCSID!
|
||||
_ Enter the command "sh make.sh > makelog 2>&1'
|
||||
_ Examine the makelog file to check for compilation errors.
|
||||
|
||||
Leaving file initscript.sh unchanged, this will produce the following OS/400
|
||||
objects:
|
||||
_ Library LIBSSH2. All other objects will be stored in this library.
|
||||
_ Modules for all libssh2 units.
|
||||
_ Binding directory LIBSSH2_A, to be used at calling program link time for
|
||||
statically binding the modules (specify BNDSRVPGM(QADRTTS) when creating a
|
||||
program using LIBSSH2_A. Also give access to the zlib BNDDIR/SRVPGM if
|
||||
libssh2 is compiled with zlib).
|
||||
_ Service program LIBSSH2.<soname>, where <soname> is extracted from the
|
||||
src/Makefile.am VERSION variable. To be used at calling program run-time
|
||||
when this program has dynamically bound libssh2 at link time.
|
||||
_ Binding directory LIBSSH2. To be used to dynamically bind libssh2 when
|
||||
linking a calling program.
|
||||
_ Source file H. It contains all the include members needed to compile a C/C++
|
||||
module using libssh2.
|
||||
_ LIBSSH2, SSH2_PKEY, SSH2_SFTP members in file H. These are the C/C++ header
|
||||
files. Original fames have been mangled to fit member name allowed syntax.
|
||||
_ Source file LIBSSH2RPG. It contains all the ILE/RPG /INCLUDE members
|
||||
needed to compile an ILE/RPG program calling libssh2 procedures.
|
||||
_ LIBSSH2, SSH2_PKEY, SSH2_SFTP members in file LIBSSH2RPG. These are
|
||||
ILE/RPG translations of the corresponding C header files.
|
||||
|
||||
|
||||
|
||||
Special programming consideration:
|
||||
|
||||
QADRT being used, the following points must be considered:
|
||||
_ If static binding is used, service program QADRTTS must be linked too.
|
||||
_ Likewise, if libssh2 has been compiled with zlib support, access to the
|
||||
zlib objects must be provided at link time.
|
||||
_ The EBCDIC CCSID used by QADRT is 37 by default, NOT THE JOB'S CCSID. If
|
||||
another EBCDIC CCSID is required, it must be set via a locale through a call
|
||||
to setlocale_a (QADRT's setlocale() ASCII wrapper) with category LC_ALL or
|
||||
LC_CTYPE, or by setting environment variable QADRT_ENV_LOCALE to the locale
|
||||
object path before executing the program.
|
||||
_ Do not use original source include files unless you know what you are doing.
|
||||
Use the installed members instead (in /QSYS.LIB/LIBSSH2.LIB/H.FILE).
|
||||
|
||||
|
||||
|
||||
String transcoding support:
|
||||
|
||||
To help passing arbitrarily encoded string arguments and/or receiving string
|
||||
values from/to the libssh2 API, three non-standard additional procedures are
|
||||
provided. They use a session pointer and a "string cache" pointer.
|
||||
Each time a string is transcoded, it is cached in the given cache. It is
|
||||
the responsibility of the caller to release the cache when its associted strings
|
||||
are no longer needed. These procedures and the string cache type are defined
|
||||
in a new libssh2_ccsid.h header file.
|
||||
To create a string cache, use:
|
||||
|
||||
#include <libssh2_ccsid.h>
|
||||
libssh2_string_cache * cache = NULL;
|
||||
|
||||
To release all strings in a cache, call:
|
||||
|
||||
libssh2_release_string_cache(session, &cache);
|
||||
|
||||
The transcoding procedures are:
|
||||
|
||||
char * libssh2_from_ccsid(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache,
|
||||
unsigned short ccsid,
|
||||
const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
char * libssh2_to_ccsid(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache,
|
||||
unsigned short ccsid,
|
||||
const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
|
||||
where:
|
||||
session is a libssh2 session used for memory allocation.
|
||||
cache is the address of a string cache.
|
||||
ccsid is the external (i.e.: non libssh2) coded character set id.
|
||||
65535 means no conversion and 0 means the current job's CCSID.
|
||||
string is the string to convert.
|
||||
inlen is the source string length in bytes: set to -1 if
|
||||
null-terminated.
|
||||
outlen if not NULL, is the address of a variable that will receive
|
||||
the transcoded string length upon return.
|
||||
|
||||
libssh2_from_ccsid() transcodes the string from the given CCSID to libssh2
|
||||
internal encoding (UTF-8). It is intended to be used to convert API input
|
||||
parameters.
|
||||
libssh2_to_ccsid() transcodes the string from libssh2 internal encoding
|
||||
(UTF-8) to the given CCSID. This has been implemented to get standard API
|
||||
string results in a program's native encoding.
|
||||
|
||||
Both these functions return a pointer to the null-terminated converted string,
|
||||
or NULL if an error occurred. In addition, the variable pointed by outlen
|
||||
receives the effective byte length of the (cached) translated string, or -1
|
||||
in case of error.
|
||||
|
||||
|
||||
|
||||
ILE/RPG support:
|
||||
|
||||
Since 95% of the OS/400 programmers use ILE/RPG exclusively, a definition
|
||||
/INCLUDE member is provided for this language. To include libssh2
|
||||
definitions in an ILE/RPG module, line
|
||||
|
||||
h bnddir('LIBSSH2/LIBSSH2')
|
||||
|
||||
must figure in the program header, and line
|
||||
|
||||
d/include libssh2/libssh2rpg,libssh2
|
||||
|
||||
in the global data section of the module's source code.
|
||||
If required, members ssh2_sftp, ssh2_pkey and ssh2_ccsid may also be included.
|
||||
|
||||
For IFS source compilations, include members are located in directory
|
||||
/libssh2/include/libssh2rpg and have their original names retained.
|
||||
|
||||
ILE/RPG lacks a serious macro preprocessor, thus C macros requiring this
|
||||
feature have not been translated. However, function-like C macros have been
|
||||
implemented as procedures and therefore supported in ILE/RPG.
|
252
os400/ccsid.c
Normal file
252
os400/ccsid.c
Normal file
@@ -0,0 +1,252 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* Character encoding wrappers. */
|
||||
|
||||
#include "libssh2_priv.h"
|
||||
#include "libssh2_ccsid.h"
|
||||
|
||||
#include <qtqiconv.h>
|
||||
#include <iconv.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
|
||||
#define CCSID_UTF8 1208
|
||||
#define CCSID_UTF16BE 13488
|
||||
#define STRING_GRANULE 256
|
||||
#define MAX_CHAR_SIZE 4
|
||||
|
||||
#define OFFSET_OF(t, f) ((size_t) ((char *) &((t *) 0)->f - (char *) 0))
|
||||
|
||||
|
||||
struct _libssh2_string_cache {
|
||||
libssh2_string_cache * next;
|
||||
char string[1];
|
||||
};
|
||||
|
||||
|
||||
static const QtqCode_T utf8code = { CCSID_UTF8 };
|
||||
|
||||
|
||||
static ssize_t
|
||||
terminator_size(unsigned short ccsid)
|
||||
{
|
||||
QtqCode_T outcode;
|
||||
iconv_t cd;
|
||||
char *inp;
|
||||
char *outp;
|
||||
size_t ilen;
|
||||
size_t olen;
|
||||
char buf[MAX_CHAR_SIZE];
|
||||
|
||||
/* Return the null-terminator size for the given CCSID. */
|
||||
|
||||
/* Fast check usual CCSIDs. */
|
||||
switch (ccsid) {
|
||||
case CCSID_UTF8:
|
||||
case 0: /* Job CCSID is SBCS EBCDIC. */
|
||||
return 1;
|
||||
case CCSID_UTF16BE:
|
||||
return 2;
|
||||
}
|
||||
|
||||
/* Convert an UTF-8 NUL to the target CCSID: use the converted size as
|
||||
result. */
|
||||
memset((void *) &outcode, 0, sizeof outcode);
|
||||
outcode.CCSID = ccsid;
|
||||
cd = QtqIconvOpen(&outcode, (QtqCode_T *) &utf8code);
|
||||
if (cd.return_value == -1)
|
||||
return -1;
|
||||
inp = "";
|
||||
ilen = 1;
|
||||
outp = buf;
|
||||
olen = sizeof buf;
|
||||
iconv(cd, &inp, &ilen, &outp, &olen);
|
||||
iconv_close(cd);
|
||||
olen = sizeof buf - olen;
|
||||
return olen? olen: -1;
|
||||
}
|
||||
|
||||
static char *
|
||||
convert_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short outccsid, unsigned short inccsid,
|
||||
const char *instring, ssize_t inlen, size_t *outlen)
|
||||
{
|
||||
char *inp;
|
||||
char *outp;
|
||||
size_t olen;
|
||||
size_t ilen;
|
||||
size_t buflen;
|
||||
size_t curlen;
|
||||
ssize_t termsize;
|
||||
int i;
|
||||
char *dst;
|
||||
libssh2_string_cache *outstring;
|
||||
QtqCode_T incode;
|
||||
QtqCode_T outcode;
|
||||
iconv_t cd;
|
||||
|
||||
if (!instring) {
|
||||
if (outlen)
|
||||
*outlen = 0;
|
||||
return NULL;
|
||||
}
|
||||
if (outlen)
|
||||
*outlen = -1;
|
||||
if (!session || !cache)
|
||||
return NULL;
|
||||
|
||||
/* Get terminator size. */
|
||||
termsize = terminator_size(outccsid);
|
||||
if (termsize < 0)
|
||||
return NULL;
|
||||
|
||||
/* Prepare conversion parameters. */
|
||||
memset((void *) &incode, 0, sizeof incode);
|
||||
memset((void *) &outcode, 0, sizeof outcode);
|
||||
incode.CCSID = inccsid;
|
||||
outcode.CCSID = outccsid;
|
||||
curlen = OFFSET_OF(libssh2_string_cache, string);
|
||||
inp = (char *) instring;
|
||||
ilen = inlen;
|
||||
buflen = inlen + curlen;
|
||||
if (inlen < 0) {
|
||||
incode.length_option = 1;
|
||||
buflen = STRING_GRANULE;
|
||||
ilen = 0;
|
||||
}
|
||||
|
||||
/* Allocate output string buffer and open conversion descriptor. */
|
||||
dst = LIBSSH2_ALLOC(session, buflen + termsize);
|
||||
if (!dst)
|
||||
return NULL;
|
||||
cd = QtqIconvOpen(&outcode, &incode);
|
||||
if (cd.return_value == -1) {
|
||||
LIBSSH2_FREE(session, (char *) dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Convert string. */
|
||||
for (;;) {
|
||||
outp = dst + curlen;
|
||||
olen = buflen - curlen;
|
||||
i = iconv(cd, &inp, &ilen, &outp, &olen);
|
||||
if (inlen < 0 && olen == buflen - curlen) {
|
||||
/* Special case: converted 0-length (sub)strings do not store the
|
||||
terminator. */
|
||||
if (termsize) {
|
||||
memset(outp, 0, termsize);
|
||||
olen -= termsize;
|
||||
}
|
||||
}
|
||||
curlen = buflen - olen;
|
||||
if (i >= 0 || errno != E2BIG)
|
||||
break;
|
||||
/* Must expand buffer. */
|
||||
buflen += STRING_GRANULE;
|
||||
outp = LIBSSH2_REALLOC(session, dst, buflen + termsize);
|
||||
if (!outp)
|
||||
break;
|
||||
dst = outp;
|
||||
}
|
||||
|
||||
iconv_close(cd);
|
||||
|
||||
/* Check for error. */
|
||||
if (i < 0 || !outp) {
|
||||
LIBSSH2_FREE(session, dst);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Process terminator. */
|
||||
if (inlen < 0)
|
||||
curlen -= termsize;
|
||||
else if (termsize)
|
||||
memset(dst + curlen, 0, termsize);
|
||||
|
||||
/* Shorten buffer if possible. */
|
||||
if (curlen < buflen)
|
||||
dst = LIBSSH2_REALLOC(session, dst, curlen + termsize);
|
||||
|
||||
/* Link to cache. */
|
||||
outstring = (libssh2_string_cache *) dst;
|
||||
outstring->next = *cache;
|
||||
*cache = outstring;
|
||||
|
||||
/* Return length if required. */
|
||||
if (outlen)
|
||||
*outlen = curlen - OFFSET_OF(libssh2_string_cache, string);
|
||||
|
||||
return outstring->string;
|
||||
}
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_from_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen)
|
||||
{
|
||||
return convert_ccsid(session, cache,
|
||||
CCSID_UTF8, ccsid, string, inlen, outlen);
|
||||
}
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_to_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen)
|
||||
{
|
||||
return convert_ccsid(session, cache,
|
||||
ccsid, CCSID_UTF8, string, inlen, outlen);
|
||||
}
|
||||
|
||||
LIBSSH2_API void
|
||||
libssh2_release_string_cache(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache)
|
||||
{
|
||||
libssh2_string_cache *p;
|
||||
|
||||
if (session && cache)
|
||||
while ((p = *cache)) {
|
||||
*cache = p->next;
|
||||
LIBSSH2_FREE(session, (char *) p);
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
50
os400/include/alloca.h
Normal file
50
os400/include/alloca.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBSSH2_ALLOCA_H
|
||||
#define LIBSSH2_ALLOCA_H
|
||||
|
||||
/* alloca() emulation. */
|
||||
|
||||
#include <modasa.mih>
|
||||
|
||||
#define alloca(n) _MODASA(n)
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
72
os400/include/stdio.h
Normal file
72
os400/include/stdio.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBSSH2_STDIO_H
|
||||
#define LIBSSH2_STDIO_H
|
||||
|
||||
/*
|
||||
* <stdio.h> wrapper.
|
||||
* Its goal is to redefine snprintf/vsnprintf which are not supported by QADRT.
|
||||
*/
|
||||
|
||||
#include <qadrt.h>
|
||||
|
||||
#if __ILEC400_TGTVRM__ >= 710
|
||||
# include_next <stdio.h>
|
||||
#elif __ILEC400_TGTVRM__ >= 510
|
||||
# ifndef __SRCSTMF__
|
||||
# include <QADRT/h/stdio>
|
||||
# else
|
||||
# include </QIBM/ProdData/qadrt/include/stdio.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
extern int _libssh2_os400_vsnprintf(char *dst, size_t len,
|
||||
const char *fmt, va_list args);
|
||||
extern int _libssh2_os400_snprintf(char *dst, size_t len,
|
||||
const char *fmt, ...);
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
# define vsnprintf(dst, len, fmt, args) \
|
||||
_libssh2_os400_vsnprintf((dst), (len), (fmt), (args))
|
||||
# define snprintf _libssh2_os400_snprintf
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
75
os400/include/sys/socket.h
Normal file
75
os400/include/sys/socket.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef LIBSSH2_SYS_SOCKET_H
|
||||
#define LIBSSH2_SYS_SOCKET_H
|
||||
|
||||
/*
|
||||
* <sys/socket.h> wrapper.
|
||||
* Redefines connect().
|
||||
*/
|
||||
|
||||
#include <qadrt.h>
|
||||
|
||||
#ifndef _QADRT_LT
|
||||
# define _QADRT_LT <
|
||||
#endif
|
||||
#ifndef _QADRT_GT
|
||||
# define _QADRT_GT >
|
||||
#endif
|
||||
|
||||
#ifdef QADRT_SYSINC
|
||||
# include _QADRT_LT QADRT_SYSINC/sys/socket.h _QADRT_GT
|
||||
#elif __ILEC400_TGTVRM__ >= 710
|
||||
# include_next <sys/socket.h>
|
||||
#elif !defined(__SRCSTMF__)
|
||||
# include <QSYSINC/sys/socket>
|
||||
#else
|
||||
# include </QIBM/include/sys/socket.h>
|
||||
#endif
|
||||
|
||||
extern int _libssh2_os400_connect(int sd,
|
||||
struct sockaddr * destaddr, int addrlen);
|
||||
|
||||
#ifndef LIBSSH2_DISABLE_QADRT_EXT
|
||||
#define connect(sd, addr, len) _libssh2_os400_connect((sd), (addr), (len))
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
243
os400/initscript.sh
Normal file
243
os400/initscript.sh
Normal file
@@ -0,0 +1,243 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
setenv()
|
||||
|
||||
{
|
||||
# Define and export.
|
||||
|
||||
eval ${1}="${2}"
|
||||
export ${1}
|
||||
}
|
||||
|
||||
|
||||
case "${SCRIPTDIR}" in
|
||||
/*) ;;
|
||||
*) SCRIPTDIR="`pwd`/${SCRIPTDIR}"
|
||||
esac
|
||||
|
||||
while true
|
||||
do case "${SCRIPTDIR}" in
|
||||
*/.) SCRIPTDIR="${SCRIPTDIR%/.}";;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# The script directory is supposed to be in $TOPDIR/os400.
|
||||
|
||||
TOPDIR=`dirname "${SCRIPTDIR}"`
|
||||
export SCRIPTDIR TOPDIR
|
||||
|
||||
# Extract the SONAME from the library makefile.
|
||||
|
||||
SONAME=`sed -e '/^VERSION=/!d' -e 's/^.* \([0-9]*\):.*$/\1/' -e 'q' \
|
||||
< "${TOPDIR}/src/Makefile.am"`
|
||||
export SONAME
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Tunable configuration parameters.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
setenv TARGETLIB 'LIBSSH2' # Target OS/400 program library.
|
||||
setenv STATBNDDIR 'LIBSSH2_A' # Static binding directory.
|
||||
setenv DYNBNDDIR 'LIBSSH2' # Dynamic binding directory.
|
||||
setenv SRVPGM "LIBSSH2.${SONAME}" # Service program.
|
||||
setenv TGTCCSID '500' # Target CCSID of objects.
|
||||
setenv DEBUG '*ALL' # Debug level.
|
||||
setenv OPTIMIZE '10' # Optimisation level
|
||||
setenv OUTPUT '*NONE' # Compilation output option.
|
||||
setenv TGTRLS 'V5R3M0' # Target OS release.
|
||||
setenv IFSDIR '/libssh2' # Installation IFS directory.
|
||||
|
||||
# Define ZLIB availability and locations.
|
||||
|
||||
setenv WITH_ZLIB 0 # Define to 1 to enable.
|
||||
setenv ZLIB_INCLUDE '/zlib/include' # ZLIB include IFS directory.
|
||||
setenv ZLIB_LIB 'ZLIB' # ZLIB library.
|
||||
setenv ZLIB_BNDDIR 'ZLIB_A' # ZLIB binding directory.
|
||||
|
||||
|
||||
################################################################################
|
||||
|
||||
# Need to get the version definitions.
|
||||
|
||||
LIBSSH2_VERSION=`grep '^#define *LIBSSH2_VERSION ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/.*"\(.*\)".*/\1/'`
|
||||
LIBSSH2_VERSION_MAJOR=`grep '^#define *LIBSSH2_VERSION_MAJOR ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_MAJOR *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_MINOR=`grep '^#define *LIBSSH2_VERSION_MINOR ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_MINOR *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_PATCH=`grep '^#define *LIBSSH2_VERSION_PATCH ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_PATCH *\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_VERSION_NUM=`grep '^#define *LIBSSH2_VERSION_NUM ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/^#define *LIBSSH2_VERSION_NUM *0x\([^ ]*\).*/\1/'`
|
||||
LIBSSH2_TIMESTAMP=`grep '^#define *LIBSSH2_TIMESTAMP ' \
|
||||
"${TOPDIR}/include/libssh2.h" |
|
||||
sed 's/.*"\(.*\)".*/\1/'`
|
||||
export LIBSSH2_VERSION
|
||||
export LIBSSH2_VERSION_MAJOR LIBSSH2_VERSION_MINOR LIBSSH2_VERSION_PATCH
|
||||
export LIBSSH2_VERSION_NUM LIBSSH2_TIMESTAMP
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# OS/400 specific definitions.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
LIBIFSNAME="/QSYS.LIB/${TARGETLIB}.LIB"
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Procedures.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# action_needed dest [src]
|
||||
#
|
||||
# dest is an object to build
|
||||
# if specified, src is an object on which dest depends.
|
||||
#
|
||||
# exit 0 (succeeds) if some action has to be taken, else 1.
|
||||
|
||||
action_needed()
|
||||
|
||||
{
|
||||
[ ! -e "${1}" ] && return 0
|
||||
[ "${2}" ] || return 1
|
||||
[ "${1}" -ot "${2}" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
# canonicalize_path path
|
||||
#
|
||||
# Return canonicalized path as:
|
||||
# - Absolute
|
||||
# - No . or .. component.
|
||||
|
||||
canonicalize_path()
|
||||
|
||||
{
|
||||
if expr "${1}" : '^/' > /dev/null
|
||||
then P="${1}"
|
||||
else P="`pwd`/${1}"
|
||||
fi
|
||||
|
||||
R=
|
||||
IFSSAVE="${IFS}"
|
||||
IFS="/"
|
||||
|
||||
for C in ${P}
|
||||
do IFS="${IFSSAVE}"
|
||||
case "${C}" in
|
||||
.) ;;
|
||||
..) R=`expr "${R}" : '^\(.*/\)..*'`
|
||||
;;
|
||||
?*) R="${R}${C}/"
|
||||
;;
|
||||
*) ;;
|
||||
esac
|
||||
done
|
||||
|
||||
IFS="${IFSSAVE}"
|
||||
echo "/`expr "${R}" : '^\(.*\)/'`"
|
||||
}
|
||||
|
||||
|
||||
# make_module module_name source_name [additional_definitions]
|
||||
#
|
||||
# Compile source name into ASCII module if needed.
|
||||
# As side effect, append the module name to variable MODULES.
|
||||
# Set LINK to "YES" if the module has been compiled.
|
||||
|
||||
make_module()
|
||||
|
||||
{
|
||||
MODULES="${MODULES} ${1}"
|
||||
MODIFSNAME="${LIBIFSNAME}/${1}.MODULE"
|
||||
action_needed "${MODIFSNAME}" "${2}" || return 0;
|
||||
SRCDIR=`dirname \`canonicalize_path "${2}"\``
|
||||
|
||||
# #pragma convert has to be in the source file itself, i.e.
|
||||
# putting it in an include file makes it only active
|
||||
# for that include file.
|
||||
# Thus we build a temporary file with the pragma prepended to
|
||||
# the source file and we compile that temporary file.
|
||||
|
||||
echo "#line 1 \"${2}\"" > __tmpsrcf.c
|
||||
echo "#pragma convert(819)" >> __tmpsrcf.c
|
||||
echo "#line 1" >> __tmpsrcf.c
|
||||
cat "${2}" >> __tmpsrcf.c
|
||||
CMD="CRTCMOD MODULE(${TARGETLIB}/${1}) SRCSTMF('__tmpsrcf.c')"
|
||||
# CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST *SHOWINC *SHOWSYS)"
|
||||
CMD="${CMD} SYSIFCOPT(*IFS64IO) OPTION(*INCDIRFIRST)"
|
||||
CMD="${CMD} LOCALETYPE(*LOCALE)"
|
||||
CMD="${CMD} INCDIR('${TOPDIR}/os400/include'"
|
||||
CMD="${CMD} '/QIBM/ProdData/qadrt/include' '${TOPDIR}/include'"
|
||||
CMD="${CMD} '${TOPDIR}/os400' '${SRCDIR}'"
|
||||
|
||||
if [ "${WITH_ZLIB}" != "0" ]
|
||||
then CMD="${CMD} '${ZLIB_INCLUDE}'"
|
||||
fi
|
||||
|
||||
CMD="${CMD} ${INCLUDES})"
|
||||
CMD="${CMD} TGTCCSID(${TGTCCSID}) TGTRLS(${TGTRLS})"
|
||||
CMD="${CMD} OUTPUT(${OUTPUT})"
|
||||
CMD="${CMD} OPTIMIZE(${OPTIMIZE})"
|
||||
CMD="${CMD} DBGVIEW(${DEBUG})"
|
||||
|
||||
DEFINES="${3}"
|
||||
|
||||
if [ "${WITH_ZLIB}" != "0" ]
|
||||
then DEFINES="${DEFINES} HAVE_LIBZ LIBSSH2_HAVE_ZLIB"
|
||||
fi
|
||||
|
||||
if [ "${DEFINES}" ]
|
||||
then CMD="${CMD} DEFINE(${DEFINES})"
|
||||
fi
|
||||
|
||||
system "${CMD}"
|
||||
rm -f __tmpsrcf.c
|
||||
LINK=YES
|
||||
}
|
||||
|
||||
|
||||
# Determine DB2 object name from IFS name.
|
||||
|
||||
db2_name()
|
||||
|
||||
{
|
||||
if [ "${2}" = 'nomangle' ]
|
||||
then basename "${1}" |
|
||||
tr 'a-z-' 'A-Z_' |
|
||||
sed -e 's/\..*//;s/^\(.\).*\(.........\)$/\1\2/'
|
||||
else basename "${1}" |
|
||||
tr 'a-z-' 'A-Z_' |
|
||||
sed -e 's/\..*//;s/^LIBSSH2_/SSH2_/' \
|
||||
-e 's/^\(.\).*\(.........\)$/\1\2/' \
|
||||
-e 's/^SPUBLICKEY$/SSH2_PKEY/'
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Copy stream replacing version info.
|
||||
|
||||
versioned_copy()
|
||||
|
||||
{
|
||||
sed -e "s/@LIBSSH2_VERSION@/${LIBSSH2_VERSION}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_MAJOR@/${LIBSSH2_VERSION_MAJOR}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_MINOR@/${LIBSSH2_VERSION_MINOR}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_PATCH@/${LIBSSH2_VERSION_PATCH}/g" \
|
||||
-e "s/@LIBSSH2_VERSION_NUM@/${LIBSSH2_VERSION_NUM}/g" \
|
||||
-e "s/@LIBSSH2_TIMESTAMP@/${LIBSSH2_TIMESTAMP}/g"
|
||||
}
|
63
os400/libssh2_ccsid.h
Normal file
63
os400/libssh2_ccsid.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Patrick Monnerat, D+H <patrick.monnerat@dh.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* CCSID conversion support. */
|
||||
|
||||
#ifndef LIBSSH2_CCSID_H_
|
||||
#define LIBSSH2_CCSID_H_
|
||||
|
||||
#include "libssh2.h"
|
||||
|
||||
typedef struct _libssh2_string_cache libssh2_string_cache;
|
||||
|
||||
|
||||
LIBSSH2_API char *
|
||||
libssh2_from_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
LIBSSH2_API char *
|
||||
libssh2_to_ccsid(LIBSSH2_SESSION *session, libssh2_string_cache **cache,
|
||||
unsigned short ccsid, const char *string, ssize_t inlen,
|
||||
size_t *outlen);
|
||||
LIBSSH2_API void
|
||||
libssh2_release_string_cache(LIBSSH2_SESSION *session,
|
||||
libssh2_string_cache **cache);
|
||||
|
||||
#endif
|
||||
|
||||
/* vim: set expandtab ts=4 sw=4: */
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user