1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-03 13:31:11 +03:00

Improve channel_is_* functions.

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@690 7dcaeef0-15fb-0310-b436-a5af3365683c
This commit is contained in:
Andreas Schneider
2009-05-04 06:36:17 +00:00
parent 9345ba7030
commit 98fbe3020d

View File

@@ -938,34 +938,47 @@ error:
return SSH_ERROR; return SSH_ERROR;
} }
/** \brief returns if the channel is open or not /**
* \param channel channel * @brief Check if the channel is open or not.
* \return 0 if channel is closed, nonzero otherwise *
* \see channel_is_closed() * @param channel The channel to check.
*
* @return 0 if channel is closed, nonzero otherwise.
*
* @see channel_is_closed()
*/ */
int channel_is_open(CHANNEL *channel) { int channel_is_open(CHANNEL *channel) {
return (channel->open!=0 && channel->session->alive); return (channel->open != 0 && channel->session->alive != 0);
} }
/** \brief returns if the channel is closed or not /**
* \param channel channel * @brief Check if the channel is closed or not.
* \return 0 if channel is opened, nonzero otherwise *
* \see channel_is_open() * @param channel The channel to check.
*
* @return 0 if channel is opened, nonzero otherwise.
*
* @see channel_is_open()
*/ */
int channel_is_closed(CHANNEL *channel) { int channel_is_closed(CHANNEL *channel) {
return (channel->open==0 || !channel->session->alive); return (channel->open == 0 || channel->session->alive == 0);
} }
/** \brief returns if the remote has sent an EOF /**
* \param channel channel * @brief Check if remote has sent an EOF.
* \return 0 if there is no EOF, nonzero otherwise *
* @param channel The channel to check.
*
* @return 0 if there is no EOF, nonzero otherwise.
*/ */
int channel_is_eof(CHANNEL *channel) { int channel_is_eof(CHANNEL *channel) {
if((channel->stdout_buffer && buffer_get_rest_len(channel->stdout_buffer) if ((channel->stdout_buffer &&
>0) || (channel->stderr_buffer && buffer_get_rest_len( buffer_get_rest_len(channel->stdout_buffer) > 0) ||
channel->stderr_buffer)>0)) (channel->stderr_buffer &&
buffer_get_rest_len(channel->stderr_buffer) > 0)) {
return 0; return 0;
}
return (channel->remote_eof != 0); return (channel->remote_eof != 0);
} }