Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
ftp.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
4**
5** This program is free software: you can redistribute it and/or modify
6** it under the terms of the GNU General Public License as published by
7** the Free Software Foundation, either version 3 of the License, or
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
15** You should have received a copy of the GNU General Public License
16** along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19// ftp.h : Declaration of the Cftp
20
21#ifndef __FTP_H_
22#define __FTP_H_
23
24
25//#include "../resource.h" // main symbols
26
27#include "winsock.h"
28#include "stdio.h"
29
30#include "WWDownload/ftpdefs.h"
31
32// FTP server return codes. See RFC 959
33
34#define FTPREPLY_SERVEROK 220
35#define FTPREPLY_PASSWORD 331
36#define FTPREPLY_LOGGEDIN 230
37#define FTPREPLY_PORTOK 200
38#define FTPREPLY_TYPEOK 200
39#define FTPREPLY_RESTARTOK 350
40#define FTPREPLY_CWDOK 250
41#define FTPREPLY_OPENASCII 150
42#define FTPREPLY_OPENBINARY 150
43#define FTPREPLY_COMPLETE 226
44#define FTPREPLY_CONTROLCLOSED 421
45
46// Temporary download file name
47
48#define FTP_TEMPFILENAME "..\\__~DOWN_L~D"
49
50
52// Cftp
53class Cftp
54{
55private:
56 friend class CDownload;
57
58 int m_iCommandSocket; // Socket for commands
59 int m_iDataSocket; // Socket for data
60
61 struct sockaddr_in m_CommandSockAddr; // Address for commands
62 struct sockaddr_in m_DataSockAddr; // Address for data
63
64 int m_iFilePos; // Byte offset into file
65 int m_iBytesRead; // Number of bytes downloaded
66 int m_iFileSize; // Total size of the file
67 char m_szRemoteFilePath[128];
68 char m_szRemoteFileName[128];
69 char m_szLocalFilePath[128];
70 char m_szLocalFileName[128];
71 char m_szServerName[128];
72 char m_szUserName[128];
73 char m_szPassword[128];
74 FILE * m_pfLocalFile;
75 int m_iStatus;
76
77 int m_sendNewPortStatus;
78 int m_findStart;
79
80 int SendData( char * pData, int iSize );
81 int RecvData( char * pData, int iSize );
82 int SendNewPort();
83 int OpenDataConnection();
84 void CloseDataConnection();
85 int AsyncGetHostByName( char * szName, struct sockaddr_in &address );
86
87 // Convert a local filename into a temp filename to download into
88 void GetDownloadFilename( const char* localname, char* downloadname);
89
90 void CloseSockets(void);
91 void ZeroStuff(void);
92
93
94public:
95 Cftp();
96 virtual ~Cftp();
97
98public:
99 HRESULT ConnectToServer(LPCSTR szServerName);
100 HRESULT DisconnectFromServer();
101
102 HRESULT LoginToServer( LPCSTR szUserName, LPCSTR szPassword );
103 HRESULT LogoffFromServer( void );
104
105 HRESULT FindFile( LPCSTR szRemoteFileName, int * piSize );
106
107 HRESULT FileRecoveryPosition( LPCSTR szLocalFileName, LPCSTR szRegistryRoot );
108 HRESULT RestartFrom( int i ) { m_iFilePos = i; return FTP_SUCCEEDED; };
109
110 HRESULT GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead );
111
112 HRESULT RecvReply( LPCSTR pReplyBuffer, int iSize, int * piRetCode );
113 HRESULT SendCommand( LPCSTR pCommand, int iSize );
114
115};
116
117#endif //__FTP_H_
#define FTP_SUCCEEDED
Definition ftpdefs.h:25
const char * LPCSTR
Definition bittype.h:62
HRESULT DisconnectFromServer()
Definition FTP.CPP:1286
HRESULT SendCommand(LPCSTR pCommand, int iSize)
Definition FTP.CPP:869
HRESULT FindFile(LPCSTR szRemoteFileName, int *piSize)
Definition FTP.CPP:659
friend class CDownload
Definition ftp.h:56
HRESULT RestartFrom(int i)
Definition ftp.h:108
HRESULT ConnectToServer(LPCSTR szServerName)
Definition FTP.CPP:319
HRESULT LoginToServer(LPCSTR szUserName, LPCSTR szPassword)
Definition FTP.CPP:485
HRESULT FileRecoveryPosition(LPCSTR szLocalFileName, LPCSTR szRegistryRoot)
Definition FTP.CPP:1688
Cftp()
Definition FTP.CPP:170
HRESULT LogoffFromServer(void)
Definition FTP.CPP:574
HRESULT RecvReply(LPCSTR pReplyBuffer, int iSize, int *piRetCode)
Definition FTP.CPP:917
virtual ~Cftp()
Definition FTP.CPP:194
HRESULT GetNextFileBlock(LPCSTR szLocalFileName, int *piTotalRead)
Definition FTP.CPP:1383