Descent3/netcon/includes/CFtp.h

129 lines
3.1 KiB
C
Raw Normal View History

/*
* Descent 3
* Copyright (C) 2024 Parallax Software
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2024-04-16 03:43:29 +00:00
/*
2024-04-16 18:56:40 +00:00
* $Logfile: /DescentIII/Main/lib/CFtp.h $
* $Revision: 1.3 $
* $Date: 2004/02/09 04:14:51 $
* $Author: kevinb $
*
* FTP Client class (get only)
*
* $Log: CFtp.h,v $
* Revision 1.3 2004/02/09 04:14:51 kevinb
* Added newlines to all headers to reduce number of warnings printed
*
* Made some small changes to get everything compiling.
*
* All Ready to merge the 1.5 tree.
*
* Revision 1.2 2000/06/03 14:30:33 icculus
* 1.4 code merge and pthread->SDL thread conversion.
*
* Revision 1.1.1.1 2000/04/18 00:00:38 icculus
* initial checkin
*
*
2024-04-16 03:43:29 +00:00
* 4 8/21/99 6:48a Jeff
* Linux port
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 3 7/31/98 11:40a Kevin
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 2 6/01/98 10:10a Kevin
* Added DLL connection interface and auto update DLL
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 1 5/27/98 9:54a Kevin
2024-04-16 18:56:40 +00:00
*
2024-04-16 03:43:29 +00:00
* 1 5/25/98 5:31p Kevin
* Initial version
2024-04-16 18:56:40 +00:00
*
* $NoKeywords: $
*/
2024-04-16 03:43:29 +00:00
#ifndef _CFTP_HEADER_
#define _CFTP_HEADER_
2024-04-16 18:56:40 +00:00
#define FTP_STATE_INTERNAL_ERROR 0
#define FTP_STATE_SOCKET_ERROR 1
#define FTP_STATE_URL_PARSING_ERROR 2
#define FTP_STATE_CONNECTING 3
#define FTP_STATE_HOST_NOT_FOUND 4
#define FTP_STATE_CANT_CONNECT 5
#define FTP_STATE_LOGGING_IN 6
#define FTP_STATE_LOGIN_ERROR 7
#define FTP_STATE_LOGGED_IN 8
#define FTP_STATE_DIRECTORY_INVALID 9
#define FTP_STATE_FILE_NOT_FOUND 10
#define FTP_STATE_RECEIVING 11
#define FTP_STATE_FILE_RECEIVED 12
#define FTP_STATE_UNKNOWN_ERROR 13
#define FTP_STATE_RECV_FAILED 14
#define FTP_STATE_CANT_WRITE_FILE 15
#define FTP_STATE_STARTUP 16
2024-04-16 03:43:29 +00:00
#ifdef __LINUX__
2024-04-16 18:56:40 +00:00
extern int FTPObjThread(void *obj);
2024-04-16 03:43:29 +00:00
#else
2024-04-16 18:56:40 +00:00
extern void FTPObjThread(void *obj);
2024-04-16 03:43:29 +00:00
#endif
2024-04-16 18:56:40 +00:00
class CFtpGet {
2024-04-16 03:43:29 +00:00
public:
2024-04-16 18:56:40 +00:00
CFtpGet(char *URL, char *localfile, char *Username = NULL, char *Password = NULL);
~CFtpGet();
int GetStatus();
unsigned int GetBytesIn();
unsigned int GetTotalBytes();
void AbortGet();
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
void WorkerThread();
2024-04-16 03:43:29 +00:00
protected:
2024-04-16 18:56:40 +00:00
int ConnectControlSocket();
int LoginHost();
unsigned int SendFTPCommand(char *command);
unsigned int ReadFTPServerReply();
unsigned int GetFile();
unsigned int IssuePort();
unsigned int ReadDataChannel();
void FlushControlChannel();
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
unsigned int m_iBytesIn;
unsigned int m_iBytesTotal;
unsigned int m_State;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
bool m_Aborting;
bool m_Aborted;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
char m_szUserName[100];
char m_szPassword[100];
char m_szHost[200];
char m_szDir[200];
char m_szFilename[100];
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
char recv_buffer[1000];
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
SOCKET m_ListenSock;
SOCKET m_DataSock;
SOCKET m_ControlSock;
2024-04-16 03:43:29 +00:00
2024-04-16 18:56:40 +00:00
FILE *LOCALFILE;
};
2024-04-16 03:43:29 +00:00
#endif