Public Member Functions | Static Public Attributes | Private Types | Private Attributes | Static Private Attributes

ACE::FTP::Request Class Reference

#include <FTP_Request.h>

Inheritance diagram for ACE::FTP::Request:
Inheritance graph
[legend]
Collaboration diagram for ACE::FTP::Request:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Request ()
virtual ~Request ()
void reset ()
 resets the request object
Requestoperator() (const ACE_CString &cmd)
void command (const ACE_CString &cmd)
 sets the current command
const ACE_CStringcommand () const
 returns the current command
Requestoperator<< (const ACE_CString &arg)
const ACE_CStringarguments () const
 returns the arguments string
void arguments (ACE_Array< ACE_CString > &args) const
 retrieves the arguments
void write (std::ostream &str) const
 Writes the FTP request to the given stream.
bool read (std::istream &str)

Static Public Attributes

static const ACE_CString FTP_USER = "USER"
static const ACE_CString FTP_PASS = "PASS"
static const ACE_CString FTP_QUIT = "QUIT"
static const ACE_CString FTP_TYPE = "TYPE"
static const ACE_CString FTP_SYST = "SYST"
static const ACE_CString FTP_PWD = "PWD"
static const ACE_CString FTP_CWD = "CWD"
static const ACE_CString FTP_CDUP = "CDUP"
static const ACE_CString FTP_RNFR = "RNFR"
static const ACE_CString FTP_RNTO = "RNTO"
static const ACE_CString FTP_DELE = "DELE"
static const ACE_CString FTP_MKD = "MKD"
static const ACE_CString FTP_RMD = "RMD"
static const ACE_CString FTP_RETR = "RETR"
static const ACE_CString FTP_STOR = "STOR"
static const ACE_CString FTP_LIST = "LIST"
static const ACE_CString FTP_NLST = "NLST"
static const ACE_CString FTP_ABOR = "ABOR"
static const ACE_CString FTP_EPRT = "EPRT"
static const ACE_CString FTP_PORT = "PORT"
static const ACE_CString FTP_EPSV = "EPSV"
static const ACE_CString FTP_PASV = "PASV"
static const ACE_CString FTP_STAT = "STAT"

Private Types

enum  Limits { MAX_CMD_LENGTH = 4, MAX_ARG_LENGTH = 4096 }

Private Attributes

ACE_CString command_
ACE_CString args_

Static Private Attributes

static const int eof_ = std::char_traits<char>::eof ()

Detailed Description

Definition at line 23 of file FTP_Request.h.


Member Enumeration Documentation

enum ACE::FTP::Request::Limits [private]
Enumerator:
MAX_CMD_LENGTH 
MAX_ARG_LENGTH 

Definition at line 88 of file FTP_Request.h.

                   :
              static const int eof_;


Constructor & Destructor Documentation

ACE::FTP::Request::Request (  ) 

Reimplemented from ACE::INet::Request.

Definition at line 49 of file FTP_Request.cpp.

      {
      }

ACE::FTP::Request::~Request (  )  [virtual]

Reimplemented from ACE::INet::Request.

Definition at line 53 of file FTP_Request.cpp.

      {
      }


Member Function Documentation

const ACE_CString & ACE::FTP::Request::arguments (  )  const [inline]

returns the arguments string

Definition at line 51 of file FTP_Request.inl.

      {
        return this->args_;
      }

void ACE::FTP::Request::arguments ( ACE_Array< ACE_CString > &  args  )  const

retrieves the arguments

Definition at line 57 of file FTP_Request.cpp.

      {
        ACE::IOS::CString_IStream sis (this->args_);

        int ch = sis.get ();
        while (ch != eof_)
          {
            // skip whitespace
            while (ACE_OS::ace_isspace (ch))  ch = sis.get ();
            if (ch != eof_)
              {
                // get arg
                ACE_Array<ACE_CString>::size_type n =
                    args.size ();
                args.size (n + 1);
                ACE_CString& arg = args[n];
                while (ch != eof_ && !ACE_OS::ace_isspace (ch))
                  {
                    arg += ch;
                    ch = sis.get ();
                  }
              }
          }
      }

const ACE_CString & ACE::FTP::Request::command (  )  const [inline]

returns the current command

Definition at line 34 of file FTP_Request.inl.

      {
        return this->command_;
      }

void ACE::FTP::Request::command ( const ACE_CString cmd  )  [inline]

sets the current command

Definition at line 28 of file FTP_Request.inl.

      {
        this->command_ = cmd;
      }

Request & ACE::FTP::Request::operator() ( const ACE_CString cmd  )  [inline]

resets the request object and sets new command

Definition at line 20 of file FTP_Request.inl.

      {
        this->reset ();
        this->command (cmd);
        return *this;
      }

Request & ACE::FTP::Request::operator<< ( const ACE_CString arg  )  [inline]

adds a command argument separates multiple arguments with a space

Definition at line 40 of file FTP_Request.inl.

      {
        if (!arg.empty ())
          {
            if (!this->args_.empty ())  this->args_ += ' ' ;
            this->args_ += arg;
          }
        return *this;
      }

bool ACE::FTP::Request::read ( std::istream &  str  ) 

Reads the FTP request from the given stream.

Definition at line 96 of file FTP_Request.cpp.

      {
        ACE_CString cmd (4, '\0');
        ACE_CString args (128, '\0');

        int ch =  str.peek ();
        if (ch == eof_)
          {
            str.get (); // skip to eof
            return false;
          }
        // skip whitespace
        while (ACE_OS::ace_isspace (str.peek ()))
          {
            str.get ();
          }
        // get method
        ch = str.get ();
        while (!ACE_OS::ace_isspace (ch) && ch != eof_ && cmd.length () < MAX_CMD_LENGTH)
          {
            cmd += ch;
            ch = str.get ();
          }
        if (!ACE_OS::ace_isspace (ch))
          return false; // invalid FTP command string
        if (ch != '\r' && ch != '\n')
          {
            // skip whitespace
            while (ACE_OS::ace_isspace (str.peek ()))
              {
                str.get ();
              }
            // get arguments
            ch = str.get ();
            while (ch != eof_ && ch != '\r' && ch != '\n' && args.length () < MAX_ARG_LENGTH)
              {
                args += ch;
                ch = str.get ();
              }
            if (ch != eof_ && ch != '\r' && ch != '\n')
              {
                return false; // args too long
              }
          }
        if (ch == '\r')
          {
            str.get ();
          }
        this->command (cmd);
        this->args_ = args;
        return true;
      }

void ACE::FTP::Request::reset ( void   )  [inline]

resets the request object

Definition at line 13 of file FTP_Request.inl.

      {
        this->command_.clear ();
        this->args_.clear ();
      }

void ACE::FTP::Request::write ( std::ostream &  str  )  const

Writes the FTP request to the given stream.

Definition at line 82 of file FTP_Request.cpp.

      {
        str << this->command_.c_str ();
        if (!this->args_.empty ())
          str << ' ' << this->args_.c_str ();
        str << "\r\n";

        INET_DEBUG (6, (LM_DEBUG, DLINFO
                        ACE_TEXT ("ACE_INet_FTP: --> %C %C\n"),
                        this->command_.c_str (),
                        this->command_ == FTP_PASS ?
                            "***" : this->args_.c_str ()));
      }


Member Data Documentation

Definition at line 95 of file FTP_Request.h.

Definition at line 94 of file FTP_Request.h.

const int ACE::FTP::Request::eof_ = std::char_traits<char>::eof () [static, private]

Definition at line 86 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_ABOR = "ABOR" [static]

Definition at line 78 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_CDUP = "CDUP" [static]

Definition at line 68 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_CWD = "CWD" [static]

Definition at line 67 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_DELE = "DELE" [static]

Definition at line 71 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_EPRT = "EPRT" [static]

Definition at line 79 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_EPSV = "EPSV" [static]

Definition at line 81 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_LIST = "LIST" [static]

Definition at line 76 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_MKD = "MKD" [static]

Definition at line 72 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_NLST = "NLST" [static]

Definition at line 77 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_PASS = "PASS" [static]

Definition at line 62 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_PASV = "PASV" [static]

Definition at line 82 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_PORT = "PORT" [static]

Definition at line 80 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_PWD = "PWD" [static]

Definition at line 66 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_QUIT = "QUIT" [static]

Definition at line 63 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_RETR = "RETR" [static]

Definition at line 74 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_RMD = "RMD" [static]

Definition at line 73 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_RNFR = "RNFR" [static]

Definition at line 69 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_RNTO = "RNTO" [static]

Definition at line 70 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_STAT = "STAT" [static]

Definition at line 83 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_STOR = "STOR" [static]

Definition at line 75 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_SYST = "SYST" [static]

Definition at line 65 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_TYPE = "TYPE" [static]

Definition at line 64 of file FTP_Request.h.

const ACE_CString ACE::FTP::Request::FTP_USER = "USER" [static]

Definition at line 61 of file FTP_Request.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines