SSH-scp

SCP protocol over SSH functions. More...

Functions

int ssh_scp_accept_request (ssh_scp scp)
 accepts transfer of a file or creation of a directory coming from the remote party
int ssh_scp_deny_request (ssh_scp scp, const char *reason)
 denies the transfer of a file or creation of a directory coming from the remote party
int ssh_scp_integer_mode (const char *mode)
 Converts a scp text mode to an integer one.
int ssh_scp_leave_directory (ssh_scp scp)
 Leaves a directory.
ssh_scp ssh_scp_new (ssh_session session, int mode, const char *location)
 Creates a new scp session.
int ssh_scp_pull_request (ssh_scp scp)
 waits for a scp request (file, directory)
int ssh_scp_push_directory (ssh_scp scp, const char *dirname, int mode)
 creates a directory in a scp in sink mode
int ssh_scp_push_file (ssh_scp scp, const char *filename, size_t size, int mode)
 initializes the sending of a file to a scp in sink mode
int ssh_scp_read (ssh_scp scp, void *buffer, size_t size)
 Read from a remote scp file.
int ssh_scp_read_string (ssh_scp scp, char *buffer, size_t len)
 reads a string on a channel, terminated by '
'
const char * ssh_scp_request_get_filename (ssh_scp scp)
 Gets the name of the directory or file being pushed from the other party.
int ssh_scp_request_get_permissions (ssh_scp scp)
 Gets the permissions of the directory or file being pushed from the other party.
size_t ssh_scp_request_get_size (ssh_scp scp)
 Gets the size of the file being pushed from the other party.
const char * ssh_scp_request_get_warning (ssh_scp scp)
 Gets the warning string.
int ssh_scp_response (ssh_scp scp, char **response)
 waits for a response of the scp server
char * ssh_scp_string_mode (int mode)
 Converts a unix mode into a scp string one.
int ssh_scp_write (ssh_scp scp, const void *buffer, size_t len)
 Write into a remote scp file.

Detailed Description

SCP protocol over SSH functions.


Function Documentation

int ssh_scp_accept_request ( ssh_scp  scp  ) 

accepts transfer of a file or creation of a directory coming from the remote party

Parameters:
scp the scp handle.
Returns:
SSH_OK the message was sent
SSH_ERROR Error sending the message, or sending it in a bad state

References channel_write().

Referenced by ssh_scp_read().

int ssh_scp_deny_request ( ssh_scp  scp,
const char *  reason 
)

denies the transfer of a file or creation of a directory coming from the remote party

Parameters:
scp the scp handle.
reason nul-terminated string with a human-readable explanation of the deny
Returns:
SSH_OK the message was sent
SSH_ERROR Error sending the message, or sending it in a bad state

References channel_write().

int ssh_scp_integer_mode ( const char *  mode  ) 

Converts a scp text mode to an integer one.

Parameters:
mode mode to convert, e.g. "0644"
Returns:
integer value, e.g. 420 for "0644"

Referenced by ssh_scp_pull_request().

int ssh_scp_leave_directory ( ssh_scp  scp  ) 

Leaves a directory.

Returns:
SSH_OK if the directory was created.
SSH_ERROR if an error happened.
See also:
ssh_scp_push_directory

References channel_read(), and channel_write().

ssh_scp ssh_scp_new ( ssh_session  session,
int  mode,
const char *  location 
)

Creates a new scp session.

Parameters:
session the SSH session to use
mode one of SSH_SCP_WRITE or SSH_SCP_READ, depending if you need to drop files remotely or read them. It is not possible to combine read and write.
location The directory in which write or read will be done. Any push or pull will be relative to this place
Returns:
NULL if the creation was impossible.
a ssh_scp handle if it worked.
int ssh_scp_pull_request ( ssh_scp  scp  ) 

waits for a scp request (file, directory)

Returns:
SSH_ERROR Some error happened
SSH_SCP_REQUEST_NEWFILE The other side is sending a file
SSH_SCP_REQUEST_NEWDIRECTORY The other side is sending a directory
SSH_SCP_REQUEST_END_DIRECTORY The other side has finished with the current directory
See also:
ssh_scp_read
ssh_scp_deny_request
ssh_scp_accept_request

References channel_is_eof(), channel_write(), ssh_log(), SSH_LOG_PROTOCOL, ssh_scp_integer_mode(), and ssh_scp_read_string().

int ssh_scp_push_directory ( ssh_scp  scp,
const char *  dirname,
int  mode 
)

creates a directory in a scp in sink mode

Parameters:
scp the scp handle.
dirname Name of the directory being created.
mode Unix permissions for the new directory, e.g. 0755.
Returns:
SSH_OK if the directory was created.
SSH_ERROR if an error happened.
See also:
ssh_scp_leave_directory

References channel_read(), channel_write(), ssh_basename(), and ssh_scp_string_mode().

int ssh_scp_push_file ( ssh_scp  scp,
const char *  filename,
size_t  size,
int  mode 
)

initializes the sending of a file to a scp in sink mode

Parameters:
scp the scp handle.
filename Name of the file being sent. It should not contain any path indicator
size Exact size in bytes of the file being sent.
mode Unix permissions for the new file, e.g. 0644
Returns:
SSH_OK if the file is ready to be sent.
SSH_ERROR if an error happened.

References channel_read(), channel_write(), ssh_basename(), ssh_log(), SSH_LOG_PROTOCOL, and ssh_scp_string_mode().

int ssh_scp_read ( ssh_scp  scp,
void *  buffer,
size_t  size 
)

Read from a remote scp file.

Parameters:
scp the scp handle.
buffer Destination buffer
size Size of the buffer
Returns:
Number of bytes read
SSH_ERROR An error happened while reading

References channel_read(), channel_write(), ssh_scp_accept_request(), and ssh_scp_response().

int ssh_scp_read_string ( ssh_scp  scp,
char *  buffer,
size_t  len 
)

reads a string on a channel, terminated by '
'

Parameters:
scp the scp handle.
buffer pointer to a buffer to place the string
len size of the buffer in bytes. If the string is bigger than len-1, only len-1 bytes are read and the string is null-terminated.
Returns:
SSH_OK The string was read
SSH_ERROR Error happened while reading

References channel_read().

Referenced by ssh_scp_pull_request(), and ssh_scp_response().

const char* ssh_scp_request_get_filename ( ssh_scp  scp  ) 

Gets the name of the directory or file being pushed from the other party.

Returns:
file name. Should not be freed.
int ssh_scp_request_get_permissions ( ssh_scp  scp  ) 

Gets the permissions of the directory or file being pushed from the other party.

Returns:
Unix permission, e.g 0644.
size_t ssh_scp_request_get_size ( ssh_scp  scp  ) 

Gets the size of the file being pushed from the other party.

Returns:
Numeric size of the file being read.
const char* ssh_scp_request_get_warning ( ssh_scp  scp  ) 

Gets the warning string.

Returns:
Warning string. Should not be freed.
char* ssh_scp_string_mode ( int  mode  ) 

Converts a unix mode into a scp string one.

Parameters:
mode mode to convert, e.g. 420 or 0644
Returns:
pointer to a malloc'ed string containing the scp mode, e.g. "0644".

Referenced by ssh_scp_push_directory(), and ssh_scp_push_file().

int ssh_scp_write ( ssh_scp  scp,
const void *  buffer,
size_t  len 
)

Write into a remote scp file.

Parameters:
scp the scp handle.
buffer the buffer to write
len the number of bytes to write
Returns:
SSH_OK the write was successful
SSH_ERROR an error happened while writing

References channel_poll(), and channel_write().

Generated on Mon Jul 5 22:12:40 2010 for libssh by  doxygen 1.6.3