00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef _FtpDTP_h_DEFINED
00013 #define _FtpDTP_h_DEFINED
00014
00015 #include <stdio.h>
00016 #include <dirent.h>
00017 #include <EndpointTypes.h>
00018 #include <TCPEndpointMsg.h>
00019 #include "TCPConnection.h"
00020 #include "FtpConfig.h"
00021
00022 #include "entry.h"
00023 #include "def.h"
00024
00025 class FtpDTP
00026 {
00027 public:
00028 FtpDTP();
00029 virtual ~FtpDTP() {}
00030
00031 OStatus Initialize(const OID& myoid,
00032 const antStackRef& ipstack, void* index);
00033 bool ListenCont (TCPEndpointListenMsg* listenMsg);
00034 bool ConnectCont(TCPEndpointConnectMsg* connectMsg);
00035 bool SendCont (TCPEndpointSendMsg* sendMsg);
00036 bool ReceiveCont(TCPEndpointReceiveMsg* receiveMsg);
00037 void CloseCont (TCPEndpointCloseMsg* closeMsg);
00038
00039 OStatus Close ();
00040
00041
00042 void SetType(FTPDataType type) {dataType = type;};
00043 void SetUser(char *user);
00044 void SetHome(char *home);
00045
00046
00047 ConnectionState GetState() {return connection.state;};
00048 FTPDataType GetType() {return dataType;};
00049 char * GetFilename() {return ftpFile;};
00050 char * GetDirectry() {return ftpDir;};
00051 size_t GetFileSize(char *name);
00052 char * GetUser() {return ftpUser;};
00053
00054
00055 Port SetIP (IPAddress ip);
00056 bool SetPort (char* ipport);
00057 bool Retrieve(char* filename);
00058 bool Store (char* filename);
00059 bool ChangeDir(char* dir);
00060 bool MakeDir(char* dir);
00061 bool RemoveDir(char* dir);
00062 bool Delete(char* filename);
00063 bool List (char* dir);
00064 bool RenameFrom(char *file);
00065 bool RenameTo(char *file);
00066 void ResetFilename();
00067
00068 private:
00069 OStatus Listen ();
00070 OStatus Connect();
00071 OStatus Send ();
00072 OStatus Receive();
00073
00074 void Save(byte *data, int length, bool end = true);
00075 void DirNorm(char *dir);
00076 bool RetrieveSend();
00077 bool ListSend();
00078
00079 OID myOID;
00080 antStackRef ipstackRef;
00081
00082
00083 IPAddress connectIP;
00084 Port connectPort;
00085 FTPMethod method;
00086 bool passive;
00087
00088
00089 FTPDataType dataType;
00090 char ftpUser[MAX_STRING_LENGTH];
00091 char ftpHome[MAX_STRING_LENGTH];
00092 char ftpDir[MAX_STRING_LENGTH];
00093 char ftpFile[MAX_STRING_LENGTH];
00094 bool listLong;
00095 bool total;
00096 FILE* fp;
00097 DIR* dirp;
00098
00099 void* continuation;
00100 TCPConnection connection;
00101 };
00102
00103 #endif