From 2c4a1bf6e44281689505d807a3c3fc02edae6439 Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 16 Aug 2012 15:24:16 +0000 Subject: [PATCH] compatibility with libssh4 git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5433 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- retroshare-nogui/src/ssh/rssshd.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/retroshare-nogui/src/ssh/rssshd.cc b/retroshare-nogui/src/ssh/rssshd.cc index 0d486d43f..a5d1cc6f0 100644 --- a/retroshare-nogui/src/ssh/rssshd.cc +++ b/retroshare-nogui/src/ssh/rssshd.cc @@ -32,7 +32,9 @@ RsSshd *rsSshd = NULL; // External Reference Variable. // NB: This must be called EARLY before all the threads are launched. RsSshd *RsSshd::InitRsSshd(std::string portStr, std::string rsakeyfile) { +#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0) ssh_threads_set_callbacks(ssh_threads_get_pthread()); +#endif ssh_init(); rsSshd = new RsSshd(portStr); @@ -321,10 +323,19 @@ int RsSshd::doEcho() char buf[2048]; do{ +#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0) i=ssh_channel_read(mChannel,buf, 2048, 0); +#else + i=channel_read(mChannel,buf, 2048, 0); +#endif if(i>0) { +#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0) ssh_channel_write(mChannel, buf, i); ssh_channel_write(mChannel, buf, i); +#else + channel_write(mChannel, buf, i); + channel_write(mChannel, buf, i); +#endif if (write(1,buf,i) < 0) { printf("error writing to buffer\n"); return 0; @@ -365,7 +376,11 @@ int RsSshd::doTermServer() while(okay) { char buf; +#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0) int size = ssh_channel_read_nonblocking(mChannel, &buf, 1, 0); +#else + int size = channel_read_nonblocking(mChannel, &buf, 1, 0); +#endif bool haveInput = (size > 0); std::string output; @@ -373,7 +388,11 @@ int RsSshd::doTermServer() if (output.size() > 0) { +#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0) ssh_channel_write(mChannel, output.c_str(), output.size()); +#else + channel_write(mChannel, output.c_str(), output.size()); +#endif } if (!haveInput)