mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-09 09:54:25 +09:00
Improve ssh_get_status().
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@475 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
@@ -261,21 +261,36 @@ int ssh_handle_packets(SSH_SESSION *session) {
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief get session status
|
/**
|
||||||
* \param session ssh session
|
* @brief Get session status
|
||||||
* \returns a bitmask including SSH_CLOSED, SSH_READ_PENDING or SSH_CLOSED_ERROR
|
*
|
||||||
* which respectively means the session is closed, has data to read on the connection socket and session was closed due to an error
|
* @param session The ssh session to use.
|
||||||
|
*
|
||||||
|
* @returns A bitmask including SSH_CLOSED, SSH_READ_PENDING or SSH_CLOSED_ERROR
|
||||||
|
* which respectively means the session is closed, has data to read on
|
||||||
|
* the connection socket and session was closed due to an error.
|
||||||
*/
|
*/
|
||||||
int ssh_get_status(SSH_SESSION *session){
|
int ssh_get_status(SSH_SESSION *session) {
|
||||||
int ret=0;
|
int socketstate;
|
||||||
int socketstate=ssh_socket_get_status(session->socket);
|
int r = 0;
|
||||||
if(session->closed)
|
|
||||||
ret |= SSH_CLOSED;
|
if (session == NULL) {
|
||||||
if(socketstate & SSH_READ_PENDING)
|
return 0;
|
||||||
ret |= SSH_READ_PENDING;
|
}
|
||||||
if(session->closed && socketstate & SSH_CLOSED_ERROR)
|
|
||||||
ret |= SSH_CLOSED_ERROR;
|
socketstate = ssh_socket_get_status(session->socket);
|
||||||
return ret;
|
|
||||||
|
if (session->closed) {
|
||||||
|
r |= SSH_CLOSED;
|
||||||
|
}
|
||||||
|
if (socketstate & SSH_READ_PENDING) {
|
||||||
|
r |= SSH_READ_PENDING;
|
||||||
|
}
|
||||||
|
if (session->closed && (socketstate & SSH_CLOSED_ERROR)) {
|
||||||
|
r |= SSH_CLOSED_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief get the disconnect message from the server
|
/** \brief get the disconnect message from the server
|
||||||
|
|||||||
Reference in New Issue
Block a user