forked from superflexible/TGPuttyLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tgputtylibvcclass.h
130 lines (114 loc) · 5.9 KB
/
tgputtylibvcclass.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#pragma once
#include <string>
#include <stdexcept>
#include <functional>
#include "ctgputtylib.h"
typedef std::function<void(const char* Msg, const bool isstderr)> TOnMessage;
typedef std::function<bool(const __int64 bytescopied, const bool isupload)> TOnProgress;
typedef std::function<bool(const struct fxp_names* names)> TOnListing;
typedef std::function<bool(char* linebuf, const int maxchars)> TOnGetInput;
typedef std::function<bool(const char* host, const int port,const char* fingerprint, const int verificationstatus, bool& storehostkey)> TOnVerifyHostKey;
static const int MinimumLibraryBuildNum = 0x1;
static const short cDummyClearedErrorCode = short(-1000); // this error code means there was no real error code
class TTGPuttySFTPException : public std::runtime_error
{
public:
explicit TTGPuttySFTPException(const std::string what_arg) : std::runtime_error(what_arg) { };
};
class TTGPuttySFTP
{
public:
TTGLibraryContext Fcontext;
bool FVerbose;
std::string FHostName;
std::string FUserName;
std::string FPassword;
std::string FKeyPassword;
int FPort;
TOnMessage FOnMessage;
TOnProgress FOnProgress;
TOnListing FOnListing;
TOnGetInput FOnGetInput;
TOnVerifyHostKey FOnVerifyHostKey;
//System::Classes::TStream* FUploadStream;
//System::Classes::TStream* FDownloadStream;
bool FConnected;
int FPasswordAttempts;
std::string FLastMessages;
char* GetHomeDir();
char* GetWorkDir();
void SetVerbose(const bool Value);
void SetKeyfile(const char* Value);
const int GetPort() { return FPort; }
void SetPort(const int Value) { FPort = Value; }
const std::string GetHostName() { return FHostName; }
void SetHostName(const std::string Value) { FHostName = Value; }
const std::string GetPassword() { return FPassword; }
void SetPassword(const std::string Value) { FPassword = Value; }
const std::string GetUserName() { return FUserName; }
void SetUserName(const std::string Value) { FUserName = Value; }
const std::string GetKeyPassword() { return FKeyPassword; }
void SetKeyPassword(const std::string Value) { FKeyPassword = Value; }
const std::string GetLastMessages() { return FLastMessages; }
void SetLastMessages(const std::string Value) { FLastMessages = Value; }
TOnMessage GetOnMessage() { return FOnMessage; }
void SetOnMessage(TOnMessage AnOnMessage) { FOnMessage = AnOnMessage; }
TOnProgress GetOnProgress() { return FOnProgress; }
void SetOnProgress(TOnProgress AnOnProgress) { FOnProgress = AnOnProgress; }
TOnListing GetOnListing() { return FOnListing; }
void SetOnListing(TOnListing AnOnListing) { FOnListing = AnOnListing; }
TOnGetInput GetOnGetInput() { return FOnGetInput; }
void SetOnGetInput(TOnGetInput AnOnGetInput) { FOnGetInput = AnOnGetInput; }
TOnVerifyHostKey GetOnVerifyHostKey() { return FOnVerifyHostKey; }
void SetOnVerifyHostKey(TOnVerifyHostKey AnOnVerifyHostKey) { FOnVerifyHostKey = AnOnVerifyHostKey; }
char* GetLibVersion();
int GetErrorCode();
const char* GetErrorMessage();
TTGPuttySFTP(const bool verbose);
virtual ~TTGPuttySFTP();
void ClearStatus();
std::string MakePSFTPErrorMsg(const char* where);
void Connect();
void Disconnect();
void ChangeDir(const char* ADirectory);
void MakeDir(const char* ADirectory);
void RemoveDir(const char* ADirectory);
void ListDir(const char* ADirectory);
void GetStat(const char* AFileName, Tfxp_attrs* Attrs);
void SetStat(const char* AFileName, struct fxp_attrs* Attrs);
void SetModifiedDate(const char* AFileName, const unsigned long unixtime);
void SetFileSize(const char* AFileName, const __int64 ASize);
void Move(const char* AFromName, const char* AToName);
void Delete_File(const char *AName);
void UploadFile(const char* ALocalFilename, const char* ARemoteFilename, const bool anAppend);
void DownloadFile(const char* ARemoteFilename, const char* ALocalFilename, const bool anAppend);
//void UploadStream(const char *ARemoteFilename, System::Classes::TStream* const AStream, const bool anAppend);
//void DownloadStream(const char *ARemoteFilename, System::Classes::TStream* const AStream, const bool anAppend);
void* OpenFile(const char* apathname, const int anopenflags, const Pfxp_attrs attrs);
int CloseFile(struct fxp_handle*& fh);
void* xfer_upload_init(struct fxp_handle* fh, const unsigned __int64 offset);
bool xfer_upload_ready(struct fxp_xfer* xfer);
void xfer_upload_data(struct fxp_xfer* xfer, char* buffer, const int len, const unsigned __int64 anoffset);
bool xfer_ensuredone(struct fxp_xfer* xfer);
bool xfer_done(struct fxp_xfer* xfer);
void xfer_cleanup(struct fxp_xfer* xfer);
__declspec(property(get = GetHostName, put = SetHostName)) std::string HostName;
__declspec(property(get = GetuserName, put = SetUserName)) std::string UserName;
__declspec(property(get = GetPort, put = SetPort)) int Port;
__declspec(property(get = GetPassword, put = SetPassword)) std::string Password;
__declspec(property(get = GetKeyPassword, put = SetKeyPassword)) std::string KeyPassword;
__declspec(property(get = GetHomeDir)) char* HomeDir;
__declspec(property(get = GetWorkDir)) char* WorkDir;
__declspec(property(get = GetLibVersion)) char* LibVersion;
__declspec(property(get = GetConnected)) bool Connected;
__declspec(property(get = GetVerbose, put = SetSetVerbose)) bool Verbose;
__declspec(property(put = SetKeyfile)) char* Keyfile;
__declspec(property(get = GetLastMessages, put = SetLastMessages)) std::string LastMessages;
__declspec(property(get = GetErrorCode)) int ErrorCode;
__declspec(property(get = GetErrorMessage)) const char* ErrorMessage;
__declspec(property(get = GetOnMessage, put = SetOnMessage)) TOnMessage OnMessage;
__declspec(property(get = GetOnProgress, put = SetOnProgress)) TOnProgress OnProgress;
__declspec(property(get = GetOnListing, put = SetOnListing)) TOnListing OnListing;
__declspec(property(get = GetOnGetInput, put = SetOnGetInput)) TOnGetInput OnGetInput;
__declspec(property(get = GetOnVerifyHostKey, put = SetOnVerifyHostKey)) TOnVerifyHostKey OnVerifyHostKey;
};