diff options
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | doc/api-sessions.texi | 1 | ||||
| -rw-r--r-- | ssh/session-func.c | 19 | ||||
| -rw-r--r-- | tests/session.scm | 3 |
4 files changed, 24 insertions, 3 deletions
@@ -1,5 +1,9 @@ 2014-08-09 Artyom Poptsov <poptsov.artyom@gmail.com> + * ssh/session-func.c (guile_ssh_session_get): Handle `port' option. + * doc/api-sessions.texi (Sessions): Update. + * tests/session.scm ("session-get"): Update. + * ssh/channel-type.c (_ssh_channel_to_scm): Rename to `_scm_from_channel_data'. All callers updated. (guile_ssh_make_channel): Update. diff --git a/doc/api-sessions.texi b/doc/api-sessions.texi index 9160ee6..40745e6 100644 --- a/doc/api-sessions.texi +++ b/doc/api-sessions.texi @@ -223,6 +223,7 @@ with this procedure. Here is the list of allowed options: @table @samp @item host +@item port @item user @item identity @item proxycommand diff --git a/ssh/session-func.c b/ssh/session-func.c index 806d575..c7c7cd9 100644 --- a/ssh/session-func.c +++ b/ssh/session-func.c @@ -285,6 +285,7 @@ Return value is undefined.\ /* Options whose values can be requested through `session-get' */ static struct symbol_mapping session_options_getable[] = { { "host", SSH_OPTIONS_HOST }, + { "port", SSH_OPTIONS_PORT }, { "user", SSH_OPTIONS_USER }, { "identity", SSH_OPTIONS_IDENTITY }, { "proxycommand", SSH_OPTIONS_PROXYCOMMAND }, @@ -300,7 +301,7 @@ Get value of the OPTION. Throw `guile-ssh-error' on an error.\ { struct session_data*sd = _scm_to_session_data (session); struct symbol_mapping *opt = NULL; - char *value = NULL; /* Value of the option */ + SCM value; /*Value of the option */ int res; SCM_ASSERT (scm_is_symbol (option), option, SCM_ARG2, FUNC_NAME); @@ -309,11 +310,23 @@ Get value of the OPTION. Throw `guile-ssh-error' on an error.\ if (! opt) guile_ssh_error1 (FUNC_NAME, "Wrong option", option); - res = ssh_options_get (sd->ssh_session, opt->value, &value); + if (opt->value == SSH_OPTIONS_PORT) + { + unsigned int port; + res = ssh_options_get_port (sd->ssh_session, &port); + value = (res == SSH_OK) ? scm_from_int (port) : SCM_UNDEFINED; + } + else + { + char *c_value = NULL; + res = ssh_options_get (sd->ssh_session, opt->value, &c_value); + value = (res == SSH_OK) ? scm_from_locale_string (c_value) : SCM_UNDEFINED; + } + if (res == SSH_ERROR) guile_ssh_error1 (FUNC_NAME, "Unable to get value of the option", option); - return scm_from_locale_string (value); + return value; } #undef FUNC_NAME diff --git a/tests/session.scm b/tests/session.scm index 3be2c04..3b5ffa2 100644 --- a/tests/session.scm +++ b/tests/session.scm @@ -98,13 +98,16 @@ (test-assert "session-get" (let* ((host "example.com") + (port 12345) (user "alice") (proxycommand "test") (session (make-session #:host host + #:port port #:user user #:identity %rsakey #:proxycommand proxycommand))) (and (string=? (session-get session 'host) host) + (= (session-get session 'port) port) (string=? (session-get session 'user) user) (string=? (session-get session 'identity) %rsakey) (string=? (session-get session 'proxycommand) proxycommand)))) |
