Functions | |
int | sftp_async_read (SFTP_FILE *file, void *data, int size, u32 id) |
Wait for an asynchronous read to complete, and save the data. | |
u32 | sftp_async_read_begin (SFTP_FILE *file, int len) |
Start an asynchronous read on a file. | |
void | sftp_attributes_free (SFTP_ATTRIBUTES *file) |
Free a SFTP_ATTRIBUTE handle. | |
int | sftp_dir_close (SFTP_DIR *dir) |
Close an open directory. | |
int | sftp_dir_eof (SFTP_DIR *dir) |
Tell if the directory has reached End Of File. | |
int | sftp_file_close (SFTP_FILE *file) |
Close an open file. | |
void | sftp_free (SFTP_SESSION *sftp) |
Close and deallocate a SFTP session. | |
SFTP_SESSION * | sftp_new (SSH_SESSION *session) |
start a new SFTP session | |
SFTP_FILE * | sftp_open (SFTP_SESSION *sftp, const char *file, int access, SFTP_ATTRIBUTES *attr) |
Open a remote file. | |
SFTP_DIR * | sftp_opendir (SFTP_SESSION *sftp, const char *path) |
open a directory | |
SFTP_ATTRIBUTES * | sftp_readdir (SFTP_SESSION *sftp, SFTP_DIR *dir) |
Read file attributes of a directory. | |
int | sftp_server_version (SFTP_SESSION *sftp) |
return the version of the SFTP protocol supported by the server |
int sftp_async_read | ( | SFTP_FILE * | file, | |
void * | data, | |||
int | size, | |||
u32 | id | |||
) |
Wait for an asynchronous read to complete, and save the data.
file | The SFTP_FILE handle on the file | |
data | Pointer on the destination buffer | |
size | Size of the destination buffer. It should be bigger or equal to the length parameter of the sftp_async_read_begin() call | |
id | Identifier returned by sftp_async_read_begin() |
SSH_AGAIN if the file is opened in nonblocking mode and the request hasn't been executed yet
0 on end of file
Number of bytes read otherwise
u32 sftp_async_read_begin | ( | SFTP_FILE * | file, | |
int | len | |||
) |
Start an asynchronous read on a file.
This function does an asynchronous read on a file. Its goal is to avoid the slowdowns related to the request/response pattern of a synchronous read.
To do so, you must call 2 functions : sftp_async_read_begin() and sftp_async_read().
The first step is to call sftp_async_read_begin(). This function returns a request identifier.
The second step is to call sftp_async_read using the said identifier.
file | SFTP_FILE handle on an open file | |
len | Length of data to be read |
A call to sftp_async_read_begin() sends a request to the server. When the server answers, libssh allocates memory to store it until sftp_async_read() is called.
Not calling sftp_async_read() will lead to memory leaks.
void sftp_attributes_free | ( | SFTP_ATTRIBUTES * | file | ) |
Free a SFTP_ATTRIBUTE handle.
file | SFTP_ATTRIBUTE handle to free |
int sftp_dir_close | ( | SFTP_DIR * | dir | ) |
Close an open directory.
dir | SFTP_DIR handle to an open directory |
SSH_ERROR An error happened
int sftp_dir_eof | ( | SFTP_DIR * | dir | ) |
Tell if the directory has reached End Of File.
dir | SFTP_DIR open handle |
int sftp_file_close | ( | SFTP_FILE * | file | ) |
Close an open file.
file | SFTP_FILE handle to an open file |
SSH_ERROR An error happened
void sftp_free | ( | SFTP_SESSION * | sftp | ) |
Close and deallocate a SFTP session.
sftp | the SFTP session handle |
SFTP_SESSION* sftp_new | ( | SSH_SESSION * | session | ) |
start a new SFTP session
session | the SSH session |
NULL in case of an error
SFTP_FILE* sftp_open | ( | SFTP_SESSION * | sftp, | |
const char * | file, | |||
int | access, | |||
SFTP_ATTRIBUTES * | attr | |||
) |
SFTP_DIR* sftp_opendir | ( | SFTP_SESSION * | sftp, | |
const char * | path | |||
) |
open a directory
sftp | SFTP session handle | |
path | path to the directory |
SFTP_ATTRIBUTES* sftp_readdir | ( | SFTP_SESSION * | sftp, | |
SFTP_DIR * | dir | |||
) |
Read file attributes of a directory.
sftp | SFTP session handle | |
dir | SFTP_DIR open directory handle |
NULL End of directory
sftp_attribute_free()
int sftp_server_version | ( | SFTP_SESSION * | sftp | ) |
return the version of the SFTP protocol supported by the server
sftp | SFTP session handle |