Finish making SFTP fully non-blocking capable.

Functions that return an "int", and friends, return LIBSSH2SFTP_EAGAIN.
Functions that return a structure return NULL and set the error to
LIBSSH2_ERROR_EAGAIN
This commit is contained in:
James Housley
2007-06-07 16:01:12 +00:00
parent d141ba49f3
commit 7d57222912
15 changed files with 665 additions and 721 deletions

View File

@@ -1,5 +1,5 @@
/*
* $Id: sftp_write_nonblock.c,v 1.5 2007/06/06 19:52:11 jehousley Exp $
* $Id: sftp_write_nonblock.c,v 1.6 2007/06/07 16:01:14 jehousley Exp $
*
* Sample showing how to do SFTP non-blocking write transfers.
*
@@ -175,16 +175,19 @@ int main(int argc, char *argv[])
fprintf(stderr, "libssh2_sftp_open()!\n");
/* Request a file via SFTP */
sftp_handle =
do {
sftp_handle =
libssh2_sftp_open(sftp_session, sftppath,
LIBSSH2_FXF_WRITE|LIBSSH2_FXF_CREAT|LIBSSH2_FXF_TRUNC,
LIBSSH2_SFTP_S_IRUSR|LIBSSH2_SFTP_S_IWUSR|
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IROTH);
if ((!sftp_handle) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
} while (!sftp_handle);
if (!sftp_handle) {
fprintf(stderr, "Unable to open file with SFTP\n");
goto shutdown;
}
fprintf(stderr, "libssh2_sftp_open() is done, now send data!\n");
do {
nread = fread(mem, 1, sizeof(mem), local);