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

socket: Reformat ssh_socket_unbuffered_read()

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Andreas Schneider
2018-09-24 18:27:33 +02:00
parent 642a1b1aa4
commit 491a42d046

View File

@@ -524,28 +524,30 @@ int ssh_socket_is_open(ssh_socket s) {
/** \internal /** \internal
* \brief read len bytes from socket into buffer * \brief read len bytes from socket into buffer
*/ */
static int ssh_socket_unbuffered_read(ssh_socket s, void *buffer, uint32_t len) { static int ssh_socket_unbuffered_read(ssh_socket s, void *buffer, uint32_t len)
int rc = -1; {
int rc = -1;
if (s->data_except) { if (s->data_except) {
return -1; return -1;
} }
if(s->fd_is_socket) if (s->fd_is_socket) {
rc = recv(s->fd_in,buffer, len, 0); rc = recv(s->fd_in,buffer, len, 0);
else } else {
rc = read(s->fd_in,buffer, len); rc = read(s->fd_in,buffer, len);
}
#ifdef _WIN32 #ifdef _WIN32
s->last_errno = WSAGetLastError(); s->last_errno = WSAGetLastError();
#else #else
s->last_errno = errno; s->last_errno = errno;
#endif #endif
s->read_wontblock = 0; s->read_wontblock = 0;
if (rc < 0) { if (rc < 0) {
s->data_except = 1; s->data_except = 1;
} }
return rc; return rc;
} }
/** \internal /** \internal