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
This commit is contained in:
csoler 2012-08-16 15:24:16 +00:00
parent f51af0d4de
commit 2c4a1bf6e4

View File

@ -32,7 +32,9 @@ RsSshd *rsSshd = NULL; // External Reference Variable.
// NB: This must be called EARLY before all the threads are launched. // NB: This must be called EARLY before all the threads are launched.
RsSshd *RsSshd::InitRsSshd(std::string portStr, std::string rsakeyfile) 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()); ssh_threads_set_callbacks(ssh_threads_get_pthread());
#endif
ssh_init(); ssh_init();
rsSshd = new RsSshd(portStr); rsSshd = new RsSshd(portStr);
@ -321,10 +323,19 @@ int RsSshd::doEcho()
char buf[2048]; char buf[2048];
do{ do{
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
i=ssh_channel_read(mChannel,buf, 2048, 0); i=ssh_channel_read(mChannel,buf, 2048, 0);
#else
i=channel_read(mChannel,buf, 2048, 0);
#endif
if(i>0) { 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);
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) { if (write(1,buf,i) < 0) {
printf("error writing to buffer\n"); printf("error writing to buffer\n");
return 0; return 0;
@ -365,7 +376,11 @@ int RsSshd::doTermServer()
while(okay) while(okay)
{ {
char buf; char buf;
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
int size = ssh_channel_read_nonblocking(mChannel, &buf, 1, 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); bool haveInput = (size > 0);
std::string output; std::string output;
@ -373,7 +388,11 @@ int RsSshd::doTermServer()
if (output.size() > 0) if (output.size() > 0)
{ {
#if LIBSSH_VERSION_INT >= SSH_VERSION_INT(0,5,0)
ssh_channel_write(mChannel, output.c_str(), output.size()); ssh_channel_write(mChannel, output.c_str(), output.size());
#else
channel_write(mChannel, output.c_str(), output.size());
#endif
} }
if (!haveInput) if (!haveInput)