summaryrefslogtreecommitdiffstats
path: root/libssh/include/libssh/libsshpp.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'libssh/include/libssh/libsshpp.hpp')
-rw-r--r--libssh/include/libssh/libsshpp.hpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/libssh/include/libssh/libsshpp.hpp b/libssh/include/libssh/libsshpp.hpp
index 1a5d80a9..af08a914 100644
--- a/libssh/include/libssh/libsshpp.hpp
+++ b/libssh/include/libssh/libsshpp.hpp
@@ -56,6 +56,7 @@
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
+#include <string>
namespace ssh {
@@ -361,18 +362,18 @@ public:
* @see ssh_channel_forward_accept
* @see Session::listenForward
*/
- Channel *acceptForward(int timeout_ms);
- /* acceptForward is implemented later in this file */
+ inline Channel *acceptForward(int timeout_ms);
+ /* implemented outside the class due Channel references */
void_throwable cancelForward(const char *address, int port){
- int err=ssh_forward_cancel(c_session, address, port);
+ int err=ssh_channel_cancel_forward(c_session, address, port);
ssh_throw(err);
return_throwable;
}
void_throwable listenForward(const char *address, int port,
int &boundport){
- int err=ssh_forward_listen(c_session, address, port, &boundport);
+ int err=ssh_channel_listen_forward(c_session, address, port, &boundport);
ssh_throw(err);
return_throwable;
}
@@ -480,12 +481,30 @@ public:
ssh_throw(err);
return err;
}
- int read(void *dest, size_t count, bool is_stderr=false){
+ int read(void *dest, size_t count, bool is_stderr){
int err;
/* handle int overflow */
if(count > 0x7fffffff)
count = 0x7fffffff;
- err=ssh_channel_read(channel,dest,count,is_stderr);
+ err=ssh_channel_read_timeout(channel,dest,count,is_stderr,-1);
+ ssh_throw(err);
+ return err;
+ }
+ int read(void *dest, size_t count, int timeout){
+ int err;
+ /* handle int overflow */
+ if(count > 0x7fffffff)
+ count = 0x7fffffff;
+ err=ssh_channel_read_timeout(channel,dest,count,false,timeout);
+ ssh_throw(err);
+ return err;
+ }
+ int read(void *dest, size_t count, bool is_stderr=false, int timeout=-1){
+ int err;
+ /* handle int overflow */
+ if(count > 0x7fffffff)
+ count = 0x7fffffff;
+ err=ssh_channel_read_timeout(channel,dest,count,is_stderr,timeout);
ssh_throw(err);
return err;
}
@@ -581,10 +600,9 @@ private:
};
-/* This code cannot be put inline due to references to Channel */
-Channel *Session::acceptForward(int timeout_ms){
- ssh_channel forward = ssh_forward_accept(c_session,
- timeout_ms);
+inline Channel *Session::acceptForward(int timeout_ms){
+ ssh_channel forward =
+ ssh_channel_accept_forward(c_session, timeout_ms, NULL);
ssh_throw_null(c_session,forward);
Channel *newchan = new Channel(*this,forward);
return newchan;