summaryrefslogtreecommitdiff
path: root/modules/ssh
diff options
context:
space:
mode:
authorArtyom V. Poptsov <poptsov.artyom@gmail.com>2015-12-05 20:07:41 +0300
committerArtyom V. Poptsov <poptsov.artyom@gmail.com>2015-12-05 20:07:41 +0300
commite477fc5cd7b95cbde4e1ec25f58eb2754ce0f404 (patch)
tree55598f81372b1762acd0228db6e9f954e3e1b6dd /modules/ssh
parentchannel.scm (open-remote-pipe): Handle errors (diff)
downloadguile-ssh-e477fc5cd7b95cbde4e1ec25f58eb2754ce0f404.tar.gz
channel.scm (make-channel): Accept optional flags
* modules/ssh/channel.scm (make-channel): Accept optional flags that allow to create an input, output or input/output channel. The procedure creates a bidirectional tunnel by default. * libguile-ssh/channel-type.c (guile_ssh_make_channel): Likewise. Rename the Scheme procedure to '%make-channel'. All callers updated. (_scm_from_channel_data): Accept flags. Assert flags value. (print_channel): Print the direction of a channel. (init_channel_type): Define 'RDNG' and 'WRTNG' symbols. * libguile-ssh/channel-type.h: Update. * libguile-ssh/message-func.c (guile_ssh_message_channel_request_open_reply_accept): Update. * doc/api-channels.texi: Update description of 'make-channel'.
Diffstat (limited to 'modules/ssh')
-rw-r--r--modules/ssh/channel.scm11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/ssh/channel.scm b/modules/ssh/channel.scm
index eddb91b..7b3629e 100644
--- a/modules/ssh/channel.scm
+++ b/modules/ssh/channel.scm
@@ -72,6 +72,17 @@
open-remote-pipe
open-remote-pipe*))
+(define* (make-channel session #:optional (flags O_RDWR))
+ (cond
+ ((= flags O_RDWR)
+ (%make-channel session (logior RDNG WRTNG)))
+ ((= flags O_RDONLY)
+ (%make-channel session RDNG))
+ ((= flags O_WRONLY)
+ (%make-channel session WRTNG))
+ (else
+ (throw 'guile-ssh-error "Wrong flags" flags))))
+
(define* (channel-open-forward channel
#:key (source-host "localhost") local-port