From 7372cd837ac97a3be853843f0eb08da073e7310d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 6 Nov 2013 14:11:52 -0500 Subject: Add ssh_get_poll_flags() For integration with an external mainloop, we need to know how to replicate libssh's internal poll() calls. We originally through ssh_get_status() was that API, but it's not really - those flags only get updated from the *result* of a poll(), where what we really need is to know how libssh would *start* a poll(). Reviewed-by: Andreas Schneider --- src/session.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/session.c') diff --git a/src/session.c b/src/session.c index d4b3643f..06e7567f 100644 --- a/src/session.c +++ b/src/session.c @@ -607,6 +607,25 @@ int ssh_get_status(ssh_session session) { return r; } +/** + * @brief Get poll flags for an external mainloop + * + * @param session The ssh session to use. + * + * @returns A bitmask including SSH_READ_PENDING or SSH_WRITE_PENDING. + * For SSH_READ_PENDING, your invocation of poll() should include + * POLLIN. For SSH_WRITE_PENDING, your invocation of poll() should + * include POLLOUT. + */ +int ssh_get_poll_flags(ssh_session session) +{ + if (session == NULL) { + return 0; + } + + return ssh_socket_get_poll_flags (session->socket); +} + /** * @brief Get the disconnect message from the server. * -- cgit