1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-10 06:23:01 +03:00

Improve ssh_get_disconnect_message().

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@476 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-04-14 14:52:50 +00:00
parent 8e34f0cf0c
commit 317e90c1c1

View File

@@ -298,18 +298,24 @@ 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. * \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() * \see ssh_get_error()
*/ */
const char *ssh_get_disconnect_message(SSH_SESSION *session){ const char *ssh_get_disconnect_message(SSH_SESSION *session) {
if(!session->closed) if (session == NULL) {
ssh_set_error(session,SSH_REQUEST_DENIED,"Connection not closed" return NULL;
" yet"); }
else if(session->closed_by_except)
ssh_set_error(session,SSH_REQUEST_DENIED,"Connection closed by " if (!session->closed) {
"socket error"); ssh_set_error(session, SSH_REQUEST_DENIED,
else if(!session->discon_msg) "Connection not closed yet");
ssh_set_error(session,SSH_FATAL,"Connection correctly closed but " } else if(session->closed_by_except) {
"no disconnect message"); ssh_set_error(session, SSH_REQUEST_DENIED,
else "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 session->discon_msg;
}
return NULL; return NULL;
} }