aboutsummaryrefslogtreecommitdiff
path: root/src/channels.c
diff options
context:
space:
mode:
authormilo <milo@r0ot.me>2010-09-29 16:58:48 +0200
committerAris Adamantiadis <aris@0xbadc0de.be>2010-10-02 22:51:14 +0200
commitc4356531f78fdcf2f3b6a9861f6129eac81990f8 (patch)
treeb9250f0a5fff64564f1f859be7d6b8a30f2ca769 /src/channels.c
parent873e02fc6a0de3792a2a0a713ef21d4b67c308d2 (diff)
downloadlibssh-c4356531f78fdcf2f3b6a9861f6129eac81990f8.tar.gz
libssh-c4356531f78fdcf2f3b6a9861f6129eac81990f8.tar.xz
libssh-c4356531f78fdcf2f3b6a9861f6129eac81990f8.zip
Add new callbacks in session and channels
Diffstat (limited to 'src/channels.c')
-rw-r--r--src/channels.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/channels.c b/src/channels.c
index 6bf8543d..83d01023 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -430,8 +430,10 @@ SSH_PACKET_CALLBACK(channel_rcv_change_window) {
SSH_PACKET_CALLBACK(channel_rcv_data){
ssh_channel channel;
ssh_string str;
+ ssh_buffer buf;
size_t len;
int is_stderr;
+ int rest;
(void)user;
enter_function();
if(type==SSH2_MSG_CHANNEL_DATA)
@@ -495,6 +497,25 @@ SSH_PACKET_CALLBACK(channel_rcv_data){
channel->remote_window);
ssh_string_free(str);
+
+ if(ssh_callbacks_exists(channel->callbacks, channel_data_function)) {
+ if(is_stderr) {
+ buf = channel->stderr_buffer;
+ } else {
+ buf = channel->stdout_buffer;
+ }
+ rest = channel->callbacks->channel_data_function(channel->session,
+ channel,
+ buffer_get_rest(buf),
+ buffer_get_rest_len(buf),
+ is_stderr,
+ channel->callbacks->userdata);
+ if(rest > 0) {
+ buffer_pass_bytes(buf, rest);
+ channel->local_window += rest;
+ }
+ }
+
leave_function();
return SSH_PACKET_USED;
}
@@ -519,6 +540,12 @@ SSH_PACKET_CALLBACK(channel_rcv_eof) {
/* channel->remote_window = 0; */
channel->remote_eof = 1;
+ if(ssh_callbacks_exists(channel->callbacks, channel_eof_function)) {
+ channel->callbacks->channel_eof_function(channel->session,
+ channel,
+ channel->callbacks->userdata);
+ }
+
leave_function();
return SSH_PACKET_USED;
}
@@ -560,6 +587,12 @@ SSH_PACKET_CALLBACK(channel_rcv_close) {
* buffer because the eof is ignored until the buffer is empty.
*/
+ if(ssh_callbacks_exists(channel->callbacks, channel_close_function)) {
+ channel->callbacks->channel_close_function(channel->session,
+ channel,
+ channel->callbacks->userdata);
+ }
+
leave_function();
return SSH_PACKET_USED;
}