Joedb 9.1.4
The Journal-Only Embedded Database
Loading...
Searching...
No Matches
Forward_Channel.cpp
Go to the documentation of this file.
2
3namespace joedb::ssh
4{
5 ///////////////////////////////////////////////////////////////////////////
7 ///////////////////////////////////////////////////////////////////////////
8 channel(ssh_channel_new(session.get()))
9 {
11 }
12
13 ///////////////////////////////////////////////////////////////////////////
15 ///////////////////////////////////////////////////////////////////////////
16 {
17 ssh_channel_free(channel);
18 }
19
20 ///////////////////////////////////////////////////////////////////////////
21 size_t Forward_Channel::write_some(const char *data, size_t size)
22 ///////////////////////////////////////////////////////////////////////////
23 {
24 const int result = ssh_channel_write(channel, data, uint32_t(size));
25
26 if (result == SSH_ERROR)
27 throw Exception("Error writing to channel");
28
29 return size_t(result);
30 }
31
32 ///////////////////////////////////////////////////////////////////////////
33 size_t Forward_Channel::read_some(char *data, size_t size)
34 ///////////////////////////////////////////////////////////////////////////
35 {
36 const int result = ssh_channel_read(channel, data, uint32_t(size), 0);
37
38 if (result == SSH_ERROR)
39 throw Exception("Error reading from channel");
40
41 if (result == 0)
42 throw Exception("End of file when reading from channel");
43
44 return size_t(result);
45 }
46
47 ///////////////////////////////////////////////////////////////////////////
49 ///////////////////////////////////////////////////////////////////////////
50 (
51 Session &session,
52 const char *remote_host,
53 uint16_t remote_port
54 ):
56 {
57 session.check_result
58 (
60 (
61 channel,
64 "", // unused parameter
65 0 // unused parameter
66 )
67 );
68 }
69}
70
void read(char *data, size_t size)
Definition Channel.cpp:12
Forward_Channel(Session &session, const char *remote_host, uint16_t remote_port)
C++ wrappers for libssh.
void check_not_null(void *p)
Definition ssh.h:13