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