Compare commits

..

232 Commits

Author SHA1 Message Date
Daniel Stenberg
98b0afdab8 release 1.1 2009-04-02 08:49:29 +00:00
Daniel Stenberg
5a3da233ec Sofian Brabez removed duplicate calls to libssh2_session_set_blocking() 2009-03-31 12:20:36 +00:00
Daniel Stenberg
74f4b7817b Uh, it is important that we don't set the local state 'local.close' to TRUE
until _after_ we're done as otherwise we might not get called again properly
to clean the entire thing since the close state is checked in
libssh2_channel_free
2009-03-31 08:52:25 +00:00
Daniel Stenberg
9ba11a374c Removed the trace output that said "May block until packet of type..." since
it simply wasn't true for non-blocking operations.
2009-03-30 09:19:49 +00:00
Daniel Stenberg
117b95e6e3 made sure the SFTP code makes more use of internal non-blocking functions
instead of the external API entries
2009-03-29 22:09:29 +00:00
Daniel Stenberg
60ee30b6c9 Fixed the memory leak in in libssh2_userauth_hostbased_fromfile_ex() that
Jean-Louis Charton found. Additional minor indent and comment edits.
2009-03-28 21:31:53 +00:00
Daniel Stenberg
55744f8f34 indent changes and removed libssh2_ prefix from static function 2009-03-28 21:22:16 +00:00
Yang Tse
8f78a935ca include libssh2_priv.h instead of libssh2.h in order to get
LIBSSH2_API properly defined on LIBSSH2_WIN32 build targets
2009-03-28 12:50:34 +00:00
Daniel Stenberg
75d5830490 Additional non-blocking fixes. 2009-03-27 22:24:09 +00:00
Daniel Stenberg
103a6e9e0b Me and my long fingers couldn't resist "merging" these statements in a previous
commit but of course that broke functionality and this is a revert of that
change.
2009-03-27 21:52:49 +00:00
Daniel Stenberg
76dab196b1 Dump to stderr simply because the other tracing functions in misc.c already
use stderr and mixing output "channels" causes too much confusion for me!
2009-03-27 21:51:43 +00:00
Daniel Stenberg
4353711127 fixed sftp_shutdown() for the blockiness and fixed libssh2_channel_close()
to work properly non-blocking
2009-03-27 20:20:48 +00:00
Daniel Stenberg
ad8b49b208 Fixed the order of the check in the BLOCK_ADJUST() macro so that it also works
for libssh2_session_free()
2009-03-27 12:48:03 +00:00
Daniel Stenberg
1d2bd301d3 kill warnings 2009-03-27 09:52:19 +00:00
Daniel Stenberg
5936d9ce4e Fix the BLOCK_ADJUST_ERRNO() macro to behave properly in blocking mode. 2009-03-27 09:37:48 +00:00
Simon Josefsson
de0c4159bf Add AC_CONFIG_MACRO_DIR to avoid warnings with libtool v2.2.x. 2009-03-27 08:54:15 +00:00
Daniel Stenberg
f390c8e02d fix comments, moved to htonu64 function to sftp.c and made it static 2009-03-27 07:03:00 +00:00
Daniel Stenberg
9df891e412 More cleaning up converting libssh2_ to _libssh2_ for internal functions and
removing libssh2_ from static functions. Added mac.h.
2009-03-26 22:25:23 +00:00
Daniel Stenberg
fc28f33384 comp.c only as a single _libssh2_ function, no external one 2009-03-26 22:09:35 +00:00
Daniel Stenberg
eabe072496 * Renamed the functions in src/transport.c to be _libssh2_transport_ prefixed
and introduced a transport.h header.

* Fixed the blocking mode to only change behavior not the actual underlying
  socket mode so we now always work with non-blocking sockets. This also
  introduces a new rule of thumb in libssh2 code: we don't call the
  external function calls internally. We use the internal (non-blocking)
  ones!

* libssh2_channel_receive_window_adjust2 was added and
  libssh2_channel_receive_window_adjust is now deprecated

* Introduced "local" header files with prototypes etc for different parts
  instead of cramming everything into libssh2_priv.h. channel.h is the
  first.
2009-03-26 15:41:14 +00:00
Daniel Stenberg
239bdffb59 avoid some busy-looping 2009-03-25 22:52:32 +00:00
Daniel Stenberg
bab3a30220 one function to remove, one proto to correct 2009-03-23 13:54:16 +00:00
Daniel Stenberg
2e548c1ca0 Updated comments and removed "libssh2_" prefixes from static functions 2009-03-23 13:35:20 +00:00
Daniel Stenberg
1e1ba6219e added basic docs 2009-03-23 13:20:48 +00:00
Daniel Stenberg
27d74a7bd5 quite possibly one of the most pointless functions in the libssh2 API...a 2009-03-23 13:17:49 +00:00
Daniel Stenberg
3d97a87669 ENOTCONN obviously doesn't exist in win32 so don't try to map that 2009-03-23 13:08:17 +00:00
Daniel Stenberg
022cac8510 [no comment] 2009-03-23 12:53:50 +00:00
Daniel Stenberg
d187a0fdb6 EEK revert the part of the previous commit that was just my non-functional
attempts to make things work with blocking sockets.
2009-03-23 12:51:53 +00:00
Daniel Stenberg
1936d167d1 I cut out the poll_socket argument from the protos for_libssh2_packet_askv()
and _libssh2_packet_ask() since they are internal and nothing in the code base
uses that functionality == simplicity with no drawbacks!
2009-03-23 12:43:59 +00:00
Daniel Stenberg
26b65e06b1 pass in unsigned ints for u32 values and not longs 2009-03-19 12:54:58 +00:00
Daniel Stenberg
468272d648 - (Mar 19 2009) Daniel Stenberg: based on a patch by "E L" we now use errno
properly after recv() and send() calls (that internally are now known as
  _libssh2_recv() and _libssh2_send()) so that the API and more works fine on
  windows too!
2009-03-19 12:45:59 +00:00
Daniel Stenberg
563f627647 I'm upgrading myself! 2009-03-18 13:11:28 +00:00
Simon Josefsson
872a6e28dc Add StrictModes=no to work around cygwin problem.
Reported by Yang Tse <yangsita@gmail.com>.
2009-03-17 19:07:35 +00:00
Simon Josefsson
fa5509d9f2 Add UsePrivilegeSeparation=no for cygwin.
Reported by Yang Tse <yangsita@gmail.com>
2009-03-17 17:25:42 +00:00
Daniel Stenberg
53ad07633e re-indented for clarity 2009-03-17 14:58:24 +00:00
Daniel Stenberg
0b7f20566c re-indented _libssh2_channel_packet_data_len() somewhat to make the huge
condition somewhat easier on the eye
2009-03-17 14:44:38 +00:00
Daniel Stenberg
cc5e952fa0 A cleanup effort: libssh2_ prefixes only on external APIs. Use _libssh2_ prefix
for library-wide internal functions. Don't use any of those on static functions.
I also did some comments and whitespace changes.
2009-03-17 13:48:35 +00:00
Daniel Stenberg
f2fa02c575 bump packet default size to 32768 2009-03-17 12:09:53 +00:00
Daniel Stenberg
0dbc6ed8b6 Refer to the exact symbol name, which also is the exact file name of the man
page file.
2009-03-17 10:34:27 +00:00
Simon Josefsson
c7a1d30590 Use libtool -export-symbols-regex to reduce numer of exported symbols. 2009-03-17 10:19:54 +00:00
Daniel Stenberg
8096b459d4 cleanup round 2009-03-16 23:25:14 +00:00
Daniel Stenberg
7ef3406b57 Added (templates for) the 13 missing man pages 2009-03-16 15:00:45 +00:00
Daniel Stenberg
d870042496 two more renaming of man pages to the actual function name 2009-03-16 14:40:37 +00:00
Daniel Stenberg
27355c740f rename the man page to use the same name as the actual function 2009-03-16 14:28:37 +00:00
Daniel Stenberg
f8ad00e6ae mention the basic changes in my previous few commits 2009-03-16 08:23:54 +00:00
Daniel Stenberg
94090cf55c Patch from bug report #1960894 by "Heiner" applied, and edited by me. It makes
SCP recv and send deal with file names containing spaces (and other
shell-special letters) by quoting them before they are passed to the remote
server.
2009-03-15 23:28:25 +00:00
Daniel Stenberg
ce9d44a3ff fixed some wrong comments and did a minor code edit and some further
whitespace changes
2009-03-15 23:07:09 +00:00
Daniel Stenberg
a678dbac06 added three more public functions I found lacking man pages 2009-03-15 22:59:46 +00:00
Daniel Stenberg
0812744424 fix a compiler warning 2009-03-15 22:40:11 +00:00
Daniel Stenberg
f56b8ef605 simplified how the "scp" command line is created in the libssh2_scp_recv()
function
2009-03-15 22:38:47 +00:00
Daniel Stenberg
1a630c5c09 Simplified libssh2_channel_read_ex() and made it send window adjustments less
frequent, use a few less struct fields in the channel struct and improved
reading from the network with libssh2_packet_read(). I also modified the
windowing algorithm and now use a much larger window. This greatly enhances
SSH/SCP performance. I also increased the size of the buffer the transport
layer uses from 4k to 16K.
2009-03-15 22:29:23 +00:00
Daniel Stenberg
3793b6768d oops, use %06d for the microseconds! 2009-03-14 23:04:25 +00:00
Daniel Stenberg
269bd5e9a4 re-indented and other whitespace edits 2009-03-14 22:29:48 +00:00
Daniel Stenberg
d7566e5065 improved trace logs with time stamps 2009-03-14 22:29:28 +00:00
Daniel Stenberg
bdd005a5e5 fixed to work quite similar to the sftp_nonblock example so that it waits
for the socket correctly and measures the transfer speed fine
2009-03-14 09:40:57 +00:00
Daniel Stenberg
a52f5d3b7e Cleanups, that do seem to have boosted SFTP download performance up to 300% in
some tests:

  * cut off "_ex" from several internal function names

  * corrected some log outputs

  * simplified libssh2_channel_read_ex() and made it much faster in the process

  * cut out {{{ and }}} comments that were incorrect anyway

  * fixed sftp_packet_ask() to return the correct packet by using memcmp() and
    not strncmp()

  * fixed mkdir()'s wait for packet to use the correct request_id - it
    semi-worked previously because strncmp() in sftp_packet_ask() made it
    match far too easily.

  * took away the polling functionality from sftp_packet_ask() since it wasn't
    used
2009-03-13 22:15:27 +00:00
Daniel Stenberg
d89782d99f improved non-blocking behavior for some of the initing stuff before the actual
data transfer begins
2009-03-13 22:14:47 +00:00
Daniel Stenberg
2ba8db9168 wait for socket action accordingly, and do some measurements on the transfer
to make this better to use for speed tests
2009-03-13 12:35:13 +00:00
Daniel Stenberg
5f32304805 - (Mar 7 2009) Olivier Hervieu pointed out a flaw in the
libssh2_channel_x11_req_ex() function that made it produce a crappy random
  chunk of data. Peter Stuge improved the fix to not do out-of-boundary
  writes. I (Daniel Stenberg) replaced the snprintf() with a plain sprintf()
  since the size argument wasn't adding anything anyway.
2009-03-07 22:08:05 +00:00
Guenter Knauf
16941e1fcf some minor Makefile tweaks. 2009-03-06 07:25:37 +00:00
Daniel Stenberg
663da93b42 - Added libssh2_version() 2009-02-23 16:22:46 +00:00
Daniel Stenberg
1addcbbf53 - (Feb 20 2009) libssh2_channel_direct_tcpip_ex() bug #1902169 fixed, which
caused it to fail when called a second time.
2009-02-20 16:14:45 +00:00
Mikhail Gusarov
d722e09196 Fixed dash-as-minus warning in libssh2_base64_decode.3 manpage 2009-02-17 16:22:51 +00:00
Mikhail Gusarov
317740415a Fixed syntax error in libssh2_banner_set.3 manpage 2009-02-17 16:22:17 +00:00
Simon Josefsson
558de5e103 Bump ABI revision from 1.0.0 to 1.0.1 due to code changes. 2009-02-16 21:49:31 +00:00
Simon Josefsson
74aad1869d Fix typo. 2009-02-16 21:48:22 +00:00
Simon Josefsson
b9de72732b Add date for v1.0 release. 2009-02-16 21:46:40 +00:00
Daniel Stenberg
c672b837f8 - (Feb 12 2009) Romain Bondue extended Markus Moeller fix from Feb 8, based on
a previous (uncommitted) patch by Erik Brossler. It improves
  libssh2_channel_write_ex in blocking situations when the socket is set non-
  blocking.
2009-02-12 11:46:28 +00:00
Daniel Stenberg
c547e07caa Markus Moeller fixed a flaw in libssh2_channel_write_ex() that would occur
on EAGAIN situations.
2009-02-08 12:09:20 +00:00
Daniel Stenberg
6a78a6b358 I want to remove all those macros from the official API at next soname bump 2009-01-01 22:52:46 +00:00
Daniel Stenberg
369fcddb24 fixed compiler warnings, and stripped off "libssh2_" from static functions
as that makes shorter function names and then making the code look fine within
80 columns is easier!
2009-01-01 22:47:06 +00:00
Daniel Stenberg
97fbb77da5 made the three public headers use (mostly) lines shorter than 80 columns as
HACKING says - it makes them much more readable to my old tired eyes...
2009-01-01 22:27:08 +00:00
Daniel Stenberg
acc2c5dfb9 we're actually working on the 1.0.1 version now (or should it be 1.1?) 2008-12-28 21:01:36 +00:00
Daniel Stenberg
27197bcff3 Added 'TODO' file (again) with some fresh things I could think of right now 2008-12-26 07:54:08 +00:00
Daniel Stenberg
64b3e5e3f6 Added libssh2_trace man page 2008-12-26 07:46:45 +00:00
Daniel Stenberg
ba79d6b52d libssh2_base64_decode is deprecated and subject for removal in a future
version (like on the next soname bump)
2008-12-26 07:37:55 +00:00
Daniel Stenberg
6b38e21fa7 wrote up a first libssh2_base64_decode man page, added a few missing man
pages to the tarball
2008-12-23 13:23:45 +00:00
Daniel Stenberg
11330ee6da based on Heiner Steven's report, fix the name and description of these man
pages!
2008-12-23 12:34:17 +00:00
Daniel Stenberg
b3649e86a8 briefly mention my recent sftp-related fixes 2008-12-22 23:40:27 +00:00
Daniel Stenberg
2f32080772 mention web site and mailing list, as I think they're not mentioned anywhere
else in the package!
2008-12-22 23:39:46 +00:00
Daniel Stenberg
7aac082782 removed obviously superfluous comments 2008-12-22 22:43:05 +00:00
Daniel Stenberg
5a35edcb9a use a single >>32 instead of "(value / 65536) / 65536", just make sure that
the shift is done on a 64bit type
2008-12-22 22:33:03 +00:00
Daniel Stenberg
079d20aca8 remove unused #ifndef, and two whitespace changes 2008-12-22 22:31:51 +00:00
Daniel Stenberg
b357379923 style/indent changes only to enforce < 80 column lines more strict 2008-12-22 22:10:47 +00:00
Daniel Stenberg
62769b438f libssh2_sftp_seek64() it is now for the 64bit seek function too as the seek2
name has never been used in a release and it makes the naming consistent
2008-12-22 13:18:36 +00:00
Daniel Stenberg
d602478e87 0.19 is now 1.0 2008-12-22 12:51:27 +00:00
Daniel Stenberg
8eba2961ac Based on Alexander Lamaison's patch, there's now a new
function called libssh2_sftp_tell64() that returns the 64 bit file offset,
as the existing libssh2_sftp_tell() only returns a size_t.
2008-12-22 12:46:45 +00:00
Daniel Stenberg
962a41e4ec first conversion of a malloc => buffer in the sftp handle struct 2008-12-22 12:38:41 +00:00
Daniel Stenberg
31841e7c74 helper script for emacs users to get the code style done libssh2-style
automatically
2008-12-20 12:36:50 +00:00
Daniel Stenberg
70f844e57c - Markus Moeller fixed the issue also reported by Alexander Lamaison which
caused SFTP reads with large buffers to fail.
2008-12-19 22:21:36 +00:00
Simon Josefsson
942a81c8d5 Sshd is slow to start on some systems. 2008-12-17 16:22:37 +00:00
Daniel Stenberg
e26956be72 Avoid one malloc by putting the entire handle buffer in the handle struct
at once, use a define for the maximum size length of the handle instead of
'256' in the code.
2008-12-17 10:45:20 +00:00
Daniel Stenberg
2535c5c2ee removed some more libssh2_ prefixes from private functions
Made the libssh2_sftp_open_ex() deal with servers that first responds with
STATUS OK and then sends the actual HANDLE. It seems openssh does this at
times and it screwed things up. To me it seems like a spec violation...
2008-12-16 15:35:33 +00:00
Daniel Stenberg
197a26ef8c removed unused code, intended the code somewhat 2008-12-16 15:32:20 +00:00
Daniel Stenberg
f1dae83d5e Nothing used libssh2_sftp_packet_read's flush argument anymore so I removed
it and simplified the code somewhat thanks to that. I then renamed the function
to sftp_packet_read() only since it is private in this file anyway.
2008-12-16 12:31:58 +00:00
Daniel Stenberg
bcad67636b renamed libssh2_sftp_packet_requirev to plain sftp_packet_requirev since it
is private in this file only and a shorter name is nicer

Removed a "flush" of the data in sftp_packet_requirev() that now seems to have
made SFTP operations a lot more reliable. It didn't make much sense to have it
there but if someone can present a reason for one I figure we should carefully
investigate one and only do it conditionally where/when needed.
2008-12-15 22:58:07 +00:00
Daniel Stenberg
fbb25c7ad0 Clarify that this is only fine to use after an actual SFTP protocol error
return code.
2008-12-15 18:48:09 +00:00
Simon Josefsson
e47bedf17c Support EXEEXT in self-test. 2008-11-27 16:00:07 +00:00
Simon Josefsson
19f78244de Cygwin needs -lcrypto for -lssl.
Reported by "Yang Tse" <yangsita@gmail.com>.
2008-11-27 15:47:05 +00:00
Daniel Stenberg
9d5ba0dee2 oops, add missing file 2008-11-27 12:19:43 +00:00
Yang Tse
0934c4b39d fix again cygwin build failure unreleased regression 2008-11-26 18:15:09 +00:00
Dan Fandrich
cc3a7d8e83 Fixed a potential use of an uninitialized variable, the result of which lead
to an unneeded but harmless realloc.
Reduced the scope of some automatic variables.
2008-11-25 07:01:47 +00:00
Dan Fandrich
8f860e249e Fixed some typos in log messages 2008-11-25 06:49:04 +00:00
Daniel Stenberg
160f89f42e - Vlad Grachov brought the new function called
libssh2_session_block_directions() which returns a bitmask for what
  directions the connection blocks. It is to be used applications that use
  non-blocking sockets and when a libssh2 function returns
  LIBSSH2_ERROR_EAGAIN this function can be used to figure out in which
  direction the socket would block and thus it can wait for the socket to
  again be ready for communication in that direction before it calls libssh2
  again.
2008-11-24 13:31:00 +00:00
Simon Josefsson
881b01e522 Add a more realistic self-test of libssh2. 2008-11-21 15:00:18 +00:00
Simon Josefsson
74d33d50ba Ignore coverage/. 2008-11-21 14:51:43 +00:00
Simon Josefsson
fcaa810350 Add rules to generate a code coverage report. 2008-11-21 14:51:28 +00:00
Simon Josefsson
1f015d72b1 Use AM_CPPFLAGS instead of deprecated INCLUDES. 2008-11-21 14:34:03 +00:00
Simon Josefsson
8c8ba3bc20 Add self-test of base64 decode. 2008-11-21 08:36:38 +00:00
Simon Josefsson
9d433d4f80 Add gcov files. 2008-11-21 08:23:54 +00:00
Dan Fandrich
50a3255dde Use only C89-style comments 2008-11-21 02:25:38 +00:00
Dan Fandrich
482072939a Check LIBSSH2_HMAC_RIPEMD consistently 2008-11-21 01:07:08 +00:00
Simon Josefsson
f2253aeee9 Fix compiler warnings. 2008-11-20 10:29:01 +00:00
Simon Josefsson
2b5becfe85 Move pem.c to libgcrypt section, it is not needed for OpenSSL. 2008-11-20 10:09:43 +00:00
Simon Josefsson
8b25820589 Drop pkg-config test, not needed now. 2008-11-19 11:17:53 +00:00
Simon Josefsson
fd0bffdb2e Rewrite OpenSSL+libz detection logic. 2008-11-19 11:10:48 +00:00
Simon Josefsson
86eaae7886 Add more. 2008-11-18 17:00:57 +00:00
Daniel Stenberg
8e8dc43b0c fix the include path to also point out the build dir's src/ dir for the cases
where we build the lot outside of the source dir
2008-11-11 22:33:26 +00:00
Daniel Stenberg
e45bddb9fd avoid duplicate function declarations on windows 2008-11-11 22:32:33 +00:00
Daniel Stenberg
e5a36fb1cf WINSOCK_VERSION is no longer used (Richard W.M. Jones fixed) 2008-11-10 21:26:14 +00:00
Daniel Stenberg
5438cffd9a Richard W.M. Jones' 5 patches that enables libssh2 to get cross-compiled with
mingw
2008-11-10 16:48:41 +00:00
Paul Thomas
95b73812e7 Fixes a problem that the last code change apparently didn't fix. Verified
that this works correctly with another user.
2008-11-09 17:54:23 +00:00
Paul Thomas
85b953d0dd Fixed an issue with a patch that I submitted where the channel_read_ex()
could get stuck in a busy read loop.
2008-11-01 17:28:30 +00:00
Yang Tse
c3447ea29f fix cygwin build failure unreleased regression 2008-10-25 01:43:08 +00:00
Paul Thomas
8896b675f8 Reformatted the code, updated line endings to match original file,
fixed the build problem, removed tabs and replaced with spaces
 and removed C89 unfriendly comments.
2008-10-03 01:14:46 +00:00
Daniel Stenberg
b2334b227d mention libssh2_channel_request_pty_size_ex() 2008-10-02 09:44:38 +00:00
Daniel Stenberg
88d0ef1f3f two new committers! 2008-10-02 09:42:09 +00:00
Paul Thomas
006f233361 This fix addresses bug# 2141548. Channel reads would fail despite
libssh2_poll() detecting that there was data ready to be read on
the socket. This is seen when small amounts of data are ready to
be read, typically 1-4 chars worth.
2008-10-02 02:26:49 +00:00
Paul Thomas
fa620b2a7b Committed changes to add in support for pty resizing. Credit for this
patch goes to Vincent Jaulin.
2008-10-01 01:47:48 +00:00
Paul Thomas
b228f132f7 Fixed an issue with the libssh2_poll_channel_read function not
reading both normal and extended data when a non-zero value
is passed in as the 2nd parameter. This now matches the functionallity
described in the documentation.
2008-10-01 01:31:15 +00:00
Daniel Stenberg
8c43bc52b1 Carlo Bramini fixed the build for msys+mingw. Bug #1943976. 2008-09-30 21:54:20 +00:00
Daniel Stenberg
d26a330483 Carlo Bramini's fixes for the nonblocking examples for msys/mingw 2008-09-30 08:55:35 +00:00
Daniel Stenberg
b4b8c51b32 Neil Gierman provided improved Visual Studio 2008 code in bug #1946268 2008-09-29 18:59:40 +00:00
Daniel Stenberg
818e9edfb1 - Bug #1862727 fixed libssh2_poll() to work on windows (by defining HAVE_SELECT). 2008-09-29 14:16:19 +00:00
Daniel Stenberg
61fda23340 - Based on bug #1815692, we introduce libssh2_sftp_seek2() that allows seeking
beyond the 2GB margin even on 32bit machines.
2008-09-29 14:11:29 +00:00
Daniel Stenberg
93ae080bbc - Based on a patch in bug #1878059 by Steven Ayre libssh2 now parses >2GB file
sizes when downloading SCP files.
2008-09-29 14:04:01 +00:00
Daniel Stenberg
bd3dfed7e8 Adhere to RFC4253 better and don't use dash in the banner string. Bug #2064371 2008-09-29 13:42:41 +00:00
Daniel Stenberg
99afc66665 Sean Peterson's key re-exchange fix. See his long explanation on:
http://daniel.haxx.se/projects/libssh2/mail/libssh2-devel-archive-2008-06/0002.shtml
2008-07-03 16:26:55 +00:00
Daniel Stenberg
903307113e minor language updates 2008-07-03 10:58:53 +00:00
Daniel Stenberg
9b31ca67ac Gah, I broke Sebastian's patch when I left out the parentheses his patch
did contain. Added properly now.
2008-06-24 22:33:25 +00:00
Daniel Stenberg
3f0d30d1d6 |sftp.c:1470: warning: cast to pointer from integer of different size Another
reason why macros are evil: The string (which is allready char *) should be
cast into char * not the integer.

Signed-off-by: Sebastian Siewior <sebastian@breakpoint.cc>
2008-06-23 22:20:00 +00:00
Mikhail Gusarov
d4aa801f6f Added manpage for libssh2_userauth_keyboard_interactive_ex(3) 2008-03-08 18:26:32 +00:00
Daniel Stenberg
f56daac7fe - Mike Protts filed the bug report #1908724 that identified and fixed a problem
with SFTP stat on files >4GB in size. Previously it used 32bit math only.
2008-03-07 11:55:07 +00:00
Dan Fandrich
a55e6c10c9 Removed a stderr debug message that was accidentally left in (bug #1863153) 2008-01-03 19:12:50 +00:00
Daniel Stenberg
2fcaa00e3a as mentioned in bug #1841442, select wants maxfd+1 in its first argument! 2008-01-02 14:48:48 +00:00
Daniel Stenberg
0242a3b6af corrected wrong comment and made libssh2_channel_wait_closed() return 0 as
documented!
2007-11-29 11:32:34 +00:00
Daniel Stenberg
b310cc3465 oops 2007-11-29 10:04:16 +00:00
Daniel Stenberg
092e5f4b44 added libssh2_channel_wait_closed man page 2007-11-29 10:02:58 +00:00
Daniel Stenberg
c1a83abff9 remove trailing junk character 2007-11-29 09:57:22 +00:00
Mikhail Gusarov
f3c344da22 Fix syntax errors in libssh2_sftp_init and libssh2_sftp_open_ex manpages. 2007-11-21 14:07:32 +00:00
Guenter Knauf
4600d108ed fixed 'uninitialized' compiler warnings. 2007-11-18 20:57:13 +00:00
Daniel Stenberg
76e8e81402 valgrind was friendly enough to point out that doing memcpy() on overlapping
memory areas is a very bad idea so I changed this to memmove()
2007-11-12 23:09:45 +00:00
Daniel Stenberg
d27dd927cd add 0.18 release date 2007-11-12 09:22:32 +00:00
Daniel Stenberg
63d863241a 0.19 in progress 2007-11-12 09:21:46 +00:00
Daniel Stenberg
dbbd9eafc6 mention Dan Fandrich and Guenter Knauf 2007-11-10 23:36:41 +00:00
Daniel Stenberg
c92465930d fix three compiler warnings on comparison between signed and unsigned 2007-11-08 15:53:04 +00:00
Daniel Stenberg
34d5c9a4b1 Added a note about recent changes in a summarized way, added dates to the three
most recent releases and made many lines < 80 columns.
2007-11-08 15:42:09 +00:00
Daniel Stenberg
e8bb993437 include specified files from the win32 dir, not everything within it since
that gives us CVS files too etc
2007-11-08 15:14:13 +00:00
Daniel Stenberg
030b670e2a Moved the check that the amount of data is larger than the blocksize to
only get done on the first block. Based on the bug report #1826989
https://sourceforge.net/tracker/?func=detail&atid=703942&aid=1826989&group_id=125852
2007-11-08 13:51:23 +00:00
Daniel Stenberg
371a795443 fix transfer stall bug with non-blocking transfers, by Gavrie Philipson 2007-11-08 13:46:54 +00:00
Dan Fandrich
2d773f9322 Stop shadowing a global declaration 2007-09-28 18:29:40 +00:00
Daniel Stenberg
80f6c7c6d1 Immanuel Gregoire made libssh2_packet_read() properly deal with blocks when
in non-blocking state. Until this fix, libssh2 just couldn't work properly
on Windows while non-blocking.
2007-09-24 20:49:43 +00:00
Daniel Stenberg
46f26d3d0e oops, that was debugging code that wasn't supposed to be committed! 2007-09-24 12:15:45 +00:00
Daniel Stenberg
5d91d286f1 fix by Immanuel Gregoire, sizeof != strlen! 2007-09-24 12:14:18 +00:00
Guenter Knauf
5a854cfb26 fixed ssize_t typedef; added a define to detect already defined ssize_t. 2007-09-18 18:13:18 +00:00
Guenter Knauf
e905b206ed fix line endings to crlf and flag binary to avoid nasty conversions. 2007-09-15 15:26:37 +00:00
Dan Fandrich
fe7a6f967d Mention the const change in libssh2_channel_setenv_ex since it's a (minor)
change to the API.
2007-08-20 23:26:58 +00:00
Guenter Knauf
5879a0245b added link to native Win32 awk. 2007-08-18 18:53:26 +00:00
Daniel Stenberg
d90d8bdae7 The libssh2_channel_receive_window_adjust() function failed to set the state
variables at times and thus this function would misbehave on repeated invokes.
2007-08-12 21:53:32 +00:00
Daniel Stenberg
f216b36328 When we have less than blocksize data left we MUST (attempt to) read more
since we can't decrypt anything in that situation.
2007-08-10 22:22:45 +00:00
Dan Fandrich
c4630d1ffb Removed unnecessary casts and added const where necessary. 2007-08-09 01:10:11 +00:00
Dan Fandrich
17173aab0e Added const to varname parameter of libssh2_channel_setenv_ex 2007-08-09 01:09:09 +00:00
Dan Fandrich
f8d4de78e9 Fixed the samples to build outside the source tree.
Removed redundant _SOURCES lines.
2007-08-09 00:42:05 +00:00
Daniel Stenberg
e32ff531a3 Satish Mittal and David J Sullivan fixed an infinit recv() loop in
libssh2_banner_receive()
2007-08-08 21:43:12 +00:00
Guenter Knauf
a227554c26 fixed test makefile to generate config.h. 2007-08-08 16:32:42 +00:00
Daniel Stenberg
9f27d176f8 we work on 0.18 now, although it might be 1.0 - who knows? 2007-08-06 20:59:08 +00:00
Daniel Stenberg
bcc4fd6e82 0.17 re-indent 2007-08-06 20:50:22 +00:00
Daniel Stenberg
210459db4b re-indented the source code with this script:
indent \
--braces-on-if-line \
--braces-after-struct-decl-line \
--space-after-cast \
--line-length 79 \
--comment-line-length 79 \
--cuddle-else \
--no-tabs \
--tab-size 8 \
--indent-level 4 \
--no-space-after-for \
--space-after-if \
--space-after-while \
--no-space-after-function-call-names \
*.[ch]
2007-08-06 20:48:04 +00:00
Daniel Stenberg
4c3dd3ea9f 0.16 news 2007-08-06 15:00:48 +00:00
James Housley
0d78e69016 libssh2_userauth_list() requires the lenght of the username to be passed,
and not the sizeof() the array holding it.
2007-08-03 15:08:28 +00:00
Daniel Stenberg
02e5b3b423 LIBSSH2_APINO is now gone, the sooner the better. This is gonna cause some
pains in apps relying on it, but it is broken by design and we should not
rely on it at all. Go for the LIBSSH2_VERSION_* defines instead if you need
to check for versions.
2007-08-03 08:05:36 +00:00
Daniel Stenberg
9399ef83c4 this is generated, no need to commit it 2007-08-03 08:04:15 +00:00
Daniel Stenberg
68c86e2c4c The examples no longer have an include path pointing to the private source dir
but instead uses its own config.h file, that now is included first to make
large file magic have an effect.
2007-07-31 11:00:29 +00:00
Daniel Stenberg
15e0f56d01 add large file magic checks, and make sure we update the config.h file in the
example/simple subdir as well
2007-07-31 10:04:57 +00:00
Daniel Stenberg
d2ef367552 create a private config.h file for the examples 2007-07-31 10:04:24 +00:00
Daniel Stenberg
3167f054ff Peter O'Gorman pointed out (and fixed) that the non-blocking check in
configure made libssh2 use blocking sockets on AIX 4 and 5, while that
wasn't the intention.
2007-07-30 22:55:43 +00:00
Daniel Stenberg
209d06d6c9 libssh2_poll() no longer relies on C99 features but instead uses alloca()
on systems that have it - and uses a fixed-size array on those that don't.
session.c was also cleaned from a large amount of trailing whitespace.
2007-07-23 21:18:43 +00:00
Guenter Knauf
2b7856ad32 ooups - forgotten var added. 2007-07-22 02:15:31 +00:00
Guenter Knauf
9a1ce06e31 added keyboard-interactive auth method;
added 5. argument to specify auth method.
2007-07-22 02:07:55 +00:00
Guenter Knauf
c9413c628d changed prelude file for gcc build. 2007-07-22 00:47:21 +00:00
Guenter Knauf
327c31a634 added var to specify cross compiler prefix. 2007-07-21 22:59:24 +00:00
Guenter Knauf
4ace76b30d added some defines for MSVC and other non-gcc compilers. 2007-07-20 09:52:02 +00:00
Guenter Knauf
2127c5967e moved the inclusion of libssh2_config.h to the top. 2007-07-20 09:51:05 +00:00
Guenter Knauf
242475c42a added keyboard-interactive auth method;
added 4. argument to specify auth method.
2007-07-20 01:23:10 +00:00
Guenter Knauf
854dffe0a4 moved blocks to make keyboard-interactive second choice (if implemented). 2007-07-19 17:08:54 +00:00
Guenter Knauf
278219fc0a few cosmetic changes; added block for future implementation of keyboard-interactive method. 2007-07-19 15:43:48 +00:00
Guenter Knauf
16be3fc778 removed obsolete line. 2007-07-19 15:29:06 +00:00
Guenter Knauf
edcfab905a added selection of authentication method based on what libssh2_userauth_list() returns; added vars for the key files. 2007-07-19 15:25:46 +00:00
James Housley
46f59112d9 * After setting the error to the error string from in the packet, set
the pointer to NULL so it can't be double freed.
* On session cleanup be sure to free the last error if it needs to be
2007-07-19 15:02:37 +00:00
James Housley
05c1164a67 The test after the memory allocation was backwards, so keyboard-interactive
would always fail due to a memory problem.
2007-07-18 19:54:51 +00:00
Guenter Knauf
3fc4caf42f fixed call to libssh2_userauth_list() since NULL isnt supported for the username. 2007-07-18 19:31:15 +00:00
Guenter Knauf
1a9fee074b added check for available authentication methods. 2007-07-18 11:46:25 +00:00
Guenter Knauf
8f62c7322f added NMakefile to Makefile.am so that it gets included with releases and daily snapshots. 2007-07-17 13:22:55 +00:00
Guenter Knauf
839be89a49 added test success messages. 2007-07-16 22:16:21 +00:00
Guenter Knauf
669e69966a another trial to fix the typedefs. 2007-07-16 22:05:30 +00:00
Guenter Knauf
138b1b3830 fixed MSVC project files to build static lib and dll in separate direcories. 2007-07-15 23:46:30 +00:00
Daniel Stenberg
4088283465 support --enable-maintainer-mode 2007-07-15 22:21:46 +00:00
Guenter Knauf
402978bd1b fixed MSVC project files. 2007-07-15 22:11:12 +00:00
Daniel Stenberg
387a1fdf4b add maketgz to release archives 2007-07-15 21:47:27 +00:00
Daniel Stenberg
d574d7dea0 Added LIBSSH2_TIMESTAMP to the public header and it contains the timestamp of
the making of the release archive.

Added 'maketgz' as a script to build release archives with, including automated
snapshots or whatever. It updates the defines in include/libssh2.h.

configure now extracts the version number from the include/libssh2.h header in
the source tree instead of using it fixed set in the script (to remove the
need for regenerating the configure script when we run maketgz).

Makefile.am now has a dist-hook that puts ".dist" files in the release tree
instead of the file without the .dist extension, so that we can easily add
modified files in release archives. Like maketgz.
2007-07-15 21:36:29 +00:00
Guenter Knauf
b2df0b26f7 fixed test makefile to build all samples. 2007-07-15 20:34:33 +00:00
Guenter Knauf
bb76ed34a0 fixed NMakefile stuff to build at least the DLL again. 2007-07-15 20:06:19 +00:00
Simon Josefsson
153e1959f4 Fix make distcheck. Noted by Daniel. 2007-07-15 08:22:00 +00:00
Daniel Stenberg
a3155d5d12 I'm fine with just name 2007-07-14 23:33:21 +00:00
Guenter Knauf
8485ee6fd5 introduced some more version defines. 2007-07-14 22:18:32 +00:00
Daniel Stenberg
4f76c2b80c Metion the current code style in the new file called HACKING. In this, we
could also add descriptions on how to send us patches and bug reports etc...
2007-07-14 21:28:02 +00:00
Daniel Stenberg
accd865aff converted to 4-level space indents, no trailing whitespace 2007-07-14 21:24:38 +00:00
Guenter Knauf
84e16944b4 some more NetWare makefile fixes. 2007-07-14 21:04:32 +00:00
Daniel Stenberg
e0254f3936 removed compiler warnings, narrowed some source lines, killed trailing
whitespace
2007-07-14 20:54:47 +00:00
James Housley
14881b2370 For now make LIBSSH2_APINO a long, some compilers make constants an int it
seems.
2007-07-14 16:21:50 +00:00
Guenter Knauf
4ec68bdc04 added build for older CLIB version. 2007-07-09 22:47:24 +00:00
James Housley
a87fdff9e9 The variable "packet" needs to be in LIBSSH2_SFTP_HANDLE for re-entry when
blocking in libssh2_sftp_close_handle()
2007-07-09 15:11:37 +00:00
James Housley
50fd6590f0 While the previous commit seemed to correct a problem, it actually exposed
another problem.  Commit this until a proper fix is found
2007-07-08 17:14:19 +00:00
James Housley
2b1c979d7e Remove a blocking while loop that wasn't removed when the code to
return PACKET_EAGAIN was added, but should have been.
2007-07-08 15:37:44 +00:00
James Housley
6ac790a477 * Since the packet as already had data read from it, it can't retrun
PACKET_EAGAIN while reading the rest of it.
* Get the error message in libssh2_scp_recv() in the same manner as it
  was gotten in libssh2_scp_send_ex()
2007-07-05 15:31:19 +00:00
Guenter Knauf
b53db3d3a9 fix bug #1701782 - for now we only define for the compiler versions where we know for sure - if later versions still need those defines please report to the list. 2007-07-05 12:52:30 +00:00
Guenter Knauf
83d77f3878 enter next round after release. 2007-07-05 12:46:42 +00:00
James Housley
530e57d4ac Gavrie Philipson sumitted a patch to get the actual text of the error
on scp upload.
2007-07-05 11:08:17 +00:00
James Housley
a9fc3bdb4e Change the wording of the return value to match the rest of the man pages 2007-07-04 10:44:40 +00:00
Mikhail Gusarov
e2c88f6ae3 Fixed manpage syntax (catched by Debian's lintian) 2007-07-04 09:42:08 +00:00
Daniel Stenberg
cf9ed016e7 as mentioned in bug #1655429, the CRLF pair was stripped off in the wrong
order!
2007-06-28 20:53:32 +00:00
Daniel Stenberg
1901324122 added missing files (in 0.15) to the release tarball 2007-06-25 20:48:07 +00:00
159 changed files with 13947 additions and 9226 deletions

View File

@@ -1,5 +1,5 @@
jas4711:Simon Josefsson <simon@josefsson.org>
bagder:Daniel Stenberg <daniel@haxx.se>
bagder:Daniel Stenberg
sarag:Sara Golemon <pollita@libssh2.org>
gusarov:Mikhail Gusarov <dottedmag@dottedmag.net>
wez:Wez Furlong
@@ -7,3 +7,5 @@ edink:Edink Kadribasic
jehousley: James Housley
gknauf: Guenter Knauf
dfandrich: Dan Fandrich
yangtse: Yang Tse
thomaspu: Paul Thomas

View File

@@ -1,11 +1,15 @@
* Sara Golemon: Author / Project Manager
* Daniel Stenberg: Co-maintainer
* James Housleys: Nonblocking conversion
* Simon Josefsson: libgcrypt support
* Daniel Stenberg: Nonblocking fixes, Build Improvements, and Daily snapshot artist
* Mikhail Gusarov: Keyboard Interactive Authentication
* Wez Furlong & Edink Kadribasic: Windows Port
* Dan Fandrich: bug fixes, cleanups
* Guenter Knauf: win32 work and more

1606
ChangeLog

File diff suppressed because it is too large Load Diff

32
HACKING Normal file
View File

@@ -0,0 +1,32 @@
libssh2 source code style guide:
- 4 level indent
- spaces-only (no tabs)
- open braces on the if/for line:
if (banana) {
go_nuts();
}
- write both braces on the else line:
if (banana) {
go_nuts();
} else {
stay_calm();
}
- use braces even for single-statement blocks
- keep source lines shorter than 80 columns
------------
Older libssh2 code that still hasn't quite transitioned to the above
mentioned style, used a different style:
- indented with tabs (only)
- no line length limits

View File

@@ -5,7 +5,18 @@ include_HEADERS = \
include/libssh2_publickey.h \
include/libssh2_sftp.h
EXTRA_DIST = win32 buildconf
NETWAREFILES = nw/keepscreen.c \
nw/Makefile \
nw/Makefile.netware \
nw/nwlib.c \
nw/test/Makefile.netware
WIN32FILES = win32/libssh2_dll.dsp win32/libssh2.dsw win32/Makefile.win32 \
win32/config.mk win32/Makefile win32/test/Makefile.win32 win32/libssh2_lib.dsp \
win32/libssh2_config.h win32/tests.dsp win32/rules.mk
EXTRA_DIST = $(WIN32FILES) buildconf $(NETWAREFILES) get_ver.awk HACKING \
maketgz NMakefile TODO
ACLOCAL_AMFLAGS = -I m4
@@ -14,3 +25,35 @@ ChangeLog:
if test -f .cvsusers; then \
cvs2cl --utc --fsf --FSF --usermap .cvsusers -I ChangeLog -I .cvs; \
fi
dist-hook:
rm -rf $(top_builddir)/tests/log
find $(distdir) -name "*.dist" -exec rm {} \;
(distit=`find $(srcdir) -name "*.dist"`; \
for file in $$distit; do \
strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \
cp $$file $(distdir)$$strip; \
done)
# Code Coverage
init-coverage:
make clean
lcov --directory . --zerocounters
COVERAGE_CCOPTS ?= "-g --coverage"
COVERAGE_OUT ?= docs/coverage
build-coverage:
make CFLAGS=$(COVERAGE_CCOPTS) check
mkdir -p $(COVERAGE_OUT)
lcov --directory . --output-file $(COVERAGE_OUT)/$(PACKAGE).info \
--capture
gen-coverage:
genhtml --output-directory $(COVERAGE_OUT) \
$(COVERAGE_OUT)/$(PACKAGE).info \
--highlight --frames --legend \
--title "$(PACKAGE_NAME)"
coverage: init-coverage build-coverage gen-coverage

292
NEWS
View File

@@ -1,5 +1,219 @@
Version
------------
Version 1.1 (April 2, 2009)
---------------------------
- (Mar 28 2009) Daniel Stenberg:
Jean-Louis Charton found a memory leak in
libssh2_userauth_hostbased_fromfile_ex()
- (Mar 25 2009) Daniel Stenberg:
* Renamed the functions in src/transport.c to be _libssh2_transport_ prefixed
and introduced a transport.h header.
* Fixed the blocking mode to only change behavior not the actual underlying
socket mode so we now always work with non-blocking sockets. This also
introduces a new rule of thumb in libssh2 code: we don't call the
external function calls internally. We use the internal (non-blocking)
ones!
* libssh2_channel_receive_window_adjust2 was added and
libssh2_channel_receive_window_adjust is now deprecated
* Introduced "local" header files with prototypes etc for different parts
instead of cramming everything into libssh2_priv.h. channel.h is the
first.
- (Mar 19 2009) Daniel Stenberg: based on a patch by "E L" we now use errno
properly after recv() and send() calls (that internally are now known as
_libssh2_recv() and _libssh2_send()) so that the API and more works fine on
windows too!
- (Mar 17 2009) Simon Josefsson:
Added a Libtool -export-symbols-regex flag to reduce the number of
exported symbols in shared libraries. Reported by Mikhail Gusarov.
- (Mar 16 2009) Daniel Stenberg:
I renamed a few man pages to match the exact name of the functions they
describe. I also added template versions for the 13 functions that
previously lacked man pages. While these don't contain any docs just yet, it
will now be easier to add the info as the foundation is there!
- (Mar 15 2009) Daniel Stenberg:
* libssh2_channel_read_ex() was simplified and enhanced. It now adjusts the
window less frequent and uses much larger window that now allows MUCH
faster transfers.
* SCP send/recv now allow file names with whitespaces etc, thanks to a patch
by Heiner Steven
- (Mar 13 2009) Daniel Stenberg: Cleanups, that do seem to have boosted SFTP
download performance up to 300% in some tests:
* cut off "_ex" from several internal function names
* corrected some log outputs
* simplified libssh2_channel_read_ex() and made it much faster in the process
* cut out {{{ and }}} comments that were incorrect anyway
* fixed sftp_packet_ask() to return the correct packet by using memcmp() and
not strncmp()
* fixed mkdir()'s wait for packet to use the correct request_id - it
semi-worked previously because strncmp() in sftp_packet_ask() made it
match far too easily.
* took away the polling functionality from sftp_packet_ask() since it wasn't
used
- (Mar 7 2009) Olivier Hervieu pointed out a flaw in the
libssh2_channel_x11_req_ex() function that made it produce a crappy random
chunk of data. Peter Stuge improved the fix to not do out-of-boundary
writes. I (Daniel Stenberg) replaced the snprintf() with a plain sprintf()
since the size argument wasn't adding anything anyway.
- (Feb 23 2009) Added libssh2_version()
- (Feb 20 2009) libssh2_channel_direct_tcpip_ex() bug #1902169 fixed, which
caused it to fail when called a second time.
- (Feb 12 2009) Romain Bondue extended Markus Moeller fix from Feb 8, based on
a previous (uncommitted) patch by Erik Brossler. It improves
libssh2_channel_write_ex in blocking situations when the socket is set non-
blocking.
- (Feb 8 2009) Markus Moeller fixed a flaw in libssh2_channel_write_ex() that
would occur on EAGAIN situations.
Version 1.0 (December 26 2008)
------------------------------
- (Dec 20 2008) Based on Alexander Lamaison's patch, there's now a new
function called libssh2_sftp_tell64() that returns the 64 bit file offset,
as the existing libssh2_sftp_tell() only returns a size_t.
- (Dec 18 2008) Markus Moeller fixed the issue also reported by Alexander
Lamaison which caused SFTP reads with large buffers to fail.
- Several flaws were fixed that prevented at least SFTP to work reliably
- Vlad Grachov brought the new function called
libssh2_session_block_directions() which returns a bitmask for what
directions the connection blocks. It is to be used applications that use
non-blocking sockets and when a libssh2 function returns
LIBSSH2_ERROR_EAGAIN this function can be used to figure out in which
direction the socket would block and thus it can wait for the socket to
again be ready for communication in that direction before it calls libssh2
again.
- Vincent Jaulin brought the new libssh2_channel_request_pty_size_ex()
function.
- Carlo Bramini fixed the build for msys+mingw. Bug #1943976.
- Neil Gierman provided improved Visual Studio 2008 code in bug #1946268
- Bug #1862727 fixed libssh2_poll() to work on windows (by defining
HAVE_SELECT).
- Based on bug #1815692, we introduce libssh2_sftp_seek64() that allows
seeking beyond the 2GB margin even on 32bit machines.
- Based on a patch in bug #1878059 by Steven Ayre libssh2 now parses >2GB file
sizes when downloading SCP files.
- Bug #2064371 pointed out that the SSH2 banner may not use dash
('-'). Reported by Bjorn Stenborg.
- Sean Peterson fixed a key re-exchange bug:
http://daniel.haxx.se/projects/libssh2/mail/libssh2-devel-archive-2008-06/0002.shtml
- Mike Protts filed the bug report #1908724 that identified and fixed a problem
with SFTP stat on files >4GB in size. Previously it used 32bit math only.
- Removed a stderr debug message that was accidentally left in (bug #1863153)
- OpenSSL and libz detection changed to make cross-compiling to Mingw
work. See README for parameters to use if the auto-detection does
not work for you. From Simon Josefsson.
- Simon Josefsson added a self-test that uses libssh2 to connect to a
local sshd (only enabled if if OpenSSH is installed).
Version 0.18 (November 11 2007)
-------------------------------
- Various changes that improve non-blocking operations and prevent stalls.
Especially noticable on Windows since libssh2 just didn't work properly
non-blocking on Windows before.
- Peter O'Gorman reported how a SCP transfer would hang for him, and it was
fairly easy reproducable. One bug was in the transport layer, ignoring to
read more data while there was data left even though it couldn't decrypt the
data that was left due to it being too little... The other bug was in the
channel layer, where the libssh2_channel_receive_window_adjust() function
missed to set the state variables at times and thus this function would
misbehave on repeated invokes.
- Changed the signature of libssh2_channel_setenv_ex to add const to the
"varname" parameter (Dan Fandrich)
- Satish Mittal and David J Sullivan fixed an infinit recv() loop in
libssh2_banner_receive()
Version 0.17 (August 6 2007)
----------------------------
Changes since previous version include:
o Re-indented the source code with this GNU indent setup:
--braces-on-if-line
--braces-after-struct-decl-line
--space-after-cast
--line-length 79
--comment-line-length 79
--cuddle-else
--no-tabs
--tab-size 8
--indent-level 4
--no-space-after-for
--space-after-if
--space-after-while
--no-space-after-function-call-names
Version 0.16 (August 6 2007)
----------------------------
Changes since previous version include:
o CRLF stripping fix for PEM reading
o libssh2_scp_recv() error message fix
o added HACKING as an initial attempt to describe our source code format
o new public defines in include/libssh2.h to allow applictions to figure out
version number etc
o new script (maketgz) to build releases with
o updated files for building with MSVC and mingw
o keyboard-interactive would always fail due to claimed memory problem
o a few minor memory leaks fixed
o libssh2_poll() no longer relies on C99 features
o AIX 4 and 5 now supports non-blocking sockets
o large file magic checks in configure
o LIBSSH2_APINO was removed from the public header file
This release would not have been possible without these friendly contributors:
James Housley, Simon Josefsson, Dan Fandrich, Guenter Knauf and I too did
some poking. (Sorry if I forgot anyone I should've mentioned here.)
Of course we would have nothing without the great work by Sara Golemon that
we're extending and building upon.
Version 0.15 (June 15 2007)
---------------------------
Added libssh2_sftp_readdir_ex() and updated LIBSSH2_APINO to
200706151200 (James Housley)
@@ -72,7 +286,8 @@ Version 0.14
Allow socket_fd == 0 in libssh2_session_startup(). (puudeli)
Swap ordering of packet_add/packet-inspection to avoid inspect after free. (Selcuk)
Swap ordering of packet_add/packet-inspection to avoid inspect after
free. (Selcuk)
Swap KEX_INIT ordering, send our KEX_INIT first.
@@ -83,9 +298,11 @@ Version 0.14
Version 0.13
------------
Fixed channel not being marked closed when CHANNEL_CLOSE package cannot be sent. (David Robins)
Fixed channel not being marked closed when CHANNEL_CLOSE package cannot be
sent. (David Robins)
Fixed payload packet allocation bug when invalid packet length received. (David Robins)
Fixed payload packet allocation bug when invalid packet length
received. (David Robins)
Fixed `make install' target for MacOSX.
@@ -102,10 +319,12 @@ Version 0.12
(Thanks Simon Hart)
Fix generation of 'e' portion of Diffie-Hellman keyset.
Use appropriate order for BN_rand() rather than fixed group1-specific value.
Use appropriate order for BN_rand() rather than fixed group1-specific value.
Re-fixed libssh2_sftp_rename_ex()
Transport had right packet_len, but sftp layer still had extra 4 bytes.
Transport had right packet_len, but sftp layer still had extra 4 bytes.
Fixed build with newer OpenSSL headers.
@@ -120,42 +339,52 @@ Version 0.11
Added libssh2_userauth_keyboard_interactive_ex() -- Mikhail
Added libssh2_channel_receive_window_adjust() to be able to increase the size of the receive window.
Added libssh2_channel_receive_window_adjust() to be able to increase the
size of the receive window.
Added queueing for small window_adjust packets to avoid unnecessary packet conversation.
Added queueing for small window_adjust packets to avoid unnecessary packet
conversation.
Fixed libssh2_sftp_rename_ex() to only send flags parameter if version >= 5 negotiated
(not currently possible, but will be and might as well keep the API consistent).
Fixed libssh2_sftp_rename_ex() to only send flags parameter if version >= 5
negotiated (not currently possible, but will be and might as well keep the
API consistent).
Version 0.10
------------
Added developer debugging hooks. See --enable-debug-* options to ./configure
Ignore extended data in the SFTP layer. With no other mechanism to deal with that data it'd just fill up and get stuck.
Ignore extended data in the SFTP layer. With no other mechanism to deal
with that data it'd just fill up and get stuck.
(Re)Fixed channel_write() to provide an opportunity for window space to become available again.
(Re)Fixed channel_write() to provide an opportunity for window space to
become available again.
(Re)Fixed SFTP INIT to send the correct SFTP packet length.
Fixed segfault when client and host can't agree on a hostkey/crypt/mac/comp method. (Thanks puudeli)
Fixed segfault when client and host can't agree on a hostkey/crypt/mac/comp
method. (Thanks puudeli)
Fixed major issue with sftp packet buffering mechanism. Using wrong blocking semantics. (No puudeli, YOU the man)
Fixed major issue with sftp packet buffering mechanism. Using wrong
blocking semantics. (No puudeli, YOU the man)
Reduced busy-looping of libssh2_sftp_packet_requirev.
Version 0.9
-----------
Changed blocking_read to only block as much as necessary and not an arbitrary length of time. (Thanks Felix)
Changed blocking_read to only block as much as necessary and not an
arbitrary length of time. (Thanks Felix)
Fixed SFTP INIT/VERSION to exclude request_id and send correct maximum version number.
Fixed SFTP INIT/VERSION to exclude request_id and send correct maximum
version number.
Fixed SFTP to be properly BC with version 1 and 2 servers.
Fixed libssh2_poll() to recognized closed sessions/channels.
Fixed libssh2_channel_write_ex() to fully block when set to blocking mode. Return actual bytes written as well. (Thanks deadem)
Fixed libssh2_channel_write_ex() to fully block when set to blocking mode.
Return actual bytes written as well. (Thanks deadem)
Added tests for -lm and -lsocket and add them when necessary.
@@ -169,9 +398,11 @@ Version 0.8
Fix compatability with older versions of OpenSSL
Swapped order of none,zlib compression modes to prefer no compression by default.
Swapped order of none,zlib compression modes to prefer no compression by
default.
Added sys/uio.h for platforms (FBSD) which need it in order to define struct iovec.
Added sys/uio.h for platforms (FBSD) which need it in order to define struct
iovec.
Added libssh2_poll() to check status of sockets/channels/listeners.
@@ -194,15 +425,18 @@ Version 0.7
Version 0.6
-----------
Added LIBSSH2_FLAG_SIGPIPE to enable/disable SIGPIPE generated by send()/recv() calls. Default off.
Added LIBSSH2_FLAG_SIGPIPE to enable/disable SIGPIPE generated by
send()/recv() calls. Default off.
Added libssh2_session_flag() to set optional session flags.
Collapsed exchanging_keys/newkeys/authenticated flags into single state attribute.
Collapsed exchanging_keys/newkeys/authenticated flags into single state
attribute.
Fix zlib compression issue when internal buffer state misses partial sync.
Fix segfault when libssh2_session_methods() is called prior to session_startup().
Fix segfault when libssh2_session_methods() is called prior to
session_startup().
Fixed client to server channel windowing. Pervent send queue overruns.
@@ -212,7 +446,8 @@ Version 0.5
-----------
*** BC Break ***
Reimplemented libssh2_session_methods() to match libssh2_session_method_pref() style
Reimplemented libssh2_session_methods() to match
libssh2_session_method_pref() style
Fixed libssh2_attr2bin() (effects any setstat style call).
@@ -222,11 +457,14 @@ Version 0.5
Fixed KEX_INIT cookie and packet padding to use actual random data
Added DESTDIR support to makefiles (Adam Go<47><6F>biowski -- I hope that character set translates right)
Added DESTDIR support to makefiles (Adam Go<47><6F>biowski -- I hope that
character set translates right)
Added libssh2_channel_forward_listen_ex(), libssh2_channel_forward_cancel(), and libssh2_channel_forward_accept().
Added libssh2_channel_forward_listen_ex(), libssh2_channel_forward_cancel(),
and libssh2_channel_forward_accept().
Added ./configure option '--disable-gex-new' to allow using the older group-exchange format
Added ./configure option '--disable-gex-new' to allow using the older
group-exchange format
Added MAC methods hmac-md5 and hmac-md5-96.

View File

@@ -1,16 +1,19 @@
!include "win32/config.mk"
# SUBDIRS=src example\simple
SUBDIRS=src
all: all-sub ssh2_sample.exe
ssh2_sample.exe: ssh2_sample.c
$(CC) $(CFLAGS) -DWIN32 -o ssh2_sample.exe ssh2_sample.c libssh2$(SUFFIX).lib $(LIBS)
all-sub:
-for %D in ($(SUBDIRS)) do $(MAKE) /nologo /f %D/NMakefile BUILD=$(BUILD) SUBDIR=%D all-sub
clean:
rmdir /s/q $(TARGET)
-rmdir /s/q $(TARGET)
real-clean: clean
-del libssh2.dll
-del libssh2.exp
-del libssh2.ilk
-del libssh2.lib
-del *.pdb

54
README
View File

@@ -4,6 +4,10 @@ libssh2 - SSH2 library
libssh2 is a library implementing the SSH2 protocol, available under
the revised BSD license.
Web site: http://www.libssh2.org/
Mailing list: https://lists.sourceforge.net/lists/listinfo/libssh2-devel
Generic installation instructions are in INSTALL. Some ./configure
options deserve additional comments:
@@ -48,49 +52,43 @@ options deserve additional comments:
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 in the
default location, but if you have installed it
somewhere else, use the --with-libgrypt-prefix=DIR
parameter.
Configure will attempt to locate Libgcrypt
automatically.
* --with-openssl=[DIR]
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 a number
of default locations:
/usr/local/ssl
/usr/local
/usr
/usr/local/openssl
Configure will attempt to locate OpenSSL in the
default location.
If your installation of OpenSSL is in another
location, specify it here.
location, specify it using --with-libssl-prefix.
* --with-libz=[DIR]
* --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 present, libssh2 will attempt to use the zlib
(http://www.zlib.org) for payload compression, however
zlib is not required.
Configure will attempt to location a zlib installation
in a number of default locations:
/usr/local
/usr
/usr/local/libz
/usr/libz
/usr/local/zlib
/usr/zlib
If your installation of zlib is in another location,
you may specify it here.
If your installation of Libz is in another location,
specify it using --with-libz-prefix.
* --enable-debug

38
TODO Normal file
View File

@@ -0,0 +1,38 @@
Things TODO
===========
* Add one of the missing man pages:
libssh2_channel_receive_window_adjust
libssh2_channel_request_pty_size_ex
libssh2_channel_window_read_ex
libssh2_channel_window_write_ex
libssh2_publickey_add_ex
libssh2_publickey_init
libssh2_publickey_list_fetch
libssh2_publickey_list_free
libssh2_publickey_remove_ex
libssh2_publickey_shutdown
libssh2_userauth_hostbased_fromfile_ex
* Decrease the number of mallocs. Everywhere.
* Use SO_NOSIGPIPE for Mac OS/BSD systems where MSG_NOSIGNAL doesn't exist/work
* Extend the test suite to actually test lots of aspects of libssh2
* libssh2_channel_receive_window_adjust() can return EAGAIN while documented
to return the window as an "unsigned long".
At next SONAME bump
===================
* stop using #defined macros as part of the official API. The macros should
either be turned into real functions or discarded from the API.
* remove the following functions from the API/ABI
libssh2_base64_decode()
libssh2_session_flag()
libssh2_channel_handle_extended_data()
libssh2_channel_receive_window_adjust()

View File

@@ -178,7 +178,7 @@ AC_DEFUN([CURL_CHECK_NONBLOCKING_SOCKET],
# define PLATFORM_SUNOS4
# endif
#endif
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX4)
#if (defined(_AIX) || defined(__xlC__)) && !defined(_AIX41)
# define PLATFORM_AIX_V3
#endif

View File

@@ -3,5 +3,9 @@
${LIBTOOLIZE:-libtoolize} --copy --automake --force
${ACLOCAL:-aclocal} -I m4 $ACLOCAL_FLAGS
${AUTOHEADER:-autoheader}
# copy the private libssh2_config.h.in to the examples dir so that
# it can be included without pointing the include path to the private
# source dir
cp src/libssh2_config.h.in example/simple/config.h.in
${AUTOCONF:-autoconf}
${AUTOMAKE:-automake} --add-missing --copy

View File

@@ -1,8 +1,27 @@
# AC_PREREQ(2.57)
AC_INIT(libssh2, 0.15, libssh2-devel@lists.sourceforge.net)
AM_INIT_AUTOMAKE(libssh2, 0.15)
AC_INIT(libssh2, [-], libssh2-devel@lists.sourceforge.net)
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADER([src/libssh2_config.h])
AM_MAINTAINER_MODE
dnl SED is needed by some of the tools
AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure,
$PATH:/usr/bin:/usr/local/bin)
AC_SUBST(SED)
if test "x$SED" = "xsed-was-not-found-by-configure"; then
AC_MSG_WARN([sed was not found, this may ruin your chances to build fine])
fi
dnl figure out the libssh2 version
VERSION=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h`
AM_INIT_AUTOMAKE(libssh2,$VERSION)
AC_MSG_CHECKING([libssh2 version])
AC_MSG_RESULT($VERSION)
AB_VERSION=$VERSION
AB_INIT
# Check for the OS.
@@ -10,6 +29,10 @@ AB_INIT
# get this removed.
AC_CANONICAL_HOST
case "$host" in
*-mingw*)
CFLAGS="$CFLAGS -DLIBSSH2_WIN32 -DWINSOCK_VERSION=0x0200"
LIBS="$LIBS -lws2_32"
;;
*-cygwin)
CFLAGS="$CFLAGS -DLIBSSH2_WIN32"
;;
@@ -22,6 +45,11 @@ case "$host" in
;;
esac
AC_CHECK_TYPE(long long,
[AC_DEFINE(HAVE_LONGLONG, 1,
[Define to 1 if the compiler supports the 'long long' data type.])]
longlong="yes"
)
# Some systems (Solaris?) have socket() in -lsocket.
AC_SEARCH_LIBS(socket, socket)
@@ -34,150 +62,57 @@ AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PATH_PROGS(SSHD, [sshd], [],
[$PATH$PATH_SEPARATOR/usr/libexec$PATH_SEPARATOR]dnl
[/usr/sbin$PATH_SEPARATOR/usr/etc$PATH_SEPARATOR/etc])
AM_CONDITIONAL(SSHD, test -n "$SSHD")
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
AC_C_BIGENDIAN
if test -z "$PKG_CONFIG"; then
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
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(libz,
AC_HELP_STRING([--with-libz],[Use Libz for compression]),
use_libz=$withval,use_libz=auto)
# Look for OpenSSL (default)
if test "$use_openssl" != "no" && test "$use_libgcrypt" != "yes"; then
AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [#include <openssl/ssl.h>])
fi
# Look for libgcrypt.
AC_ARG_WITH(libgcrypt,
AC_HELP_STRING([--with-libgcrypt],[Use libgcrypt for crypto]),
use_libgcrypt=$withval,use_libgcrypt=no)
if test "$use_libgcrypt" != "no"; then
# Look for libgcrypt
if test "$ac_cv_libssl" != "yes" && test "$use_libgcrypt" != "no"; then
AC_LIB_HAVE_LINKFLAGS([gcrypt], [], [#include <gcrypt.h>])
fi
if test "$ac_cv_libgcrypt" = yes; then
use_libgcrypt=yes
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])
fi
AM_CONDITIONAL(LIBGCRYPT, test "$use_libgcrypt" != "no")
AM_CONDITIONAL(LIBGCRYPT, test "$ac_cv_libgcrypt" = "yes")
# Need to define SHLIB_SUFFIX_NAME before checking for libcrypt and libz
# $shrext_cmds (from libtool) can contain commands so it must be eval'd
# Simon's note: replace the find-openssl/libz logic with Bruno's
# AC_LIB_LINKFLAGS which is more portable and flexible.
eval SHLIB_SUFFIX_NAME=\"$shrext_cmds\"
AC_SUBST(SHLIB_SUFFIX_NAME)
#
# Look for OpenSSL
#
AC_ARG_WITH(openssl,
AC_HELP_STRING([--with-openssl=DIR],[Look for OpenSSL in PATH]),
[LIBSSH2_OPENSSL_DIR=$withval],[LIBSSH2_OPENSSL_DIR=yes])
if test "$use_libgcrypt" = "no"; then
if test "$LIBSSH2_OPENSSL_DIR" = "no" || test "$LIBSSH2_OPENSSL_DIR" = "yes"; then
unset LIBSSH2_OPENSSL_DIR
fi
found_openssl=no
pkgcfg_openssl=no
unset OPENSSL_INCDIR
unset OPENSSL_INCLINE
unset OPENSSL_LIBLINE
AC_MSG_CHECKING([for OpenSSL])
# Explicit path given, use it rather than pkg-config
if test ! -z "$LIBSSH2_OPENSSL_DIR"; then
found_openssl=yes
OPENSSL_LIBLINE="-L$LIBSSH2_OPENSSL_DIR/lib -lcrypto"
OPENSSL_INCLINE="-I$LIBSSH2_OPENSSL_DIR/include"
OPENSSL_INCDIR=$LIBSSH2_OPENSSL_DIR/include
AC_MSG_RESULT([Using explicit path $LIBSSH2_OPENSSL_DIR])
fi
# If pkg-config is found try using it
if test "$found_openssl" = "no" && test -x "$PKG_CONFIG" && $PKG_CONFIG --exists openssl; then
found_openssl=yes
pkgcfg_openssl=yes
OPENSSL_LIBLINE=`$PKG_CONFIG --libs openssl`
OPENSSL_INCLINE=`$PKG_CONFIG --cflags-only-I openssl`
AC_MSG_RESULT([Using paths from pkg-config])
fi
# Elsewise, search for OpenSSL wherever it might be
if test "$found_openssl" = "no"; then
OPENSSL_SEARCH_PATH="/usr/local/ssl /usr/local /usr /usr/local/openssl"
for i in $OPENSSL_SEARCH_PATH; do
if test -r $i/include/openssl/evp.h; then
OPENSSL_INCLINE="-I$i/include"
OPENSSL_INCDIR=$i/include
fi
if test -r $i/include/openssl/hmac.h; then
OPENSSL_INCLINE="-I$i/include"
OPENSSL_INCDIR=$i/include
fi
if test -r $i/lib/libcrypto.a -o -r $i/lib/libcrypto$SHLIB_SUFFIX_NAME; then
OPENSSL_LIBLINE="-L$i/lib -lcrypto"
fi
test -n "$OPENSSL_INCLINE" && test -n "$OPENSSL_LIBLINE" && break
done
if test -z "$OPENSSL_INCLINE"; then
AC_MSG_ERROR([Cannot find OpenSSL's <evp.h> or <hmac.h>])
# 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([Try --with-libz-prefix=PATH if you know you have it])
else
AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support])
fi
if test -z "$OPENSSL_LIBLINE"; then
AC_MSG_ERROR([Cannot find OpenSSL's libcrypto])
fi
AC_MSG_RESULT([$OPENSSL_INCLINE $OPENSSL_LIBLINE])
fi
#
# Confirm required OpenSSL libs
#
if test ! "$pkgcfg_openssl" = "yes"; then
if test ! -r $OPENSSL_INCDIR/openssl/bn.h || test ! -r $OPENSSL_INCDIR/openssl/evp.h || \
test ! -r $OPENSSL_INCDIR/openssl/hmac.h || test ! -r $OPENSSL_INCDIR/openssl/pem.h || \
test ! -r $OPENSSL_INCDIR/openssl/sha.h; then
AC_MSG_ERROR([Missing one or more of <openssl/bn.h>, <openssl/evp.h>, <openssl/hmac.h>, <openssl/pem.h>, <openssl/sha.h>])
fi
fi
CFLAGS="$CFLAGS $OPENSSL_INCLINE"
LDFLAGS="$LDFLAGS $OPENSSL_LIBLINE"
fi
#
# zlib
#
AC_ARG_WITH(libz,
AC_HELP_STRING([--with-libz=PATH],[Look for libz in PATH]),
[LIBSSH2_LIBZ_DIR=$withval],[LIBSSH2_LIBZ_DIR="/usr/local /usr /usr/local/libz /usr/libz /usr/local/zlib /usr/zlib"])
if test "$LIBSSH2_LIBZ_DIR" = "no" || test "$LIBSSH2_LIBZ_DIR" = "yes"; then
unset LIBSSH2_LIBZ_DIR
fi
unset LIBZ_INCDIR
unset LIBZ_LIBDIR
AC_MSG_CHECKING([for libz])
for i in $LIBSSH2_LIBZ_DIR; do
if test -r $i/include/zlib.h; then
LIBZ_INCDIR=$i/include
fi
if test -r $i/lib/libz.a -o -r $i/lib/libz$SHLIB_SUFFIX_NAME; then
LIBZ_LIBDIR=$i/lib
fi
test -n "$LIBZ_INCDIR" && test -n "$LIBZ_LIBDIR" && break
done
if test -n "$LIBZ_INCDIR" && test -n "$LIBZ_LIBDIR"; then
AC_MSG_RESULT([Found in $LIBZ_INCDIR $LIBZ_LIBDIR])
CFLAGS="$CFLAGS -I$LIBZ_INCDIR"
LDFLAGS="$LDFLAGS -L$LIBZ_LIBDIR -lz"
AC_DEFINE(LIBSSH2_HAVE_ZLIB, 1, [Compile in zlib support])
else
AC_MSG_RESULT([Cannot find libz's <zlib.h>])
fi
#
@@ -228,7 +163,41 @@ AC_HELP_STRING([--disable-debug],[Disable debug options]),
AC_CHECK_HEADERS([errno.h fcntl.h stdio.h stdlib.h unistd.h sys/uio.h])
AC_CHECK_HEADERS([sys/select.h sys/socket.h sys/ioctl.h sys/time.h])
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h])
AC_CHECK_FUNCS(poll gettimeofday select)
case $host in
*-*-cygwin* | *-*-cegcc*)
# These are POSIX-like systems using BSD-like sockets API.
;;
*)
AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h])
;;
esac
AC_CHECK_FUNCS(poll gettimeofday select strtoll)
dnl Check for select() into ws2_32 for Msys/Mingw
if test "$ac_cv_func_select" != "yes"; then
AC_MSG_CHECKING([for select in ws2_32])
AC_TRY_LINK([
#ifdef HAVE_WINSOCK2_H
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#endif
],[
select(0,(fd_set *)NULL,(fd_set *)NULL,(fd_set *)NULL,(struct timeval *)NULL);
],[
AC_MSG_RESULT([yes])
HAVE_SELECT="1"
AC_DEFINE_UNQUOTED(HAVE_SELECT, 1,
[Define to 1 if you have the select function.])
],[
AC_MSG_RESULT([no])
])
fi
AC_FUNC_ALLOCA
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

View File

@@ -1,2 +1,3 @@
Makefile
Makefile.in
coverage

View File

@@ -1,4 +1,4 @@
# $Id: Makefile.am,v 1.26 2007/06/15 11:01:22 jehousley Exp $
# $Id: Makefile.am,v 1.37 2009/03/26 15:41:15 bagder Exp $
EXTRA_DIST = template.3
@@ -18,20 +18,27 @@ dist_man_MANS = \
libssh2_channel_open_ex.3 \
libssh2_channel_process_startup.3 \
libssh2_channel_read_ex.3 \
libssh2_channel_receive_window_adjust.3 \
libssh2_channel_receive_window_adjust2.3 \
libssh2_channel_request_pty_ex.3 \
libssh2_channel_send_eof.3 \
libssh2_channel_set_blocking.3 \
libssh2_channel_setenv_ex.3 \
libssh2_channel_wait_eof.3 \
libssh2_channel_wait_closed.3 \
libssh2_channel_window_read_ex.3 \
libssh2_channel_window_write_ex.3 \
libssh2_channel_write_ex.3 \
libssh2_channel_x11_req_ex.3 \
libssh2_hostkey_hash.3 \
libssh2_scp_recv.3 \
libssh2_scp_send_ex.3 \
libssh2_session_abstract.3 \
libssh2_session_block_directions.3 \
libssh2_session_callback_set.3 \
libssh2_session_free.3 \
libssh2_session_disconnect_ex.3 \
libssh2_session_init.3 \
libssh2_session_init_ex.3 \
libssh2_session_last_errno.3 \
libssh2_session_last_error.3 \
libssh2_session_method_pref.3 \
@@ -47,7 +54,7 @@ dist_man_MANS = \
libssh2_sftp_open_ex.3 \
libssh2_sftp_mkdir_ex.3 \
libssh2_sftp_read.3 \
libssh2_sftp_readdir.3 \
libssh2_sftp_readdir_ex.3 \
libssh2_sftp_rename_ex.3 \
libssh2_sftp_rmdir_ex.3 \
libssh2_sftp_seek.3 \
@@ -55,9 +62,27 @@ dist_man_MANS = \
libssh2_sftp_stat_ex.3 \
libssh2_sftp_symlink_ex.3 \
libssh2_sftp_tell.3 \
libssh2_sftp_tell64.3 \
libssh2_sftp_unlink_ex.3 \
libssh2_sftp_write.3 \
libssh2_userauth_authenticated.3 \
libssh2_userauth_keyboard_interactive_ex.3 \
libssh2_userauth_list.3 \
libssh2_userauth_password_ex.3 \
libssh2_userauth_publickey_fromfile.3
libssh2_userauth_publickey_fromfile_ex.3 \
libssh2_base64_decode.3 \
libssh2_trace.3 \
libssh2_version.3
libssh2_channel_request_pty_size_ex.3 \
libssh2_free_host_entry.3 \
libssh2_host_entry_match.3 \
libssh2_new_host_entry.3 \
libssh2_publickey_add_ex.3 \
libssh2_publickey_init.3 \
libssh2_publickey_list_fetch.3 \
libssh2_publickey_list_free.3 \
libssh2_publickey_remove_ex.3 \
libssh2_publickey_shutdown.3 \
libssh2_session_flag.3 \
libssh2_session_get_blocking.3 \
libssh2_userauth_hostbased_fromfile_ex.3

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_banner_set.3,v 1.1 2007/06/13 17:03:38 jehousley Exp $
.\" $Id: libssh2_banner_set.3,v 1.3 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_banner_set 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,14 +11,14 @@ libssh2_banner_set(LIBSSH2_SESSION *session, const char *banner);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIbanner\fP - A pointer to a user defined banner
Set the banner that will be sent to the remote host when the SSH session is
started with
.BR libssh2_session_startup(3)
. This is optional; a banner corresponding to the protocol and libssh2 version will be sent by default.
This is optional; a banner corresponding to the protocol and libssh2 version will be sent by default.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns

View File

@@ -0,0 +1,27 @@
.\" $Id: libssh2_base64_decode.3,v 1.3 2009/02/17 16:22:51 dottedmag Exp $
.\"
.TH libssh2_base64_decode 3 "23 Dec 2008" "libssh2 1.0" "libssh2 manual"
.SH NAME
libssh2_base64_decode - decode a base64 encoded string
.SH SYNOPSIS
#include <libssh2.h>
int libssh2_base64_decode(LIBSSH2_SESSION *session, char **dest,
unsigned int *dest_len, const char *src,
unsigned int src_len);
.SH DESCRIPTION
This function is deemed DEPRECATED and will be removed from libssh2 in a
future version. Don't use it!
Decode a base64 chunk and store it into a newly allocated buffer. 'dest_len'
will be set to hold the length of the returned buffer that '*dest' will point
to.
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
reliable way!
.SH RETURN VALUE
0 if successful, \-1 if any error occurred.

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_channel_close.3,v 1.1 2007/06/13 17:03:38 jehousley Exp $
.\" $Id: libssh2_channel_close.3,v 1.3 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_close 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_close - close a channel<
libssh2_channel_close - close a channel
.SH SYNOPSIS
#include <libssh2.h>
@@ -28,4 +28,4 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
.SH SEE ALSO
.BR libssh2_channel_open(3)
.BR libssh2_channel_open_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_direct_tcpip_ex.3,v 1.1 2007/06/13 17:22:15 jehousley Exp $
.\" $Id: libssh2_channel_direct_tcpip_ex.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_channel_direct_tcpip_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_channel_direct_tcpip(LIBSSH2_SESSION *session, const char *host, int por
.SH DESCRIPTION
/fIsession/fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
/fIhost/fP - Third party host to connect to using the SSH host as a proxy.
@@ -31,9 +31,7 @@ in cleartext.
.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.
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_eof.3,v 1.1 2007/06/13 17:22:15 jehousley Exp $
.\" $Id: libssh2_channel_eof.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_eof 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -8,11 +8,11 @@ libssh2_channel_eof - check a channel's EOF status
int
libssh2_channel_eof(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
\fIchannel\fP - active channel stream to set closed status on.
Check if the remote host has sent an EOF status for the selected stream.
.SH RETURN VALUE
Returns 1 if the remote host has sent EOF, otherwise 0.
.SH SEE ALSO
.BR libssh2_channel_close(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_forward_accept.3,v 1.5 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_channel_forward_accept.3,v 1.6 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_forward_accept 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,11 +11,11 @@ libssh2_channel_forward_accept(LIBSSH2_LISTENER *listener);
.SH DESCRIPTION
\fIlistener\fP is a forwarding listener instance as returned by
\fBlibssh2_channel_forward_listen(3)\fP.
\fBlibssh2_channel_forward_listen_ex(3)\fP.
.SH RETURN VALUE
A newly allocated channel instance or NULL on failure.
.SH ERRORS
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call
would block.
.SH SEE ALSO
.BR libssh2_channel_forward_listen(3)
.BR libssh2_channel_forward_listen_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_forward_cancel.3,v 1.1 2007/06/13 19:53:09 jehousley Exp $
.\" $Id: libssh2_channel_forward_cancel.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_forward_cancel 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_channel_forward_cancel(LIBSSH2_LISTENER *listener);
.SH DESCRIPTION
/fIlistener/fP - Forwarding listener instance as returned by
.BR libssh2_channel_forward_listen(3)
.BR libssh2_channel_forward_listen_ex(3)
Instruct the remote host to stop listening for new connections on a previously requested host/port.
@@ -26,4 +26,4 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
.SH SEE ALSO
.BR libssh2_channel_forward_listen(3)
.BR libssh2_channel_forward_listen_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_handle_extended_data.3,v 1.1 2007/06/13 20:09:15 jehousley Exp $
.\" $Id: libssh2_channel_handle_extended_data.3,v 1.2 2009/03/26 15:41:16 bagder Exp $
.\"
.TH libssh2_channel_handle_extended_data 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -10,6 +10,9 @@ void
libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode);
.SH DESCRIPTION
This function is deprecated. Use the
\fIlibssh2_channel_handle_extended_data2(3)\fP function instead!
\fIchannel\fP - Active channel stream to change extended data handling on.
\fIignore_mode\fP - One of the three LIBSSH2_CHANNEL_EXTENDED_DATA_* Constants.
@@ -17,21 +20,18 @@ libssh2_channel_handle_extended_data(LIBSSH2_CHANNEL *channel, int ignore_mode);
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_NORMAL\fP: Queue extended data for eventual
reading
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_MERGE\fP: Treat extended data and ordinary
data the same. Merge all substreams such that calls to
.BR libssh2_channel_read(3)
will pull from all substreams on a first-in/first-out basis.
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_MERGE\fP: Treat extended data and ordinary
data the same. Merge all substreams such that calls to
\fIlibssh2_channel_read(3)\fP will pull from all substreams on a
first-in/first-out basis.
.br
\fBLIBSSH2_CHANNEL_EXTENDED_DATA_IGNORE\fP: Discard all extended data as it
arrives.
Change how a channel deals with extended data packets. By default all
extended data is queued until read by
.BR libssh2_channel_read_ex(3)
Change how a channel deals with extended data packets. By default all extended
data is queued until read by \fIlibssh2_channel_read_ex(3)\fP
.SH RETURN VALUE
None.
.SH SEE ALSO
.BR libssh2_channel_handle_extended_data2(3)
.BR libssh2_channel_read_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_open_ex.3,v 1.1 2007/06/13 20:54:25 jehousley Exp $
.\" $Id: libssh2_channel_open_ex.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_channel_open_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_channel_open_session(session);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIchannel_type\fP - Channel type to open. Typically one of session,
direct-tcpip, or tcpip-forward. The SSH2 protocol allowed for additional

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_process_startup.3,v 1.1 2007/06/13 20:54:25 jehousley Exp $
.\" $Id: libssh2_channel_process_startup.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_process_startup 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -31,19 +31,16 @@ defines shell, exec, and subsystem as standard process services.
\fImessage_len\fP - Length of message parameter.
Initiate a request on a session type channel such as returned by
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)
.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_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)

View File

@@ -0,0 +1,31 @@
.\" $Id: libssh2_channel_receive_window_adjust.3,v 1.3 2009/03/26 15:41:16 bagder Exp $
.\"
.TH libssh2_channel_receive_window_adjust 3 "15 Mar 2009" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_receive_window_adjust - adjust the channel window
.SH SYNOPSIS
#include <libssh2.h>
unsigned long
libssh2_channel_receive_window_adjust(LIBSSH2_CHANNEL * channel,
unsigned long adjustment,
unsigned char force);
.SH DESCRIPTION
This function is deprecated in 1.1. Use
\fIlibssh2_channel_receive_window_adjust2(3)\fP!
Adjust the receive window for a channel by adjustment bytes. If the amount to
be adjusted is less than LIBSSH2_CHANNEL_MINADJUST and force is 0 the
adjustment amount will be queued for a later packet.
.SH RETURN VALUE
Returns the new size of the receive window (as understood by remote end). Note
that the window value sent over the wire is strictly 32bit, but this API is
made to return a 'long' which may not be 32 bit on all platforms.
.SH ERRORS
In 1.0 and earlier, this function returns LIBSSH2_ERROR_EAGAIN for
non-blocking channels where it would otherwise block. However, that is a
negative number and this function only returns an unsigned value and this then
leads to a very strange value being returned.
.SH SEE ALSO
.BR libssh2_channel_window_read_ex(3)

View File

@@ -0,0 +1,29 @@
.\" $Id: libssh2_channel_receive_window_adjust2.3,v 1.1 2009/03/26 15:41:16 bagder Exp $
.\"
.TH libssh2_channel_receive_window_adjust2 3 "26 Mar 2009" "libssh2 1.1" "libssh2 manual"
.SH NAME
libssh2_channel_receive_window_adjust2 - adjust the channel window
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_receive_window_adjust2(LIBSSH2_CHANNEL * channel,
unsigned long adjustment,
unsigned char force,
unsigned int *window);
.SH DESCRIPTION
Adjust the receive window for a channel by adjustment bytes. If the amount to
be adjusted is less than LIBSSH2_CHANNEL_MINADJUST and force is 0 the
adjustment amount will be queued for a later packet.
This function stores the new size of the receive window (as understood by
remote end) in the variable 'window' points to.
.SH RETURN VALUE
Return 0 on success and a negative value on error. If used in non-blocking
mode it will return LIBSSH2_ERROR_EAGAIN when it would otherwise block.
.SH ERRORS
.SH AVAILABILITY
Added in libssh2 1.1 since the previous API has deficiencies.
.SH SEE ALSO
.BR libssh2_channel_window_read_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_request_pty_ex.3,v 1.1 2007/06/13 21:07:59 jehousley Exp $
.\" $Id: libssh2_channel_request_pty_ex.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_request_pty_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_channel_request_pty(LIBSSH2_CHANNEL *channel, char *term);
.SH DESCRIPTION
\fIchannel\fP - Previously opened channel instance such as returned by
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)
\fIterm\fP - Terminal emulation (e.g. vt102, ansi, etc...)
@@ -35,18 +35,15 @@ libssh2_channel_request_pty(LIBSSH2_CHANNEL *channel, char *term);
Request a PTY on an established channel. Note that this does not make sense
for all channel types and may be ignored by the server despite returning
success.
.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_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_channel_request_pty_size_ex.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_channel_request_pty_size_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_request_pty_size_ex - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_set_blocking.3,v 1.5 2007/06/14 17:23:13 jehousley Exp $
.\" $Id: libssh2_channel_set_blocking.3,v 1.6 2009/03/26 15:41:16 bagder Exp $
.\"
.TH libssh2_channel_set_blocking 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -8,7 +8,6 @@ libssh2_channel_set_blocking - set or clear blocking mode on channel
void
libssh2_channel_set_blocking(LIBSSH2_CHANNEL *channel, int blocking);
.SH DESCRIPTION
\fIchannel\fP - channel stream to set or clean blocking status on.
@@ -18,10 +17,8 @@ make it non-blocking.
Currently this is just a short cut call to
.BR libssh2_session_set_blocking(3)
and therefore will affect the session and all channels.
.SH RETURN VALUE
None
.SH SEE ALSO
.BR libssh2_session_set_blocking(3)
.BR libssh2_channel_read_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_setenv_ex.3,v 1.1 2007/06/13 21:30:15 jehousley Exp $
.\" $Id: libssh2_channel_setenv_ex.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_setenv_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_channel_setenv(LIBSSH2_CHANNEL *channel, char *varname, const char *valu
.SH DESCRIPTION
\fIchannel\fP - Previously opened channel instance such as returned by
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)
\fIvarname\fP - Name of environment variable to set on the remote
channel instance.
@@ -25,8 +25,9 @@ channel instance.
\fIvalue_len\fP - Length of value parameter.
Set an environment variable in the remote channel's process space. Note that this does not make sense for all channel types and may be ignored by the server despite returning success.
Set an environment variable in the remote channel's process space. Note that
this does not make sense for all channel types and may be ignored by the
server despite returning success.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
@@ -38,6 +39,5 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
\fILIBSSH2_ERROR_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)

View File

@@ -0,0 +1,24 @@
.\" $Id: libssh2_channel_wait_closed.3,v 1.2 2007/11/29 10:04:16 bagder Exp $
.\"
.TH libssh2_channel_wait_closed 3 "29 Nov 2007" "libssh2 0.19" "libssh2 manual"
.SH NAME
libssh2_channel_wait_closed - wait for the remote to close the channel
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_channel_wait_closed(LIBSSH2_CHANNEL *channel);
.SH DESCRIPTION
Enter a temporary blocking state until the remote host closes the named
channel. Typically sent after \fIlibssh2_channel_close(3)\fP in order to
examine the exit status.
.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 SEE ALSO
.BR libssh2_channel_send_eof(3)
.BR libssh2_channel_eof(3)
.BR libssh2_channel_wait_eof(3)

View File

@@ -0,0 +1,26 @@
.\" $Id: libssh2_channel_window_read_ex.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_window_read_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_window_read_ex - Check the status of the read window
.SH SYNOPSIS
#include <libssh2.h>
unsigned long
libssh2_channel_window_read_ex(LIBSSH2_CHANNEL *channel,
unsigned long *read_avail,
unsigned long *window_size_initial)
.SH DESCRIPTION
Check the status of the read window. Returns the number of bytes which the
remote end may send without overflowing the window limit read_avail (if
passed) will be populated with the number of bytes actually available to be
read window_size_initial (if passed) will be populated with the
window_size_initial as defined by the channel_open request
.SH RETURN VALUE
The number of bytes which the remote end may send without overflowing the
window limit
.SH ERRORS
.SH SEE ALSO
.BR libssh2_channel_receive_window_adjust(3),
.BR libssh2_channel_window_write_ex(3)

View File

@@ -0,0 +1,23 @@
.\" $Id: libssh2_channel_window_write_ex.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_window_write_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_channel_window_write_ex - Check the status of the write window
.SH SYNOPSIS
#include <libssh2.h>
unsigned long
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
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.
.SH ERRORS
.SH SEE ALSO
.BR libssh2_channel_window_read_ex(3),
.BR libssh2_channel_receive_window_adjust(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_write_ex.3,v 1.5 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_channel_write_ex.3,v 1.6 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_write_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -41,7 +41,8 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_CHANNEL_CLOSED\fP - The channel has been closed.
\fILIBSSH2_ERROR_CHANNEL_EOF_SENT\fP - The channel has been requested to be closed.
\fILIBSSH2_ERROR_CHANNEL_EOF_SENT\fP - The channel has been requested to be
closed.
.SH SEE ALSO
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_read(3)
.BR libssh2_channel_open_ex(3)
.BR libssh2_channel_read_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_x11_req_ex.3,v 1.1 2007/06/13 21:30:15 jehousley Exp $
.\" $Id: libssh2_channel_x11_req_ex.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_channel_x11_req_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel, int screen_number);
.SH DESCRIPTION
\fIchannel\fP - Previously opened channel instance such as returned by
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)
\fIsingle_connection\fP - non-zero to only forward a single connection.
@@ -26,8 +26,8 @@ libssh2_channel_x11_req(LIBSSH2_CHANNEL *channel, int screen_number);
Request an X11 forwarding on \fIchannel\fP. To use X11 forwarding,
.BR libssh2_session_callback_set(3)
must first be called to set \fBLIBSSH2_CALLBACK_X11/fP. This callback will
be invoked when the remote host accepts the X11 forwarding.
must first be called to set \fBLIBSSH2_CALLBACK_X11\fP. This callback will be
invoked when the remote host accepts the X11 forwarding.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
@@ -42,5 +42,5 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_CHANNEL_REQUEST_DENIED\fP -
.SH SEE ALSO
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_open_ex(3)
.BR libssh2_session_callback_set(3)

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_free_host_entry.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_free_host_entry 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_free_host_entry - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_host_entry_match.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_host_entry_match 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_host_entry_match - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_hostkey_hash.3,v 1.1 2007/06/14 14:56:32 jehousley Exp $
.\" $Id: libssh2_hostkey_hash.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_hostkey_hash 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIhash_type\fP - One of: \fBLIBSSH2_HOSTKEY_HASH_MD5\fP or
\fBLIBSSH2_HOSTKEY_HASH_SHA1\fP.
@@ -19,11 +19,9 @@ libssh2_hostkey_hash(LIBSSH2_SESSION *session, int hash_type);
Returns the computed digest of the remote system's hostkey. The length of
the returned string is hash_type specific (e.g. 16 bytes for MD5,
20 bytes for SHA1).
.SH RETURN VALUE
Computed hostkey hash value. or NULL if the session has not yet been started
up. (The hash consists of raw binary bytes, not hex digits, so is not
directly printable.)
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_new_host_entry.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_new_host_entry 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_new_host_entry - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_publickey_add_ex.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_publickey_add_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_publickey_add_ex - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_publickey_init.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_publickey_init 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_publickey_init - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_publickey_list_fetch.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_publickey_list_fetch 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_publickey_list_fetch - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_publickey_list_free.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_publickey_list_free 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_publickey_list_free - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_publickey_remove_ex.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_publickey_list_remove_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_publickey_list_remove_ex - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_publickey_shutdown.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_publickey_shutdown 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_publickey_shutdown - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_scp_recv.3,v 1.1 2007/06/14 14:56:32 jehousley Exp $
.\" $Id: libssh2_scp_recv.3,v 1.3 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_scp_recv 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,30 +11,23 @@ libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat *sb);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIpath\fP - Full path and filename of file to transfer
\fIsb\fP - Populated with remote file's size, mode, mtime, and atime
Request a file from the remote host via SCP. This
function acts as a wrapper calling
.BR libssh2_channel_open_session(3)
,
.BR libssh2_channel_exec(3)
, and negotiating rcp protocol handshakes.
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.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would
block.
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_exec(3)
.BR libssh2_session_init_ex(3)
.BR libssh2_channel_open_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_scp_send_ex.3,v 1.1 2007/06/14 14:56:32 jehousley Exp $
.\" $Id: libssh2_scp_send_ex.3,v 1.3 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_scp_send_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -8,13 +8,9 @@ libssh2_scp_send_ex - Send a file via SCP
LIBSSH2_CHANNEL *
libssh2_scp_send_ex(LIBSSH2_SESSION *session, const char *path, int mode, size_t size, long mtime, long atime);
LIBSSH2_CHANNEL *
libssh2_scp_send_ex(LIBSSH2_SESSION *session, const char *path, int mode, size_t size);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIpath\fP - Full path and filename of file to transfer
@@ -28,13 +24,7 @@ ahead of time precisely)
\fIatime\fP - atime to assign to file being created (Set this and
mtime to zero to instruct remote host to use current time).
Send a file to the remote host via SCP. This function
acts as a wrapper calling
.BR libssh2_channel_open_session(3)
,
.BR libssh2_channel_exec(3)
, and negotiating rcp protocol handshakes.
Send a file to the remote host via SCP.
.SH RETURN VALUE
Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
@@ -45,8 +35,8 @@ Pointer to a newly allocated LIBSSH2_CHANNEL instance, or NULL on errors.
\fILIBSSH2_ERROR_SCP_PROTOCOL\fP -
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would block.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would
block.
.SH SEE ALSO
.BR libssh2_channel_open_session(3)
.BR libssh2_channel_exec(3)
.BR libssh2_channel_open_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_abstract.3,v 1.1 2007/06/14 15:26:58 jehousley Exp $
.\" $Id: libssh2_session_abstract.3,v 1.2 2008/07/03 10:58:53 bagder Exp $
.\"
.TH libssh2_session_abstract 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -13,10 +13,10 @@ libssh2_session_abstract(LIBSSH2_SESSION *session);
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init_ex(3)
Return a pointer to where the abstract pointer provided to
.BR libssh2_session_init_ex(3)
is stored. By providing a doubly de-referenced pointer, the internal
storage of the session instance may be modified in place.
Return a pointer to where the abstract pointer provided to
\fBlibssh2_session_init_ex(3)\fP is stored. By providing a doubly
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

View File

@@ -0,0 +1,31 @@
.\" $Id: libssh2_session_block_directions.3,v 1.3 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_session_block_directions 3 "1 Oct 2008" "libssh2 1.0" "libssh2 manual"
.SH NAME
libssh2_session_block_directions - get directions that socket should wait for before calling libssh2 function again
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_session_block_directions(LIBSSH2_SESSION *session);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by \fBlibssh2_session_init_ex(3)\fP
When any of libssh2 functions return \fBLIBSSH2_ERROR_EAGAIN\fP an application
should wait for the socket to have data available for reading or
writing. Depending on the return value of
\fIlibssh2_session_block_directions(3)\fP an application should wait for read,
write or both.
.SH RETURN VALUE
Returns the set of directions as a binary mask. Can be a combination of:
LIBSSH2_SESSION_BLOCK_INBOUND: Inbound direction blocked.
LIBSSH2_SESSION_BLOCK_OUTBOUND: Outbound direction blocked.
Application should wait for data to be available for socket prior to calling a
libssh2 function again. If \fBLIBSSH2_SESSION_BLOCK_INBOUND\fP is set select
should contain the session socket in readfds set. Correspondingly in case of
\fBLIBSSH2_SESSION_BLOCK_INBOUND\fP writefds set should contain the socket.
.SH AVAILABILITY
Added in 1.0

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_callback_set.3,v 1.1 2007/06/14 15:26:58 jehousley Exp $
.\" $Id: libssh2_session_callback_set.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_session_callback_set 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_session_callback_set(LIBSSH2_SESSION *session, int cbtype, void *callbac
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIcbtype\fP - Callback type. One of the types listed in Callback Types.
@@ -27,4 +27,4 @@ Pointer to previous callback handler. Returns NULL if no
prior callback handler was set.
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_disconnect_ex.3,v 1.4 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_session_disconnect_ex.3,v 1.5 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_session_disconnect_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_session_disconnect(LIBSSH2_SESSION *session, const char *description);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIreason\fP - One of the Disconnect Reason constants.
@@ -37,4 +37,4 @@ 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 SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -0,0 +1,15 @@
.\" $Id: libssh2_session_flag.3,v 1.2 2009/03/23 13:17:49 bagder Exp $
.\"
.TH libssh2_session_flag 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_session_flag - TODO
.SH SYNOPSIS
int
libssh2_session_flag(LIBSSH2_SESSION * session, int flag, int value);
.SH DESCRIPTION
This function has no purpose and no documented flags can be set nor read.
.SH RETURN VALUE
0
.SH ERRORS
Its mere existence is an error
.SH SEE ALSO

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_free.3,v 1.4 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_session_free.3,v 1.5 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_session_free 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -10,12 +10,11 @@ int
libssh2_session_free(LIBSSH2_SESSION *session);
.SH DESCRIPTION
Frees resources associated with a session instance. Typically called after
.BR libssh2_session_disconnect(3)
.BR libssh2_session_disconnect_ex(3)
.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 SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_disconnect(3)
.BR libssh2_session_init_ex(3)
.BR libssh2_session_disconnect_ex(3)

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_session_get_blocking.3,v 1.2 2009/03/23 13:20:48 bagder Exp $
.\"
.TH libssh2_session_get_blocking 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_session_get_blocking - TODO
.SH SYNOPSIS
int libssh2_session_get_blocking(LIBSSH2_SESSION *session);
.SH DESCRIPTION
Returns 0 if the state of the session has previously be set to non-blocking
and it returns 1 if the state was set to blocking.
.SH RETURN VALUE
See description.
.SH SEE ALSO
.BR libssh2_session_set_blocking(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_init.3,v 1.6 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_session_init_ex.3,v 1.1 2009/03/16 14:40:37 bagder Exp $
.\"
.TH libssh2_session_init_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_last_errno.3,v 1.1 2007/06/13 23:02:08 jehousley Exp $
.\" $Id: libssh2_session_last_errno.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_session_last_errno 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_session_last_errno(LIBSSH2_SESSION *session);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
Determine the most recent error condition.

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_last_error.3,v 1.1 2007/06/13 23:02:08 jehousley Exp $
.\" $Id: libssh2_session_last_error.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_session_last_error 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_session_last_error(LIBSSH2_SESSION *session, char **errmsg, int *errmsg_
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIerrmsg\fP - If not NULL, is populated by reference with the human
readable form of the most recent error message.

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_method_pref.3,v 1.1 2007/06/14 15:26:58 jehousley Exp $
.\" $Id: libssh2_session_method_pref.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_session_method_pref 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_session_method_pref(LIBSSH2_SESSION *session, int method_type, const cha
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fImethod_type\fP - One of the Method Type constants.
@@ -38,5 +38,5 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_METHOD_NOT_SUPPORTED\fP - The requested method is not supported.
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
.BR libssh2_session_startup(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_methods.3,v 1.1 2007/06/14 15:26:58 jehousley Exp $
.\" $Id: libssh2_session_methods.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_session_methods 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_session_methods(LIBSSH2_SESSION *session, int method_type);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fImethod_type\fP - One of the Method Type constants.
@@ -26,4 +26,4 @@ Negotiated method or NULL if the session has not yet been started.
\fILIBSSH2_ERROR_METHOD_NONE\fP -
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_set_blocking.3,v 1.1 2007/06/14 17:23:13 jehousley Exp $
.\" $Id: libssh2_session_set_blocking.3,v 1.3 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_session_set_blocking 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,22 +11,22 @@ libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking);
.SH DESCRIPTION
\fIsession\fP - session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIblocking\fP - Set to a non-zero value to make the channel block, or zero to
make it non-blocking.
Set or clear blocking mode on the selected on the sessoin. This will
instantly affect any channels associtated with this session. If a read is
performed on a session with no data currently available, a blocking
session will wait for data to arrive and return what it receives.
A non-blocking session will return immediately with an empty buffer.
If a write is performed on a session with
no room for more data, a blocking session will wait for room. A non-blocking
session will return immediately without writing anything.
Set or clear blocking mode on the selected on the session. This will
instantly affect any channels associated with this session. If a read is
performed on a session with no data currently available, a blocking session
will wait for data to arrive and return what it receives. A non-blocking
session will return immediately with an empty buffer. If a write is performed
on a session with no room for more data, a blocking session will wait for
room. A non-blocking session will return immediately without writing
anything.
.SH RETURN VALUE
None
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_session_startup.3,v 1.6 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_session_startup.3,v 1.7 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_session_startup 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_session_startup(LIBSSH2_SESSION *session, int socket);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIsocket\fP - Connected socket descriptor. Typically a TCP connection
though the protocol allows for any reliable transport and the library will
@@ -39,4 +39,4 @@ the socket.
.SH SEE ALSO
.BR libssh2_session_free(3)
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_close_handle.3,v 1.1 2007/06/14 15:45:03 jehousley Exp $
.\" $Id: libssh2_sftp_close_handle.3,v 1.3 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_sftp_close_handle 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -17,19 +17,17 @@ int
libssh2_sftp_closedir(LIBSSH2_SFTP_HANDLE *handle);
.SH DESCRIPTION
\fIhandle\fP - SFTP File Handle as returned by
.BR libssh2_sftp_open(3)
or
.BR libssh2_sftp_opendir(3)
\fIhandle\fP - SFTP File Handle as returned by \fBlibssh2_sftp_open_ex(3)\fP
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. It is recommended that
.BR libssh2_sftp_close()
.BR libssh2_sftp_closedir()
be used for files and that
.BR libssh2_sftp_closedir()
be used for directories so that future changes in the library
may cause minimal disruption.
be used for directories so that future changes in the library may cause
minimal disruption. Both are macros for \fBlibssh2_sftp_close_handle\fP.
.SH RETURN VALUE
Return 0 on success or negative on failure. It returns
@@ -48,5 +46,4 @@ received on the socket, or an SFTP operation caused an errorcode to
be returned by the server.
.SH SEE ALSO
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_opendir(3)
.BR libssh2_sftp_open_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_fstat_ex.3,v 1.1 2007/06/14 15:45:03 jehousley Exp $
.\" $Id: libssh2_sftp_fstat_ex.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_sftp_fstat_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -18,7 +18,7 @@ libssh2_sftp_fsetstat(LIBSSH2_SFTP_HANDLE *handle, LIBSSH2_SFTP_ATTRIBUTES *attr
.SH DESCRIPTION
\fIhandle\fP - SFTP File Handle as returned by
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3)
\fIattrs\fP - Pointer to attribute structure to set file metadata
from or into depending on the value of setstat.
@@ -28,12 +28,10 @@ with the data found in attrs according to the values of attrs->flags
and other relevant member attributes.
Get or Set statbuf type data for a given LIBSSH2_SFTP_HANDLE instance.
.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.
@@ -44,6 +42,5 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\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.
.SH SEE ALSO
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3)

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_sftp_init.3,v 1.6 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_sftp_init.3,v 1.8 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_sftp_init 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_sftp_init -
libssh2_sftp_init - open SFTP channel for the given SSH session.
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>
@@ -12,7 +12,7 @@ libssh2_sftp_init(LIBSSH2_SESSION *session);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
Open a channel and initialize the SFTP subsystem. Although the SFTP subsystem
operates over the same type of channel as those exported by the Channel API,
@@ -34,8 +34,8 @@ A pointer to the newly allocated SFTP instance or NULL on failure.
received on the socket, or an SFTP operation caused an errorcode to be
returned by the server.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would block.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would
block.
.SH SEE ALSO
.BR libssh2_sftp_shutdown(3)
.BR libssh2_sftp_open_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_last_error.3,v 1.1 2007/06/14 16:08:43 jehousley Exp $
.\" $Id: libssh2_sftp_last_error.3,v 1.2 2008/12/15 18:48:09 bagder Exp $
.\"
.TH libssh2_sftp_last_error 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,10 @@ libssh2_sftp_last_error(LIBSSH2_SFTP *sftp);
\fIsftp\fP - SFTP instance as returned by
.BR libssh2_sftp_init(3)
Determines the last error code produced by the SFTP layer.
Returns the last error code produced by the SFTP layer. Note that this only
returns a sensible error code if libssh2 returned LIBSSH2_ERROR_SFTP_PROTOCOL
in a previous call. Using \fBlibssh2_sftp_last_error(3)\fP without a
preceeding SFTP protocol error, it will return an unspecified value.
.SH RETURN VALUE
Current error code state of the SFTP instance.

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_mkdir_ex.3,v 1.6 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_sftp_mkdir_ex.3,v 1.7 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_sftp_mkdir_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -12,7 +12,6 @@ libssh2_sftp_mkdir_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_le
int
libssh2_sftp_mkdir(LIBSSH2_SFTP *sftp, const char *path, long mode);
.SH DESCRIPTION
\fIsftp\fP - SFTP instance as returned by
.BR libssh2_sftp_init(3)
@@ -25,12 +24,10 @@ directory's parents must all exist priot to making this call.
\fImode\fP - directory creation mode (e.g. 0755).
Create a directory on the remote file system.
.SH RETURN VALUE
Return 0 on success or negative on failure.
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.
@@ -41,6 +38,5 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\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.
.SH SEE ALSO
.BR libssh2_sftp_opendir(3)
.BR libssh2_sftp_open_ex(3)

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_sftp_open_ex.3,v 1.8 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_sftp_open_ex.3,v 1.10 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_sftp_open_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_sftp_open -
libssh2_sftp_open - open filehandle for file on SFTP.
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>
@@ -46,8 +46,8 @@ failure.
received on the socket, or an SFTP operation caused an errorcode to be
returned by the server.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would block.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call would
block.
.SH SEE ALSO
.BR libssh_sftp_close(3)
.BR libssh2_sftp_close_handle(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_read.3,v 1.8 2007/06/13 16:41:33 jehousley Exp $
.\" $Id: libssh2_sftp_read.3,v 1.10 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_sftp_read 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -12,7 +12,7 @@ libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle, char *buffer, size_t buffer_maxle
.SH DESCRIPTION
\fIhandle\fP is the SFTP File Handle as returned by
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3)
\fIbuffer\fP is a pointer to a pre-allocated buffer of at least
@@ -23,10 +23,9 @@ after the POSIX
.BR read(2)
function and uses the same calling semantics.
.BR libssh2_sftp_read(3)
will attempt to read as much as possible however it may not fill all of
buffer if the file pointer reaches the end or
if further reads would cause the socket to block.
will attempt to read as much as possible however it may not fill all of buffer
if the file pointer reaches the end or if further reads would cause the socket
to block.
.SH RETURN VALUE
Number of bytes actually populated into buffer, or negative on failure.
It returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
@@ -38,10 +37,9 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_SOCKET_TIMEOUT\fP -
\fILIBSSH2_ERROR_SFTP_PROTOCOL\fP - An invalid SFTP protocol response was
received on the socket, or an SFTP operation caused an errorcode to be
\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.
.SH SEE ALSO
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_readnb(3)
.BR libssh2_sftp_open_ex(3)
.BR libssh2_sftp_read(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_readdir.3,v 1.9 2007/06/15 17:22:49 jehousley Exp $
.\" $Id: libssh2_sftp_readdir_ex.3,v 1.2 2009/03/16 23:25:14 bagder Exp $
.\"
.TH libssh2_sftp_readdir_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -15,7 +15,7 @@ libssh2_sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, size_t buffer_ma
.SH DESCRIPTION
\fIhandle\fP - is the SFTP File Handle as returned by
.BR libssh2_sftp_diropen(3)
.BR libssh2_sftp_open_ex(3)
\fIbuffer\fP - is a pointer to a pre-allocated buffer of at least
\fIbuffer_maxlen\fP bytes to read data into.
@@ -41,8 +41,8 @@ however, it uses a variable sized directory entry (filename) buffer and
returns statbuf type data in the same call.
.SH RETURN VALUE
Number of bytes actually populated into buffer, or -1 on failure. It returns
LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
Number of bytes actually populated into buffer, 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.
@@ -54,7 +54,6 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\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.
.SH SEE ALSO
.BR libssh2_sftp_opendir(3)
.BR libssh2_sftp_closedir(3)
.BR libssh2_sftp_open_ex(3),
.BR libssh2_sftp_close_handle(3)

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_sftp_rename_ex.3,v 1.1 2007/06/14 16:08:43 jehousley Exp $
.\" $Id: libssh2_sftp_rename_ex.3,v 1.2 2008/12/23 12:34:17 bagder Exp $
.\"
.TH libssh2_sftp_rename_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_sftp_rename_ex - rename a file
libssh2_sftp_rename_ex - rename an SFTP file
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_sftp_rmdir_ex.3,v 1.1 2007/06/14 16:08:43 jehousley Exp $
.\" $Id: libssh2_sftp_rmdir_ex.3,v 1.2 2008/12/23 12:34:17 bagder Exp $
.\"
.TH libssh2_sftp_rmdir_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_sftp_rmdir_ex - rename a file
libssh2_sftp_rmdir_ex - remove an SFTP directory
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>

View File

@@ -1,6 +1,6 @@
.\" $Id: libssh2_sftp_seek.3,v 1.1 2007/06/14 16:08:43 jehousley Exp $
.\" $Id: libssh2_sftp_seek.3,v 1.5 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_sftp_seek 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.TH libssh2_sftp_seek 3 "22 Dec 2008" "libssh2 1.0" "libssh2 manual"
.SH NAME
libssh2_sftp_seek - set the read/write position indicator within a file
.SH SYNOPSIS
@@ -10,9 +10,12 @@ libssh2_sftp_seek - set the read/write position indicator within a file
void
libssh2_sftp_seek(LIBSSH2_SFTP_HANDLE *handle, size_t offset);
void
libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset);
.SH DESCRIPTION
\fIhandle\fP - SFTP File Handle as returned by
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3)
\fIoffset\fP - Number of bytes from the beginning of file to seek to.
@@ -21,6 +24,7 @@ Note that libssh2 implements file pointers as a localized concept to make
file access appear more POSIX like. No packets are exchanged with the server
during a seek operation. The localized file pointer is simply used as a
convenience offset during read/write operations.
.SH AVAILABILITY
libssh2_sftp_seek64(3) was added in 1.0
.SH SEE ALSO
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3)

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_sftp_stat_ex.3,v 1.1 2007/06/14 16:33:38 jehousley Exp $
.\" $Id: libssh2_sftp_stat_ex.3,v 1.2 2008/12/23 12:34:17 bagder Exp $
.\"
.TH libssh2_sftp_stat_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_sftp_stat_ex - rename a file
libssh2_sftp_stat_ex - get status about an SFTP file
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_tell.3,v 1.1 2007/06/14 16:33:38 jehousley Exp $
.\" $Id: libssh2_sftp_tell.3,v 1.3 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_sftp_tell 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,16 +11,12 @@ size_t
libssh2_sftp_tell(LIBSSH2_SFTP_HANDLE *handle);
.SH DESCRIPTION
\fIhandle\fP - SFTP File Handle as returned by
.BR libssh2_sftp_open(3)
Identify the current offset of the file handle's internal pointer. Note
that the SSH2 protocol does not have a notion of file pointers and that
libssh2 implements this using a localized file pointer which is updated
with each read/write call.
\fIhandle\fP - SFTP File Handle as returned by \fBlibssh2_sftp_open_ex(3)\fP.
Returns the current offset of the file handle's internal pointer. Note that
this is now deprecated. Use the newer \fBlibssh2_sftp_tell64(3)\fP instead!
.SH RETURN VALUE
Current offset from beginning of file in bytes.
.SH SEE ALSO
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3),
.BR libssh2_sftp_tell64(3)

View File

@@ -0,0 +1,23 @@
.\" $Id: libssh2_sftp_tell64.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_sftp_tell64 3 "22 Dec 2008" "libssh2 1.0" "libssh2 manual"
.SH NAME
libssh2_sftp_tell64 - get the current read/write position indicator for a file
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>
libssh2_uint64_t
libssh2_sftp_tell64(LIBSSH2_SFTP_HANDLE *handle);
.SH DESCRIPTION
\fIhandle\fP - SFTP File Handle as returned by \fBlibssh2_sftp_open_ex(3)\fP
Identify the current offset of the file handle's internal pointer.
.SH RETURN VALUE
Current offset from beginning of file in bytes.
.SH AVAILABILITY
Added in libssh2 1.0
.SH SEE ALSO
.BR libssh2_sftp_open_ex(3),
.BR libssh2_sftp_tell(3)

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_sftp_unlink_ex.3,v 1.1 2007/06/14 16:46:14 jehousley Exp $
.\" $Id: libssh2_sftp_unlink_ex.3,v 1.2 2008/12/23 12:34:17 bagder Exp $
.\"
.TH libssh2_sftp_unlink_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_sftp_unlink_ex - rename a file
libssh2_sftp_unlink_ex - unlink an SFTP file
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>

View File

@@ -1,8 +1,8 @@
.\" $Id: libssh2_sftp_write.3,v 1.1 2007/06/14 16:46:14 jehousley Exp $
.\" $Id: libssh2_sftp_write.3,v 1.3 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_sftp_rename_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.TH libssh2_sftp_write 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_sftp_rename_ex - rename a file
libssh2_sftp_write - write SFTP data
.SH SYNOPSIS
#include <libssh2.h>
#include <libssh2_sftp.h>
@@ -12,7 +12,7 @@ libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer, size_t count
.SH DESCRIPTION
\fIhandle\fP - SFTP File Handle as returned by
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3)
\fIbuffer\fP - Pre-initialized data buffer to write to the LIBSSH2_SFTP_HANDLE.
@@ -38,4 +38,4 @@ received on the socket, or an SFTP operation caused an errorcode to
be returned by the server.
.SH SEE ALSO
.BR libssh2_sftp_open(3)
.BR libssh2_sftp_open_ex(3)

35
docs/libssh2_trace.3 Normal file
View File

@@ -0,0 +1,35 @@
.\" $Id: libssh2_trace.3,v 1.1 2008/12/26 07:46:45 bagder Exp $
.\"
.TH libssh2_trace 3 "26 Dec 2008" "libssh2 1.0" "libssh2 manual"
.SH NAME
libssh2_trace - enable debug info from inside libssh2
.SH SYNOPSIS
#include <libssh2.h>
void libssh2_trace(int bitmask);
.SH DESCRIPTION
This is a function present in the library that can be used to get debug info
from within libssh2 when it is running. Helpful when trying to trace or debug
behaviors. This function has no effect unless libssh2 was built to support
this option, and a typical "release build" might not.
\fBbitmask\fP can be set to none, one or more of these bits:
.RS
.IP LIBSSH2_TRACE_TRANS
Transport layer debugging
.IP LIBSSH2_TRACE_KEX
Key exchange debugging
.IP LIBSSH2_TRACE_AUTH
Authentication debugging
.IP LIBSSH2_TRACE_CONN
Connection layer debugging
.IP LIBSSH2_TRACE_SCP
SCP debugging
.IP LIBSSH2_TRACE_SFTP
SFTP debugging
.IP LIBSSH2_TRACE_ERROR
Error debugging
.IP LIBSSH2_TRACE_PUBLICKEY
Public Key debugging
.RE

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_userauth_authenticated.3,v 1.1 2007/06/14 17:15:32 jehousley Exp $
.\" $Id: libssh2_userauth_authenticated.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_userauth_authenticated 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_userauth_authenticated(LIBSSH2_SESSION *session);
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
Indicates whether or not the named session has been successfully authenticated.
@@ -19,4 +19,4 @@ Indicates whether or not the named session has been successfully authenticated.
Returns 1 if authenticated and 0 if not.
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -0,0 +1,14 @@
.\" $Id: libssh2_userauth_hostbased_fromfile_ex.3,v 1.1 2009/03/16 15:00:45 bagder Exp $
.\"
.TH libssh2_userauth_hostbased_fromfile_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
libssh2_userauth_hostbased_fromfile_ex - TODO
.SH SYNOPSIS
.SH DESCRIPTION
.SH RETURN VALUE
.SH ERRORS
.SH SEE ALSO

View File

@@ -0,0 +1,43 @@
.\" $Id: libssh2_userauth_keyboard_interactive_ex.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_userauth_keyboard_interactive_ex 3 "8 Mar 2008" "libssh2 0.19" "libssh2 manual"
.SH NAME
libssh2_userauth_keyboard_interactive_ex - authenticate a session using a challenge-response authentication
.SH SYNOPSIS
#include <libssh2.h>
int
libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION *session, const char *username, unsigned int username_len, LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(*response_callback));
int
libssh2_userauth_keyboard_interactive(LIBSSH2_SESSION *session, const char *username, LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC(*response_callback));
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init_ex(3)
\fIusername\fP - Name of user to attempt plain password authentication for.
\fIusername_len\fP - Length of username parameter.
\fIresponse_callback\fP - As authentication proceeds, host issues several (1 or more) challenges and requires responses. This callback will be called at this moment. Callback is responsible to obtain responses for the challenges, fill the provided data structure and then return control. Responses will be sent to the host. String values will be free(3)ed by the library.
Attempts keyboard-interactive (challenge/response) authentication.
Note that many SSH servers will always issue single "password" challenge,
requesting actual password as response, but it is not required by the protocol,
and various authentication schemes, such as smartcard authentication may use
keyboard-interactive authentication type too.
.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.
.SH SEE ALSO
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_userauth_list.3,v 1.1 2007/06/14 17:15:32 jehousley Exp $
.\" $Id: libssh2_userauth_list.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_userauth_list 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -11,7 +11,7 @@ libssh2_userauth_list(LIBSSH2_SESSION *session, const char *username, unsigned i
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIusername\fP - Username which will be used while authenticating. Note
that most server implementations do not permit attempting authentication
@@ -40,4 +40,4 @@ internally managed by libssh2. On failure ruturns NULL.
\fILIBSSH2_ERROR_EAGAIN\fP - Marked for non-blocking I/O but the call
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_userauth_password_ex.3,v 1.1 2007/06/14 17:15:32 jehousley Exp $
.\" $Id: libssh2_userauth_password_ex.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_userauth_password_ex 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_userauth_password(LIBSSH2_SESSION *session, const char *username, const
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIusername\fP - Name of user to attempt plain password authentication for.
@@ -47,4 +47,4 @@ LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
\fILIBSSH2_ERROR_PASSWORD_EXPIRED\fP -
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

View File

@@ -1,4 +1,4 @@
.\" $Id: libssh2_userauth_publickey_fromfile.3,v 1.1 2007/06/14 17:15:32 jehousley Exp $
.\" $Id: libssh2_userauth_publickey_fromfile_ex.3,v 1.2 2009/03/17 10:34:27 bagder Exp $
.\"
.TH libssh2_userauth_publickey_fromfile 3 "1 Jun 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME
@@ -14,7 +14,7 @@ libssh2_userauth_publickey_fromfile_ex(LIBSSH2_SESSION *session, const char *use
.SH DESCRIPTION
\fIsession\fP - Session instance as returned by
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)
\fIusername\fP - Remote user name to authenticate as.
@@ -48,4 +48,4 @@ combination was invalid, or the signature for the supplied public
key was invalid.
.SH SEE ALSO
.BR libssh2_session_init(3)
.BR libssh2_session_init_ex(3)

38
docs/libssh2_version.3 Normal file
View File

@@ -0,0 +1,38 @@
.\" $Id: libssh2_version.3,v 1.1 2009/02/23 16:22:46 bagder Exp $
.\"
.TH libssh2_version 3 "23 Feb 2009" "libssh2 1.1" "libssh2 manual"
.SH NAME
libssh2_version - return the libssh2 version number
.SH SYNOPSIS
#include <libssh2.h>
const char *
libssh2_version(int required_version);
.SH DESCRIPTION
If \fIrequired_version\fP is lower than or equal to the version number of the
libssh2 in use, the version number of libssh2 is returned as a pointer to a
zero terminated string.
The \fIrequired_version\fP should be the version number as constructed by the
LIBSSH2_VERSION_NUM define in the libssh2.h public header file, which is a 24
bit number in the 0xMMmmpp format. MM for major, mm for minor and pp for patch
number.
.SH RETURN VALUE
The version number of libssh2 is returned as a pointer to a zero terminated
string or NULL if the \fIrequired_version\fP isn't fulfilled.
.SH EXAMPLE
To make sure you run with the correct libssh2 version:
.nf
if (!libssh2_version(LIBSSH2_VERSION_NUM)) {
fprintf (stderr, \&"Runtime libssh2 version too old!\&");
exit(1);
}
.fi
Unconditionally get the version number:
printf(\&"libssh2 version: %s\&", libssh2_version(0) );
.SH AVAILABILITY
This function was added in libssh2 1.1, in previous versions there way no way
to extract this info in run-time.

View File

@@ -2,8 +2,12 @@ Makefile
Makefile.in
.deps
.libs
*.gcno
*.gcda
scp
scp_nonblock
scp_write
scp_write_nonblock
sftp
sftp_nonblock
sftpdir

View File

@@ -10,34 +10,7 @@ noinst_PROGRAMS = ssh2 \
sftp_RW_nonblock \
sftpdir sftpdir_nonblock
INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/src
# the examples need the $(top_builddir)/src since when building outside of the
# source dir they still need to reach the libssh2_config.h header
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include -I$(top_builddir)/src
LDADD = $(top_builddir)/src/libssh2.la
ssh2_SOURCES = ssh2.c
scp_SOURCES = scp.c
scp_nonblock_SOURCES = scp_nonblock.c
scp_write_SOURCES = scp_write.c
scp_write_nonblock_SOURCES = scp_write_nonblock.c
sftp_SOURCES = sftp.c
sftp_nonblock_SOURCES = sftp_nonblock.c
sftp_write_SOURCES = sftp_write.c
sftp_write_nonblock_SOURCES = sftp_write_nonblock.c
sftp_mkdir_SOURCES = sftp_mkdir.c
sftp_mkdir_nonblock_SOURCES = sftp_mkdir_nonblock.c
sftpdir_SOURCES = sftpdir.c
sftpdir_nonblock_SOURCES = sftpdir_nonblock.c
sftp_RW_nonblock_SOURCES = sftp_RW_nonblock.c

View File

@@ -1,11 +1,11 @@
/*
* $Id: scp.c,v 1.7 2007/06/06 12:34:08 jehousley Exp $
* $Id: scp.c,v 1.11 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do a simple SCP transfer.
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -40,9 +40,9 @@ int main(int argc, char *argv[])
const char *fingerprint;
LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel;
char *username=(char *)"username";
char *password=(char *)"password";
char *scppath=(char *)"/tmp/TEST";
const char *username="username";
const char *password="password";
const char *scppath="/tmp/TEST";
struct stat fileinfo;
int rc;
off_t got=0;
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@@ -67,7 +67,7 @@ int main(int argc, char *argv[])
if (argc > 4) {
scppath = argv[4];
}
/* Ultra basic "connect to port 22 on localhost"
* Your code is responsible for creating the socket establishing the
* connection

View File

@@ -1,11 +1,16 @@
/*
* $Id: scp_nonblock.c,v 1.5 2007/06/08 13:33:08 jehousley Exp $
* $Id: scp_nonblock.c,v 1.15 2009/03/25 22:52:32 bagder Exp $
*
* Sample showing how to do SCP transfers in a non-blocking manner.
*
* The sample code has default values for host name, user name, password
* and path to copy, but you can specify them on the command line like:
*
* "scp_nonblock 192.168.0.1 user password /tmp/secrets"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -32,6 +37,43 @@
#include <stdio.h>
#include <ctype.h>
/* 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;
}
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
fd_set fd;
fd_set *writefd = NULL;
fd_set *readfd = NULL;
int dir;
timeout.tv_sec = 10;
timeout.tv_usec = 0;
FD_ZERO(&fd);
FD_SET(socket_fd, &fd);
/* now make sure we wait in the correct direction */
dir = libssh2_session_block_directions(session);
if(dir & LIBSSH2_SESSION_BLOCK_INBOUND)
readfd = &fd;
if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
writefd = &fd;
rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
return rc;
}
int main(int argc, char *argv[])
{
unsigned long hostaddr;
@@ -40,19 +82,27 @@ int main(int argc, char *argv[])
const char *fingerprint;
LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel;
char *username=(char *)"username";
char *password=(char *)"password";
char *scppath=(char *)"/tmp/TEST";
const char *username="username";
const char *password="password";
const char *scppath="/tmp/TEST";
struct stat fileinfo;
struct timeval start;
struct timeval end;
int rc;
int total = 0;
long time_ms;
int spin = 0;
#if defined(HAVE_IOCTLSOCKET)
long flag = 1;
#endif
off_t got=0;
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
@@ -67,13 +117,13 @@ int main(int argc, char *argv[])
if (argc > 4) {
scppath = argv[4];
}
/* Ultra basic "connect to port 22 on localhost"
* Your code is responsible for creating the socket establishing the
* connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
@@ -81,34 +131,44 @@ int main(int argc, char *argv[])
fprintf(stderr, "failed to connect!\n");
return -1;
}
/* We set the socket non-blocking. We do it after the connect just to
simplify the example code. */
#ifdef F_SETFL
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance */
session = libssh2_session_init();
if (!session)
return -1;
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
gettimeofday(&start, NULL);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
while ((rc = libssh2_session_startup(session, sock)) == LIBSSH2_ERROR_EAGAIN);
while ((rc = libssh2_session_startup(session, sock)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
@@ -120,90 +180,101 @@ int main(int argc, char *argv[])
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
}
fprintf(stderr, "\n");
if (auth_pw) {
/* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) {
while ((rc = libssh2_userauth_password(session, username, password)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
}
} else {
/* Or by public key */
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) == LIBSSH2_ERROR_EAGAIN);
"/home/username/"
".ssh/id_rsa.pub",
"/home/username/"
".ssh/id_rsa",
password)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown;
}
}
#if 0
libssh2_trace(session, LIBSSH2_TRACE_CONN);
#endif
/* Request a file via SCP */
fprintf(stderr, "libssh2_scp_recv()!\n");
do {
channel = libssh2_scp_recv(session, scppath, &fileinfo);
if ((!channel) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to open a session\n");
goto shutdown;
if (!channel) {
if(libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
char *err_msg;
libssh2_session_last_error(session, &err_msg, NULL, 0);
fprintf(stderr, "%s\n", err_msg);
goto shutdown;
}
else {
fprintf(stderr, "libssh2_scp_recv() spin\n");
waitsocket(sock, session);
}
}
} while (!channel);
fprintf(stderr, "libssh2_scp_recv() is done, now receive data!\n");
while(got < fileinfo.st_size) {
char mem[1000];
struct timeval timeout;
char mem[1024*24];
int rc;
fd_set fd;
do {
int amount=sizeof(mem);
if ((fileinfo.st_size -got) < amount) {
amount = fileinfo.st_size - got;
}
/* loop until we block */
rc = libssh2_channel_read(channel, mem, amount);
if (rc > 0) {
write(1, mem, rc);
got += rc;
total += rc;
}
} while (rc > 0);
if (rc == LIBSSH2_ERROR_EAGAIN) {
if ((rc == LIBSSH2_ERROR_EAGAIN) && (got < fileinfo.st_size)) {
/* this is due to blocking that would occur otherwise
so we loop on this condition */
timeout.tv_sec = 10;
timeout.tv_usec = 0;
FD_ZERO(&fd);
FD_SET(sock, &fd);
rc = select(sock+1, &fd, &fd, NULL, &timeout);
if (rc <= 0) {
/* negative is error
0 is timeout */
fprintf(stderr, "SCP timed out: %d\n", rc);
}
spin++;
waitsocket(sock, session); /* now we wait */
continue;
}
break;
}
gettimeofday(&end, NULL);
time_ms = tvdiff(end, start);
printf("Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
time_ms, total/(time_ms/1000.0), spin );
libssh2_channel_free(channel);
channel = NULL;
shutdown:
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_disconnect(session,
"Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
#ifdef WIN32
Sleep(1000);
closesocket(sock);

View File

@@ -1,11 +1,11 @@
/*
* $Id: scp_write.c,v 1.1 2007/06/06 12:34:08 jehousley Exp $
* $Id: scp_write.c,v 1.6 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do a simple SCP transfer.
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -40,10 +40,10 @@ int main(int argc, char *argv[])
const char *fingerprint;
LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel;
char *username=(char *)"username";
char *password=(char *)"password";
char *loclfile=(char *)"scp_write.c";
char *scppath=(char *)"/tmp/TEST";
const char *username="username";
const char *password="password";
const char *loclfile="scp_write.c";
const char *scppath="/tmp/TEST";
FILE *local;
int rc;
char mem[1024];
@@ -54,7 +54,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@@ -74,15 +74,15 @@ int main(int argc, char *argv[])
if (argc > 5) {
scppath = argv[5];
}
local = fopen(loclfile, "rb");
if (!local) {
fprintf(stderr, "Can't local file %s\n", loclfile);
goto shutdown;
}
stat(loclfile, &fileinfo);
/* Ultra basic "connect to port 22 on localhost"
* Your code is responsible for creating the socket establishing the
* connection
@@ -142,10 +142,9 @@ int main(int argc, char *argv[])
}
}
//libssh2_trace(session, 0xFFFF);
/* Request a file via SCP */
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode, (unsigned long)fileinfo.st_size);
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode,
(unsigned long)fileinfo.st_size);
if (!channel) {
fprintf(stderr, "Unable to open a session\n");
@@ -160,7 +159,7 @@ int main(int argc, char *argv[])
break;
}
ptr = mem;
do {
/* write data in a loop until we block */
rc = libssh2_channel_write(channel, ptr, nread);
@@ -171,16 +170,13 @@ int main(int argc, char *argv[])
fprintf(stderr, "Sending EOF\n");
libssh2_channel_send_eof(channel);
fprintf(stderr, "Waiting for EOF\n");
libssh2_channel_wait_eof(channel);
fprintf(stderr, "Waiting for channel to close\n");
libssh2_channel_wait_closed(channel);
// fprintf(stderr, "Closing channel\n");
// libssh2_channel_close(channel);
libssh2_channel_free(channel);
channel = NULL;

View File

@@ -1,11 +1,12 @@
/*
* $Id: scp_write_nonblock.c,v 1.2 2007/06/08 13:33:08 jehousley Exp $
* $Id: scp_write_nonblock.c,v 1.9 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do a simple SCP transfer.
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -40,12 +41,15 @@ int main(int argc, char *argv[])
const char *fingerprint;
LIBSSH2_SESSION *session;
LIBSSH2_CHANNEL *channel;
char *username=(char *)"username";
char *password=(char *)"password";
char *loclfile=(char *)"scp_write.c";
char *scppath=(char *)"/tmp/TEST";
const char *username="username";
const char *password="password";
const char *loclfile="scp_write.c";
const char *scppath="/tmp/TEST";
FILE *local;
int rc;
#if defined(HAVE_IOCTLSOCKET)
long flag = 1;
#endif
char mem[1024];
size_t nread;
char *ptr;
@@ -54,7 +58,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@@ -74,15 +78,15 @@ int main(int argc, char *argv[])
if (argc > 5) {
scppath = argv[5];
}
local = fopen(loclfile, "rb");
if (!local) {
fprintf(stderr, "Can't local file %s\n", loclfile);
goto shutdown;
}
stat(loclfile, &fileinfo);
/* Ultra basic "connect to port 22 on localhost"
* Your code is responsible for creating the socket establishing the
* connection
@@ -104,10 +108,17 @@ int main(int argc, char *argv[])
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance
*/
session = libssh2_session_init();
@@ -116,11 +127,11 @@ int main(int argc, char *argv[])
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
while ((rc = libssh2_session_startup(session, sock))
while ((rc = libssh2_session_startup(session, sock))
== LIBSSH2_ERROR_EAGAIN);
if(rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
@@ -141,7 +152,8 @@ int main(int argc, char *argv[])
if (auth_pw) {
/* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
while ((rc = libssh2_userauth_password(session, username, password)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
@@ -158,14 +170,17 @@ int main(int argc, char *argv[])
}
}
// libssh2_trace(session, 0xFF7D);
/* Request a file via SCP */
do {
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode, (unsigned long)fileinfo.st_size);
if ((!channel) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to open a session\n");
channel = libssh2_scp_send(session, scppath, 0x1FF & fileinfo.st_mode,
(unsigned long)fileinfo.st_size);
if ((!channel) && (libssh2_session_last_errno(session) !=
LIBSSH2_ERROR_EAGAIN)) {
char *err_msg;
libssh2_session_last_error(session, &err_msg, NULL, 0);
fprintf(stderr, "%s\n", err_msg);
goto shutdown;
}
} while (!channel);
@@ -178,10 +193,11 @@ int main(int argc, char *argv[])
break;
}
ptr = mem;
do {
/* write data in a loop until we block */
while ((rc = libssh2_channel_write(channel, ptr, nread)) == LIBSSH2_ERROR_EAGAIN);
while ((rc = libssh2_channel_write(channel, ptr, nread)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc < 0) {
fprintf(stderr, "ERROR %d\n", rc);
}
@@ -192,22 +208,20 @@ int main(int argc, char *argv[])
fprintf(stderr, "Sending EOF\n");
while (libssh2_channel_send_eof(channel) == LIBSSH2_ERROR_EAGAIN);
fprintf(stderr, "Waiting for EOF\n");
while (libssh2_channel_wait_eof(channel) == LIBSSH2_ERROR_EAGAIN);
fprintf(stderr, "Waiting for channel to close\n");
while (libssh2_channel_wait_closed(channel) == LIBSSH2_ERROR_EAGAIN);
// fprintf(stderr, "Closing channel\n");
// while (libssh2_channel_close(channel) == LIBSSH2_ERROR_EAGAIN);
libssh2_channel_free(channel);
channel = NULL;
shutdown:
while ((rc = libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")) == LIBSSH2_ERROR_EAGAIN);
while ((rc = libssh2_session_disconnect(session,
"Normal Shutdown, Thank you for playing")) == LIBSSH2_ERROR_EAGAIN);
libssh2_session_free(session);
#ifdef WIN32

View File

@@ -1,17 +1,17 @@
/*
* $Id: sftp.c,v 1.8 2007/06/06 12:34:08 jehousley Exp $
* $Id: sftp.c,v 1.16 2009/03/31 12:20:36 bagder Exp $
*
* Sample showing how to do SFTP transfers.
*
* The sample code has default values for host name, user name, password
* and path to copy, but you can specify them on the command line like:
*
* "sftp 192.168.0.1 user password /tmp/secrets"
* "sftp 192.168.0.1 user password /tmp/secrets -p|-i|-k"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -38,155 +38,210 @@
#include <stdio.h>
#include <ctype.h>
const char *keyfile1="~/.ssh/id_rsa.pub";
const char *keyfile2="~/.ssh/id_rsa";
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/TEST";
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;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *sftppath=(char *)"/tmp/TEST";
int rc;
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
unsigned long hostaddr;
int sock, i, auth_pw = 0;
struct sockaddr_in sin;
const char *fingerprint;
char *userauthlist;
LIBSSH2_SESSION *session;
int rc;
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
#ifdef WIN32
WSADATA wsadata;
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
hostaddr = htonl(0x7F000001);
}
if (argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
hostaddr = htonl(0x7F000001);
}
if(argc > 2) {
username = argv[2];
}
if(argc > 3) {
password = argv[3];
}
if(argc > 4) {
sftppath = argv[4];
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
if(argc > 2) {
username = argv[2];
}
if(argc > 3) {
password = argv[3];
}
if(argc > 4) {
sftppath = argv[4];
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
}
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
}
/* Create a session instance
*/
session = libssh2_session_init();
if(!session)
return -1;
/* Create a session instance
*/
session = libssh2_session_init();
if(!session)
return -1;
/* Since we have set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
rc = libssh2_session_startup(session, sock);
if(rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
/* Since we have set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
/* Since we have not set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
rc = libssh2_session_startup(session, sock);
if(rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
* user, that's your call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
fprintf(stderr, "Fingerprint: ");
for(i = 0; i < 16; i++) {
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
}
fprintf(stderr, "\n");
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
* user, that's your call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
fprintf(stderr, "Fingerprint: ");
for(i = 0; i < 16; i++) {
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
}
fprintf(stderr, "\n");
if (auth_pw) {
/* We could authenticate via password */
if (libssh2_userauth_password(session, username, password)) {
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
}
} 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;
}
}
/* check what authentication methods are available */
userauthlist = libssh2_userauth_list(session, username, strlen(username));
printf("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;
}
fprintf(stderr, "libssh2_sftp_init()!\n");
sftp_session = libssh2_sftp_init(session);
if (!sftp_session) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
/* Since we have not set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
fprintf(stderr, "libssh2_sftp_open()!\n");
/* Request a file via SFTP */
sftp_handle =
libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
if (!sftp_handle) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
do {
char mem[1024];
/* loop until we fail */
fprintf(stderr, "libssh2_sftp_read()!\n");
rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
if (rc > 0) {
write(1, mem, rc);
} else {
break;
/* if we got an 4. argument we set this option if supported */
if(argc > 5) {
if ((auth_pw & 1) && !strcasecmp(argv[5], "-p")) {
auth_pw = 1;
}
} while (1);
if ((auth_pw & 2) && !strcasecmp(argv[5], "-i")) {
auth_pw = 2;
}
if ((auth_pw & 4) && !strcasecmp(argv[5], "-k")) {
auth_pw = 4;
}
}
libssh2_sftp_close(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
if (auth_pw & 1) {
/* We could authenticate via password */
if (libssh2_userauth_password(session, username, password)) {
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
}
} else if (auth_pw & 2) {
/* Or via keyboard-interactive */
if (libssh2_userauth_keyboard_interactive(session, username, &kbd_callback) ) {
printf("\tAuthentication by keyboard-interactive failed!\n");
goto shutdown;
} else {
printf("\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)) {
printf("\tAuthentication by public key failed!\n");
goto shutdown;
} else {
printf("\tAuthentication by public key succeeded.\n");
}
} else {
printf("No supported authentication methods found!\n");
goto shutdown;
}
shutdown:
fprintf(stderr, "libssh2_sftp_init()!\n");
sftp_session = libssh2_sftp_init(session);
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
if (!sftp_session) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
fprintf(stderr, "libssh2_sftp_open()!\n");
/* Request a file via SFTP */
sftp_handle =
libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
if (!sftp_handle) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
do {
char mem[1024];
/* loop until we fail */
fprintf(stderr, "libssh2_sftp_read()!\n");
rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
if (rc > 0) {
write(1, mem, rc);
} else {
break;
}
} while (1);
libssh2_sftp_close(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
shutdown:
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
#ifdef WIN32
Sleep(1000);
closesocket(sock);
Sleep(1000);
closesocket(sock);
#else
sleep(1);
close(sock);
sleep(1);
close(sock);
#endif
fprintf(stderr, "all done\n");
return 0;
fprintf(stderr, "all done\n");
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_RW_nonblock.c,v 1.7 2007/06/08 13:33:08 jehousley Exp $
* $Id: sftp_RW_nonblock.c,v 1.12 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP transfers in a non-blocking manner.
*
@@ -9,9 +9,9 @@
* Using the SFTP server running on 127.0.0.1
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -44,251 +44,261 @@
int main(int argc, char *argv[])
{
int sock, i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *sftppath=(char *)"/tmp/TEST"; /* source path */
char *dest=(char *)"/tmp/TEST2"; /* destination path */
int rc;
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
FILE *tempstorage;
char mem[1000];
struct timeval timeout;
fd_set fd;
int sock, i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/TEST"; /* source path */
const char *dest="/tmp/TEST2"; /* destination path */
int rc;
#if defined(HAVE_IOCTLSOCKET)
long flag = 1;
#endif
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
FILE *tempstorage;
char mem[1000];
struct timeval timeout;
fd_set fd;
#ifdef WIN32
WSADATA wsadata;
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
/* Ultra basic "connect to port 22 on localhost"
* The application is responsible for creating the socket establishing
* the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
/* Ultra basic "connect to port 22 on localhost"
* The application is responsible for creating the socket establishing
* the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = htonl(0x7F000001);
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
}
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = htonl(0x7F000001);
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
}
/* We set the socket non-blocking. We do it after the connect just to
simplify the example code. */
/* We set the socket non-blocking. We do it after the connect just to
simplify the example code. */
#ifdef F_SETFL
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance
*/
session = libssh2_session_init();
if(!session)
return -1;
/* Create a session instance
*/
session = libssh2_session_init();
if(!session)
return -1;
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
rc = libssh2_session_startup(session, sock);
if(rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
rc = libssh2_session_startup(session, sock);
if(rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
libssh2_session_set_blocking(session, 0);
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
* user, that's your call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
printf("Fingerprint: ");
for(i = 0; i < 16; i++) {
printf("%02X ", (unsigned char)fingerprint[i]);
}
printf("\n");
if(argc > 1) {
username = argv[1];
}
if(argc > 2) {
password = argv[2];
}
if(argc > 3) {
sftppath = argv[3];
}
if(argc > 4) {
dest = argv[4];
}
tempstorage = fopen(STORAGE, "wb");
if(!tempstorage) {
printf("Can't open temp storage file %s\n", STORAGE);
goto shutdown;
}
if (auth_pw) {
/* We could authenticate via password */
if (libssh2_userauth_password(session, username, password)) {
printf("Authentication by password failed.\n");
goto shutdown;
}
libssh2_session_set_blocking(session, 0);
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
* user, that's your call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
printf("Fingerprint: ");
for(i = 0; i < 16; i++) {
printf("%02X ", (unsigned char)fingerprint[i]);
} else {
/* Or by public key */
if (libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) {
printf("\tAuthentication by public key failed\n");
goto shutdown;
}
printf("\n");
}
if(argc > 1) {
username = argv[1];
}
if(argc > 2) {
password = argv[2];
}
if(argc > 3) {
sftppath = argv[3];
}
if(argc > 4) {
dest = argv[4];
}
sftp_session = libssh2_sftp_init(session);
tempstorage = fopen(STORAGE, "wb");
if(!tempstorage) {
printf("Can't open temp storage file %s\n", STORAGE);
goto shutdown;
}
if (!sftp_session) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
if (auth_pw) {
/* We could authenticate via password */
if (libssh2_userauth_password(session, username, password)) {
printf("Authentication by password failed.\n");
goto shutdown;
}
} else {
/* Or by public key */
if (libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) {
printf("\tAuthentication by public key failed\n");
goto shutdown;
}
}
/* Request a file via SFTP */
sftp_handle =
libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
sftp_session = libssh2_sftp_init(session);
if (!sftp_session) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
/* Request a file via SFTP */
sftp_handle =
libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
if (!sftp_handle) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
if (!sftp_handle) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
do {
do {
do {
/* read in a loop until we block */
rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
fprintf(stderr, "libssh2_sftp_read returned %d\n",
rc);
/* read in a loop until we block */
rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
fprintf(stderr, "libssh2_sftp_read returned %d\n",
rc);
if(rc > 0) {
/* write to stderr */
write(2, mem, rc);
/* write to temporary storage area */
fwrite(mem, rc, 1, tempstorage);
}
} while (rc > 0);
if(rc > 0) {
/* write to stderr */
write(2, mem, rc);
/* write to temporary storage area */
fwrite(mem, rc, 1, tempstorage);
}
} while (rc > 0);
if(rc != LIBSSH2_ERROR_EAGAIN) {
/* error or end of file */
break;
}
if(rc != LIBSSH2_ERROR_EAGAIN) {
/* error or end of file */
break;
}
timeout.tv_sec = 10;
timeout.tv_usec = 0;
timeout.tv_sec = 10;
timeout.tv_usec = 0;
FD_ZERO(&fd);
FD_ZERO(&fd);
FD_SET(sock, &fd);
FD_SET(sock, &fd);
/* wait for readable or writeable */
rc = select(sock+1, &fd, &fd, NULL, &timeout);
if(rc <= 0) {
/* negative is error
0 is timeout */
fprintf(stderr, "SFTP download timed out: %d\n", rc);
break;
}
/* wait for readable or writeable */
rc = select(sock+1, &fd, &fd, NULL, &timeout);
if(rc <= 0) {
/* negative is error
0 is timeout */
fprintf(stderr, "SFTP download timed out: %d\n", rc);
break;
}
} while (1);
libssh2_sftp_close(sftp_handle);
fclose(tempstorage);
tempstorage = fopen(STORAGE, "rb");
if(!tempstorage) {
/* weird, we can't read the file we just wrote to... */
fprintf(stderr, "can't open %s for reading\n", STORAGE);
goto shutdown;
}
/* we're done downloading, now reverse the process and upload the
temporarily stored data to the destination path */
sftp_handle =
libssh2_sftp_open(sftp_session, dest,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT,
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
if(sftp_handle) {
size_t nread;
char *ptr;
do {
nread = fread(mem, 1, sizeof(mem), tempstorage);
if(nread <= 0) {
/* end of file */
break;
}
ptr = mem;
do {
/* write data in a loop until we block */
rc = libssh2_sftp_write(sftp_handle, ptr,
nread);
ptr += rc;
nread -= nread;
} while (rc > 0);
if(rc != LIBSSH2_ERROR_EAGAIN) {
/* error or end of file */
break;
}
timeout.tv_sec = 10;
timeout.tv_usec = 0;
FD_ZERO(&fd);
FD_SET(sock, &fd);
/* wait for readable or writeable */
rc = select(sock+1, &fd, &fd, NULL, &timeout);
if(rc <= 0) {
/* negative is error
0 is timeout */
fprintf(stderr, "SFTP upload timed out: %d\n",
rc);
break;
}
} while (1);
fprintf(stderr, "SFTP upload done!\n");
}
else {
fprintf(stderr, "SFTP failed to open destination path: %s\n",
dest);
}
libssh2_sftp_close(sftp_handle);
fclose(tempstorage);
libssh2_sftp_shutdown(sftp_session);
tempstorage = fopen(STORAGE, "rb");
if(!tempstorage) {
/* weird, we can't read the file we just wrote to... */
fprintf(stderr, "can't open %s for reading\n", STORAGE);
goto shutdown;
}
shutdown:
/* we're done downloading, now reverse the process and upload the
temporarily stored data to the destination path */
sftp_handle =
libssh2_sftp_open(sftp_session, dest,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT,
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
if(sftp_handle) {
size_t nread;
char *ptr;
do {
nread = fread(mem, 1, sizeof(mem), tempstorage);
if(nread <= 0) {
/* end of file */
break;
}
ptr = mem;
do {
/* write data in a loop until we block */
rc = libssh2_sftp_write(sftp_handle, ptr,
nread);
ptr += rc;
nread -= nread;
} while (rc > 0);
if(rc != LIBSSH2_ERROR_EAGAIN) {
/* error or end of file */
break;
}
timeout.tv_sec = 10;
timeout.tv_usec = 0;
FD_ZERO(&fd);
FD_SET(sock, &fd);
/* wait for readable or writeable */
rc = select(sock+1, &fd, &fd, NULL, &timeout);
if(rc <= 0) {
/* negative is error
0 is timeout */
fprintf(stderr, "SFTP upload timed out: %d\n",
rc);
break;
}
} while (1);
fprintf(stderr, "SFTP upload done!\n");
}
else {
fprintf(stderr, "SFTP failed to open destination path: %s\n",
dest);
}
libssh2_sftp_shutdown(sftp_session);
shutdown:
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
#ifdef WIN32
Sleep(1000);
closesocket(sock);
Sleep(1000);
closesocket(sock);
#else
sleep(1);
close(sock);
sleep(1);
close(sock);
#endif
printf("all done\n");
return 0;
printf("all done\n");
return 0;
}

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_mkdir.c,v 1.4 2007/06/06 12:34:08 jehousley Exp $
* $Id: sftp_mkdir.c,v 1.8 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP mkdir
*
@@ -9,9 +9,9 @@
* "sftp 192.168.0.1 user password /tmp/sftp_mkdir"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -42,16 +42,16 @@ int main(int argc, char *argv[])
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *sftppath=(char *)"/tmp/sftp_mkdir";
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/sftp_mkdir";
int rc;
LIBSSH2_SFTP *sftp_session;
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@@ -69,7 +69,7 @@ int main(int argc, char *argv[])
if(argc > 4) {
sftppath = argv[4];
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
@@ -79,7 +79,7 @@ int main(int argc, char *argv[])
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
/* Since we have not set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
fprintf(stderr, "libssh2_sftp_mkdir()!\n");
/* Make a directory via SFTP */
rc = libssh2_sftp_mkdir(sftp_session, sftppath,

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_mkdir_nonblock.c,v 1.6 2007/06/08 13:33:08 jehousley Exp $
* $Id: sftp_mkdir_nonblock.c,v 1.11 2008/11/10 16:48:41 bagder Exp $
*
* Sample showing how to do SFTP non-blocking mkdir.
*
@@ -9,9 +9,9 @@
* "sftp 192.168.0.1 user password /tmp/sftp_write_nonblock.c"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -42,16 +42,19 @@ int main(int argc, char *argv[])
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *sftppath=(char *)"/tmp/sftp_mkdir_nonblock";
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/sftp_mkdir_nonblock";
int rc;
#if defined(HAVE_IOCTLSOCKET)
long flag = 1;
#endif
LIBSSH2_SFTP *sftp_session;
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@@ -69,7 +72,7 @@ int main(int argc, char *argv[])
if(argc > 4) {
sftppath = argv[4];
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
@@ -79,7 +82,7 @@ int main(int argc, char *argv[])
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
@@ -91,8 +94,15 @@ int main(int argc, char *argv[])
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance
@@ -149,7 +159,7 @@ int main(int argc, char *argv[])
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
fprintf(stderr, "libssh2_sftp_mkdirnb()!\n");
/* Make a directory via SFTP */
while ((rc = libssh2_sftp_mkdir(sftp_session, sftppath,

View File

@@ -1,17 +1,17 @@
/*
* $Id: sftp_nonblock.c,v 1.10 2007/06/08 13:33:08 jehousley Exp $
* $Id: sftp_nonblock.c,v 1.17 2009/03/13 22:14:47 bagder Exp $
*
* Sample showing how to do SFTP non-blocking transfers.
*
* The sample code has default values for host name, user name, password
* and path to copy, but you can specify them on the command line like:
*
* "sftp 192.168.0.1 user password /tmp/secrets"
* "sftp_nonblock 192.168.0.1 user password /tmp/secrets"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -38,6 +38,43 @@
#include <stdio.h>
#include <ctype.h>
/* 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;
}
static int waitsocket(int socket_fd, LIBSSH2_SESSION *session)
{
struct timeval timeout;
int rc;
fd_set fd;
fd_set *writefd = NULL;
fd_set *readfd = NULL;
int dir;
timeout.tv_sec = 10;
timeout.tv_usec = 0;
FD_ZERO(&fd);
FD_SET(socket_fd, &fd);
/* now make sure we wait in the correct direction */
dir = libssh2_session_block_directions(session);
if(dir & LIBSSH2_SESSION_BLOCK_INBOUND)
readfd = &fd;
if(dir & LIBSSH2_SESSION_BLOCK_OUTBOUND)
writefd = &fd;
rc = select(socket_fd + 1, readfd, writefd, NULL, &timeout);
return rc;
}
int main(int argc, char *argv[])
{
unsigned long hostaddr;
@@ -45,25 +82,33 @@ int main(int argc, char *argv[])
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *sftppath=(char *)"/tmp/TEST";
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/TEST";
struct timeval start;
struct timeval end;
int rc;
int total = 0;
long time_ms;
int spin = 0;
#if defined(HAVE_IOCTLSOCKET)
long flag = 1;
#endif
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
hostaddr = htonl(0x7F000001);
}
if (argc > 2) {
username = argv[2];
}
@@ -78,7 +123,7 @@ int main(int argc, char *argv[])
* and establishing the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
@@ -87,34 +132,44 @@ int main(int argc, char *argv[])
fprintf(stderr, "failed to connect!\n");
return -1;
}
/* We set the socket non-blocking. We do it after the connect just to
simplify the example code. */
#ifdef F_SETFL
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance */
session = libssh2_session_init();
if (!session)
return -1;
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
gettimeofday(&start, NULL);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
while ((rc = libssh2_session_startup(session, sock)) == LIBSSH2_ERROR_EAGAIN);
while ((rc = libssh2_session_startup(session, sock)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
@@ -126,71 +181,102 @@ int main(int argc, char *argv[])
fprintf(stderr, "%02X ", (unsigned char)fingerprint[i]);
}
fprintf(stderr, "\n");
if (auth_pw) {
/* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) {
while ((rc = libssh2_userauth_password(session, username, password))
== LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
}
} else {
/* Or by public key */
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) {
while ((rc =
libssh2_userauth_publickey_fromfile(session, username,
"/home/username/"
".ssh/id_rsa.pub",
"/home/username/"
".ssh/id_rsa",
password)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown;
}
}
#if 0
libssh2_trace(session, LIBSSH2_TRACE_CONN);
#endif
fprintf(stderr, "libssh2_sftp_init()!\n");
do {
sftp_session = libssh2_sftp_init(session);
if ((!sftp_session) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
if(!sftp_session) {
if(libssh2_session_last_errno(session) ==
LIBSSH2_ERROR_EAGAIN) {
fprintf(stderr, "non-blocking init\n");
waitsocket(sock, session); /* now we wait */
}
else {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
}
} while (!sftp_session);
fprintf(stderr, "libssh2_sftp_open()!\n");
/* Request a file via SFTP */
do {
sftp_handle = libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
if ((!sftp_handle) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
sftp_handle = libssh2_sftp_open(sftp_session, sftppath,
LIBSSH2_FXF_READ, 0);
if (!sftp_handle) {
if (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
else {
fprintf(stderr, "non-blocking open\n");
waitsocket(sock, session); /* now we wait */
}
}
} while (!sftp_handle);
fprintf(stderr, "libssh2_sftp_open() is done, now receive data!\n");
do {
char mem[1024];
char mem[1024*24];
/* loop until we fail */
fprintf(stderr, "libssh2_sftp_readnb()!\n");
while ((rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem))) == LIBSSH2_ERROR_EAGAIN) {
;
while ((rc = libssh2_sftp_read(sftp_handle, mem,
sizeof(mem))) == LIBSSH2_ERROR_EAGAIN) {
spin++;
waitsocket(sock, session); /* now we wait */
}
if (rc > 0) {
total += rc;
write(1, mem, rc);
} else {
break;
}
} while (1);
gettimeofday(&end, NULL);
time_ms = tvdiff(end, start);
printf("Got %d bytes in %ld ms = %.1f bytes/sec spin: %d\n", total,
time_ms, total/(time_ms/1000.0), spin );
libssh2_sftp_close(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
shutdown:
while ((rc = libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")) == LIBSSH2_ERROR_EAGAIN);
printf("libssh2_session_disconnect\n");
while ((rc = libssh2_session_disconnect(session,
"Normal Shutdown, Thank you")) ==
LIBSSH2_ERROR_EAGAIN);
libssh2_session_free(session);
#ifdef WIN32
Sleep(1000);
closesocket(sock);

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_write.c,v 1.4 2007/06/06 12:34:09 jehousley Exp $
* $Id: sftp_write.c,v 1.10 2009/03/31 12:20:36 bagder Exp $
*
* Sample showing how to do SFTP write transfers.
*
@@ -9,9 +9,9 @@
* "sftp 192.168.0.1 user password sftp_write.c /tmp/secrets"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -42,10 +42,10 @@ int main(int argc, char *argv[])
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *loclfile=(char *)"sftp_write.c";
char *sftppath=(char *)"/tmp/TEST";
const char *username="username";
const char *password="password";
const char *loclfile="sftp_write.c";
const char *sftppath="/tmp/TEST";
int rc;
FILE *local;
LIBSSH2_SFTP *sftp_session;
@@ -57,7 +57,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@@ -78,13 +78,13 @@ int main(int argc, char *argv[])
if(argc > 5) {
sftppath = argv[5];
}
local = fopen(loclfile, "rb");
if (!local) {
printf("Can't local file %s\n", loclfile);
goto shutdown;
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
@@ -94,7 +94,7 @@ int main(int argc, char *argv[])
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
/* Since we have set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
@@ -147,8 +147,6 @@ int main(int argc, char *argv[])
}
}
//libssh2_trace(session, 0xFFFF);
fprintf(stderr, "libssh2_sftp_init()!\n");
sftp_session = libssh2_sftp_init(session);
@@ -157,9 +155,6 @@ int main(int argc, char *argv[])
goto shutdown;
}
/* Since we have not set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
fprintf(stderr, "libssh2_sftp_open()!\n");
/* Request a file via SFTP */
sftp_handle =
@@ -167,7 +162,7 @@ int main(int argc, char *argv[])
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
if (!sftp_handle) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
@@ -180,7 +175,7 @@ int main(int argc, char *argv[])
break;
}
ptr = mem;
do {
/* write data in a loop until we block */
rc = libssh2_sftp_write(sftp_handle, ptr, nread);
@@ -195,7 +190,8 @@ int main(int argc, char *argv[])
shutdown:
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_disconnect(session,
"Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
#ifdef WIN32

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_write_nonblock.c,v 1.7 2007/06/08 13:33:08 jehousley Exp $
* $Id: sftp_write_nonblock.c,v 1.13 2009/03/31 12:20:36 bagder Exp $
*
* Sample showing how to do SFTP non-blocking write transfers.
*
@@ -9,9 +9,9 @@
* "sftp 192.168.0.1 user password sftp_write_nonblock.c /tmp/sftp_write_nonblock.c"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -42,30 +42,33 @@ int main(int argc, char *argv[])
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *loclfile=(char *)"sftp_write_nonblock.c";
char *sftppath=(char *)"/tmp/sftp_write_nonblock.c";
const char *username="username";
const char *password="password";
const char *loclfile="sftp_write_nonblock.c";
const char *sftppath="/tmp/sftp_write_nonblock.c";
int rc;
#if defined(HAVE_IOCTLSOCKET)
long flag = 1;
#endif
FILE *local;
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
char mem[1024];
size_t nread;
char *ptr;
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
hostaddr = htonl(0x7F000001);
}
if (argc > 2) {
username = argv[2];
}
@@ -78,57 +81,64 @@ int main(int argc, char *argv[])
if (argc > 5) {
sftppath = argv[5];
}
local = fopen(loclfile, "rb");
if (!local) {
printf("Can't local file %s\n", loclfile);
goto shutdown;
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
}
/* We set the socket non-blocking. We do it after the connect just to
simplify the example code. */
#ifdef F_SETFL
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance
*/
session = libssh2_session_init();
if (!session)
return -1;
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
while ((rc = libssh2_session_startup(session, sock))
while ((rc = libssh2_session_startup(session, sock))
== LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
@@ -140,7 +150,7 @@ int main(int argc, char *argv[])
printf("%02X ", (unsigned char)fingerprint[i]);
}
printf("\n");
if (auth_pw) {
/* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
@@ -159,20 +169,17 @@ int main(int argc, char *argv[])
goto shutdown;
}
}
fprintf(stderr, "libssh2_sftp_init()!\n");
do {
sftp_session = libssh2_sftp_init(session);
if ((!sftp_session) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
} while (!sftp_session);
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
fprintf(stderr, "libssh2_sftp_open()!\n");
/* Request a file via SFTP */
do {
@@ -181,13 +188,13 @@ int main(int argc, char *argv[])
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
if ((!sftp_handle) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
} while (!sftp_handle);
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
do {
nread = fread(mem, 1, sizeof(mem), local);
@@ -196,7 +203,7 @@ int main(int argc, char *argv[])
break;
}
ptr = mem;
do {
/* write data in a loop until we block */
while ((rc = libssh2_sftp_write(sftp_handle, ptr, nread)) == LIBSSH2_ERROR_EAGAIN) {
@@ -206,16 +213,16 @@ int main(int argc, char *argv[])
nread -= nread;
} while (rc > 0);
} while (1);
fclose(local);
libssh2_sftp_close(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
shutdown:
while ((rc = libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")) == LIBSSH2_ERROR_EAGAIN);
libssh2_session_free(session);
#ifdef WIN32
Sleep(1000);
closesocket(sock);

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftpdir.c,v 1.6 2007/06/15 17:22:49 jehousley Exp $
* $Id: sftpdir.c,v 1.10 2008/11/10 16:48:41 bagder Exp $
*
* Sample doing an SFTP directory listing.
*
@@ -9,9 +9,9 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -42,9 +42,9 @@ int main(int argc, char *argv[])
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *sftppath=(char *)"/tmp/secretdir";
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/secretdir";
int rc;
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
@@ -139,7 +139,7 @@ int main(int argc, char *argv[])
/* Since we have not set non-blocking, tell libssh2 we are blocking */
libssh2_session_set_blocking(session, 1);
fprintf(stderr, "libssh2_sftp_opendir()!\n");
/* Request a dir listing via SFTP */
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftpdir_nonblock.c,v 1.7 2007/06/08 13:33:08 jehousley Exp $
* $Id: sftpdir_nonblock.c,v 1.12 2008/11/10 16:48:41 bagder Exp $
*
* Sample doing an SFTP directory listing.
*
@@ -9,9 +9,9 @@
* "sftpdir 192.168.0.1 user password /tmp/secretdir"
*/
#include "libssh2_config.h"
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <libssh2_config.h>
#ifdef HAVE_WINSOCK2_H
# include <winsock2.h>
@@ -37,197 +37,211 @@
int main(int argc, char *argv[])
{
unsigned long hostaddr;
int sock, i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
char *username=(char *)"username";
char *password=(char *)"password";
char *sftppath=(char *)"/tmp/secretdir";
int rc;
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
unsigned long hostaddr;
int sock, i, auth_pw = 1;
struct sockaddr_in sin;
const char *fingerprint;
LIBSSH2_SESSION *session;
const char *username="username";
const char *password="password";
const char *sftppath="/tmp/secretdir";
int rc;
#if defined(HAVE_IOCTLSOCKET)
long flag = 1;
#endif
LIBSSH2_SFTP *sftp_session;
LIBSSH2_SFTP_HANDLE *sftp_handle;
#ifdef WIN32
WSADATA wsadata;
WSADATA wsadata;
WSAStartup(WINSOCK_VERSION, &wsadata);
WSAStartup(MAKEWORD(2,0), &wsadata);
#endif
if (argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
hostaddr = htonl(0x7F000001);
}
if (argc > 1) {
hostaddr = inet_addr(argv[1]);
} else {
hostaddr = htonl(0x7F000001);
}
if(argc > 2) {
username = argv[2];
}
if(argc > 3) {
password = argv[3];
}
if(argc > 4) {
sftppath = argv[4];
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
if(argc > 2) {
username = argv[2];
}
if(argc > 3) {
password = argv[3];
}
if(argc > 4) {
sftppath = argv[4];
}
/*
* The application code is responsible for creating the socket
* and establishing the connection
*/
sock = socket(AF_INET, SOCK_STREAM, 0);
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
}
sin.sin_family = AF_INET;
sin.sin_port = htons(22);
sin.sin_addr.s_addr = hostaddr;
if (connect(sock, (struct sockaddr*)(&sin),
sizeof(struct sockaddr_in)) != 0) {
fprintf(stderr, "failed to connect!\n");
return -1;
}
/* We set the socket non-blocking. We do it after the connect just to
simplify the example code. */
/* We set the socket non-blocking. We do it after the connect just to
simplify the example code. */
#ifdef F_SETFL
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
/* FIXME: this can/should be done in a more portable manner */
rc = fcntl(sock, F_GETFL, 0);
fcntl(sock, F_SETFL, rc | O_NONBLOCK);
#elif defined(HAVE_IOCTLSOCKET)
ioctlsocket(sock, FIONBIO, &flag);
#else
#ifdef WIN32
u_long mode = 1;
ioctlsocket (sock, FIONBIO, &mode);
#else
#error "add support for setting the socket non-blocking here"
#endif
#endif
/* Create a session instance
*/
session = libssh2_session_init();
if(!session)
return -1;
/* Create a session instance
*/
session = libssh2_session_init();
if(!session)
return -1;
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
while ((rc = libssh2_session_startup(session, sock)) == LIBSSH2_ERROR_EAGAIN);
if(rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
libssh2_session_set_blocking(session, 0);
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
* user, that's your call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
printf("Fingerprint: ");
for(i = 0; i < 16; i++) {
printf("%02X ", (unsigned char)fingerprint[i]);
}
printf("\n");
/* ... start it up. This will trade welcome banners, exchange keys,
* and setup crypto, compression, and MAC layers
*/
while ((rc = libssh2_session_startup(session, sock)) == LIBSSH2_ERROR_EAGAIN);
if(rc) {
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
return -1;
}
/* At this point we havn't yet authenticated. The first thing to do
* is check the hostkey's fingerprint against our known hosts Your app
* may have it hard coded, may go to a file, may present it to the
* user, that's your call
*/
fingerprint = libssh2_hostkey_hash(session, LIBSSH2_HOSTKEY_HASH_MD5);
printf("Fingerprint: ");
for(i = 0; i < 16; i++) {
printf("%02X ", (unsigned char)fingerprint[i]);
}
printf("\n");
if (auth_pw) {
/* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) {
while ((rc = libssh2_userauth_password(session, username, password)) ==
LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "Authentication by password failed.\n");
goto shutdown;
}
} else {
/* Or by public key */
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) {
"/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa",
password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) {
fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown;
}
}
fprintf(stderr, "libssh2_sftp_init()!\n");
do {
sftp_session = libssh2_sftp_init(session);
if ((!sftp_session) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
fprintf(stderr, "libssh2_sftp_init()!\n");
do {
sftp_session = libssh2_sftp_init(session);
if ((!sftp_session) && (libssh2_session_last_errno(session) !=
LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to init SFTP session\n");
goto shutdown;
}
} while (!sftp_session);
fprintf(stderr, "libssh2_sftp_opendir()!\n");
/* Request a dir listing via SFTP */
do {
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
if ((!sftp_handle) && (libssh2_session_last_errno(session) !=
LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to open dir with SFTP\n");
goto shutdown;
}
} while (!sftp_handle);
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing!\n");
do {
char mem[512];
LIBSSH2_SFTP_ATTRIBUTES attrs;
/* loop until we fail */
while ((rc = libssh2_sftp_readdir(sftp_handle, mem, sizeof(mem),
&attrs)) == LIBSSH2_ERROR_EAGAIN) {
;
}
if(rc > 0) {
/* rc is the length of the file name in the mem
buffer */
if(attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) {
/* this should check what permissions it
is and print the output accordingly */
printf("--fix----- ");
} else {
printf("---------- ");
}
} while (!sftp_session);
fprintf(stderr, "libssh2_sftp_opendir()!\n");
/* Request a dir listing via SFTP */
do {
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
if ((!sftp_handle) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to open dir with SFTP\n");
goto shutdown;
if(attrs.flags & LIBSSH2_SFTP_ATTR_UIDGID) {
printf("%4ld %4ld ", attrs.uid, attrs.gid);
} else {
printf(" - - ");
}
} while (!sftp_handle);
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing!\n");
do {
char mem[512];
LIBSSH2_SFTP_ATTRIBUTES attrs;
/* loop until we fail */
while ((rc = libssh2_sftp_readdir(sftp_handle, mem, sizeof(mem), &attrs)) == LIBSSH2_ERROR_EAGAIN) {
;
}
if(rc > 0) {
/* rc is the length of the file name in the mem
buffer */
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
/* attrs.filesize is an uint64_t according to
the docs but there is no really good and
portable 64bit type for C before C99, and
correspondingly there was no good printf()
option for it... */
if(attrs.flags & LIBSSH2_SFTP_ATTR_PERMISSIONS) {
/* this should check what permissions it
is and print the output accordingly */
printf("--fix----- ");
} else {
printf("---------- ");
}
printf("%8lld ", attrs.filesize);
}
if(attrs.flags & LIBSSH2_SFTP_ATTR_UIDGID) {
printf("%4ld %4ld ", attrs.uid, attrs.gid);
} else {
printf(" - - ");
}
printf("%s\n", mem);
}
else if (rc == LIBSSH2_ERROR_EAGAIN) {
/* blocking */
fprintf(stderr, "Blocking\n");
} else {
break;
}
if(attrs.flags & LIBSSH2_SFTP_ATTR_SIZE) {
/* attrs.filesize is an uint64_t according to
the docs but there is no really good and
portable 64bit type for C before C99, and
correspondingly there was no good printf()
option for it... */
} while (1);
printf("%8lld ", attrs.filesize);
}
libssh2_sftp_closedir(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
printf("%s\n", mem);
}
else if (rc == LIBSSH2_ERROR_EAGAIN) {
/* blocking */
fprintf(stderr, "Blocking\n");
} else {
break;
}
shutdown:
} while (1);
libssh2_sftp_closedir(sftp_handle);
libssh2_sftp_shutdown(sftp_session);
shutdown:
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing");
libssh2_session_free(session);
#ifdef WIN32
Sleep(1000);
closesocket(sock);
Sleep(1000);
closesocket(sock);
#else
sleep(1);
close(sock);
sleep(1);
close(sock);
#endif
printf("all done\n");
return 0;
printf("all done\n");
return 0;
}

Some files were not shown because too many files have changed in this diff Show More