From 8aff91dfcb9c9b1eb612f33a6194df24e2f9eb80 Mon Sep 17 00:00:00 2001 From: Petar Koretic Date: Thu, 20 Mar 2014 09:59:43 +0000 Subject: [PATCH] libssh: libhpp: overload read function to support timeout parameter Signed-off-by: Petar Koretic Reviewed-by: Andreas Schneider (cherry picked from commit 8e2590b5353f800a2dd11045a1e7ff4848fc8c25) --- include/libssh/libsshpp.hpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/libssh/libsshpp.hpp b/include/libssh/libsshpp.hpp index f6cea649..2ac4d001 100644 --- a/include/libssh/libsshpp.hpp +++ b/include/libssh/libsshpp.hpp @@ -480,7 +480,7 @@ 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) @@ -489,6 +489,24 @@ public: 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; + } int readNonblocking(void *dest, size_t count, bool is_stderr=false){ int err; /* handle int overflow */