-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathFtp.h
83 lines (66 loc) · 2.09 KB
/
Ftp.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
// Ftp.h: interface for the CFtp class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FTP_H__71290CDE_05DC_44BC_9230_34C09BE43FEA__INCLUDED_)
#define AFX_FTP_H__71290CDE_05DC_44BC_9230_34C09BE43FEA__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include <winsock.h>
#define MAX_LINE_LEN 1024
#define STATUS_SUCCESS 0
#define STATUS_ERROR 1
#define STATUS_FAILED 2
#define SERVER_PORT 21
class CFtp
{
public:
int PWD();
int MakeDir(const char *lpszDir);
int RemoveDir(const char *lpszDir);
int Port(const char *lpszHost, unsigned short uPort = SERVER_PORT);
int Quit();
int Passive();
int NOOP();
int CDUP();
int ChangeWorkingDir(const char *lpszWorkingDir);
int DeleteFile(const char *lpszFilePath);
int Abort();
int Help();
int SetType(char chType);
int Login(const char *lpszUserName, const char *lpszPassword);
void GetIPandPort();
int List();
void SetControlFunc(void *pVoidData, BOOL (*pfn)(void *pVoidData, const char *lpszBuf));
void SetDataFunc(void *pVoidData, BOOL (*pfn)(void *pVoidData, const char *lpszBuf));
SOCKET GetCtrlSocket() {return m_socketCtrl;};
void SetCtrlSocket(SOCKET socket) {m_socketCtrl = socket;};
SOCKET GetDataSocket(){return m_socketData;};
void SetDataSocket(SOCKET socket){m_socketData = socket;};
public:
int CWD(CString str);
CFtp();
virtual ~CFtp();
int ConnectToServer(const char *lpszServerIP, unsigned short uPort = 21);
public:
DWORD m_dwTransDirectionFlag;
char m_szBuf[MAX_LINE_LEN];
protected:
SOCKET m_socketCtrl;
SOCKET m_socketData;
char m_szDataIP[20];
unsigned short m_uDataPort;
char *m_pData;
DWORD m_dwDataBufSize;
DWORD m_dwDataCount;
BOOL (*m_pControlFunc)(void *pVoidData, const char *lpszBuf);
BOOL (*m_pDataFunc)(void *pVoidData, const char *lpszBuf);
void *m_pControlFuncData;
void *m_pDataFuncData;
private:
int RecvBuffer();
int SendBuffer();
int CheckReplyCode(const char *lpszBuf = NULL);
int SendGeneralCommand(BOOL bCanWait = FALSE);
};
#endif // !defined(AFX_FTP_H__71290CDE_05DC_44BC_9230_34C09BE43FEA__INCLUDED_)