secsh_sft.h File Reference


Data Structures

struct  SshSftInitParamsRec
struct  SshSftFileAttributesRec
struct  SshSftParamRec
struct  SshSftOffsetRec

Defines

#define SSH_SFT_API_VERSION   1
#define ssh_sft_init_2(broker, init_params, emsgr)   ssh_sft_init_2_v(broker, init_params, emsgr, SSH_SFT_API_VERSION)

Typedefs

typedef unsigned int SshSftUInt32
typedef signed int SshSftInt32
typedef unsigned long long SshSftUInt64
typedef signed long long SshSftInt64
typedef SshSftInt64 SshSftTime
typedef unsigned int SshSftBoolean
typedef struct SshSftInitParamsRec SshSftInitParamsStruct
typedef struct
SshSftInitParamsRec
SshSftInitParams
typedef struct
SshSftFileAttributesRec 
SshSftFileAttributesStruct
typedef
SshSftFileAttributesStruct
SshSftFileAttributes
typedef int(* SshSftSignalCB )(void *context, SshSftSignal signal_type)
typedef void(* SshSftProgressCB )(void *context, SshSftUInt64 start_offset, SshSftUInt64 offset, SshSftUInt64 block_len, SshSftUInt64 total_len, SshSftBoolean finished)
typedef void(* SshSftProgressCtxCreateCB )(void *context, char *src_path, char *src_name, char *dst_path, char *dst_name, void **progress_cb_ctx_ret)
typedef void(* SshSftProgressCtxDestroyCB )(void *context, void *progress_cb_ctx)
typedef void(* SshSftMessageCB )(void *message_cb_ctx, void *progress_cb_ctx, SshSftOperation operation, SshSftAction action, char *src_path, char *src_name, char *dst_path, char *dst_name, char *long_name, SshSftFileAttributes attrs, SshSftError res, char *status_msg, SshSftInteract *interact_ret)
typedef struct SshSftParamRec SshSftParamStruct
typedef SshSftParamStructSshSftParam
typedef struct SshSftOffsetRec SshSftOffsetStruct
typedef SshSftOffsetStructSshSftOffset
typedef struct SshSftRec * SshSft
typedef struct SshSftFileRec * SshSftFile
typedef struct SshSftDirRec * SshSftDir
typedef struct SshSftGlobRec * SshSftGlob

Enumerations

enum  SshSftError {
  SSH_SFT_OK = 0, SSH_SFT_OK_HASH_MATCH = 1, SSH_SFT_OK_HASH_MATCH_DST_TRUNCATED = 2, SSH_SFT_OK_SKIP = 3,
  SSH_SFT_OK_ABORT = 4, SSH_SFT_OK_WITH_ERRORS = 5, SSH_SFT_ERROR = 10, SSH_SFT_ERROR_NO_LICENSE = 11,
  SSH_SFT_ERROR_NO_SERVER_LICENSE = 12, SSH_SFT_ERROR_NOT_DIR = 13, SSH_SFT_ERROR_EOF = 100, SSH_SFT_ERROR_NO_SUCH_FILE = 101,
  SSH_SFT_ERROR_PERMISSION_DENIED = 102, SSH_SFT_ERROR_FAILURE = 103, SSH_SFT_ERROR_BAD_MESSAGE = 104, SSH_SFT_ERROR_NO_CONNECTION = 105,
  SSH_SFT_ERROR_CONNECTION_LOST = 106, SSH_SFT_ERROR_OP_UNSUPPORTED = 107, SSH_SFT_ERROR_INVALID_HANDLE = 108, SSH_SFT_ERROR_NO_SUCH_PATH = 109,
  SSH_SFT_ERROR_FILE_ALREADY_EXISTS = 110, SSH_SFT_ERROR_WRITE_PROTECT = 111, SSH_SFT_ERROR_NO_MEDIA = 112, SSH_SFT_ERROR_EOF_SRC = 200,
  SSH_SFT_ERROR_NO_SUCH_FILE_SRC = 201, SSH_SFT_ERROR_PERMISSION_DENIED_SRC = 202, SSH_SFT_ERROR_FAILURE_SRC = 203, SSH_SFT_ERROR_BAD_MESSAGE_SRC = 204,
  SSH_SFT_ERROR_NO_CONNECTION_SRC = 205, SSH_SFT_ERROR_CONNECTION_LOST_SRC = 206, SSH_SFT_ERROR_OP_UNSUPPORTED_SRC = 207, SSH_SFT_ERROR_INVALID_HANDLE_SRC = 208,
  SSH_SFT_ERROR_NO_SUCH_PATH_SRC = 209, SSH_SFT_ERROR_FILE_ALREADY_EXISTS_SRC = 210, SSH_SFT_ERROR_WRITE_PROTECT_SRC = 211, SSH_SFT_ERROR_NO_MEDIA_SRC = 212,
  SSH_SFT_ERROR_EOF_DST = 300, SSH_SFT_ERROR_NO_SUCH_FILE_DST = 301, SSH_SFT_ERROR_PERMISSION_DENIED_DST = 302, SSH_SFT_ERROR_FAILURE_DST = 303,
  SSH_SFT_ERROR_BAD_MESSAGE_DST = 304, SSH_SFT_ERROR_NO_CONNECTION_DST = 305, SSH_SFT_ERROR_CONNECTION_LOST_DST = 306, SSH_SFT_ERROR_OP_UNSUPPORTED_DST = 307,
  SSH_SFT_ERROR_INVALID_HANDLE_DST = 308, SSH_SFT_ERROR_NO_SUCH_PATH_DST = 309, SSH_SFT_ERROR_FILE_ALREADY_EXISTS_DST = 310, SSH_SFT_ERROR_WRITE_PROTECT_DST = 311,
  SSH_SFT_ERROR_NO_MEDIA_DST = 312, SSH_SFT_ERROR_NO_BROKER_CONNECTION = 500, SSH_SFT_ERROR_AUTHENTICATION_FAILED = 501, SSH_SFT_ERROR_UNABLE_TO_CONNECT_SERVER = 502,
  SSH_SFT_ERROR_BROKER_FAILED = 503, SSH_SFT_ERROR_LOCAL_STREAM_FAILED = 504, SSH_SFT_ERROR_CONNECTION_ABORTED = 600, SSH_SFT_ERROR_READ = 601,
  SSH_SFT_ERROR_WRITE = 602, SSH_SFT_ERROR_OUT_OF_MEMORY = 603, SSH_SFT_ERROR_LISTENER = 604, SSH_SFT_ERROR_LIB_UNINITIALIZED = 605,
  SSH_SFT_ERROR_ILLEGAL_PARAMETER = 606, SSH_SFT_ERROR_NO_CHECKPOINT_ENTRY = 700, SSH_SFT_ERROR_CHECKPOINT_DATABASE = 701, SSH_SFT_ERROR_CHECKPOINT_READ = 702,
  SSH_SFT_ERROR_INTERNAL = 1000
}
enum  SshSftInteract {
  SSH_SFT_INTERACT_NO = 0, SSH_SFT_INTERACT_YES = 1, SSH_SFT_INTERACT_ABORT = 2, SSH_SFT_INTERACT_ASCII_CONV_DOS = 3,
  SSH_SFT_INTERACT_ASCII_CONV_UNIX = 4, SSH_SFT_INTERACT_ASCII_CONV_MAC = 5
}
enum  SshSftFileType {
  SSH_SFT_FILE_TYPE_REGULAR = 1, SSH_SFT_FILE_TYPE_DIRECTORY = 2, SSH_SFT_FILE_TYPE_SYMLINK = 3, SSH_SFT_FILE_TYPE_SPECIAL = 4,
  SSH_SFT_FILE_TYPE_UNKNOWN = 5
}
enum  SshSftFileFlags {
  SSH_SFT_FILE_FLAG_RDWR = 0x0001, SSH_SFT_FILE_FLAG_WRONLY = 0x0002, SSH_SFT_FILE_FLAG_RDONLY = 0x0004, SSH_SFT_FILE_FLAG_APPEND = 0x0008,
  SSH_SFT_FILE_FLAG_CREAT = 0x0010, SSH_SFT_FILE_FLAG_TRUNC = 0x0020, SSH_SFT_FILE_FLAG_EXCL = 0x0040
}
enum  SshSftChecksum {
  SSH_SFT_CHECKSUM_MD5 = 0, SSH_SFT_CHECKSUM_SHA1 = 1, SSH_SFT_CHECKSUM_NO = 2, SSH_SFT_CHECKSUM_MD5_FORCE = 3,
  SSH_SFT_CHECKSUM_SHA1_FORCE = 4, SSH_SFT_CHECKSUM_CHECKPOINT = 5
}
enum  SshSftStreaming { SSH_SFT_STREAMING_YES = 0, SSH_SFT_STREAMING_NO = 1, SSH_SFT_STREAMING_FORCE = 2, SSH_SFT_STREAMING_EXT = 3 }
enum  SshSftOperation {
  SSH_SFT_OPERATION_FILE_COPY = 0, SSH_SFT_OPERATION_FILE_MOVE = 1, SSH_SFT_OPERATION_DIR_STAT = 2, SSH_SFT_OPERATION_DIR_SETSTAT = 3,
  SSH_SFT_OPERATION_DIR_COPY = 4, SSH_SFT_OPERATION_DIR_MOVE = 5, SSH_SFT_OPERATION_DIR_REMOVE = 6, SSH_SFT_OPERATION_DIR_GLOB = 32768
}
enum  SshSftAction {
  SSH_SFT_ACTION_ENTER_DIR = 0, SSH_SFT_ACTION_LEAVE_DIR = 1, SSH_SFT_ACTION_CREATE_DIR = 2, SSH_SFT_ACTION_LIST = 3,
  SSH_SFT_ACTION_START = 4, SSH_SFT_ACTION_COMPLETE = 5, SSH_SFT_ACTION_OVERWRITE = 6, SSH_SFT_ACTION_ASCII_CONVERSION_SRC = 7,
  SSH_SFT_ACTION_ASCII_CONVERSION_DST = 8, SSH_SFT_ACTION_REMOVE = 9, SSH_SFT_ACTION_REMOVE_DIR = 10, SSH_SFT_ACTION_REPORT_INFO = 11,
  SSH_SFT_ACTION_REPORT_WARNING = 12, SSH_SFT_ACTION_REPORT_ERROR = 13
}
enum  SshSftTransferMode { SSH_SFT_TRANSFER_MODE_BINARY = 0, SSH_SFT_TRANSFER_MODE_ASCII = 1, SSH_SFT_TRANSFER_MODE_AUTO = 2, SSH_SFT_TRANSFER_MODE_BINARY_ZOS = 3 }
enum  SshSftSignal { SSH_SFT_SIGNAL_SUSPEND = 0, SSH_SFT_SIGNAL_RESUME = 1, SSH_SFT_SIGNAL_ABORT = 2, SSH_SFT_SIGNAL_KILL = 3 }
enum  SshSftSetstatMode { SSH_SFT_SETSTAT_MODE_OCTAL = 0, SSH_SFT_SETSTAT_MODE_ADD = 1, SSH_SFT_SETSTAT_MODE_SUB = 2 }
enum  SshSftFileAttrFlags {
  SSH_SFT_FILE_ATTR_SIZE = 0x00000001, SSH_SFT_FILE_ATTR_UIDGID = 0x00000002, SSH_SFT_FILE_ATTR_PERMISSIONS = 0x00000004, SSH_SFT_FILE_ATTR_ACMODTIME = 0x00000008,
  SSH_SFT_FILE_ATTR_ACCESSTIME = 0x00000008, SSH_SFT_FILE_ATTR_CREATETIME = 0x00000010, SSH_SFT_FILE_ATTR_MODIFYTIME = 0x00000020, SSH_SFT_FILE_ATTR_ACL = 0x00000040,
  SSH_SFT_FILE_ATTR_OWNERGROUP = 0x00000080, SSH_SFT_FILE_ATTR_SUBSECOND_TIMES = 0x00000100, SSH_SFT_FILE_ATTR_EXTENDED = (int) 0x80000000
}
enum  {
  SSH_SFT_REQUEST_MAX_SIZE = 0x8000, SSH_SFT_REQUEST_MAX_NUM = 10, SSH_SFT_HASH_MAX_ITERATIONS = 20, SSH_SFT_HASH_MIN_BLOCK_SIZE = (1 * 1024 * 1024),
  SSH_SFT_HASH_MAX_BLOCK_SIZE = (10 * 1024 * 1024)
}
enum  SshSftDirSortFlags { SSH_SFT_DIR_FLAG_SORT_NAME = 0x00000001, SSH_SFT_DIR_FLAG_SORT_SIZE = 0x00000002, SSH_SFT_DIR_FLAG_SORT_REVERSE = 0x00000004 }
enum  { SSH_SFT_DIR_RECURSIVE = 0 }

Functions

SshSftFileAttributes ssh_sft_file_attrs_dup (SshSftFileAttributes attrs)
void ssh_sft_file_attrs_free (SshSftFileAttributes *attrs)
void ssh_sft_data_free (unsigned char **data)
void ssh_sft_error_msg_free (char **error_msg)
void ssh_sft_name_free (char **name)
SshSftGlob ssh_sft_glob_create (char *glob_string, char **root_ret, int *depth_ret)
void ssh_sft_glob_destroy (SshSftGlob *glob)
SshSftError ssh_sft_init_2_v (SshSecShBroker broker, SshSftInitParams init_params, char **error_msg_ret, unsigned int version)
SshSftError ssh_sft_init (const char *crypto_dll_path, SshSftBoolean fips_mode, char **error_msg_ret)
void ssh_sft_uninit (void)
SshSftError ssh_sft_open (SshSftParam param, const char *broker_addr, const char *user, const char *host, const char *port, SshSecShBrokerAuthCb auth_cb, void *auth_cb_ctx, SshSft *handle_ret, char **error_msg_ret)
SshSftError ssh_sft_open_window (SshSftParam param, const char *broker_addr, const char *user, const char *host, const char *port, SshSecShBrokerAuthCb auth_cb, void *auth_cb_ctx, SshSft *handle_ret, char **error_msg_ret, void *window)
SshSftError ssh_sft_open_with_connection (SshSftParam param, unsigned int connection_id, void *window, SshSft *handle_ret, char **error_msg_ret)
SshSftError ssh_sft_config (SshSft handle, SshSftParam param, char **error_msg_ret)
SshSftError ssh_sft_config_get (SshSft handle, SshSftParam param, char **error_msg_ret)
SshSftUInt32 ssh_sft_fxp_version (SshSft handle)
SshSftError ssh_sft_fxp_ext_data (SshSft handle, const char *ext_data_type, unsigned char **ext_data_ret, size_t *ext_data_len_ret)
SshSftError ssh_sft_close (SshSft handle, char **error_msg_ret)
SshSftError ssh_sft_destroy (SshSft handle, char **error_msg_ret)
SshSftError ssh_sft_file_open (SshSft handle, char *file, SshSftFileFlags flags, SshSftFileAttributes attrs, SshSftFile *handle_ret, char **error_msg_ret)
SshSftError ssh_sft_file_read (SshSftFile handle, SshSftUInt64 offset, char *data, SshSftUInt64 len, SshSftUInt64 *data_len_ret, char **error_msg_ret)
SshSftError ssh_sft_file_read_alloc (SshSftFile handle, SshSftUInt64 offset, SshSftUInt64 len, unsigned char **data_ret, SshSftUInt64 *data_len_ret, char **error_msg_ret)
SshSftError ssh_sft_file_write (SshSftFile handle, SshSftUInt64 offset, char *data, SshSftUInt64 data_len, char **error_msg_ret)
SshSftError ssh_sft_file_fstat (SshSftFile handle, SshSftFileAttributes *attrs_ret, char **error_msg_ret)
SshSftError ssh_sft_file_close (SshSftFile handle, char **error_msg_ret)
SshSftError ssh_sft_file_remove (SshSftFile handle, char **error_msg_ret)
SshSftError ssh_sft_stat (SshSft handle, char *file, SshSftFileAttributes *attrs_ret, char **error_msg_ret)
SshSftError ssh_sft_stat_dir (SshSft handle, char *dir, SshSftGlob glob, int max_depth, SshSftDirSortFlags sort_flags, SshSftMessageCB message_cb, void *message_cb_ctx, char **error_msg_ret)
SshSftError ssh_sft_lstat (SshSft handle, char *file, SshSftFileAttributes *attrs_ret, char **error_msg_ret)
SshSftError ssh_sft_hash (SshSft handle, char *file, const char *hash_name, SshSftUInt64 offset, size_t len, unsigned char **digest_ret, size_t *digest_len_ret, char **error_msg_ret)
SshSftError ssh_sft_copy (SshSft src_handle, char *src_file, SshSft dst_handle, char *dst_file, SshSftProgressCB progress_cb, void *progress_cb_ctx, SshSftMessageCB message_cb, void *message_cb_ctx, SshSftOffset copy_offset, char **error_msg_ret)
SshSftError ssh_sft_move (SshSft src_handle, char *src_file, SshSft dst_handle, char *dst_file, SshSftProgressCB progress_cb, void *progress_cb_ctx, SshSftMessageCB message_cb, void *message_cb_ctx, SshSftOffset copy_offset, char **error_msg_ret)
SshSftError ssh_sft_copy_dir (SshSft src_handle, char *src_dir, SshSft dst_handle, char *dst_dir, SshSftGlob glob, int max_depth, SshSftProgressCB progress_cb, void *progress_cb_ctx, SshSftProgressCtxCreateCB progress_ctx_create_cb, SshSftProgressCtxDestroyCB progress_ctx_destroy_cb, SshSftMessageCB message_cb, void *message_cb_ctx, char **error_msg_ret)
SshSftError ssh_sft_move_dir (SshSft src_handle, char *src_dir, SshSft dst_handle, char *dst_dir, SshSftGlob glob, int max_depth, SshSftProgressCB progress_cb, void *progress_cb_ctx, SshSftProgressCtxCreateCB progress_cb_ctx_create_cb, SshSftProgressCtxDestroyCB progress_cb_ctx_destroy_cb, SshSftMessageCB message_cb, void *message_cb_ctx, char **error_msg_ret)
SshSftError ssh_sft_setstat (SshSft handle, char *file, SshSftFileAttributes attrs, char **error_msg_ret)
SshSftError ssh_sft_truncate (SshSft handle, char *file, SshSftUInt64 size, char **error_msg_ret)
SshSftError ssh_sft_setstat_dir (SshSft handle, char *dir, SshSftGlob glob, int max_depth, SshSftUInt32 permissions, SshSftSetstatMode mode, SshSftMessageCB message_cb, void *message_cb_ctx, char **error_msg_ret)
SshSftError ssh_sft_dir_open (SshSft handle, char *dir, SshSftDir *handle_ret, char **error_msg_ret)
SshSftError ssh_sft_dir_read (SshSftDir handle, char **entry_name_ret, char **entry_long_name_ret, SshSftFileAttributes *entry_attrs_ret, size_t *queue_size_ret, char **error_msg_ret)
SshSftError ssh_sft_dir_close (SshSftDir handle, char **error_msg_ret)
SshSftError ssh_sft_dir_rmdir (SshSftDir handle, char **error_msg_ret)
SshSftError ssh_sft_mkdir (SshSft handle, char *dir, SshSftFileAttributes attrs, char **error_msg_ret)
SshSftError ssh_sft_rmdir (SshSft handle, char *dir, char **error_msg_ret)
SshSftError ssh_sft_rename (SshSft handle, char *old_file, char *new_file, char **error_msg_ret)
SshSftError ssh_sft_symlink (SshSft handle, char *target, char *link, char **error_msg_ret)
SshSftError ssh_sft_readlink (SshSft handle, char *link, char **file_ret, char **error_msg_ret)
SshSftError ssh_sft_realpath (SshSft handle, char *file, char **path_ret, char **error_msg_ret)
SshSftError ssh_sft_remove (SshSft handle, char *file, char **error_msg_ret)
SshSftError ssh_sft_remove_dir (SshSft handle, char *dir, SshSftGlob glob, int max_depth, SshSftMessageCB message_cb, void *message_cb_ctx, char **error_msg_ret)
SshSftError ssh_sft_abort (SshSft handle, char **error_msg_ret)
SshSftError ssh_sft_suspend (SshSft handle, char **error_msg_ret)
SshSftError ssh_sft_resume (SshSft handle, char **error_msg_ret)

Detailed Description

SSH Tectia Secure File Transfer (SFT) C-API

Version:
1.2.1
Author:
Tommi Linnakangas <tkl@ssh.com>
Copyright (C) Tectia Corporation. This software is protected by international copyright laws. All rights reserved.

Define Documentation

SshSftError ssh_sft_init_2 ( broker,
init_params,
emsgr   )     ssh_sft_init_2_v(broker, init_params, emsgr, SSH_SFT_API_VERSION)

Simple macro to automatically include version in init call


Typedef Documentation

typedef struct SshSftRec* SshSft

Main context used in all operations.

typedef unsigned int SshSftBoolean

Boolean variables are integers. FALSE is 0 and all nonzero values are interpreted as TRUE.

typedef struct SshSftDirRec* SshSftDir

Context used in directory operations.

typedef struct SshSftFileRec* SshSftFile

Context used in file operations.

Data structure for representing file attributes.

typedef struct SshSftGlobRec* SshSftGlob

Context used in globbing.

SFT initialization parameters

typedef signed int SshSftInt32

Signed 32 bit integers.

typedef signed long long SshSftInt64

Signed 64 bit integers.

typedef void(* SshSftMessageCB)(void *message_cb_ctx, void *progress_cb_ctx, SshSftOperation operation, SshSftAction action, char *src_path, char *src_name, char *dst_path, char *dst_name, char *long_name, SshSftFileAttributes attrs, SshSftError res, char *status_msg, SshSftInteract *interact_ret)

Function prototype for message callback.

SFT library calls message callback function when it needs to interact with the application. Different operations have different actions:

SSH_SFT_OPERATION_FILE_COPY -> SSH_SFT_ACTION_START (start file copy?) SSH_SFT_ACTION_OVERWRITE (overwrite file?) SSH_SFT_ACTION_ASCII_CONVERSION_SRC (conversion from source?) SSH_SFT_ACTION_ASCII_CONVERSION_DST (conversion to destination?)

SSH_SFT_OPERATION_FILE_MOVE -> SSH_SFT_ACTION_START (start file copy?) SSH_SFT_ACTION_OVERWRITE (overwrite file?) SSH_SFT_ACTION_ASCII_CONVERSION_SRC (conversion from source?) SSH_SFT_ACTION_ASCII_CONVERSION_DST (conversion to destination?) SSH_SFT_ACTION_REMOVE (remove file?)

SSH_SFT_OPERATION_DIR_COPY -> SSH_SFT_ACTION_ENTER_DIR (enter directory?) SSH_SFT_ACTION_LIST (list file/directory?) SSH_SFT_ACTION_CREATE_DIR (create directory?) SSH_SFT_ACTION_START (start file copy?) SSH_SFT_ACTION_OVERWRITE (overwrite file?) SSH_SFT_ACTION_ASCII_CONVERSION_SRC (conversion from source?) SSH_SFT_ACTION_ASCII_CONVERSION_DST (conversion to destination?) SSH_SFT_ACTION_REPORT_ERROR (continue with error?) SSH_SFT_ACTION_REPORT_WARNING (-) SSH_SFT_ACTION_REPORT_INFO (-)

SSH_SFT_OPERATION_DIR_MOVE -> SSH_SFT_ACTION_ENTER_DIR (enter directory?) SSH_SFT_ACTION_LIST (list file/directory?) SSH_SFT_ACTION_CREATE_DIR (create directory?) SSH_SFT_ACTION_START (start file copy?) SSH_SFT_ACTION_OVERWRITE (overwrite file?) SSH_SFT_ACTION_ASCII_CONVERSION_SRC (conversion from source?) SSH_SFT_ACTION_ASCII_CONVERSION_DST (conversion to destination?) SSH_SFT_ACTION_REMOVE (remove file?) SSH_SFT_ACTION_REMOVE_DIR (remove directory?) SSH_SFT_ACTION_REPORT_ERROR (continue with error?) SSH_SFT_ACTION_REPORT_WARNING (-) SSH_SFT_ACTION_REPORT_INFO (-)

SSH_SFT_OPERATION_DIR_REMOVE -> SSH_SFT_ACTION_ENTER_DIR (enter directory?) SSH_SFT_ACTION_LIST (list file/directory?) SSH_SFT_ACTION_REMOVE (remove file?) SSH_SFT_ACTION_REMOVE_DIR (remove directory?) SSH_SFT_ACTION_REPORT_ERROR (continue with error?) SSH_SFT_ACTION_REPORT_WARNING (-) SSH_SFT_ACTION_REPORT_INFO (-)

Parameters:
message_cb_ctx Message callback function context.
progress_cb_ctx Progress callback function context.
operation Operation.
action Action.
src_path Path to the source file.
src_name Name of the source file.
dst_path Path to the destination file.
dst_name Name of the destination file.
long_name Long name of the file in action SSH_SFT_ACTION_LIST.
attrs File attributes in action SSH_SFT_ACTION_LIST.
res Status code for the SFT operation.
status_msg Status message for the SFT operation.
interact_ret Interact return value.

Offsets used in file copy.

SFT parameters.

Each SFT session can be configured with parameters.

typedef void(* SshSftProgressCB)(void *context, SshSftUInt64 start_offset, SshSftUInt64 offset, SshSftUInt64 block_len, SshSftUInt64 total_len, SshSftBoolean finished)

Function prototype for file copy progress callback.

SFT library calls progress callback function after each succesful data transfer. This means that the progress callback function is called very often and should not perform any heavy functionality. It is suggested that progress callback function only updates statistics and some other thread performs further actions, like drawing the progress bar.

Parameters:
context Application specific context.
start_offset Initial offset in the file.
offset Current offset in the file.
block_len Length of the transferred block.
total_len Total length of the file.
finished Flag to specify, whether transfer is finished.

typedef void(* SshSftProgressCtxCreateCB)(void *context, char *src_path, char *src_name, char *dst_path, char *dst_name, void **progress_cb_ctx_ret)

Function prototype for creating file copy progress context.

Directory copy is performed so that more than one file is copied at the same time. For this reason, application must provide one context for each file transfer. SFT library calls progress context creation function before each file transfer. This context is then given to progress callback function during the file transfer.

Parameters:
context Application specific context.
src_path Path to the source file.
src_name Name of the source file.
dst_path Path to the destination file.
dst_name Name of the destination file.
progress_cb_ctx_ret Returned progress callback context.

typedef void(* SshSftProgressCtxDestroyCB)(void *context, void *progress_cb_ctx)

Function prototype for destroying file copy progress context.

After file transfer SFT library calls progress context destroy function. Application can then free resources bound to the context.

Parameters:
context Application specific context.
progress_cb_ctx Progress callback context.

typedef int(* SshSftSignalCB)(void *context, SshSftSignal signal_type)

Function prototype for signal callback function.

Signal callback is used by the library to tell the application that it has performed some action. For example, if library loses the connection (SSH_SFT_SIGNAL_KILL), the application must tear done the corresponding contexts. Also, for example if the application aborts file operation with 'ssh_sft_abort' function, SSH_SFT_SIGNAL_ABORT is received when abort is ready.

Parameters:
context Application specific context.
signal_type Type of the signal requested.
Returns:
TRUE, if signal has been received, FALSE otherwise.

Timestamps are signed 64 bit integers.

typedef unsigned int SshSftUInt32

Unsigned 32 bit integers.

typedef unsigned long long SshSftUInt64

Unsigned 64 bit integers.


Enumeration Type Documentation

anonymous enum

Enumerator:
SSH_SFT_REQUEST_MAX_SIZE  Default value for the maximum size of one SFTP data packet.
SSH_SFT_REQUEST_MAX_NUM  Default value for the maximum number of SFTP data packets sent in parallel.
SSH_SFT_HASH_MAX_ITERATIONS  Default value for the maximum number of binary search iterations in comparing two files.
SSH_SFT_HASH_MAX_BLOCK_SIZE  Default value for the minimum size that is used in calculating checksums (minimum binary search granularity). Default value for the maximum size that is used in calculating checksums (maximum binary search granularity).

anonymous enum

Enumerator:
SSH_SFT_DIR_RECURSIVE  Directory depth for recursive operation.

SFT action code.

Action codes are used in directory and other operations to tell the user what kind of action starts. The user can then decide whether the action can start or not.

Enumerator:
SSH_SFT_ACTION_ENTER_DIR  Directory is entered.
SSH_SFT_ACTION_LEAVE_DIR  Directory is stepped out.
SSH_SFT_ACTION_CREATE_DIR  Directory is created.
SSH_SFT_ACTION_LIST  File or directory is listed.
SSH_SFT_ACTION_START  File copy or move is started.
SSH_SFT_ACTION_COMPLETE  File copy, move, remove and setstat is completed.
SSH_SFT_ACTION_OVERWRITE  File is overwritten.
SSH_SFT_ACTION_ASCII_CONVERSION_SRC  ASCII conversion method for source file is not known.
SSH_SFT_ACTION_ASCII_CONVERSION_DST  ASCII conversion method for destination file is not known.
SSH_SFT_ACTION_REMOVE  File is removed.
SSH_SFT_ACTION_REMOVE_DIR  Directory is removed.
SSH_SFT_ACTION_REPORT_INFO  Information about progress of an operation is passed to the user. No interaction is expected => interact_ret returned by user is ignored.
SSH_SFT_ACTION_REPORT_WARNING  Warning is reported to the user. No interaction is expected => interact_ret returned by user is ignored.
SSH_SFT_ACTION_REPORT_ERROR  Error is reported to the user. User can decide whether to continue operation after error or not.

Checksum types.

SFT can use checksums to check whether two files are identical. There is also separate checkpoint database that can be used for saving the state of the file transfer. If the file transfer is interrupted, the database can be used for determining the point from where file transfer can be resumed.

Enumerator:
SSH_SFT_CHECKSUM_MD5  MD5 checksums are used for checking whether two files are identical. Checksums are not calculated for files that are smaller than the size of one data packet in SFTP protocol.
SSH_SFT_CHECKSUM_SHA1  SHA-1 checksums are used for checking whether two files are identical. Checksums are not calculated for files that are smaller than the size of one data packet in SFTP protocol.
SSH_SFT_CHECKSUM_NO  No checksums are used for checking whether two files are identical.
SSH_SFT_CHECKSUM_MD5_FORCE  MD5 checksums are used for checking whether two files are identical. Checksums are calculated for all files.
SSH_SFT_CHECKSUM_SHA1_FORCE  SHA-1 checksums are used for checking whether two files are identical. Checksums are calculated for all files.
SSH_SFT_CHECKSUM_CHECKPOINT  Separate checkpoint database is used for checking whether file transfer was interrupted. The transfer will resume from the point saved in the checkpoint database.

Enumerator:
SSH_SFT_DIR_FLAG_SORT_NAME  Directory listing is sorted by name (default).
SSH_SFT_DIR_FLAG_SORT_SIZE  Directory listing is sorted by size.
SSH_SFT_DIR_FLAG_SORT_REVERSE  Directory listing sort order is reversed.

Return values for SFT API functions.

All SFT API functions return these values. There is always a descriptive status message returned with the return value.

Enumerator:
SSH_SFT_OK  Operation was successful.
SSH_SFT_OK_HASH_MATCH  Destination file was identical to source file.
SSH_SFT_OK_HASH_MATCH_DST_TRUNCATED  Destination file was larger than source file, but the beginning part of it was identical to source file. Destination file was truncated to the size of the source file.
SSH_SFT_OK_SKIP  File operation was not performed.
SSH_SFT_OK_ABORT  File operation was aborted.
SSH_SFT_OK_WITH_ERRORS  Operation on multiple files was completed with some non-critical errors. Currently only operations working on directory trees can return this error.
SSH_SFT_ERROR  Operation failed.
SSH_SFT_ERROR_NO_LICENSE  No suitable license found.
SSH_SFT_ERROR_NO_SERVER_LICENSE  No suitable license found on the server.
SSH_SFT_ERROR_NOT_DIR  Entry is not directory.
SSH_SFT_ERROR_EOF  An attempt to read past the end-of-file was made; or, there are no more directory entries to return.
SSH_SFT_ERROR_NO_SUCH_FILE  A reference was made to a file which does not exist.
SSH_SFT_ERROR_PERMISSION_DENIED  The user does not have sufficient permissions to perform the operation.
SSH_SFT_ERROR_FAILURE  An error occured, but no specific error code exists to describe the failure.
SSH_SFT_ERROR_BAD_MESSAGE  A badly formatted packet or other SFTP protocol incompatibility was detected.
SSH_SFT_ERROR_NO_CONNECTION  There is no connection to the server.
SSH_SFT_ERROR_CONNECTION_LOST  The connection to the server was lost.
SSH_SFT_ERROR_OP_UNSUPPORTED  An attempted operation could not be completed by the server because the server does not support the operation.
SSH_SFT_ERROR_INVALID_HANDLE  The handle value was invalid.
SSH_SFT_ERROR_NO_SUCH_PATH  The file path does not exist or is invalid.
SSH_SFT_ERROR_FILE_ALREADY_EXISTS  The file already exists.
SSH_SFT_ERROR_WRITE_PROTECT  The file is on read-only media, or the media is write protected.
SSH_SFT_ERROR_NO_MEDIA  The requested operation cannot be completed because there is no media available in the drive.
SSH_SFT_ERROR_EOF_SRC  An attempt to read past the end-of-file was made; or, there are no more directory entries to return.
SSH_SFT_ERROR_NO_SUCH_FILE_SRC  A reference was made to a file which does not exist.
SSH_SFT_ERROR_PERMISSION_DENIED_SRC  The user does not have sufficient permissions to perform the operation.
SSH_SFT_ERROR_FAILURE_SRC  An error occured, but no specific error code exists to describe the failure.
SSH_SFT_ERROR_BAD_MESSAGE_SRC  A badly formatted packet or other SFTP protocol incompatibility was detected.
SSH_SFT_ERROR_NO_CONNECTION_SRC  There is no connection to the server.
SSH_SFT_ERROR_CONNECTION_LOST_SRC  The connection to the server was lost.
SSH_SFT_ERROR_OP_UNSUPPORTED_SRC  An attempted operation could not be completed by the server because the server does not support the operation.
SSH_SFT_ERROR_INVALID_HANDLE_SRC  The handle value was invalid.
SSH_SFT_ERROR_NO_SUCH_PATH_SRC  The file path does not exist or is invalid.
SSH_SFT_ERROR_FILE_ALREADY_EXISTS_SRC  The file already exists.
SSH_SFT_ERROR_WRITE_PROTECT_SRC  The file is on read-only media, or the media is write protected.
SSH_SFT_ERROR_NO_MEDIA_SRC  The requested operation cannot be completed because there is no media available in the drive.
SSH_SFT_ERROR_EOF_DST  An attempt to read past the end-of-file was made; or, there are no more directory entries to return.
SSH_SFT_ERROR_NO_SUCH_FILE_DST  A reference was made to a file which does not exist.
SSH_SFT_ERROR_PERMISSION_DENIED_DST  The user does not have sufficient permissions to perform the operation.
SSH_SFT_ERROR_FAILURE_DST  An error occured, but no specific error code exists to describe the failure.
SSH_SFT_ERROR_BAD_MESSAGE_DST  A badly formatted packet or other SFTP protocol incompatibility was detected.
SSH_SFT_ERROR_NO_CONNECTION_DST  There is no connection to the server.
SSH_SFT_ERROR_CONNECTION_LOST_DST  The connection to the server was lost.
SSH_SFT_ERROR_OP_UNSUPPORTED_DST  An attempted operation could not be completed by the server because the server does not support the operation.
SSH_SFT_ERROR_INVALID_HANDLE_DST  The handle value was invalid.
SSH_SFT_ERROR_NO_SUCH_PATH_DST  The file path does not exist or is invalid.
SSH_SFT_ERROR_FILE_ALREADY_EXISTS_DST  The file already exists.
SSH_SFT_ERROR_WRITE_PROTECT_DST  The file is on read-only media, or the media is write protected.
SSH_SFT_ERROR_NO_MEDIA_DST  The requested operation cannot be completed because there is no media available in the drive.
SSH_SFT_ERROR_NO_BROKER_CONNECTION  No connection to SSH Tectia Connection Broker.
SSH_SFT_ERROR_AUTHENTICATION_FAILED  Authentication failed.
SSH_SFT_ERROR_UNABLE_TO_CONNECT_SERVER  Could not connect to SSH server.
SSH_SFT_ERROR_BROKER_FAILED  Unspecified Broker error.
SSH_SFT_ERROR_LOCAL_STREAM_FAILED  Could not create local stream.
SSH_SFT_ERROR_CONNECTION_ABORTED  Connection was aborted.
SSH_SFT_ERROR_READ  Reading from stream failed.
SSH_SFT_ERROR_WRITE  Writing to stream failed.
SSH_SFT_ERROR_OUT_OF_MEMORY  Could not allocate memory.
SSH_SFT_ERROR_LISTENER  Could not create local listener.
SSH_SFT_ERROR_LIB_UNINITIALIZED  SFT library was not initialized.
SSH_SFT_ERROR_ILLEGAL_PARAMETER  Illegal parameter was given.
SSH_SFT_ERROR_NO_CHECKPOINT_ENTRY  No checkpoint entry was found in checkpoint database.
SSH_SFT_ERROR_INTERNAL  Internal error was encountered. This should not happen.

Attribute flags are used for specifying, which attributes are present.

Enumerator:
SSH_SFT_FILE_ATTR_SIZE  Size attributes is present.
SSH_SFT_FILE_ATTR_UIDGID  UIDGID attribute is present. UIDGID is not allowed in SFTPv4.
SSH_SFT_FILE_ATTR_PERMISSIONS  Permissions attributes is present.
SSH_SFT_FILE_ATTR_ACMODTIME  Last modified time attribute is present. This attribute is only used in SFTPv3.
SSH_SFT_FILE_ATTR_ACCESSTIME  Last accessed time attribute is present. This attribute is only used in SFTPv4.
SSH_SFT_FILE_ATTR_CREATETIME  Create time attribute is present. This attribute is only used in SFTPv4 and later.
SSH_SFT_FILE_ATTR_MODIFYTIME  Last modified time attribute is present. This attribute is only used in SFTPv4 and later.
SSH_SFT_FILE_ATTR_ACL  Access control list attribute is present. This attribute is only used in SFTPv4 and later.
SSH_SFT_FILE_ATTR_OWNERGROUP  Owner and group attribute is present. This attribute is only used in SFTPv4 and later.
SSH_SFT_FILE_ATTR_SUBSECOND_TIMES  Subsecond times (time value granularity is less that second) attribute is present. This attribute is only used in SFTPv4 and later.
SSH_SFT_FILE_ATTR_EXTENDED  Extended attribute is present. This attribute is only used in SFTPv4 and later.

File open flags.

Different flags are used in opening file.

Enumerator:
SSH_SFT_FILE_FLAG_RDWR  Open file in read/write mode.
SSH_SFT_FILE_FLAG_WRONLY  Open file in write-only mode.
SSH_SFT_FILE_FLAG_APPEND  Open file in read-only mode. Open file in append mode.
SSH_SFT_FILE_FLAG_CREAT  The file is created, if it does not exist.
SSH_SFT_FILE_FLAG_TRUNC  Existing file is truncated when opened.
SSH_SFT_FILE_FLAG_EXCL  When used with SSH_SFT_FILE_OPEN_FLAG_CREAT, if the file already exists it is an error and the open will fail.

File types.

Different file types are used in SFT operations.

Enumerator:
SSH_SFT_FILE_TYPE_REGULAR  File is a regular file.
SSH_SFT_FILE_TYPE_DIRECTORY  File is a directory.
SSH_SFT_FILE_TYPE_SYMLINK  File is a symbolic link.
SSH_SFT_FILE_TYPE_SPECIAL  File is a special file.
SSH_SFT_FILE_TYPE_UNKNOWN  The type of the file is unknown.

Return values for user interaction.

These values are used when user interaction is needed to perform some operation. Interaction callback function is called from the library and the function must return the value for the library.

Enumerator:
SSH_SFT_INTERACT_NO  User answered 'no'.
SSH_SFT_INTERACT_YES  User answered 'yes'.
SSH_SFT_INTERACT_ABORT  User answered 'abort'.
SSH_SFT_INTERACT_ASCII_CONV_DOS  User was asked about ASCII conversion and he/she answered 'dos'.
SSH_SFT_INTERACT_ASCII_CONV_UNIX  User was asked about ASCII conversion and he/she answered 'unix'.
SSH_SFT_INTERACT_ASCII_CONV_MAC  User was asked about ASCII conversion and he/she answered 'mac'.

SFT operation code.

Operation codes are used whenever the user needs to be informed about what kind of operation is going on. User can decide then whether the operation can continue or not. The main use of these operation codes is in directory operations.

Enumerator:
SSH_SFT_OPERATION_FILE_COPY  File copy is in progress.
SSH_SFT_OPERATION_FILE_MOVE  File move is in progress.
SSH_SFT_OPERATION_DIR_STAT  Directory STAT is in progress.
SSH_SFT_OPERATION_DIR_SETSTAT  Directory SETSTAT is in progress.
SSH_SFT_OPERATION_DIR_COPY  Directory copy is in progress.
SSH_SFT_OPERATION_DIR_MOVE  Directory move is in progress.
SSH_SFT_OPERATION_DIR_REMOVE  Directory remove is in progress.
SSH_SFT_OPERATION_DIR_GLOB  Directory globing stage is in progress.

SETSTAT permissions modes.

Enumerator:
SSH_SFT_SETSTAT_MODE_OCTAL  The permissions are set explicitely.
SSH_SFT_SETSTAT_MODE_ADD  The permissions are added to the existing values.
SSH_SFT_SETSTAT_MODE_SUB  The permissions is subtracted from the existing values.

Signal type.

Signal types are used for transfering signals from the library to the application. Signal callback is used by the library to tell the application that it has performed some action. For example, if library loses the connection (SSH_SFT_SIGNAL_KILL), the application must tear done the corresponding contexts.

Enumerator:
SSH_SFT_SIGNAL_SUSPEND  Library has suspended file operation.
SSH_SFT_SIGNAL_RESUME  Library has resumed file operation.
SSH_SFT_SIGNAL_ABORT  Library has aborted file operation.
SSH_SFT_SIGNAL_KILL  Library has lost connection.

Streaming types.

SFT can use two file transfer methods: traditional SFTP protocol and streaming. Traditional SFTP file transfer uses SFTP READ and WRITE messages to transfer file data. Streaming does not use SFTP protocol, but transfers the file data over a dedicated SSH channel without protocol overhead. There is a small overhead on setting up streaming channel, so it is not used for small files that can be sent using just one READ and WRITE messages.

Enumerator:
SSH_SFT_STREAMING_YES  Streaming is used in file transfer. Streaming is not used for files that are smaller than the size of one data packet in SFTP protocol.
SSH_SFT_STREAMING_NO  Streaming is not used in file transfer. Traditional SFTP READ and WRITE messages are used in file transfer.
SSH_SFT_STREAMING_FORCE  Streaming is used for all files in file transfer.
SSH_SFT_STREAMING_EXT  Streaming is used for all files in file transfer. New extended version of streaming is used.

File transfer mode.

File can be transferred either in binary or ASCII mode. In ASCII mode newlines are converted from source convention to destination convention.

Enumerator:
SSH_SFT_TRANSFER_MODE_BINARY  Binary transfer mode.
SSH_SFT_TRANSFER_MODE_ASCII  Ascii transfer mode.
SSH_SFT_TRANSFER_MODE_AUTO  Tranfer mode is selected automatically from the file extensions.
SSH_SFT_TRANSFER_MODE_BINARY_ZOS  Binary transfer mode with predefined parameters suitable for SSH Tectia for z/OS server. For other servers this mode is the same as original binary transfer mode.


Function Documentation

SshSftError ssh_sft_abort ( SshSft  handle,
char **  error_msg_ret 
)

Abort operation.

The ongoing file operations can be aborted with this function. 'handle' specifies the session that is aborted.

Parameters:
handle Handle to SFT session.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_close ( SshSft  handle,
char **  error_msg_ret 
)

Close SFT session.

This function closes the session given in 'handle'.

Parameters:
handle Handle to SFT session.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_config ( SshSft  handle,
SshSftParam  param,
char **  error_msg_ret 
)

Configure SFT session.

This function re-configures the session given in 'handle' using the parameters in 'param'.

Parameters:
handle Handle to SFT session.
param SFT parameters.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_config_get ( SshSft  handle,
SshSftParam  param,
char **  error_msg_ret 
)

Get SFT configuration.

This function gets the configuration of the session given in 'handle'.

Parameters:
handle Handle to SFT session.
param SFT parameters.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_copy ( SshSft  src_handle,
char *  src_file,
SshSft  dst_handle,
char *  dst_file,
SshSftProgressCB  progress_cb,
void *  progress_cb_ctx,
SshSftMessageCB  message_cb,
void *  message_cb_ctx,
SshSftOffset  copy_offset,
char **  error_msg_ret 
)

Copy file.

Source file name with path is given in 'src_file'. Destination file name with path is given in 'dst_file'. File is copied from remote or local host specified by 'src_handle' to remote or local host specified by 'dst_handle'. 'handles' must be successfully opened before they are used.

'progress_cb' and 'progress_cb_ctx' are used for informing the caller about the progress of the file transfer.

'message_cb' and 'message_cb_ctx' are used for informing the caller about different actions during file transfer. For example, if destination file already exists and the user must be asked, whether the file can be overwritten, 'message_cb' function is called.

With 'copy_offset' it is possible to give the starting offsets of the source and destination files. If 'copy_offset' is NULL, no offsets are used.

Parameters:
src_handle Handle to source SFT session.
src_file Absolute path of the source file.
dst_handle Handle to destination SFT session.
dst_file Absolute path of the destination file.
progress_cb Progress callback function pointer.
progress_cb_ctx Progress callback context.
message_cb Message callback function pointer.
message_cb_ctx Message callback context.
copy_offset Offsets to be used.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_copy_dir ( SshSft  src_handle,
char *  src_dir,
SshSft  dst_handle,
char *  dst_dir,
SshSftGlob  glob,
int  max_depth,
SshSftProgressCB  progress_cb,
void *  progress_cb_ctx,
SshSftProgressCtxCreateCB  progress_ctx_create_cb,
SshSftProgressCtxDestroyCB  progress_ctx_destroy_cb,
SshSftMessageCB  message_cb,
void *  message_cb_ctx,
char **  error_msg_ret 
)

Copy directory.

Source directory name with path is given in 'src_dir'. Destination directory name with path is given in 'dst_dir'. Directory is copied from remote or local host specified by 'src_handle' to remote or local host specified by 'dst_handle'. 'src_handle' and 'dst_handle' must be successfully opened before they are used.

'glob' context is used for globbing. If 'glob' is NULL, no globbing is done. 'max_depth' specifies the maximum depth of the directory traversal. If 'max_depth' is set to 0, the whole directory is copied recursively. 'progress_cb' and 'progress_cb_ctx' are used for informing the caller about the progress of the file transfer. 'progress_ctx_create_cb' function is used for creating context for each file copy operation. 'progress_ctx_destroy_cb' function is used for destroying the created context. 'progress_cb_ctx' is given to both create adn destroy functions as an argument. 'message_cb' and 'message_cb_ctx' are used for informing the caller about different actions during file transfer. For example, if destination file already exists and the user must be asked, whether the file can be overwritten, 'message_cb' function is called.

Parameters:
src_handle Handle to source SFT session.
src_dir Absolute path of the source directory.
dst_handle Handle to destination SFT session.
dst_dir Absolute path of the destination directory.
glob Globbing context.
max_depth Maximum depth of directory traversal.
progress_cb Progress callback function pointer.
progress_cb_ctx Progress callback context.
progress_ctx_create_cb Progress callback context create function pointer.
progress_ctx_destroy_cb Progress callback context destroy function pointer.
message_cb Message callback function pointer.
message_cb_ctx Message callback context.
error_msg_ret Returned error message.
Returns:
SshSftError.

void ssh_sft_data_free ( unsigned char **  data  ) 

Free data.

This function frees data that was allocated by SFT API function. The pointer is also zeroed.

Parameters:
data Pointer to data pointer.

SshSftError ssh_sft_destroy ( SshSft  handle,
char **  error_msg_ret 
)

Destroy SFT session.

This function frees allocated memory of the session given in 'handle'.

Parameters:
handle Handle to SFT session.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_dir_close ( SshSftDir  handle,
char **  error_msg_ret 
)

Run CLOSE on open directory.

This function closes directory specified by 'handle'. The 'handle' is also destroyed and cannot be used anymore.

Parameters:
handle Handle to opened directory.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_dir_open ( SshSft  handle,
char *  dir,
SshSftDir handle_ret,
char **  error_msg_ret 
)

Run OPENDIR on directory 'dir'.

This function opens the directory on the remote or local host specified by session 'handle'. Directory name with path is given in 'dir'. The handle to the opened directory is returned in 'handle_ret'. The directory can be closed with 'ssh_sft_dir_close' after it has been used. Directory handle must not be used after SFT session handle is closed.

Parameters:
handle Handle to SFT session.
dir Absolute path of the directory.
handle_ret Returned handle to opened directory.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_dir_read ( SshSftDir  handle,
char **  entry_name_ret,
char **  entry_long_name_ret,
SshSftFileAttributes entry_attrs_ret,
size_t *  queue_size_ret,
char **  error_msg_ret 
)

Run READDIR on open directory.

This function reads directory contents from the directory specified by 'handle'. Directory must be successfully opened with 'ssh_sft_dir_open' before it is used. Directory name with path is given in 'dir'. The data of one directory entry is returned in 'entry_name_ret', 'entry_long_name_ret' and 'entry_attrs_ret'. The number of entries in the queue is returned in 'queue_size_ret'. Its value tells the caller how many entries can be fetched without sending protocol message to the server. The memory for the directory entry is dynamically allocated and must be freed using 'ssh_sft_name_free' and 'ssh_sft_file_attrs_free' functions. The function returns SSH_SFT_ERROR_EOF, if no more entries can be found.

Parameters:
handle Handle to opened directory.
entry_name_ret Returned name of the entry.
entry_long_name_ret Returned long name of the entry.
entry_attrs_ret Returned attributes of the entry.
queue_size_ret Returned number of entries queued.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_dir_rmdir ( SshSftDir  handle,
char **  error_msg_ret 
)

Run RMDIR on open directory.

This function closes and removes directory specified by 'handle'. The 'handle' is also destroyed and cannot be used anymore.

Parameters:
handle Handle to opened directory.
error_msg_ret Returned error message.
Returns:
SshSftError.

void ssh_sft_error_msg_free ( char **  error_msg  ) 

Free error message.

This function frees error message that was allocated by SFT API function. The pointer is also zeroed.

Parameters:
error_msg Pointer to error message string pointer.

SshSftFileAttributes ssh_sft_file_attrs_dup ( SshSftFileAttributes  attrs  ) 

Duplicate file attributes.

This function allocates memory for file attributes and copies the values to the newly allocated memory. Attributes must be freed with 'ssh_sft_file_attrs_free' function.

Parameters:
attrs File attributes.
Returns:
Copy of file attributes.

void ssh_sft_file_attrs_free ( SshSftFileAttributes attrs  ) 

Free file attributes.

This function frees file attribute structure that was allocated by SFT API function. The pointer is also zeroed.

Parameters:
attrs Pointer to file attributes pointer.

SshSftError ssh_sft_file_close ( SshSftFile  handle,
char **  error_msg_ret 
)

Run CLOSE on open file.

This function closes the file specified by 'handle'. The 'handle' is also destroyed and cannot be used anymore.

Parameters:
handle Handle to opened file.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_file_fstat ( SshSftFile  handle,
SshSftFileAttributes attrs_ret,
char **  error_msg_ret 
)

Run STAT on open file.

This function gets file attributes of the file specified by 'handle'. File must be successfully opened before it is used. File attributes are returned in 'attrs_ret'. The memory for the attributes is dynamically allocated. It must be freed using 'ssh_sft_file_attrs_free' function.

Parameters:
handle Handle to opened file.
attrs_ret Returned file attributes.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_file_open ( SshSft  handle,
char *  file,
SshSftFileFlags  flags,
SshSftFileAttributes  attrs,
SshSftFile handle_ret,
char **  error_msg_ret 
)

Run OPEN on file 'file'.

This function opens the file on the remote or local host specified by SFT session 'handle'. File name with path is given in 'file'. The open flags must be given in 'flags' (SSH_SFT_FILE_FLAG_RDWR | SSH_SFT_FILE_FLAG_WRONLY | SSH_SFT_FILE_FLAG_RDONLY | SSH_SFT_FILE_FLAG_APPEND | SSH_SFT_FILE_FLAG_CREAT | SSH_SFT_FILE_FLAG_TRUNC | SSH_SFT_FILE_FLAG_EXCL). The handle to the opened file is returned in 'handle_ret'. The file can be closed with 'ssh_sft_file_close' after it has been used. File handle must not be used after SFT session handle is closed.

Parameters:
handle Handle to SFT session.
file Absolute path of the file.
flags Flags used in opening the file.
attrs File attributes used in opening the file.
handle_ret Returned handle to opened file.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_file_read ( SshSftFile  handle,
SshSftUInt64  offset,
char *  data,
SshSftUInt64  len,
SshSftUInt64 data_len_ret,
char **  error_msg_ret 
)

Run READ on open file.

This function reads the data of the file specified by 'handle'. File must be successfully opened with 'ssh_sft_file_open' before it is used. The offset to the file data is given in 'offset'. The length of the data block requested is given in 'len'. The data is stored into a user allocated buffer 'data'. The length of the data in the buffer is returned in 'data_len_ret'.

Parameters:
handle Handle to opened file.
offset Offset in the file.
data Data buffer.
len Length of the requested data.
data_len_ret Length of the received data.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_file_read_alloc ( SshSftFile  handle,
SshSftUInt64  offset,
SshSftUInt64  len,
unsigned char **  data_ret,
SshSftUInt64 data_len_ret,
char **  error_msg_ret 
)

Run READ on open file.

This function reads the data of the file specified by 'handle'. File must be successfully opened with 'ssh_sft_file_open' before it is used. The offset to the file data is given in 'offset'. The length of the data block requested is given in 'len'. The allocated data buffer is returned in 'data_ret'. The length of the buffer is returned in 'data_len_ret'.

Parameters:
handle Handle to opened file.
offset Offset in the file.
len Length of the requested data.
data_ret Returned data buffer.
data_len_ret Returned length of the received data.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_file_remove ( SshSftFile  handle,
char **  error_msg_ret 
)

Run REMOVE on open file.

This function closes and removes the file specified by 'handle'. The 'handle' is also destroyed and cannot be used anymore.

Parameters:
handle Handle to opened file.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_file_write ( SshSftFile  handle,
SshSftUInt64  offset,
char *  data,
SshSftUInt64  data_len,
char **  error_msg_ret 
)

Run WRITE on open file.

This function writes file data to the file specified by 'handle'. File must be successfully opened with 'ssh_sft_file_open' before it is used. The offset to the file is given in 'offset'. The data buffer to be written is given in 'data'. The length of the buffer is given in 'data_len'.

Parameters:
handle Handle to opened file.
offset Offset in the file.
data Data buffer.
data_len Length of the data in the buffer.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_fxp_ext_data ( SshSft  handle,
const char *  ext_data_type,
unsigned char **  ext_data_ret,
size_t *  ext_data_len_ret 
)

Get SFT protocol extension data.

This function gets extension data received from the server. The type of the data is given in string 'ext_data_type'. The data is returned in 'ext_data_ret'. The length of the data is returned in 'ext_data_len'. Extension data is dynamically allocated and must be freed with function 'ssh_sft_data_free'.

Parameters:
handle Handle to SFT session.
ext_data_type Extension data type.
ext_data_ret Returned extension data.
ext_data_len_ret Returned length of the extension data.
Returns:
SshSftError.

SshSftUInt32 ssh_sft_fxp_version ( SshSft  handle  ) 

Get SFT protocol version.

This function returns the negotiated SFTP protocol version.

Parameters:
handle Handle to SFT session.
Returns:
Negotiated SFTP protocol version.

SshSftGlob ssh_sft_glob_create ( char *  glob_string,
char **  root_ret,
int *  depth_ret 
)

Create globbing context.

This function creates globbing context out of 'glob_string'. The root directory, below which globbing is performed is returned in 'root_ret'. The depth of the globbing is returned in 'depth_ret'.

Parameters:
glob_string Globbing string.
root_ret Returned root string.
depth_ret Returned depth.
Returns:
The globbing context.

void ssh_sft_glob_destroy ( SshSftGlob glob  ) 

Free globbing context.

This function frees memory allocated for the globbing context. The pointer is also zeroed.

Parameters:
glob Pointer to globbing context.

SshSftError ssh_sft_hash ( SshSft  handle,
char *  file,
const char *  hash_name,
SshSftUInt64  offset,
size_t  len,
unsigned char **  digest_ret,
size_t *  digest_len_ret,
char **  error_msg_ret 
)

Get HASH of the 'file'.

This functions returns the file data digest of length 'len' from 'offset'. The digest is returned in 'digest_ret' and its length in 'digest_len_ret'. The hash algorithm name is given in 'hash_name'. Supported values for hash algorithm names are: "md5". The memory for the digest is dynamically allocated. It must be freed using 'ssh_sft_data_free' function.

Parameters:
handle Handle to SFT session.
file Absolute path of file.
hash_name Name of the hash algorithm.
offset Offset in the file.
len Length of the data to be hashed.
digest_ret Returned digest.
digest_len_ret Returned length of the digest.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_init ( const char *  crypto_dll_path,
SshSftBoolean  fips_mode,
char **  error_msg_ret 
)

Initialize SFT library (depricated).

The path to an SSH crypto library DLL is given in 'crypto_dll_path'. The cryptographic functions to be used in the SFT library are taken from this DLL only if 'fips_mode' is set. Otherwise static functions are used.

'fips_mode' flag indicates whether the FIPS certification mode is to be used for the cryptographic operations. Note that if 'fips_mode' is TRUE, the DLL in 'crypto_dll_path' (or the static library) must support FIPS mode or this function will fail.

The function returns SshSftError with associated error message in 'error_msg_ret'.

Parameters:
crypto_dll_path Path to crypto DLL plugin.
fips_mode Flag to enable FIPS mode.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_init_2_v ( SshSecShBroker  broker,
SshSftInitParams  init_params,
char **  error_msg_ret,
unsigned int  version 
)

Initialize SFT library.

This function initializes the SFT library. The SFT library must be initialized before it is used.

Parameters:
broker Broker handle obtained from Tectia API.
init_params Parameter structure.
error_msg_ret Returned error message.
Returns:
SshSftError.
You can call the function with broker == NULL and init_params == NULL.

SshSftError ssh_sft_lstat ( SshSft  handle,
char *  file,
SshSftFileAttributes attrs_ret,
char **  error_msg_ret 
)

Run LSTAT on file 'file'.

This function gets the attribute of the file on the remote or local host specified by session 'handle'. If the file is a symbolic link, the link attributes are returned. 'handle' must be successfully opened before it is used. File name with path is given in 'file'. File attributes are returned in 'attrs_ret'. The memory for the attributes is dynamically allocated. It must be freed using 'ssh_sft_file_attrs_free' function.

Parameters:
handle Handle to SFT session.
file Absolute path of the file.
attrs_ret Returned file attributes.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_mkdir ( SshSft  handle,
char *  dir,
SshSftFileAttributes  attrs,
char **  error_msg_ret 
)

Create directory.

The remote or local host of the file is specified by session 'handle'. 'handle' must be successfully opened before it are used. Directory name with path is given in 'dir' and directory attributes, e.g. permissions, in 'attrs'.

Parameters:
handle Handle to SFT session.
dir Absolute path of the directory.
attrs Attributes for the new directory.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_move_dir ( SshSft  src_handle,
char *  src_dir,
SshSft  dst_handle,
char *  dst_dir,
SshSftGlob  glob,
int  max_depth,
SshSftProgressCB  progress_cb,
void *  progress_cb_ctx,
SshSftProgressCtxCreateCB  progress_cb_ctx_create_cb,
SshSftProgressCtxDestroyCB  progress_cb_ctx_destroy_cb,
SshSftMessageCB  message_cb,
void *  message_cb_ctx,
char **  error_msg_ret 
)

Move directory.

This function is the same as 'ssh_sft_copy_dir' except that the source directory is remove after successful directory copy.

Parameters:
src_handle Handle to source SFT session.
src_dir Absolute path of the source directory.
dst_handle Handle to destination SFT session.
dst_dir Absolute path of the destination directory.
glob Globbing context.
max_depth Maximum depth of directory traversal.
progress_cb Progress callback function pointer.
progress_cb_ctx Progress callback context.
progress_ctx_create_cb Progress callback context create function pointer.
progress_ctx_destroy_cb Progress callback context destroy function pointer.
message_cb Message callback function pointer.
message_cb_ctx Message callback context.
error_msg_ret Returned error message.
Returns:
SshSftError.

void ssh_sft_name_free ( char **  name  ) 

Free name.

This function frees name that was allocated by SFT API function. The pointer is also zeroed.

Parameters:
name Pointer to name pointer.

SshSftError ssh_sft_open ( SshSftParam  param,
const char *  broker_addr,
const char *  user,
const char *  host,
const char *  port,
SshSecShBrokerAuthCb  auth_cb,
void *  auth_cb_ctx,
SshSft handle_ret,
char **  error_msg_ret 
)

Open SFT session to "user@host:port".

The SFT session can be configured by giving suitable values in 'param'. The broker can be identified with 'broker_addr'. The function returns a handle to the session in 'handle_ret'. The returned handle must be used in all succeeding file operations. If 'host' is NULL, session to local file access is opened.

All calls of this function must receive the same broker address. If some call receives different address than previous calls the function will fail with error: SSH_SFT_ERROR_ILLEGAL_PARAMETER.

Parameters:
param SFT parameters.
broker_addr Broker address string.
user Username string.
host Hostname string.
port Port number in a string.
auth_cb Pointer to function that is used by the Broker to request authentication.
auth_cb_ctx Context given to Broker authentication function.
handle_ret Returned handle to SFT session.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_open_window ( SshSftParam  param,
const char *  broker_addr,
const char *  user,
const char *  host,
const char *  port,
SshSecShBrokerAuthCb  auth_cb,
void *  auth_cb_ctx,
SshSft handle_ret,
char **  error_msg_ret,
void *  window 
)

Open SFT session to "user@host:port".

The SFT session can be configured by giving suitable values in 'param'. The broker can be identified with 'broker_addr'. The function returns a handle to the session in 'handle_ret'. The returned handle must be used in all succeeding file operations. If 'host' is NULL, session to local file access is opened.

Behavior of this function is the same as ssh_sft_open.

Parameters:
param SFT parameters.
broker_addr Broker address string.
user Username string.
host Hostname string.
port Port number in a string.
auth_cb Pointer to function that is used by the Broker to request authentication.
auth_cb_ctx Context given to Broker authentication function.
handle_ret Returned handle to SFT session.
error_msg_ret Returned error message.
window Deprecated.
Returns:
SshSftError.

SshSftError ssh_sft_open_with_connection ( SshSftParam  param,
unsigned int  connection_id,
void *  window,
SshSft handle_ret,
char **  error_msg_ret 
)

Open SFT session over an existing connection

Parameters:
param SFT parameters.
connection_id Preopened connection.
window Deprecated.
handle_ret Returned handle to SFT session.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_readlink ( SshSft  handle,
char *  link,
char **  file_ret,
char **  error_msg_ret 
)

Run READLINK on symbolic link 'link'.

The remote or local host of the link is specified by session 'handle'. 'handle' must be successfully opened before it are used. Link name with path is given in 'link'. The real name of the file the link points to is returned in 'file_ret'. The memory for the file name is dynamically allocated and must be freed using 'ssh_sft_name_free' function.

Parameters:
handle Handle to SFT session.
link Absolute path of the link.
file_ret Returned absolute path of the resolved file/directory.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_realpath ( SshSft  handle,
char *  file,
char **  path_ret,
char **  error_msg_ret 
)

Resolve absolute path of 'file'.

The remote or local host of the link is specified by session 'handle'. 'handle' must be successfully opened before it are used. File name with path is given in 'file'. The absolute path of 'file' is returned in 'path_ret'. The memory for the path name is dynamically allocated and must be freed using 'ssh_sft_name_free' function.

Parameters:
handle Handle to SFT session.
file Absolute path of the file.
path_ret Returned absolute path of the resolved file/directory.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_remove ( SshSft  handle,
char *  file,
char **  error_msg_ret 
)

Remove file.

The remote or local host of the file is specified by session 'handle'. 'handle' must be successfully opened before it are used. File name with path is given in 'file'.

Parameters:
handle Handle to SFT session.
file Absolute path of the file.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_remove_dir ( SshSft  handle,
char *  dir,
SshSftGlob  glob,
int  max_depth,
SshSftMessageCB  message_cb,
void *  message_cb_ctx,
char **  error_msg_ret 
)

Remove directory recursively.

The remote or local host of the directory is specified by session 'handle'. 'handle' must be successfully opened before it are used. Directory name with path is given in 'dir'.

'glob' context is used for globbing. 'max_depth' specifies the maximum depth of the directory traversal. If 'max_depth' is set to 0, the whole directory is removed recursively. 'message_cb' and 'message_cb_ctx' are used for informing the caller about different actions.

Parameters:
handle Handle to SFT session.
dir Absolute path of the directory.
glob Globbing context.
max_depth Maximum depth of directory traversal.
message_cb Message callback function pointer.
message_cb_ctx Message callback context.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_rename ( SshSft  handle,
char *  old_file,
char *  new_file,
char **  error_msg_ret 
)

Rename file.

Old file name with path is given in 'old_file'. New file name with path is given in 'new_file'. File is renamed in the remote or local host specified by session 'handle'. 'handle' must be successfully opened before it is used.

Parameters:
handle Handle to SFT session.
old_file Absolute path of the old file.
new_file Absolute path of the new file.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_resume ( SshSft  handle,
char **  error_msg_ret 
)

Resume operation.

The ongoing operations can be resumed with this function. 'handle' specifies the session that is resumed. If the session is not suspended, this function does nothing.

Parameters:
handle Handle to SFT session.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_rmdir ( SshSft  handle,
char *  dir,
char **  error_msg_ret 
)

Remove directory.

The remote or local host of the file is specified by session 'handle'. 'handle' must be successfully opened before it are used. Directory name with path is given in 'dir'. The directory must be empty for the operation to succeed.

Parameters:
handle Handle to SFT session.
dir Absolute path of the directory.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_setstat ( SshSft  handle,
char *  file,
SshSftFileAttributes  attrs,
char **  error_msg_ret 
)

Run SETSTAT on file 'file'.

The remote or local host of the file is specified by session 'handle'. 'handle' must be successfully opened before it are used. File name with path is given in 'file'. File attributes are given in 'attrs'.

Parameters:
handle Handle to SFT session.
file Absolute path of the file.
attrs File attributes.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_setstat_dir ( SshSft  handle,
char *  dir,
SshSftGlob  glob,
int  max_depth,
SshSftUInt32  permissions,
SshSftSetstatMode  mode,
SshSftMessageCB  message_cb,
void *  message_cb_ctx,
char **  error_msg_ret 
)

Run SETSTAT on directory 'dir'.

This function sets file and directory modes recursively.

'glob' context is used for globbing. If 'glob' is NULL, no globbing is used. 'max_depth' specifies the maximum depth of the directory traversal. If 'max_depth' is set to 0, the whole directory is set recursively. 'permissions' is the desired permissions in UNIX format for the files and directories. 'mode' specifies how the permissions are applied to the entry. 'message_cb' and 'message_cb_ctx' are used for informing the caller about different actions.

Parameters:
handle Handle to SFT session.
dir Absolute path of the directory.
glob Globbing context.
max_depth Maximum depth of directory traversal.
permissions Desired permissions.
mode Mode of how permissions are applied.
message_cb Message callback function pointer.
message_cb_ctx Message callback context.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_stat ( SshSft  handle,
char *  file,
SshSftFileAttributes attrs_ret,
char **  error_msg_ret 
)

Run STAT on file 'file'.

This function gets the attributes of the file on the remote or local host specified by session 'handle'. 'handle' must be successfully opened before it is used. File name with path is given in 'file'. File attributes are returned in 'attrs_ret'. The memory for the attributes is dynamically allocated. It must be freed using 'ssh_sft_file_attrs_free' function.

Parameters:
handle Handle to SFT session.
file Absolute path of the file.
attrs_ret Returned file attributes.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_stat_dir ( SshSft  handle,
char *  dir,
SshSftGlob  glob,
int  max_depth,
SshSftDirSortFlags  sort_flags,
SshSftMessageCB  message_cb,
void *  message_cb_ctx,
char **  error_msg_ret 
)

Run STAT on directory 'dir'.

This function gets file and directory attributes recursively. 'glob' context is used for globbing. If 'glob' is NULL, no globbing is done. 'max_depth' specifies the maximum depth of the directory traversal. If 'max_depth' is set to 0, the whole directory is listed recursively. 'sort_flags' specify the sort order of the directory listing (SSH_SFT_DIR_FLAG_SORT_NAME or SSH_SFT_DIR_FLAG_SORT_SIZE combined with SSH_SFT_DIR_FLAG_SORT_REVERSE). The name and attributes of each entry are returned to the user using 'message_cb' function.

Parameters:
handle Handle to SFT session.
dir Absolute path of the directory.
glob Globbing context.
max_depth Maximum depth of directory traversal.
sort_flags Flags to specify sort order.
message_cb Message callback function pointer.
message_cb_ctx Message callback context.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_suspend ( SshSft  handle,
char **  error_msg_ret 
)

Suspend operation.

The ongoing operations can be suspended with this function. 'handle' specifies the session that is suspended. If the session is already suspended, this function does nothing.

Parameters:
handle Handle to SFT session.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_symlink ( SshSft  handle,
char *  target,
char *  link,
char **  error_msg_ret 
)

Create symbolic link.

This function creates symbolic link of name 'link'. The link points to 'target'. Symbolic link is created in the remote or local host specified by session 'handle'. 'handle' must be successfully opened before it is used.

Parameters:
handle Handle to SFT session.
target Absolute path of the target file/directory.
link Absolute path of the link.
error_msg_ret Returned error message.
Returns:
SshSftError.

SshSftError ssh_sft_truncate ( SshSft  handle,
char *  file,
SshSftUInt64  size,
char **  error_msg_ret 
)

Truncate file 'file'.

This function truncates the file on the remote or local host specified by session 'handle'. 'handle' must be successfully opened before it is used. File name with path is given in 'file'.

Parameters:
handle Handle to SFT session.
file Absolute path of the file.
size New size of the file.
error_msg_ret Returned error message.
Returns:
SshSftError.

void ssh_sft_uninit ( void   ) 

Uninitialize SFT library.

The SFT library must be uninitialized after it has been used.