From af454c0f3473dcd3afb3e08958eb3d4a26732729 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 14 Apr 2009 14:54:20 +0000 Subject: Improve ssh_get_version(). git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@477 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/session.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'libssh') diff --git a/libssh/session.c b/libssh/session.c index d70a112b..894506f2 100644 --- a/libssh/session.c +++ b/libssh/session.c @@ -319,12 +319,19 @@ const char *ssh_get_disconnect_message(SSH_SESSION *session) { return NULL; } -/** \brief get the protocol version of the session - * \param session ssh session - * \return 1 or 2, for ssh1 or ssh2 +/** + * @brief Get the protocol version of the session. + * + * @param session The ssh session to use. + * + * @return 1 or 2, for ssh1 or ssh2, < 0 on error. */ -int ssh_get_version(SSH_SESSION *session){ - return session->version; +int ssh_get_version(SSH_SESSION *session) { + if (session == NULL) { + return -1; + } + + return session->version; } /** @} */ -- cgit