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:
parent
d141ba49f3
commit
7d57222912
@ -1,4 +1,4 @@
|
||||
.\" $Id: libssh2_sftp_mkdir_ex.3,v 1.1 2007/04/22 19:51:53 jehousley Exp $
|
||||
.\" $Id: libssh2_sftp_mkdir_ex.3,v 1.2 2007/06/07 16:01:12 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_sftp_mkdir_ex 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
@ -21,6 +21,8 @@ directory's parents must all exist priot to making this call.
|
||||
\fImode\fP directory creation mode (e.g. 0755).
|
||||
|
||||
.SH RETURN VALUE
|
||||
0 on success, or -1 on failure.
|
||||
0 on success, or -1 on failure. It returns
|
||||
LIBSSH2SFTP_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2SFTP_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
.SH "SEE ALSO"
|
||||
.BR libssh2_sftp_opendir(3)
|
||||
|
@ -1,29 +0,0 @@
|
||||
.\" $Id: libssh2_sftp_mkdirnb_ex.3,v 1.1 2007/04/22 19:51:54 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_sftp_mkdir_ex 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_sftp_mkdir_ex - create a directory on the remote file system in
|
||||
non-blocking mode
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
int libssh2_sftp_mkdir_ex(LIBSSH2_SFTP *sftp, const char *path,
|
||||
unsigned int path_len, long mode);
|
||||
|
||||
.SH DESCRIPTION
|
||||
\fIsftp\fP SFTP instance as returned by \fIlibssh2_sftp_init(3)\fP.
|
||||
|
||||
\fIpath\fP full path of the new directory to create. Note that the new
|
||||
directory's parents must all exist priot to making this call.
|
||||
|
||||
\fIpath_len\fP length of the full path of the new directory to create.
|
||||
|
||||
\fImode\fP directory creation mode (e.g. 0755).
|
||||
|
||||
.SH RETURN VALUE
|
||||
0 on success, or -1 on failure. It returns LIBSSH2CHANNEL_EAGAIN when
|
||||
it would otherwise block. While LIBSSH2CHANNEL_EAGAIN is a negative
|
||||
number, it isn't really a failure per se.
|
||||
.SH "SEE ALSO"
|
||||
.BR libssh2_sftp_opendir(3)
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: libssh2_sftp_open_ex.3,v 1.3 2007/04/22 17:18:03 jehousley Exp $
|
||||
.\" $Id: libssh2_sftp_open_ex.3,v 1.4 2007/06/07 16:01:12 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_sftp_open_ex 3 "23 Jan 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
@ -34,6 +34,9 @@ LIBSSH2_SFTP_OPENDIR (to open a directory).
|
||||
.SH RETURN VALUE
|
||||
A pointer to the newly created LIBSSH2_SFTP_HANDLE instance or NULL on
|
||||
failure.
|
||||
.SH ERRORS
|
||||
LIBSSH2_ERROR_EAGAIN
|
||||
Marked for non-blocking I/O but the call would block.
|
||||
.SH "SEE ALSO"
|
||||
.BI libssh_sftp_close(3)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: libssh2_sftp_read.3,v 1.3 2007/04/22 17:18:03 jehousley Exp $
|
||||
.\" $Id: libssh2_sftp_read.3,v 1.4 2007/06/07 16:01:12 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_sftp_read 3 "6 Feb 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
@ -21,7 +21,9 @@ if further reads would cause the socket to block.
|
||||
\fIbuffer\fP is a pointer to a pre-allocated buffer of at least
|
||||
\fIbuffer_maxlen\fP bytes to read data into.
|
||||
.SH RETURN VALUE
|
||||
Number of bytes actually populated into buffer, or -1 on failure.
|
||||
Number of bytes actually populated into buffer, or -1 on failure. It returns
|
||||
LIBSSH2SFTP_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2SFTP_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
.SH "SEE ALSO"
|
||||
.BR libssh2_sftp_open(3)
|
||||
.BR libssh2_sftp_readnb(3)
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: libssh2_sftp_readdir.3,v 1.3 2007/04/22 17:18:03 jehousley Exp $
|
||||
.\" $Id: libssh2_sftp_readdir.3,v 1.4 2007/06/07 16:01:12 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_sftp_readdir 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
@ -29,7 +29,9 @@ truncated to fit.
|
||||
statbuf style data into.
|
||||
|
||||
.SH RETURN VALUE
|
||||
Number of bytes actually populated into buffer, or -1 on failure.
|
||||
Number of bytes actually populated into buffer, or -1 on failure. It returns
|
||||
LIBSSH2SFTP_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2SFTP_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
.SH "SEE ALSO"
|
||||
.BR libssh2_sftp_opendir(3)
|
||||
.BR libssh2_sftp_readdirnb(3)
|
||||
|
@ -1,40 +0,0 @@
|
||||
.\" $Id: libssh2_sftp_readdirnb.3,v 1.3 2007/04/22 17:18:03 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_sftp_readdir 3 "16 Apr 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_sftp_readdirnb - read directory data from an SFTP handle non-blocking
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
int libssh2_sftp_readdirnb(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
|
||||
size_t buffer_maxlen, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
|
||||
.SH DESCRIPTION
|
||||
Read a block of data from a LIBSSH2_SFTP_HANDLE non-blocking. This method is
|
||||
modeled after the POSIX \fIreaddir(3)\fP however, it uses a variable sized
|
||||
directory entry (filename) buffer and returns statbuf type data in the same
|
||||
call.
|
||||
|
||||
\fIhandle\fP is the SFTP File Handle as returned by
|
||||
\fIlibssh2_sftp_diropen(3)\fP.
|
||||
|
||||
\fIbuffer\fP is a pointer to a pre-allocated buffer of at least
|
||||
\fIbuffer_maxlen\fP bytes to read data into.
|
||||
|
||||
\fIbuffer_maxlen\fP is the length of buffer in bytes. If the length of the
|
||||
filename is longer than the space provided by buffer_maxlen it will be
|
||||
truncated to fit.
|
||||
|
||||
\fIattrs\fP is a pointer to LIBSSH2_SFTP_ATTRIBUTES storage to populate
|
||||
statbuf style data into.
|
||||
|
||||
.SH RETURN VALUE
|
||||
Number of bytes actually populated into buffer, or negative on failure. It
|
||||
returns LIBSSH2CHANNEL_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2CHANNEL_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR libssh2_sftp_opendir(3)
|
||||
.BR libssh2_sftp_readdirnb(3)
|
@ -1,29 +0,0 @@
|
||||
.\" $Id: libssh2_sftp_readnb.3,v 1.3 2007/04/22 17:18:03 jehousley Exp $
|
||||
.\"
|
||||
.TH libssh2_sftp_read 3 "6 Feb 2007" "libssh2 0.15" "libssh2 manual"
|
||||
.SH NAME
|
||||
libssh2_sftp_readnb - read data from an SFTP handle non-blocking
|
||||
.SH SYNOPSIS
|
||||
#include <libssh2.h>
|
||||
#include <libssh2_sftp.h>
|
||||
|
||||
ssize_t libssh2_sftp_readnb(LIBSSH2_SFTP_HANDLE *handle,
|
||||
char *buffer, size_t buffer_maxlen);
|
||||
.SH DESCRIPTION
|
||||
Reads a block of data from an LIBSSH2_SFTP_HANDLE non-blocking. This method is
|
||||
modelled after the POSIX \Iread(3)\fP function and uses the same calling
|
||||
semantics. \fIlibssh2_sftp_read(3)\fP will attempt to read as much as possible
|
||||
however it may not fill all of buffer if the file pointer reaches the end or
|
||||
if further reads would cause the socket to block.
|
||||
|
||||
\fIhandle\fP is the SFTP File Handle as returned by \fIlibssh2_sftp_open(3)\fP.
|
||||
|
||||
\fIbuffer\fP is a pointer to a pre-allocated buffer of at least
|
||||
\fIbuffer_maxlen\fP bytes to read data into.
|
||||
.SH RETURN VALUE
|
||||
Number of bytes actually populated into buffer, or negative on failure. It
|
||||
returns LIBSSH2CHANNEL_EAGAIN when it would otherwise block. While
|
||||
LIBSSH2CHANNEL_EAGAIN is a negative number, it isn't really a failure per se.
|
||||
.SH "SEE ALSO"
|
||||
.BR libssh2_sftp_read(3)
|
||||
.BR libssh2_sftp_open(3)
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sftp_RW_nonblock.c,v 1.5 2007/06/06 19:52:11 jehousley Exp $
|
||||
* $Id: sftp_RW_nonblock.c,v 1.6 2007/06/07 16:01:13 jehousley Exp $
|
||||
*
|
||||
* Sample showing how to do SFTP transfers in a non-blocking manner.
|
||||
*
|
||||
@ -175,8 +175,7 @@ int main(int argc, char *argv[])
|
||||
do {
|
||||
do {
|
||||
/* read in a loop until we block */
|
||||
rc = libssh2_sftp_readnb(sftp_handle, mem,
|
||||
sizeof(mem));
|
||||
rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem));
|
||||
fprintf(stderr, "libssh2_sftp_read returned %d\n",
|
||||
rc);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sftp_mkdir_nonblock.c,v 1.4 2007/06/06 12:34:09 jehousley Exp $
|
||||
* $Id: sftp_mkdir_nonblock.c,v 1.5 2007/06/07 16:01:13 jehousley Exp $
|
||||
*
|
||||
* Sample showing how to do SFTP non-blocking mkdir.
|
||||
*
|
||||
@ -152,10 +152,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_mkdirnb()!\n");
|
||||
/* Make a directory via SFTP */
|
||||
while ((rc = libssh2_sftp_mkdirnb(sftp_session, sftppath,
|
||||
LIBSSH2_SFTP_S_IRWXU|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IXGRP|
|
||||
LIBSSH2_SFTP_S_IROTH|LIBSSH2_SFTP_S_IXOTH))
|
||||
while ((rc = libssh2_sftp_mkdir(sftp_session, sftppath,
|
||||
LIBSSH2_SFTP_S_IRWXU|
|
||||
LIBSSH2_SFTP_S_IRGRP|LIBSSH2_SFTP_S_IXGRP|
|
||||
LIBSSH2_SFTP_S_IROTH|LIBSSH2_SFTP_S_IXOTH))
|
||||
== LIBSSH2SFTP_EAGAIN) {
|
||||
;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sftp_nonblock.c,v 1.8 2007/06/06 12:34:09 jehousley Exp $
|
||||
* $Id: sftp_nonblock.c,v 1.9 2007/06/07 16:01:13 jehousley Exp $
|
||||
*
|
||||
* Sample showing how to do SFTP non-blocking transfers.
|
||||
*
|
||||
@ -158,20 +158,22 @@ int main(int argc, char *argv[])
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_open()!\n");
|
||||
/* Request a file via SFTP */
|
||||
sftp_handle =
|
||||
libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
|
||||
do {
|
||||
sftp_handle = libssh2_sftp_open(sftp_session, sftppath, LIBSSH2_FXF_READ, 0);
|
||||
|
||||
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 receive data!\n");
|
||||
do {
|
||||
char mem[1024];
|
||||
|
||||
/* loop until we fail */
|
||||
fprintf(stderr, "libssh2_sftp_readnb()!\n");
|
||||
while ((rc = libssh2_sftp_readnb(sftp_handle, mem, sizeof(mem))) == LIBSSH2SFTP_EAGAIN) {
|
||||
while ((rc = libssh2_sftp_read(sftp_handle, mem, sizeof(mem))) == LIBSSH2SFTP_EAGAIN) {
|
||||
;
|
||||
}
|
||||
if (rc > 0) {
|
||||
|
@ -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);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: sftpdir_nonblock.c,v 1.5 2007/06/06 12:34:09 jehousley Exp $
|
||||
* $Id: sftpdir_nonblock.c,v 1.6 2007/06/07 16:01:14 jehousley Exp $
|
||||
*
|
||||
* Sample doing an SFTP directory listing.
|
||||
*
|
||||
@ -101,10 +101,13 @@ int main(int argc, char *argv[])
|
||||
if(!session)
|
||||
return -1;
|
||||
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
/* ... start it up. This will trade welcome banners, exchange keys,
|
||||
* and setup crypto, compression, and MAC layers
|
||||
*/
|
||||
rc = libssh2_session_startup(session, sock);
|
||||
while ((rc = libssh2_session_startup(session, sock)) == LIBSSH2_ERROR_EAGAIN);
|
||||
if(rc) {
|
||||
fprintf(stderr, "Failure establishing SSH session: %d\n", rc);
|
||||
return -1;
|
||||
@ -122,42 +125,45 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
if (libssh2_userauth_password(session, username, password)) {
|
||||
printf("Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
/* Or by public key */
|
||||
if (libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) {
|
||||
printf("\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
if (auth_pw) {
|
||||
/* We could authenticate via password */
|
||||
while ((rc = libssh2_userauth_password(session, username, password)) == LIBSSH2CHANNEL_EAGAIN);
|
||||
if (rc) {
|
||||
fprintf(stderr, "Authentication by password failed.\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} else {
|
||||
/* Or by public key */
|
||||
while ((rc = libssh2_userauth_publickey_fromfile(session, username,
|
||||
"/home/username/.ssh/id_rsa.pub",
|
||||
"/home/username/.ssh/id_rsa",
|
||||
password)) == LIBSSH2CHANNEL_EAGAIN);
|
||||
if (rc) {
|
||||
fprintf(stderr, "\tAuthentication by public key failed\n");
|
||||
goto shutdown;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_init()!\n");
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if (!sftp_session) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
/* Since we have set non-blocking, tell libssh2 we are non-blocking */
|
||||
libssh2_session_set_blocking(session, 0);
|
||||
|
||||
do {
|
||||
sftp_session = libssh2_sftp_init(session);
|
||||
|
||||
if ((!sftp_session) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to init SFTP session\n");
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_session);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_opendir()!\n");
|
||||
/* Request a dir listing via SFTP */
|
||||
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
||||
|
||||
if (!sftp_handle) {
|
||||
do {
|
||||
sftp_handle = libssh2_sftp_opendir(sftp_session, sftppath);
|
||||
|
||||
if ((!sftp_handle) && (libssh2_session_last_errno(session) != LIBSSH2_ERROR_EAGAIN)) {
|
||||
fprintf(stderr, "Unable to open dir with SFTP\n");
|
||||
goto shutdown;
|
||||
}
|
||||
goto shutdown;
|
||||
}
|
||||
} while (!sftp_handle);
|
||||
|
||||
fprintf(stderr, "libssh2_sftp_opendir() is done, now receive listing!\n");
|
||||
do {
|
||||
@ -165,7 +171,7 @@ int main(int argc, char *argv[])
|
||||
LIBSSH2_SFTP_ATTRIBUTES attrs;
|
||||
|
||||
/* loop until we fail */
|
||||
while ((rc = libssh2_sftp_readdirnb(sftp_handle, mem, sizeof(mem), &attrs)) == LIBSSH2SFTP_EAGAIN) {
|
||||
while ((rc = libssh2_sftp_readdir(sftp_handle, mem, sizeof(mem), &attrs)) == LIBSSH2SFTP_EAGAIN) {
|
||||
;
|
||||
}
|
||||
if(rc > 0) {
|
||||
|
@ -181,22 +181,20 @@ LIBSSH2_API int libssh2_sftp_shutdown(LIBSSH2_SFTP *sftp);
|
||||
LIBSSH2_API unsigned long libssh2_sftp_last_error(LIBSSH2_SFTP *sftp);
|
||||
|
||||
/* File / Directory Ops */
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp, const char *filename, unsigned int filename_len, unsigned long flags, long mode, int open_type);
|
||||
#define libssh2_sftp_open(sftp, filename, flags, mode) libssh2_sftp_open_ex((sftp), (filename), strlen(filename), (flags), (mode), LIBSSH2_SFTP_OPENFILE)
|
||||
#define libssh2_sftp_opendir(sftp, path) libssh2_sftp_open_ex((sftp), (path), strlen(path), 0, 0, LIBSSH2_SFTP_OPENDIR)
|
||||
LIBSSH2_API LIBSSH2_SFTP_HANDLE *libssh2_sftp_open_ex(LIBSSH2_SFTP *sftp, const char *filename, unsigned int filename_len,
|
||||
unsigned long flags, long mode, int open_type);
|
||||
#define libssh2_sftp_open(sftp, filename, flags, mode) \
|
||||
libssh2_sftp_open_ex((sftp), (filename), strlen(filename), (flags), (mode), LIBSSH2_SFTP_OPENFILE)
|
||||
#define libssh2_sftp_opendir(sftp, path) \
|
||||
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_readnb(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,
|
||||
size_t buffer_maxlen, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
LIBSSH2_API int libssh2_sftp_readdirnb(LIBSSH2_SFTP_HANDLE *handle, char *buffer,
|
||||
size_t buffer_maxlen, LIBSSH2_SFTP_ATTRIBUTES *attrs);
|
||||
|
||||
LIBSSH2_API ssize_t libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer, size_t count);
|
||||
|
||||
@ -227,8 +225,6 @@ LIBSSH2_API int libssh2_sftp_unlink_ex(LIBSSH2_SFTP *sftp, const char *filename,
|
||||
|
||||
LIBSSH2_API int libssh2_sftp_mkdir_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len, long mode);
|
||||
#define libssh2_sftp_mkdir(sftp, path, mode) libssh2_sftp_mkdir_ex((sftp), (path), strlen(path), (mode))
|
||||
LIBSSH2_API int libssh2_sftp_mkdirnb_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len, long mode);
|
||||
#define libssh2_sftp_mkdirnb(sftp, path, mode) libssh2_sftp_mkdirnb_ex((sftp), (path), strlen(path), (mode))
|
||||
|
||||
LIBSSH2_API int libssh2_sftp_rmdir_ex(LIBSSH2_SFTP *sftp, const char *path, unsigned int path_len);
|
||||
#define libssh2_sftp_rmdir(sftp, path) libssh2_sftp_rmdir_ex((sftp), (path), strlen(path))
|
||||
|
@ -466,6 +466,10 @@ struct _LIBSSH2_SFTP_HANDLE {
|
||||
char *next_name;
|
||||
} dir;
|
||||
} u;
|
||||
|
||||
/* State variables used in libssh2_sftp_close_handle() */
|
||||
libssh2_nonblocking_states close_state;
|
||||
unsigned long close_request_id;
|
||||
};
|
||||
|
||||
struct _LIBSSH2_SFTP {
|
||||
@ -480,34 +484,70 @@ struct _LIBSSH2_SFTP {
|
||||
unsigned long last_errno;
|
||||
|
||||
/* Holder for partial packet, use in libssh2_sftp_packet_read() */
|
||||
unsigned char *partial_packet; /* The data */
|
||||
unsigned long partial_len; /* Desired number of bytes */
|
||||
unsigned long partial_received; /* Bytes received so far */
|
||||
unsigned char *partial_packet; /* The data */
|
||||
unsigned long partial_len; /* Desired number of bytes */
|
||||
unsigned long partial_received; /* Bytes received so far */
|
||||
|
||||
/* Time that libssh2_sftp_packet_requirev() started reading */
|
||||
time_t requirev_start;
|
||||
time_t requirev_start;
|
||||
|
||||
/* State variables used in _libssh2_sftp_read() */
|
||||
/* State variables used in libssh2_sftp_open_ex() */
|
||||
libssh2_nonblocking_states open_state;
|
||||
unsigned char *open_packet;
|
||||
ssize_t open_packet_len;
|
||||
unsigned long open_request_id;
|
||||
|
||||
/* State variables used in libssh2_sftp_read() */
|
||||
libssh2_nonblocking_states read_state;
|
||||
unsigned char *read_packet;
|
||||
unsigned long read_request_id;
|
||||
size_t read_total_read;
|
||||
unsigned long read_request_id;
|
||||
size_t read_total_read;
|
||||
|
||||
/* State variables used in _libssh2_sftp_readdir() */
|
||||
/* State variables used in libssh2_sftp_readdir() */
|
||||
libssh2_nonblocking_states readdir_state;
|
||||
unsigned char *readdir_packet;
|
||||
unsigned long readdir_request_id;
|
||||
|
||||
/* State variables used in _libssh2_sftp_write() */
|
||||
/* State variables used in libssh2_sftp_write() */
|
||||
libssh2_nonblocking_states write_state;
|
||||
unsigned char *write_packet;
|
||||
unsigned long write_request_id;
|
||||
|
||||
/* State variables used in _libssh2_sftp_mkdir() */
|
||||
/* State variables used in libssh2_sftp_fstat_ex() */
|
||||
libssh2_nonblocking_states fstat_state;
|
||||
unsigned char *fstat_packet;
|
||||
unsigned long fstat_request_id;
|
||||
|
||||
/* State variables used in libssh2_sftp_unlink_ex() */
|
||||
libssh2_nonblocking_states unlink_state;
|
||||
unsigned char *unlink_packet;
|
||||
unsigned long unlink_request_id;
|
||||
|
||||
/* State variables used in libssh2_sftp_rename_ex() */
|
||||
libssh2_nonblocking_states rename_state;
|
||||
unsigned char *rename_packet;
|
||||
unsigned char *rename_s;
|
||||
unsigned long rename_request_id;
|
||||
|
||||
/* State variables used in libssh2_sftp_mkdir() */
|
||||
libssh2_nonblocking_states mkdir_state;
|
||||
unsigned char *mkdir_packet;
|
||||
unsigned long mkdir_request_id;
|
||||
|
||||
/* State variables used in libssh2_sftp_rmdir() */
|
||||
libssh2_nonblocking_states rmdir_state;
|
||||
unsigned char *rmdir_packet;
|
||||
unsigned long rmdir_request_id;
|
||||
|
||||
/* State variables used in libssh2_sftp_stat() */
|
||||
libssh2_nonblocking_states stat_state;
|
||||
unsigned char *stat_packet;
|
||||
unsigned long stat_request_id;
|
||||
|
||||
/* State variables used in libssh2_sftp_symlink() */
|
||||
libssh2_nonblocking_states symlink_state;
|
||||
unsigned char *symlink_packet;
|
||||
unsigned long symlink_request_id;
|
||||
};
|
||||
|
||||
#define LIBSSH2_SCP_RESPONSE_BUFLEN 256
|
||||
|
1065
src/sftp.c
1065
src/sftp.c
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user