00001 // $Id: FTP_Request.h 90894 2010-06-28 10:38:29Z mcorino $ 00002 00003 /** 00004 * @file FTP_Request.h 00005 * 00006 * @author Martin Corino <mcorino@remedy.nl> 00007 */ 00008 00009 #ifndef ACE_FTP_REQUEST_H 00010 #define ACE_FTP_REQUEST_H 00011 00012 #include /**/ "ace/pre.h" 00013 00014 #include "ace/Array.h" 00015 #include "ace/INet/INet_Export.h" 00016 #include "ace/INet/Request.h" 00017 #include "ace/SString.h" 00018 00019 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00020 00021 namespace ACE 00022 { 00023 namespace FTP 00024 { 00025 00026 /** 00027 * @class ACE_FTP_Request 00028 * 00029 * @brief Encapsulates FTP requests/commands. 00030 * 00031 */ 00032 class ACE_INET_Export Request 00033 : public ACE::INet::Request 00034 { 00035 public: 00036 Request (); 00037 00038 virtual ~Request (); 00039 00040 /// resets the request object 00041 void reset (); 00042 00043 /// resets the request object and sets 00044 /// new command 00045 Request& operator ()(const ACE_CString& cmd); 00046 00047 /// sets the current command 00048 void command (const ACE_CString& cmd); 00049 00050 /// returns the current command 00051 const ACE_CString& command () const; 00052 00053 /// adds a command argument 00054 /// separates multiple arguments with a space 00055 Request& operator <<(const ACE_CString& arg); 00056 00057 /// returns the arguments string 00058 const ACE_CString& arguments () const; 00059 00060 /// retrieves the arguments 00061 void arguments (ACE_Array<ACE_CString> & args) const; 00062 00063 /// Writes the FTP request to the given stream 00064 void write(std::ostream& str) const; 00065 00066 /// Reads the FTP request from the 00067 /// given stream. 00068 bool read(std::istream& str); 00069 00070 static const ACE_CString FTP_USER; 00071 static const ACE_CString FTP_PASS; 00072 static const ACE_CString FTP_QUIT; 00073 static const ACE_CString FTP_TYPE; 00074 static const ACE_CString FTP_SYST; 00075 static const ACE_CString FTP_PWD; 00076 static const ACE_CString FTP_CWD; 00077 static const ACE_CString FTP_CDUP; 00078 static const ACE_CString FTP_RNFR; 00079 static const ACE_CString FTP_RNTO; 00080 static const ACE_CString FTP_DELE; 00081 static const ACE_CString FTP_MKD; 00082 static const ACE_CString FTP_RMD; 00083 static const ACE_CString FTP_RETR; 00084 static const ACE_CString FTP_STOR; 00085 static const ACE_CString FTP_LIST; 00086 static const ACE_CString FTP_NLST; 00087 static const ACE_CString FTP_ABOR; 00088 static const ACE_CString FTP_EPRT; 00089 static const ACE_CString FTP_PORT; 00090 static const ACE_CString FTP_EPSV; 00091 static const ACE_CString FTP_PASV; 00092 static const ACE_CString FTP_STAT; 00093 00094 private: 00095 static const int eof_; 00096 00097 enum Limits 00098 { 00099 MAX_CMD_LENGTH = 4, 00100 MAX_ARG_LENGTH = 4096 // seems like a sensible maximum 00101 }; 00102 00103 ACE_CString command_; 00104 ACE_CString args_; 00105 }; 00106 00107 } 00108 } 00109 00110 ACE_END_VERSIONED_NAMESPACE_DECL 00111 00112 #if defined (__ACE_INLINE__) 00113 #include "ace/INet/FTP_Request.inl" 00114 #endif 00115 00116 #include /**/ "ace/post.h" 00117 #endif /* ACE_FTP_REQUEST_H */