00001 // -*- C++ -*- 00002 // 00003 // $Id: FTP_Response.inl 90891 2010-06-28 09:55:39Z mcorino $ 00004 00005 ACE_BEGIN_VERSIONED_NAMESPACE_DECL 00006 00007 namespace ACE 00008 { 00009 namespace FTP 00010 { 00011 00012 ACE_INLINE 00013 void Response::reset () 00014 { 00015 this->status_ = NORESPONSE; 00016 this->response_.size (0); 00017 } 00018 00019 ACE_INLINE 00020 void Response::status(int status) 00021 { 00022 this->status_ = status; 00023 } 00024 00025 ACE_INLINE 00026 int Response::status() const 00027 { 00028 return this->status_; 00029 } 00030 00031 ACE_INLINE 00032 Response& Response::operator ()(int status) 00033 { 00034 this->reset (); 00035 this->status (status); 00036 return *this; 00037 } 00038 00039 ACE_INLINE 00040 const ACE_Array<ACE_CString>& Response::response () const 00041 { 00042 return this->response_; 00043 } 00044 00045 ACE_INLINE 00046 Response& Response::operator <<(const ACE_CString& line) 00047 { 00048 ACE_Array<ACE_CString>::size_type n = 00049 this->response_.size (); 00050 this->response_.size (n+1); 00051 this->response_[n] = line; 00052 return *this; 00053 } 00054 00055 ACE_INLINE 00056 Response::StatusType Response::status_type (int status) 00057 { 00058 if (status == NORESPONSE) 00059 return NORESPONSE; 00060 int st = status / 100; 00061 if (st >= PRELIM_OK && st <= PERMANENT_FAIL) 00062 return static_cast<StatusType> (st); 00063 else 00064 return NOSTATE; 00065 } 00066 00067 ACE_INLINE 00068 Response::StatusType Response::status_type () const 00069 { 00070 return status_type (this->status_); 00071 } 00072 00073 ACE_INLINE 00074 Response::StatusSubtype Response::status_sub_type () const 00075 { 00076 StatusType st = this->status_type (); 00077 if (st != NOSTATE && st != NORESPONSE) 00078 { 00079 int sst = (this->status_ - (st * 100)) / 10; 00080 if (sst >= SYNTAX && sst <= FILESYSTEM) 00081 return static_cast<StatusSubtype> (sst); 00082 } 00083 return NOSUBTYPE; 00084 } 00085 00086 ACE_INLINE 00087 bool Response::is_preliminary_ok () const 00088 { 00089 return this->status_type () == PRELIM_OK; 00090 } 00091 00092 ACE_INLINE 00093 bool Response::is_completed_ok () const 00094 { 00095 return this->status_type () == COMPLETED_OK; 00096 } 00097 00098 ACE_INLINE 00099 bool Response::is_intermediate_ok () const 00100 { 00101 return this->status_type () == INTERMEDIATE_OK; 00102 } 00103 00104 ACE_INLINE 00105 bool Response::is_transient_fail () const 00106 { 00107 return this->status_type () == TRANSIENT_FAIL; 00108 } 00109 00110 ACE_INLINE 00111 bool Response::is_permanent_fail () const 00112 { 00113 return this->status_type () == PERMANENT_FAIL; 00114 } 00115 00116 ACE_INLINE 00117 int Response::read_line (std::istream& is, std::ostream& os) 00118 { 00119 int ch; 00120 for (ch = is.get (); 00121 ch != eof_ && ch != '\r' && ch != '\n'; 00122 ch = is.get ()) 00123 { 00124 os.put (ch); 00125 } 00126 return ch; 00127 } 00128 00129 } 00130 } 00131 00132 ACE_END_VERSIONED_NAMESPACE_DECL