1 #include "ace/String_Base.h"
2 #include "ace/OS_NS_ctype.h"
3 #include "ace/INet/FTP_Request.h"
5 #if !defined (__ACE_INLINE__)
6 #include "ace/INet/FTP_Request.inl"
9 #include "ace/INet/INet_Log.h"
10 #include "ace/INet/String_IOStream.h"
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 const ACE_CString
Request::FTP_USER
= "USER";
20 const ACE_CString
Request::FTP_PASS
= "PASS";
21 const ACE_CString
Request::FTP_QUIT
= "QUIT";
22 const ACE_CString
Request::FTP_TYPE
= "TYPE";
23 const ACE_CString
Request::FTP_SYST
= "SYST";
24 const ACE_CString
Request::FTP_PWD
= "PWD";
25 const ACE_CString
Request::FTP_CWD
= "CWD";
26 const ACE_CString
Request::FTP_CDUP
= "CDUP";
27 const ACE_CString
Request::FTP_RNFR
= "RNFR";
28 const ACE_CString
Request::FTP_RNTO
= "RNTO";
29 const ACE_CString
Request::FTP_DELE
= "DELE";
30 const ACE_CString
Request::FTP_MKD
= "MKD";
31 const ACE_CString
Request::FTP_RMD
= "RMD";
32 const ACE_CString
Request::FTP_RETR
= "RETR";
33 const ACE_CString
Request::FTP_STOR
= "STOR";
34 const ACE_CString
Request::FTP_LIST
= "LIST";
35 const ACE_CString
Request::FTP_NLST
= "NLST";
36 const ACE_CString
Request::FTP_ABOR
= "ABOR";
37 const ACE_CString
Request::FTP_EPRT
= "EPRT";
38 const ACE_CString
Request::FTP_PORT
= "PORT";
39 const ACE_CString
Request::FTP_EPSV
= "EPSV";
40 const ACE_CString
Request::FTP_PASV
= "PASV";
41 const ACE_CString
Request::FTP_STAT
= "STAT";
43 const int Request::eof_
= std::char_traits
<char>::eof ();
53 void Request::arguments (ACE_Array
<ACE_CString
> & args
) const
55 ACE::IOS::CString_IStream
sis (this->args_
);
61 while (ACE_OS::ace_isspace (ch
)) ch
= sis
.get ();
65 ACE_Array
<ACE_CString
>::size_type n
=
68 ACE_CString
& arg
= args
[n
];
69 while (ch
!= eof_
&& !ACE_OS::ace_isspace (ch
))
78 void Request::write(std::ostream
& str
) const
80 str
<< this->command_
.c_str ();
81 if (!this->args_
.empty ())
82 str
<< ' ' << this->args_
.c_str ();
85 INET_DEBUG (6, (LM_DEBUG
, DLINFO
86 ACE_TEXT ("ACE_INet_FTP: --> %C %C\n"),
87 this->command_
.c_str (),
88 this->command_
== FTP_PASS
?
89 "***" : this->args_
.c_str ()));
92 bool Request::read(std::istream
& str
)
94 ACE_CString
cmd (4, '\0');
95 ACE_CString
args (128, '\0');
100 str
.get (); // skip to eof
104 while (ACE_OS::ace_isspace (str
.peek ()))
110 while (!ACE_OS::ace_isspace (ch
) && ch
!= eof_
&& cmd
.length () < MAX_CMD_LENGTH
)
115 if (!ACE_OS::ace_isspace (ch
))
116 return false; // invalid FTP command string
117 if (ch
!= '\r' && ch
!= '\n')
120 while (ACE_OS::ace_isspace (str
.peek ()))
126 while (ch
!= eof_
&& ch
!= '\r' && ch
!= '\n' && args
.length () < MAX_ARG_LENGTH
)
131 if (ch
!= eof_
&& ch
!= '\r' && ch
!= '\n')
133 return false; // args too long
148 ACE_END_VERSIONED_NAMESPACE_DECL