diff options
| author | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2015-12-05 21:52:13 +0300 |
|---|---|---|
| committer | Artyom V. Poptsov <poptsov.artyom@gmail.com> | 2015-12-05 21:52:13 +0300 |
| commit | 1aa5b0ed2c537dcf8fc40a70ce1d80fe9ce2734e (patch) | |
| tree | e5ecd0fbf510fda93a7453460f87d157f9645f04 | |
| parent | NEWS: Update (diff) | |
| download | guile-ssh-1aa5b0ed2c537dcf8fc40a70ce1d80fe9ce2734e.tar.gz | |
channel.scm (make-channel): Use mode symbols from (ice-9 popen)
* modules/ssh/channel.scm (make-channel): Use mode symbols 'OPEN_READ',
'OPEN_WRITE' and 'OPEN_BOTH' from (ice-9 popen).
* doc/api-channels.texi, NEWS: Update.
| -rw-r--r-- | NEWS | 2 | ||||
| -rw-r--r-- | doc/api-channels.texi | 8 | ||||
| -rw-r--r-- | modules/ssh/channel.scm | 14 |
3 files changed, 13 insertions, 11 deletions
@@ -42,7 +42,7 @@ Copyright (C) Artyom V. Poptsov <poptsov.artyom@gmail.com> ** 'make-session' now takes 'config' option that allows to specify whether the SSH config should be parsed or not, and optionally the path to the config. -** 'make-channel' now takes optional 'flags' option +** 'make-channel' now takes optional 'mode' option that allow to specify the direction of a channel. ** Unit tests *** Expand the test suite for distributed forms diff --git a/doc/api-channels.texi b/doc/api-channels.texi index 03c5b7b..43725e9 100644 --- a/doc/api-channels.texi +++ b/doc/api-channels.texi @@ -33,13 +33,13 @@ Return @code{#t} if @var{x} is a Guile-SSH channel, @code{#f} otherwise. @end deffn -@deffn {Scheme Procedure} make-channel session [flags] +@deffn {Scheme Procedure} make-channel session [mode] Allocate a new Guile-SSH channel for the @var{session} (@pxref{Sessions}). @var{flags} are determine what kind of a channel should be created. Possible -flags are: @code{O_RDONLY}, @code{O_WRONLY}, @code{O_RDWR}. They play similar -role to @code{open} procedure flags, and allow to create an ihput channel, -output channel or input/output channel respectively. +modes are: @code{OPEN_READ}, @code{OPEN_WRITE}, @code{OPEN_BOTH}. They allow +to create either an input channel, output channel or input/output channel +respectively. @end deffn @deffn {Scheme Procedure} channel-open-session channel diff --git a/modules/ssh/channel.scm b/modules/ssh/channel.scm index 7b3629e..444d503 100644 --- a/modules/ssh/channel.scm +++ b/modules/ssh/channel.scm @@ -47,6 +47,7 @@ (define-module (ssh channel) #:use-module (ssh log) #:use-module (ssh session) + #:use-module (ice-9 popen) #:export (channel channel? make-channel @@ -70,18 +71,19 @@ ;; High-level procedures. open-remote-pipe - open-remote-pipe*)) + open-remote-pipe*) + #:re-export (OPEN_READ OPEN_WRITE OPEN_BOTH)) -(define* (make-channel session #:optional (flags O_RDWR)) +(define* (make-channel session #:optional (mode OPEN_BOTH)) (cond - ((= flags O_RDWR) + ((string=? mode OPEN_BOTH) (%make-channel session (logior RDNG WRTNG))) - ((= flags O_RDONLY) + ((string=? mode OPEN_READ) (%make-channel session RDNG)) - ((= flags O_WRONLY) + ((string=? mode OPEN_WRITE) (%make-channel session WRTNG)) (else - (throw 'guile-ssh-error "Wrong flags" flags)))) + (throw 'guile-ssh-error "Wrong mode" mode)))) (define* (channel-open-forward channel |
