diff options
author | Petar Koretic <petar.koretic@sartura.hr> | 2014-03-20 09:59:43 +0000 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2014-03-27 10:48:13 +0100 |
commit | 8e2590b5353f800a2dd11045a1e7ff4848fc8c25 (patch) | |
tree | 274eff0e0fc987a9e23885a3a67ead3078e3c5e6 /include | |
parent | c51f42a566879f61c2349066bc4e8dd35bc5c311 (diff) | |
download | libssh-8e2590b5353f800a2dd11045a1e7ff4848fc8c25.tar.gz libssh-8e2590b5353f800a2dd11045a1e7ff4848fc8c25.tar.xz libssh-8e2590b5353f800a2dd11045a1e7ff4848fc8c25.zip |
libssh: libhpp: overload read function to support timeout parameter
Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/libssh/libsshpp.hpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/libssh/libsshpp.hpp b/include/libssh/libsshpp.hpp index 0cf945be..48c51567 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 */ |