SFTP functions

SFTP handling functions. More...

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

Detailed Description

SFTP handling functions.

Bug:
Write docs !

Function Documentation

int sftp_async_read ( SFTP_FILE *  file,
void *  data,
int  size,
u32  id 
)

Wait for an asynchronous read to complete, and save the data.

Parameters:
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()
Returns:
SSH_ERROR on error

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

Warning:
A call to this function with an invalid identifier will never return
See also:
sftp_async_read_begin()

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.

Parameters:
file SFTP_FILE handle on an open file
len Length of data to be read
Returns:
A u32 identifier corresponding to the sent request.
Warning:
When calling this function, the internal offset is updated corresponding to the len parameter.

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.

See also:
sftp_async_read()

sftp_open()

void sftp_attributes_free ( SFTP_ATTRIBUTES *  file  ) 

Free a SFTP_ATTRIBUTE handle.

Parameters:
file SFTP_ATTRIBUTE handle to free
See also:
sftp_readdir()

int sftp_dir_close ( SFTP_DIR *  dir  ) 

Close an open directory.

Parameters:
dir SFTP_DIR handle to an open directory
Returns:
SSH_NO_ERROR directory closed successfully

SSH_ERROR An error happened

See also:
sftp_opendir()

int sftp_dir_eof ( SFTP_DIR *  dir  ) 

Tell if the directory has reached End Of File.

Parameters:
dir SFTP_DIR open handle
Returns:
non-zero value if the directory has reached EOF
See also:
sftp_readdir()

int sftp_file_close ( SFTP_FILE *  file  ) 

Close an open file.

Parameters:
file SFTP_FILE handle to an open file
Returns:
SSH_NO_ERROR File closed successfully

SSH_ERROR An error happened

See also:
sftp_file_open()

void sftp_free ( SFTP_SESSION *  sftp  ) 

Close and deallocate a SFTP session.

Parameters:
sftp the SFTP session handle

SFTP_SESSION* sftp_new ( SSH_SESSION *  session  ) 

start a new SFTP session

Parameters:
session the SSH session
Returns:
a SFTP_SESSION handle on success

NULL in case of an error

SFTP_FILE* sftp_open ( SFTP_SESSION *  sftp,
const char *  file,
int  access,
SFTP_ATTRIBUTES *  attr 
)

Open a remote file.

Todo:
please complete doc

SFTP_DIR* sftp_opendir ( SFTP_SESSION *  sftp,
const char *  path 
)

open a directory

Parameters:
sftp SFTP session handle
path path to the directory
Returns:
a SFTP_DIR handle
See also:
sftp_readdir()

sftp_dir_close()

SFTP_ATTRIBUTES* sftp_readdir ( SFTP_SESSION *  sftp,
SFTP_DIR *  dir 
)

Read file attributes of a directory.

Parameters:
sftp SFTP session handle
dir SFTP_DIR open directory handle
Returns:
a SFTP_ATTRIBUTE handle

NULL End of directory

See also:
sftp_opendir()

sftp_attribute_free()

sftp_dir_close()

int sftp_server_version ( SFTP_SESSION *  sftp  ) 

return the version of the SFTP protocol supported by the server

Parameters:
sftp SFTP session handle
Returns:
server version


Generated on Sun Aug 23 08:55:36 2009 for libssh by  doxygen 1.4.7