Back to product page
- Introduction
- Overview
- License agreement
- Classes
- Enumerations
- wodSFTPdll
- Create function
- Destroy function
- Methods
- Abort
- About
- AppendData
- AppendDataLen
- AppendFile
- Connect
- DeleteFile
- DeleteFiles
- Disconnect
- ExtendedCmd
- GetAttributes
- GetData
- GetDataAt
- GetDataToBuffer
- GetDataToBufferAt
- GetFile
- GetFileAt
- GetFiles
- ListAttributes
- ListDir
- ListNames
- LoadPrivateKey
- LoopFiles
- MakeDir
- PutData
- PutDataAt
- PutDataLen
- PutDataLenAt
- PutFile
- PutFileAt
- PutFiles
- RealPath
- RemoteClose
- RemoteOpen
- RemoteRead
- RemoteWrite
- RemoveDir
- Rename
- SetAttributes
- Properties
- Authentication
- Blocking
- BufferSize
- ClientName
- Compression
- Encryption
- EncryptionList
- ErrorText
- Extensions
- FIPS
- HMacList
- Hostname
- KeyExchangeList
- KeySignatureList
- LastError
- ListItem
- LocalPath
- Login
- MaxTransferRate
- MyHostname
- MyIP
- Password
- Port
- PrivateKey
- ProxyHostname
- ProxyLogin
- ProxyPassword
- ProxyPort
- ProxyType
- RemoteIdentification
- RemotePath
- Resume
- ServerErrorCode
- ServerErrorText
- State
- StateText
- Timeout
- Timezone
- TransferMode
- TransferRate
- TransferTime
- UseIPv6
- Version
- Callbacks
- How to get support
- Using callbacks
- Technical information
- Error list
Using callbacks
Instead of having events as implemented in the ActiveX component, the wodSFTP API library provides callbacks that can be defined in your code. All the callbacks are held inside the SftpEventsStruct structure, which is defined as
typedef struct SftpEventsStruct
{
void (*Connected)(void *Sftp, short ErrorCode, char *ErrorText);
void (*Disconnected)(void *Sftp);
void (*StateChange)(void *Sftp, long OldState);
void (*HostFingerprint)(void *Sftp, char *Fingerprint, int *Accept);
void (*Progress)(void *Sftp, long Position, long Total);
void (*ListItems)(void *Sftp, char *FileInfo);
void (*Done)(void *Sftp, short ErrorCode, char *ErrorText);
void (*Attributes)(void *Sftp, long Size, long Uid, long Gid, long Permissions, double AccessTime, double ModificationTime);
void (*CryptoInformation)(void *Sftp, char *Protocol, char *RemoteName, char *SCcipher, char *CScipher, char *Keys, BOOL *Accept);
void (*AttributesData)(void *Sftp, int Count, WIN32_FIND_DATA **Items);
void (*LoginChallenge)(void *Sftp, char *Request, char **Response);
void (*LoopItem)void *Sftp, char *LocalFile, char *RemoteFile, DirItemTypes ItemType, int *Skip);
void (*LoopError)(void *Sftp, char *LocalFile, char *RemoteFile, DirItemTypes ItemType, long *ErrorCode, char *ErrorText);
void (*RemoteData)(void *Sftp, char *Data, int Length);
void (*ExtendedCmdReply)(void *Sftp, char *Data, int Length);
} SftpEventsStruct;
To initialize these events, you need to create your own implementations for these functions, set proper values in the created structure and pass that structure to the Sftp_Create function. Sftp_Create will initialize callbacks and hook them up to the code. When an "event" needs to be called, your callback implementation will be invoked instead. If you don't need an event - just set its value to NULL and wodSFTP will never call it. Example: - if you don't need events in your code at all, then don't set them - call Sftp_Create with a NULL parameter
int main(int argc, char* argv[])
{
void *handle;
handle = Sftp_Create(NULL, your_license_key);
......
}
- if you only need the Done event, then implement it like so:
void SftpDone(void *Sftp, short ErrorCode, char *ErrorText)
{
MessageBox(NULL,"We're DONE!", "wodSFTP", MB_OK);
return;
}
create the proper structure
int main(int argc, char* argv[])
{
void *handle;
SftpEventsStruct mystruct;
memset(&mystruct, 0, sizeof(mystruct));
....
set the Done callback in the structure
mystruct.Done = SftpDone;
and pass this value to the Sftp_Create function
handle = Sftp_Create(&mystruct, your_license_key); that's all!
typedef struct SftpEventsStruct
{
void (*Connected)(void *Sftp, short ErrorCode, char *ErrorText);
void (*Disconnected)(void *Sftp);
void (*StateChange)(void *Sftp, long OldState);
void (*HostFingerprint)(void *Sftp, char *Fingerprint, int *Accept);
void (*Progress)(void *Sftp, long Position, long Total);
void (*ListItems)(void *Sftp, char *FileInfo);
void (*Done)(void *Sftp, short ErrorCode, char *ErrorText);
void (*Attributes)(void *Sftp, long Size, long Uid, long Gid, long Permissions, double AccessTime, double ModificationTime);
void (*CryptoInformation)(void *Sftp, char *Protocol, char *RemoteName, char *SCcipher, char *CScipher, char *Keys, BOOL *Accept);
void (*AttributesData)(void *Sftp, int Count, WIN32_FIND_DATA **Items);
void (*LoginChallenge)(void *Sftp, char *Request, char **Response);
void (*LoopItem)void *Sftp, char *LocalFile, char *RemoteFile, DirItemTypes ItemType, int *Skip);
void (*LoopError)(void *Sftp, char *LocalFile, char *RemoteFile, DirItemTypes ItemType, long *ErrorCode, char *ErrorText);
void (*RemoteData)(void *Sftp, char *Data, int Length);
void (*ExtendedCmdReply)(void *Sftp, char *Data, int Length);
} SftpEventsStruct;
To initialize these events, you need to create your own implementations for these functions, set proper values in the created structure and pass that structure to the Sftp_Create function. Sftp_Create will initialize callbacks and hook them up to the code. When an "event" needs to be called, your callback implementation will be invoked instead. If you don't need an event - just set its value to NULL and wodSFTP will never call it. Example: - if you don't need events in your code at all, then don't set them - call Sftp_Create with a NULL parameter
int main(int argc, char* argv[])
{
void *handle;
handle = Sftp_Create(NULL, your_license_key);
......
}
- if you only need the Done event, then implement it like so:
void SftpDone(void *Sftp, short ErrorCode, char *ErrorText)
{
MessageBox(NULL,"We're DONE!", "wodSFTP", MB_OK);
return;
}
create the proper structure
int main(int argc, char* argv[])
{
void *handle;
SftpEventsStruct mystruct;
memset(&mystruct, 0, sizeof(mystruct));
....
set the Done callback in the structure
mystruct.Done = SftpDone;
and pass this value to the Sftp_Create function
handle = Sftp_Create(&mystruct, your_license_key); that's all!