-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathasync-ftp-client.h
88 lines (88 loc) · 3.25 KB
/
async-ftp-client.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
#include<winsock.h>
#define CMD_SIZE 128
#define RPLY_SIZE MTU_SIZE
#define MAXNULPUT 1048576
/*FTP commands with arguments*/
#define CWD 1
#define DELE 2
#define PASS 3
#define PORT 4
#define RETR 5
#define STOR 6
#define TYPE 7
#define USER 8
/*FTP commands without arguments*/
#define ABOR 9
#define LIST 10
#define PWD 11
#define QUIT 12
/*FTP command strings*/
extern LPSTR aszFtpCmd[13];
/*Application states*/
#define NOT_CONNECTED 0
#define CTRLCONNECTED 2
#define DATACONNECTED 4
/*Global variables*/
extern char szAppName[];
extern BOOL nAppState; /*Application state*/
extern BOOL bToNul; /*get to NUL device file*/
extern BOOL bIOBeep; /*beep on FD_READ and FD_WRITE */
extern BOOL bDebug; /*debug output to WinDebug*/
extern BOOL bReAsync; /*call WSAAsyncSelect after accept*/
extern BOOL bLogFile; /*write commands and replies to log file*/
extern SOCKET hCtrlSock; /* FTP control socket */
extern SOCKET hLstnSock; /*listening data socket*/
extern SOCKET hDataSock; /*connected data socket*/
extern char szHost[MAXHOSTNAME]; /*remote host name or address*/
extern char szUser[MAXUSERNAME]; /*user ID*/
extern char szPwrd[MAXPASSWORD]; /*user password*/
extern SOCKADDR_IN stCLclName; /*Control socket name (local) */
extern SOCKADDR_IN stCRmtName; /*control socket name (Remote) */
extern SOCKADDR_IN stDLclName; /*data socket name (local client) */
extern SOCKADDR_IN stDRmtName; /*data socket name (remote client)*/
extern char achInBuf[INPUT_SIZE]; /*network input data buffer*/
extern char achOutBuf[INPUT_SIZE]; /*netwotk output buffer*/
extern char szFtpRply[RPLY_SIZE]; /*FTP reply (input) buffer*/
extern char szDataFile[MAXFILENAME]; /*file name*/
extern char szFtpCmd[CMD_SIZE]; /*FTP Command buffer*/
extern char achRplyBuf[BUF_SIZE]; /*reply display buffer*/
typedef struct stFtpCmd
{
int nFtpCmd; /*FTP command value*/
char szFtpParm[CMD_SIZE]; /*FTP parameter string*/
}
FTPCMD;
#define MAX_CMDS 4
/*first one (index=0) is awaiting a reply,
second one (index=1) is next to be sent */
extern FTPCMD astFtpCmd[MAX_CMDS]; /*FTP command queue*/
extern int nQLen; /*number entries in FTP command queue*/
extern int nFtpRplyCode; /*FTP reply code from server*/
extern int iNextRply; /*index to next reply string*/
extern int iLastRply;
extern HFILE hDataFile; /*file handle for open data file*/
extern LONG lStartTime; /*start time for data transfer*/
extern LONG lByteCount;
extern char szLogFile[]; /*FTP command and reply log file*/
extern HFILE hLogFile;
/*Function prototypes*/
BOOL CALLBACK Dlg_Main (HWND,UINT,UINT,LPARAM); /*Dialog procedures*/
BOOL CALLBACK Dlg_Login (HWND,UINT,UINT,LPARAM);
BOOL CALLBACK Dlg_File (HWND,UINT,UINT,LPARAM);
BOOL CALLBACK Dlg_Options (HWND,UINT,UINT,LPARAM);
BOOL CALLBACK Dlg_About (HWND,UINT,UINT,LPARAM);
SOCKET InitCtrlConn(PSOCKADDR_IN,HWND,u_int); /*control connection*/
BOOL QueueFtpCmd(int,LPSTR);
int SendFtpCmd(void);
void AbortFtpCmd(void);
int RecvFtpRply(SOCKET,LPSTR,int);
void ProcessFtpRply(LPSTR,int);
SOCKET InitDataConn(PSOCKADDR_IN,HWND,u_int); /*data connection*/
SOCKET AcceptDataConn(SOCKET,PSOCKADDR_IN);
long SendData(SOCKET*,HFILE,int);
int RecvData(SOCKET,HFILE,LPSTR,int);
void EndData(void);
int CloseConn(SOCKET*,LPSTR,int,HWND);
void not_connected(void); /*utility function*/
HFILE CreateLclFile(LPSTR);
/*end of async-ftp-client.h */