diff options
author | Andreas Schneider <mail@cynapses.org> | 2009-04-14 14:52:50 +0000 |
---|---|---|
committer | Andreas Schneider <mail@cynapses.org> | 2009-04-14 14:52:50 +0000 |
commit | 317e90c1c1639b29bb7ec74e74ac98321b242aff (patch) | |
tree | 427c81f310da35a784fc7eaf1904c503ef9a433c /libssh/session.c | |
parent | 8e34f0cf0cd5dba21fc19125dced3fd541f835b3 (diff) | |
download | libssh-317e90c1c1639b29bb7ec74e74ac98321b242aff.tar.gz libssh-317e90c1c1639b29bb7ec74e74ac98321b242aff.tar.xz libssh-317e90c1c1639b29bb7ec74e74ac98321b242aff.zip |
Improve ssh_get_disconnect_message().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@476 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/session.c')
-rw-r--r-- | libssh/session.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/libssh/session.c b/libssh/session.c index 05a08eee..d70a112b 100644 --- a/libssh/session.c +++ b/libssh/session.c @@ -298,19 +298,25 @@ int ssh_get_status(SSH_SESSION *session) { * \return message sent by the server along with the disconnect, or NULL in which case the reason of the disconnect may be found with ssh_get_error. * \see ssh_get_error() */ -const char *ssh_get_disconnect_message(SSH_SESSION *session){ - if(!session->closed) - ssh_set_error(session,SSH_REQUEST_DENIED,"Connection not closed" - " yet"); - else if(session->closed_by_except) - ssh_set_error(session,SSH_REQUEST_DENIED,"Connection closed by " - "socket error"); - else if(!session->discon_msg) - ssh_set_error(session,SSH_FATAL,"Connection correctly closed but " - "no disconnect message"); - else - return session->discon_msg; +const char *ssh_get_disconnect_message(SSH_SESSION *session) { + if (session == NULL) { return NULL; + } + + if (!session->closed) { + ssh_set_error(session, SSH_REQUEST_DENIED, + "Connection not closed yet"); + } else if(session->closed_by_except) { + ssh_set_error(session, SSH_REQUEST_DENIED, + "Connection closed by socket error"); + } else if(!session->discon_msg) { + ssh_set_error(session, SSH_FATAL, + "Connection correctly closed but no disconnect message"); + } else { + return session->discon_msg; + } + + return NULL; } /** \brief get the protocol version of the session |