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 11:15:39 +0100 |
| commit | 8aff91dfcb9c9b1eb612f33a6194df24e2f9eb80 (patch) | |
| tree | 6c651385838e21baa0a1a1890da7f0a5c4d13855 /include | |
| parent | c0cc12d58246e20e5af2cf561678164fbabfb910 (diff) | |
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>
(cherry picked from commit 8e2590b5353f800a2dd11045a1e7ff4848fc8c25)
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 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 */ |
