From 30ac056cb0365f6621520fca9e145e20fd64d388 Mon Sep 17 00:00:00 2001 From: liuzl Date: Thu, 8 Sep 2011 08:50:24 +0200 Subject: [PATCH] API add:libssh2_sftp_get_channel Return the channel of sftp, then caller can control the channel's behavior. Signed-off-by: liuzl --- docs/Makefile.am | 1 + docs/libssh2_sftp_get_channel.3 | 21 +++++++++++++++++++++ include/libssh2_sftp.h | 1 + src/sftp.c | 12 ++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 docs/libssh2_sftp_get_channel.3 diff --git a/docs/Makefile.am b/docs/Makefile.am index 5cf159a..e0b72b4 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -117,6 +117,7 @@ dist_man_MANS = \ libssh2_sftp_fstat.3 \ libssh2_sftp_fstat_ex.3 \ libssh2_sftp_fstatvfs.3 \ + libssh2_sftp_get_channel.3 \ libssh2_sftp_init.3 \ libssh2_sftp_last_error.3 \ libssh2_sftp_lstat.3 \ diff --git a/docs/libssh2_sftp_get_channel.3 b/docs/libssh2_sftp_get_channel.3 new file mode 100644 index 0000000..f6fa89b --- /dev/null +++ b/docs/libssh2_sftp_get_channel.3 @@ -0,0 +1,21 @@ +.TH libssh2_sftp_get_channel 3 "9 Sep 2011" "libssh2 1.3.1" "libssh2 manual" +.SH NAME +libssh2_sftp_get_channel - return the channel of sftp +.SH SYNOPSIS +.nf +#include +#include + +.fi +LIBSSH2_CHANNEL *libssh2_sftp_get_channel(LIBSSH2_SFTP *sftp); +.SH DESCRIPTION +\fIsftp\fP - SFTP instance as returned by +.BR libssh2_sftp_init(3) + +Return the channel of the given sftp handle. +.SH RETURN VALUE +The channel of the SFTP instance or NULL if something was wrong. +.SH AVAILABILITY +Added in 1.4.0 +.SH SEE ALSO +.BR libssh2_sftp_init(3) diff --git a/include/libssh2_sftp.h b/include/libssh2_sftp.h index c40420d..47b9152 100644 --- a/include/libssh2_sftp.h +++ b/include/libssh2_sftp.h @@ -219,6 +219,7 @@ struct _LIBSSH2_SFTP_STATVFS { LIBSSH2_API LIBSSH2_SFTP *libssh2_sftp_init(LIBSSH2_SESSION *session); LIBSSH2_API int libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp); LIBSSH2_API unsigned long libssh2_sftp_last_error(LIBSSH2_SFTP *sftp); +LIBSSH2_API LIBSSH2_CHANNEL *libssh2_sftp_get_channel(LIBSSH2_SFTP *sftp); /* File / Directory Ops */ LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp, diff --git a/src/sftp.c b/src/sftp.c index 2bddb37..4f846c5 100644 --- a/src/sftp.c +++ b/src/sftp.c @@ -3008,3 +3008,15 @@ libssh2_sftp_last_error(LIBSSH2_SFTP *sftp) return sftp->last_errno; } + +/* libssh2_sftp_get_channel + * Return the channel of sftp, then caller can control the channel's behavior. + */ +LIBSSH2_API LIBSSH2_CHANNEL * +libssh2_sftp_get_channel(LIBSSH2_SFTP *sftp) +{ + if (!sftp) + return NULL; + + return sftp->channel; +}