GenericRemote.h
资源名称:warftpd.zip [点击查看]
上传用户:surprise9
上传日期:2007-01-04
资源大小:426k
文件大小:6k
源码类别:
Ftp客户端
开发平台:
Visual C++
- // This is part of the WAR SOFTWARE SERIES initiated by Jarle Aase
- // Copyright 1996 by Jarle Aase. All rights reserved.
- // See the "War Software Series Licende Agreement" for details concerning
- // use and distribution.
- // ---
- // This source code, executables and programs containing source code or
- // binaries or proprietetary technology from the War Software Series are
- // NOT alloed used, viewed or tested by any governmental agencies in
- // any countries. This includes the government, departments, police,
- // military etc.
- // ---
- // This file is intended for use with Tab space = 2
- // Created and maintained in MSVC Developer Studio
- // ---
- // NAME : GenericRemote.h
- // PURPOSE : FTP/HTTP generic client
- // PROGRAM :
- // DATE : Dec 31. 1996
- // AUTHOR : Jarle Aase
- // ---
- // REVISION HISTORY
- //
- ////////////////////////////////////////////////////////////////////
- // Client Command parser
- class CCommandParser;
- class CFTPParser : public CCommandParser
- {
- public:
- CFTPParser();
- };
- class DLL_WAR_CLIENT_ CXmitInfo : public CObject
- {
- public:
- DECLARE_DYNCREATE(CXmitInfo)
- CXmitInfo();
- ~CXmitInfo();
- CString m_FromPath;
- CString m_ToPath; // Can be directory or filename
- DWORD m_Flags;
- int m_FileMode;
- FLEN m_StartOfs;
- FLEN m_FileLength;
- __int64 m_FileDate;
- };
- // CXmitInfo Flags
- #define XIF_RESM 0x0001
- #define XIF_RECR 0x0002
- #define XIF_NOMC 0x0004
- #define XIF_NWOL 0x0008
- #define XIF_CHOL 0x0010
- #define XIF_CHNO 0x0020
- #define XIF_NWNO 0x0040
- #define XIF_ASCI 0x0080 // Text mode
- #define XIF_BINR 0x0100 // Binary mode
- #define XIF_INDEX 0x0200 // Index file
- #define XIF_TEMP 0x0400 // Temporary file
- class CGenericInternetView;
- class DLL_WAR_CLIENT_ CXmitStack
- {
- public:
- int m_LastCmdID;
- int m_CurrCmdID;
- };
- class DLL_WAR_CLIENT_ CGenericRemote : public CRemoteInterface
- {
- public:
- CGenericRemote(CGenericInternetView *pView);
- ~CGenericRemote();
- BOOL Execute(LPCSTR Command);
- static BOOL RequestCallback(int nErrorCode, LPVOID ReplyBuf, LPVOID Arg);
- BOOL Request(LPCSTR Cmd);
- BOOL FTPGetPutFile(int Mode, LPCSTR LocalName,LPCSTR RemoteName,
- int argc = 0, char **argv = NULL);
- void OnGotFileOK();
- virtual void OnFileCompletion(int nErrorCode);
- BOOL TryUNIXDirParse(LPSTR Listing, CLinkedList& List);
- BOOL TryDOSDirParse(LPSTR Listing, CLinkedList& List);
- BOOL TryNovellDirParse(LPSTR Listing, CLinkedList& List);
- BOOL TryVMSDirParse(LPSTR Listing, CLinkedList& List);
- void ParseDirListing(HANDLE hFile, CLinkedList& List);
- void EndXmit();
- void ShowInfoDlg(int MsgID = 0, HICON hIcon = NULL);
- BOOL GenericXmitNextFile(BOOL IsFirst);
- BOOL GenericGetFile(int argc, char **argv);
- BOOL ParsePutGetArgs(int argc, char **argv, BOOL LookForDest, int Mode);
- BOOL ValidateGetFile(CLinkedList& List);
- void CleanUpXmitList();
- BOOL GenericPutFile(int argc, char **argv);
- BOOL IsIdle();
- BOOL Abort();
- void OnOpen(int nErrorCode);
- CString GetTempName();
- BOOL ReadTheFile(HANDLE hFile, CString& cBuf);
- void ParseIndexListing(HANDLE hFile, CLinkedList& List);
- virtual BOOL OnHandleWinsockErr(int nErrorCode );
- void PushXmitState();
- BOOL PopXmitState();
- CGenericInternetView *m_pMyView;
- CFTPParser m_Parser;
- int m_LastCmdID;
- CString m_MyRbuf;
- HANDLE m_hCancel;
- CString m_InformQueue;
- int m_FileStatus;
- int m_FileMode;
- HANDLE m_FileHandle;
- int m_FileIsTransmittedOK; // Set by FTP data sock callback
- BOOL m_IsBinaryFile;
- BOOL m_IsTmpFile;
- CString m_LocalFileName;
- CString m_RemoteFileName;
- CFTPDataSock *m_FTPData;
- struct sockaddr m_Sockaddr; // Used to connect to remote data socket
- BOOL m_ThereWasAnError;
- CLinkedList m_XmitList;
- int m_CurrentXfer;
- int m_XfersToGo;
- int m_NumSuccessfulXfers;
- int m_TotalNumOfXfers;
- BOOL m_EnableAutoUpdate;
- int m_CmdID;
- BOOL m_IsConnectedOK;
- long m_NotifyCnt;
- int m_ServerType;
- int m_ServerSoftware;
- CString m_ServerVersion;
- CString m_ListCmd;
- CXmitInfo *m_CurrentFileInfo;
- BOOL m_NoREST;
- CString m_LastTypeCommand;
- CString m_LastModeCommand;
- CString m_RenameTo;
- CLinkedList m_XmitStack;
- __int64 m_RcvFileDate;
- HANDLE CreateFile(LPCTSTR lpFileName, // pointer to name of the file
- DWORD dwDesiredAccess, // access (read-write) mode
- DWORD dwShareMode, // share mode
- LPSECURITY_ATTRIBUTES lpSecurityAttributes, // pointer to security descriptor
- DWORD dwCreationDistribution, // how to create
- DWORD dwFlagsAndAttributes, // file attributes
- HANDLE hTemplateFile // handle to file with attributes to copy
- );
- public:
- virtual BOOL OnNotification(int nErrorCode, LPSTR Notification);
- virtual void OnClientLogNotify(LPCSTR Text);
- void FTPLocalProcess();
- virtual void OnDNSLookup(int nErrorCode, CDNSLookup *pDNS);
- virtual void OnServerMessage( int nErrorCode );
- virtual void OnConnect( int nErrorCode );
- virtual void OnSend( int nErrorCode );
- virtual void OnReceive( int nErrorCode );
- virtual void OnClose( int nErrorCode );
- protected:
- BOOL _SendCmd(LPCSTR Command);
- private:
- void _OnConnect( int nErrorCode );
- void _OnReceive( int nErrorCode );
- void _OnClose( int nErrorCode );
- BOOL _Execute(LPCSTR Command);
- };
- enum // FTP File modes
- {
- FTPG_LIST, // Get file listing
- FTPG_RCVFILE, // Get a "real" file
- FTPG_SNDFILE, // Send a file
- FTPG_INVALID
- };
- enum // FTP File xmit status
- {
- PTPX_IDLE, // Nothing going on
- FTPX_INIT, // Initialize
- FTPX_SIZE, // Get size of file
- FTPX_TIME, // Get exact file time
- FTPX_REST, // Set file offset
- FTPX_TYPE, // Type send
- FTPX_PORT, // Port sent
- FTPX_PASV, // Pasv sent
- FTPX_STOR, // Send file command sent
- FTPX_RETR, // Get file command sent
- FTPX_HOLD, // Waiting for physical file transfer to end
- FTPX_RNFR, // Rename from
- FTPX_RNTO, // Rename to
- FTPX_DATE, // Get file date
- };
- enum // DNS lookup's
- {
- DNS_PREC_LOOKUP = 1, // Pre connect lookup
- };
- // Server types
- #define SVRT_UNKNOWN 0x0001 // Unknown type
- #define SVRT_GENERIC_UNIX 0x0002 // Support's LIST -L and other advanced flags
- #define SVRT_WARFTPD 0x0004 // War FTP daemon
- #define SVRT_PSEUDO_UNIX 0x0008 // Unix like, but not safe/comaptible
- #define SVRT_GENERIC_VMS 0x0010 // VMS of some type
- enum // Server software
- {
- SVRS_UNKNOWN,
- SVRS_WARFTPD,
- SVRS_SERV_U,
- SVRS_WFTPD,
- SVRS_WU_FTPD,
- SVRS_NTFTPD,
- SVRS_MSFTPDNT,
- SVRS_VERMILLION,
- SVRS_INVALID
- };
- #define SVRMSG_ID 298 // Primitive FTP server message header