Subversion Repositories tpanel

Rev

Rev 120 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 120 Rev 137
Line 23... Line 23...
23
 ***************************************************************************/
23
 ***************************************************************************/
24
 
24
 
25
#ifndef FTPLIB_H
25
#ifndef FTPLIB_H
26
#define FTPLIB_H
26
#define FTPLIB_H
27
 
27
 
-
 
28
#include <functional>
-
 
29
#include <string>
-
 
30
 
28
#include <unistd.h>
31
#include <unistd.h>
29
#include <sys/time.h>
32
#include <sys/time.h>
30
 
33
 
31
#ifdef NOLFS
34
#ifdef NOLFS
32
#define off64_t long
35
#define off64_t long
Line 67... Line 70...
67
typedef void (*FtpCallbackLog)(char *str, void* arg, bool out);
70
typedef void (*FtpCallbackLog)(char *str, void* arg, bool out);
68
typedef void (*FtpCallbackError)(char *str, void* arg, int err);
71
typedef void (*FtpCallbackError)(char *str, void* arg, int err);
69
//SSL
72
//SSL
70
typedef bool (*FtpCallbackCert)(void *arg, X509 *cert);
73
typedef bool (*FtpCallbackCert)(void *arg, X509 *cert);
71
 
74
 
-
 
75
#define LOG_INFO        1
-
 
76
#define LOG_WARNING     2
-
 
77
#define LOG_ERROR       3
-
 
78
#define LOG_TRACE       4
-
 
79
#define LOG_DEBUG       5
72
 
80
 
73
struct ftphandle
81
struct ftphandle
74
{
82
{
75
    char *cput,*cget;
83
    char *cput,*cget;
76
    int handle;
84
    int handle;
Line 176... Line 184...
176
        int RawRead(void* buf, int max, ftphandle* handle);
184
        int RawRead(void* buf, int max, ftphandle* handle);
177
        // SSL
185
        // SSL
178
        int SetDataEncryption(dataencryption enc);
186
        int SetDataEncryption(dataencryption enc);
179
        int NegotiateEncryption();
187
        int NegotiateEncryption();
180
        void SetCallbackCertFunction(FtpCallbackCert pointer);
188
        void SetCallbackCertFunction(FtpCallbackCert pointer);
-
 
189
        // Register callback for logging
-
 
190
        void regLogging(std::function<void (int level, const std::string& msg)> Logging) { _Logging = Logging; }
181
 
191
 
182
    private:
192
    private:
183
        ftphandle* mp_ftphandle;
193
        ftphandle* mp_ftphandle;
184
 
194
 
185
        int FtpXfer(const char *localfile, const char *path, ftphandle *nControl, accesstype type, transfermode mode);
195
        int FtpXfer(const char *localfile, const char *path, ftphandle *nControl, accesstype type, transfermode mode);
Line 197... Line 207...
197
        int readresp(char c, ftphandle *nControl);
207
        int readresp(char c, ftphandle *nControl);
198
        void sprint_rest(char *buf, off64_t offset);
208
        void sprint_rest(char *buf, off64_t offset);
199
        void ClearHandle();
209
        void ClearHandle();
200
        int CorrectPasvResponse(unsigned char *v);
210
        int CorrectPasvResponse(unsigned char *v);
201
        void errorHandler(const char *stub, int err, int line);
211
        void errorHandler(const char *stub, int err, int line);
-
 
212
        // Logging
-
 
213
        void Log(int level, const std::string& msg);
-
 
214
        // Callback for logging
-
 
215
        std::function<void (int level, const std::string& msg)> _Logging{nullptr};
202
    };
216
    };
203
 
217
 
204
#endif
218
#endif