To simplify the user's error interface always use LIBSSH2_ERROR_EAGAIN.

LIBSSH2CHANNEL_EAGAIN and LIBSSH2SFTP_EAGAIN are still valid, but are
defined as LIBSSH2_ERROR_EAGAIN.
This commit is contained in:
James Housley 2007-06-08 13:33:08 +00:00
parent 281283d252
commit cf8f4d1818
17 changed files with 59 additions and 60 deletions

View File

@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_read_ex.3,v 1.6 2007/06/06 12:34:06 jehousley Exp $ .\" $Id: libssh2_channel_read_ex.3,v 1.7 2007/06/08 13:33:08 jehousley Exp $
.\" .\"
.TH libssh2_channel_read_ex 3 "1 June 2007" "libssh2 0.15" "libssh2 manual" .TH libssh2_channel_read_ex 3 "1 June 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME .SH NAME
@ -32,7 +32,7 @@ currently defines a stream ID of 1 to be the stderr substream.
macros. macros.
.SH RETURN VALUE .SH RETURN VALUE
Actual number of bytes read or negative on failure. It returns Actual number of bytes read or negative on failure. It returns
LIBSSH2CHANNEL_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2CHANNEL_EAGAIN is a negative number, it isn't really a failure per se. LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR libssh2_poll_channel_read(3) .BR libssh2_poll_channel_read(3)

View File

@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_readnb_ex.3,v 1.3 2007/06/06 12:34:06 jehousley Exp $ .\" $Id: libssh2_channel_readnb_ex.3,v 1.4 2007/06/08 13:33:08 jehousley Exp $
.\" .\"
.TH libssh2_channel_read_ex 3 "1 June 2007" "libssh2 0.15" "libssh2 manual" .TH libssh2_channel_read_ex 3 "1 June 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME .SH NAME
@ -32,8 +32,8 @@ currently defines a stream ID of 1 to be the stderr substream.
macros. macros.
.SH RETURN VALUE .SH RETURN VALUE
Actual number of bytes read or negative on failure. It returns Actual number of bytes read or negative on failure. It returns
LIBSSH2CHANNEL_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2CHANNEL_EAGAIN is a negative number, it isn't really a failure per se. LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR libssh2_poll_channel_read(3) .BR libssh2_poll_channel_read(3)

View File

@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_wait_eof.3,v 1.1 2007/06/06 12:34:06 jehousley Exp $ .\" $Id: libssh2_channel_wait_eof.3,v 1.2 2007/06/08 13:33:08 jehousley Exp $
.\" .\"
.TH libssh2_channel_wait_eof 3 "1 June 2007" "libssh2 0.15" "libssh2 manual" .TH libssh2_channel_wait_eof 3 "1 June 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME .SH NAME
@ -13,7 +13,7 @@ Wait for the remote end to acknowledge an EOF request.
.SH RETURN VALUE .SH RETURN VALUE
Return 0 on success or negative on failure. It returns Return 0 on success or negative on failure. It returns
LIBSSH2CHANNEL_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2CHANNEL_EAGAIN is a negative number, it isn't really a failure per se. LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH "SEE ALSO" .SH "SEE ALSO"
.BI libssh2_channel_send_eof(3), libssh2_channel_eof(3) .BI libssh2_channel_send_eof(3), libssh2_channel_eof(3)

View File

@ -1,4 +1,4 @@
.\" $Id: libssh2_channel_write_ex.3,v 1.2 2007/06/06 12:34:06 jehousley Exp $ .\" $Id: libssh2_channel_write_ex.3,v 1.3 2007/06/08 13:33:08 jehousley Exp $
.\" .\"
.TH libssh2_channel_write_ex 3 "1 June 2007" "libssh2 0.15" "libssh2 manual" .TH libssh2_channel_write_ex 3 "1 June 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME .SH NAME
@ -32,8 +32,8 @@ defines a stream ID of 1 to be the stderr substream.
macros. macros.
.SH RETURN VALUE .SH RETURN VALUE
Actual number of bytes written or negative on failure. Actual number of bytes written or negative on failure.
LIBSSH2CHANNEL_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2CHANNEL_EAGAIN is a negative number, it isn't really a failure per se. LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR libssh2_channel_open_session(3) .BR libssh2_channel_open_session(3)
.BR libssh2_channel_read(3) .BR libssh2_channel_read(3)

View File

@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_mkdir_ex.3,v 1.2 2007/06/07 16:01:12 jehousley Exp $ .\" $Id: libssh2_sftp_mkdir_ex.3,v 1.3 2007/06/08 13:33:08 jehousley Exp $
.\" .\"
.TH libssh2_sftp_mkdir_ex 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual" .TH libssh2_sftp_mkdir_ex 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME .SH NAME
@ -22,7 +22,7 @@ directory's parents must all exist priot to making this call.
.SH RETURN VALUE .SH RETURN VALUE
0 on success, or -1 on failure. It returns 0 on success, or -1 on failure. It returns
LIBSSH2SFTP_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2SFTP_EAGAIN is a negative number, it isn't really a failure per se. LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR libssh2_sftp_opendir(3) .BR libssh2_sftp_opendir(3)

View File

@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_read.3,v 1.4 2007/06/07 16:01:12 jehousley Exp $ .\" $Id: libssh2_sftp_read.3,v 1.5 2007/06/08 13:33:08 jehousley Exp $
.\" .\"
.TH libssh2_sftp_read 3 "6 Feb 2007" "libssh2 0.15" "libssh2 manual" .TH libssh2_sftp_read 3 "6 Feb 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME .SH NAME
@ -22,8 +22,8 @@ if further reads would cause the socket to block.
\fIbuffer_maxlen\fP bytes to read data into. \fIbuffer_maxlen\fP bytes to read data into.
.SH RETURN VALUE .SH RETURN VALUE
Number of bytes actually populated into buffer, or -1 on failure. It returns Number of bytes actually populated into buffer, or -1 on failure. It returns
LIBSSH2SFTP_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2SFTP_EAGAIN is a negative number, it isn't really a failure per se. LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR libssh2_sftp_open(3) .BR libssh2_sftp_open(3)
.BR libssh2_sftp_readnb(3) .BR libssh2_sftp_readnb(3)

View File

@ -1,4 +1,4 @@
.\" $Id: libssh2_sftp_readdir.3,v 1.4 2007/06/07 16:01:12 jehousley Exp $ .\" $Id: libssh2_sftp_readdir.3,v 1.5 2007/06/08 13:33:08 jehousley Exp $
.\" .\"
.TH libssh2_sftp_readdir 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual" .TH libssh2_sftp_readdir 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual"
.SH NAME .SH NAME
@ -30,8 +30,8 @@ statbuf style data into.
.SH RETURN VALUE .SH RETURN VALUE
Number of bytes actually populated into buffer, or -1 on failure. It returns Number of bytes actually populated into buffer, or -1 on failure. It returns
LIBSSH2SFTP_EAGAIN when it would otherwise block. While LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
LIBSSH2SFTP_EAGAIN is a negative number, it isn't really a failure per se. LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR libssh2_sftp_opendir(3) .BR libssh2_sftp_opendir(3)
.BR libssh2_sftp_readdirnb(3) .BR libssh2_sftp_readdirnb(3)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: scp_nonblock.c,v 1.4 2007/06/06 12:34:08 jehousley Exp $ * $Id: scp_nonblock.c,v 1.5 2007/06/08 13:33:08 jehousley Exp $
* *
* Sample showing how to do SCP transfers in a non-blocking manner. * Sample showing how to do SCP transfers in a non-blocking manner.
*/ */
@ -123,7 +123,7 @@ int main(int argc, char *argv[])
if (auth_pw) { if (auth_pw) {
/* We could authenticate via password */ /* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2CHANNEL_EAGAIN); while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "Authentication by password failed.\n"); fprintf(stderr, "Authentication by password failed.\n");
goto shutdown; goto shutdown;
@ -133,7 +133,7 @@ int main(int argc, char *argv[])
while ((rc = libssh2_userauth_publickey_fromfile(session, username, while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub", "/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa", "/home/username/.ssh/id_rsa",
password)) == LIBSSH2CHANNEL_EAGAIN); password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "\tAuthentication by public key failed\n"); fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown; goto shutdown;
@ -174,7 +174,7 @@ int main(int argc, char *argv[])
} }
} while (rc > 0); } while (rc > 0);
if (rc == LIBSSH2CHANNEL_EAGAIN) { if (rc == LIBSSH2_ERROR_EAGAIN) {
/* this is due to blocking that would occur otherwise /* this is due to blocking that would occur otherwise
so we loop on this condition */ so we loop on this condition */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: scp_write_nonblock.c,v 1.1 2007/06/06 12:34:08 jehousley Exp $ * $Id: scp_write_nonblock.c,v 1.2 2007/06/08 13:33:08 jehousley Exp $
* *
* Sample showing how to do a simple SCP transfer. * Sample showing how to do a simple SCP transfer.
*/ */
@ -141,7 +141,7 @@ int main(int argc, char *argv[])
if (auth_pw) { if (auth_pw) {
/* We could authenticate via password */ /* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2CHANNEL_EAGAIN); while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "Authentication by password failed.\n"); fprintf(stderr, "Authentication by password failed.\n");
goto shutdown; goto shutdown;
@ -151,7 +151,7 @@ int main(int argc, char *argv[])
while ((rc = libssh2_userauth_publickey_fromfile(session, username, while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub", "/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa", "/home/username/.ssh/id_rsa",
password)) == LIBSSH2CHANNEL_EAGAIN); password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "\tAuthentication by public key failed\n"); fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown; goto shutdown;
@ -181,7 +181,7 @@ int main(int argc, char *argv[])
do { do {
/* write data in a loop until we block */ /* write data in a loop until we block */
while ((rc = libssh2_channel_write(channel, ptr, nread)) == LIBSSH2CHANNEL_EAGAIN); while ((rc = libssh2_channel_write(channel, ptr, nread)) == LIBSSH2_ERROR_EAGAIN);
if (rc < 0) { if (rc < 0) {
fprintf(stderr, "ERROR %d\n", rc); fprintf(stderr, "ERROR %d\n", rc);
} }
@ -191,23 +191,23 @@ int main(int argc, char *argv[])
} while (1); } while (1);
fprintf(stderr, "Sending EOF\n"); fprintf(stderr, "Sending EOF\n");
while (libssh2_channel_send_eof(channel) == LIBSSH2CHANNEL_EAGAIN); while (libssh2_channel_send_eof(channel) == LIBSSH2_ERROR_EAGAIN);
fprintf(stderr, "Waiting for EOF\n"); fprintf(stderr, "Waiting for EOF\n");
while (libssh2_channel_wait_eof(channel) == LIBSSH2CHANNEL_EAGAIN); while (libssh2_channel_wait_eof(channel) == LIBSSH2_ERROR_EAGAIN);
fprintf(stderr, "Waiting for channel to close\n"); fprintf(stderr, "Waiting for channel to close\n");
while (libssh2_channel_wait_closed(channel) == LIBSSH2CHANNEL_EAGAIN); while (libssh2_channel_wait_closed(channel) == LIBSSH2_ERROR_EAGAIN);
// fprintf(stderr, "Closing channel\n"); // fprintf(stderr, "Closing channel\n");
// while (libssh2_channel_close(channel) == LIBSSH2CHANNEL_EAGAIN); // while (libssh2_channel_close(channel) == LIBSSH2_ERROR_EAGAIN);
libssh2_channel_free(channel); libssh2_channel_free(channel);
channel = NULL; channel = NULL;
shutdown: shutdown:
while ((rc = libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")) == LIBSSH2CHANNEL_EAGAIN); while ((rc = libssh2_session_disconnect(session, "Normal Shutdown, Thank you for playing")) == LIBSSH2_ERROR_EAGAIN);
libssh2_session_free(session); libssh2_session_free(session);
#ifdef WIN32 #ifdef WIN32

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_RW_nonblock.c,v 1.6 2007/06/07 16:01:13 jehousley Exp $ * $Id: sftp_RW_nonblock.c,v 1.7 2007/06/08 13:33:08 jehousley Exp $
* *
* Sample showing how to do SFTP transfers in a non-blocking manner. * Sample showing how to do SFTP transfers in a non-blocking manner.
* *
@ -187,7 +187,7 @@ int main(int argc, char *argv[])
} }
} while (rc > 0); } while (rc > 0);
if(rc != LIBSSH2SFTP_EAGAIN) { if(rc != LIBSSH2_ERROR_EAGAIN) {
/* error or end of file */ /* error or end of file */
break; break;
} }
@ -246,7 +246,7 @@ int main(int argc, char *argv[])
nread -= nread; nread -= nread;
} while (rc > 0); } while (rc > 0);
if(rc != LIBSSH2SFTP_EAGAIN) { if(rc != LIBSSH2_ERROR_EAGAIN) {
/* error or end of file */ /* error or end of file */
break; break;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_mkdir_nonblock.c,v 1.5 2007/06/07 16:01:13 jehousley Exp $ * $Id: sftp_mkdir_nonblock.c,v 1.6 2007/06/08 13:33:08 jehousley Exp $
* *
* Sample showing how to do SFTP non-blocking mkdir. * Sample showing how to do SFTP non-blocking mkdir.
* *
@ -156,7 +156,7 @@ int main(int argc, char *argv[])
LIBSSH2_SFTP_S_IRWXU| LIBSSH2_SFTP_S_IRWXU|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IXGRP| LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IXGRP|
LIBSSH2_SFTP_S_IROTH|LIBSSH2_SFTP_S_IXOTH)) LIBSSH2_SFTP_S_IROTH|LIBSSH2_SFTP_S_IXOTH))
== LIBSSH2SFTP_EAGAIN) { == LIBSSH2_ERROR_EAGAIN) {
; ;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_nonblock.c,v 1.9 2007/06/07 16:01:13 jehousley Exp $ * $Id: sftp_nonblock.c,v 1.10 2007/06/08 13:33:08 jehousley Exp $
* *
* Sample showing how to do SFTP non-blocking transfers. * Sample showing how to do SFTP non-blocking transfers.
* *
@ -129,7 +129,7 @@ int main(int argc, char *argv[])
if (auth_pw) { if (auth_pw) {
/* We could authenticate via password */ /* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2CHANNEL_EAGAIN); while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "Authentication by password failed.\n"); fprintf(stderr, "Authentication by password failed.\n");
goto shutdown; goto shutdown;
@ -139,7 +139,7 @@ int main(int argc, char *argv[])
while ((rc = libssh2_userauth_publickey_fromfile(session, username, while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub", "/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa", "/home/username/.ssh/id_rsa",
password)) == LIBSSH2CHANNEL_EAGAIN); password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "\tAuthentication by public key failed\n"); fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown; goto shutdown;
@ -173,7 +173,7 @@ int main(int argc, char *argv[])
/* loop until we fail */ /* loop until we fail */
fprintf(stderr, "libssh2_sftp_readnb()!\n"); fprintf(stderr, "libssh2_sftp_readnb()!\n");
while ((rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem))) == LIBSSH2SFTP_EAGAIN) { while ((rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem))) == LIBSSH2_ERROR_EAGAIN) {
; ;
} }
if (rc > 0) { if (rc > 0) {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftp_write_nonblock.c,v 1.6 2007/06/07 16:01:14 jehousley Exp $ * $Id: sftp_write_nonblock.c,v 1.7 2007/06/08 13:33:08 jehousley Exp $
* *
* Sample showing how to do SFTP non-blocking write transfers. * Sample showing how to do SFTP non-blocking write transfers.
* *
@ -143,7 +143,7 @@ int main(int argc, char *argv[])
if (auth_pw) { if (auth_pw) {
/* We could authenticate via password */ /* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2CHANNEL_EAGAIN); while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
printf("Authentication by password failed.\n"); printf("Authentication by password failed.\n");
goto shutdown; goto shutdown;
@ -153,7 +153,7 @@ int main(int argc, char *argv[])
while ((rc = libssh2_userauth_publickey_fromfile(session, username, while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub", "/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa", "/home/username/.ssh/id_rsa",
password)) == LIBSSH2CHANNEL_EAGAIN); password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
printf("\tAuthentication by public key failed\n"); printf("\tAuthentication by public key failed\n");
goto shutdown; goto shutdown;
@ -199,7 +199,7 @@ int main(int argc, char *argv[])
do { do {
/* write data in a loop until we block */ /* write data in a loop until we block */
while ((rc = libssh2_sftp_write(sftp_handle, ptr, nread)) == LIBSSH2SFTP_EAGAIN) { while ((rc = libssh2_sftp_write(sftp_handle, ptr, nread)) == LIBSSH2_ERROR_EAGAIN) {
; ;
} }
ptr += rc; ptr += rc;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: sftpdir_nonblock.c,v 1.6 2007/06/07 16:01:14 jehousley Exp $ * $Id: sftpdir_nonblock.c,v 1.7 2007/06/08 13:33:08 jehousley Exp $
* *
* Sample doing an SFTP directory listing. * Sample doing an SFTP directory listing.
* *
@ -127,7 +127,7 @@ int main(int argc, char *argv[])
if (auth_pw) { if (auth_pw) {
/* We could authenticate via password */ /* We could authenticate via password */
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2CHANNEL_EAGAIN); while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "Authentication by password failed.\n"); fprintf(stderr, "Authentication by password failed.\n");
goto shutdown; goto shutdown;
@ -137,7 +137,7 @@ int main(int argc, char *argv[])
while ((rc = libssh2_userauth_publickey_fromfile(session, username, while ((rc = libssh2_userauth_publickey_fromfile(session, username,
"/home/username/.ssh/id_rsa.pub", "/home/username/.ssh/id_rsa.pub",
"/home/username/.ssh/id_rsa", "/home/username/.ssh/id_rsa",
password)) == LIBSSH2CHANNEL_EAGAIN); password)) == LIBSSH2_ERROR_EAGAIN);
if (rc) { if (rc) {
fprintf(stderr, "\tAuthentication by public key failed\n"); fprintf(stderr, "\tAuthentication by public key failed\n");
goto shutdown; goto shutdown;
@ -171,7 +171,7 @@ int main(int argc, char *argv[])
LIBSSH2_SFTP_ATTRIBUTES attrs; LIBSSH2_SFTP_ATTRIBUTES attrs;
/* loop until we fail */ /* loop until we fail */
while ((rc = libssh2_sftp_readdir(sftp_handle, mem, sizeof(mem), &attrs)) == LIBSSH2SFTP_EAGAIN) { while ((rc = libssh2_sftp_readdir(sftp_handle, mem, sizeof(mem), &attrs)) == LIBSSH2_ERROR_EAGAIN) {
; ;
} }
if(rc > 0) { if(rc > 0) {
@ -204,7 +204,7 @@ int main(int argc, char *argv[])
printf("%s\n", mem); printf("%s\n", mem);
} }
else if (rc == LIBSSH2SFTP_EAGAIN) { else if (rc == LIBSSH2_ERROR_EAGAIN) {
/* blocking */ /* blocking */
fprintf(stderr, "Blocking\n"); fprintf(stderr, "Blocking\n");
} else { } else {

View File

@ -327,6 +327,9 @@ LIBSSH2_API int libssh2_poll(LIBSSH2_POLLFD *fds, unsigned int nfds, long timeou
#define SSH_EXTENDED_DATA_STDERR 1 #define SSH_EXTENDED_DATA_STDERR 1
/* Returned by any function that would block during a read/write opperation */
#define LIBSSH2CHANNEL_EAGAIN LIBSSH2_ERROR_EAGAIN
LIBSSH2_API LIBSSH2_CHANNEL *libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *channel_type, unsigned int channel_type_len, unsigned int window_size, unsigned int packet_size, const char *message, unsigned int message_len); LIBSSH2_API LIBSSH2_CHANNEL *libssh2_channel_open_ex(LIBSSH2_SESSION *session, const char *channel_type, unsigned int channel_type_len, unsigned int window_size, unsigned int packet_size, const char *message, unsigned int message_len);
#define libssh2_channel_open_session(session) libssh2_channel_open_ex((session), "session", sizeof("session") - 1, LIBSSH2_CHANNEL_WINDOW_DEFAULT, LIBSSH2_CHANNEL_PACKET_DEFAULT, NULL, 0) #define libssh2_channel_open_session(session) libssh2_channel_open_ex((session), "session", sizeof("session") - 1, LIBSSH2_CHANNEL_WINDOW_DEFAULT, LIBSSH2_CHANNEL_PACKET_DEFAULT, NULL, 0)
@ -362,10 +365,6 @@ LIBSSH2_API ssize_t libssh2_channel_read_ex(LIBSSH2_CHANNEL *channel,
#define libssh2_channel_read_stderr(channel, buf, buflen) \ #define libssh2_channel_read_stderr(channel, buf, buflen) \
libssh2_channel_read_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen)) libssh2_channel_read_ex((channel), SSH_EXTENDED_DATA_STDERR, (buf), (buflen))
/* This is a public error code from libssh2_channel_read() that is returned
when it would otherwise block. */
#define LIBSSH2CHANNEL_EAGAIN -2
LIBSSH2_API int libssh2_poll_channel_read(LIBSSH2_CHANNEL *channel, int extended); LIBSSH2_API int libssh2_poll_channel_read(LIBSSH2_CHANNEL *channel, int extended);
LIBSSH2_API unsigned long libssh2_channel_window_read_ex(LIBSSH2_CHANNEL *channel, unsigned long *read_avail, unsigned long *window_size_initial); LIBSSH2_API unsigned long libssh2_channel_window_read_ex(LIBSSH2_CHANNEL *channel, unsigned long *read_avail, unsigned long *window_size_initial);

View File

@ -175,6 +175,9 @@ struct _LIBSSH2_SFTP_ATTRIBUTES {
#define LIBSSH2_FX_INVALID_FILENAME 20 #define LIBSSH2_FX_INVALID_FILENAME 20
#define LIBSSH2_FX_LINK_LOOP 21 #define LIBSSH2_FX_LINK_LOOP 21
/* Returned by any function that would block during a read/write opperation */
#define LIBSSH2SFTP_EAGAIN LIBSSH2_ERROR_EAGAIN
/* SFTP API */ /* SFTP API */
LIBSSH2_API LIBSSH2_SFTP *libssh2_sftp_init(LIBSSH2_SESSION *session); LIBSSH2_API LIBSSH2_SFTP *libssh2_sftp_init(LIBSSH2_SESSION *session);
LIBSSH2_API int libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp); LIBSSH2_API int libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp);
@ -188,9 +191,6 @@ LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp, const
#define libssh2_sftp_opendir(sftp, path) \ #define libssh2_sftp_opendir(sftp, path) \
libssh2_sftp_open_ex((sftp), (path), strlen(path), 0, 0, LIBSSH2_SFTP_OPENDIR) libssh2_sftp_open_ex((sftp), (path), strlen(path), 0, 0, LIBSSH2_SFTP_OPENDIR)
/* This is a public error code from libssh2_sftp_read() that is returned
when it would otherwise block. */
#define LIBSSH2SFTP_EAGAIN -2
LIBSSH2_API ssize_t libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle, char *buffer, size_t buffer_maxlen); LIBSSH2_API ssize_t libssh2_sftp_read(LIBSSH2_SFTP_HANDLE *handle, char *buffer, size_t buffer_maxlen);
LIBSSH2_API int libssh2_sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer, LIBSSH2_API int libssh2_sftp_readdir(LIBSSH2_SFTP_HANDLE *handle, char *buffer,

View File

@ -974,7 +974,7 @@ int libssh2_waitsocket(LIBSSH2_SESSION *session, long seconds);
#define PACKET_COMPRESS -5 #define PACKET_COMPRESS -5
#define PACKET_TOOBIG -4 #define PACKET_TOOBIG -4
#define PACKET_ENOMEM -3 #define PACKET_ENOMEM -3
#define PACKET_EAGAIN -2 #define PACKET_EAGAIN LIBSSH2_ERROR_EAGAIN
#define PACKET_FAIL -1 #define PACKET_FAIL -1
#define PACKET_NONE 0 #define PACKET_NONE 0