Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / protocols / ace / HTBP / HTBP_Addr.cpp
blob182fa4f1fbce350154dd1a093bbd391e996fff64
1 #include "HTBP_Addr.h"
2 #include "ace/OS_NS_string.h"
4 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
6 // Creates a ACE_INET_Addr from a PORT_NUMBER and the remote
7 // HOST_NAME.
8 ACE::HTBP::Addr::Addr (u_short port_number,
9 const char host_name[],
10 int address_family)
11 : ACE_INET_Addr (port_number, host_name, address_family),
12 htid_ ()
16 ACE::HTBP::Addr::Addr (const char *htid)
17 : htid_(htid)
21 ACE::HTBP::Addr::Addr (const ACE::HTBP::Addr &other)
22 : ACE_INET_Addr (other),
23 htid_(other.htid_)
27 int
28 ACE::HTBP::Addr::set (u_short port,
29 const char host[],
30 const char *htid)
32 if (htid != 0 && ACE_OS::strlen (htid) != 0)
33 return this->set_htid (htid);
34 return this->ACE_INET_Addr::set(port,host);
37 int
38 ACE::HTBP::Addr::set_htid (const char *htid)
40 this->htid_ = htid;
41 this->set_port_number (0);
42 return 0;
45 const char *
46 ACE::HTBP::Addr::get_htid () const
48 return this->htid_.c_str();
51 int
52 ACE::HTBP::Addr::addr_to_string (ACE_TCHAR buffer[],
53 size_t size,
54 int ipaddr_format) const
56 if (this->htid_.length() == 0)
57 return this->ACE_INET_Addr::addr_to_string(buffer,size,ipaddr_format);
58 if (size < htid_.length())
59 return -1;
60 ACE_OS::strncpy (buffer,
61 ACE_TEXT_CHAR_TO_TCHAR(htid_.c_str()),
62 size);
63 return 0;
66 int
67 ACE::HTBP::Addr::string_to_addr (const char address[],
68 int address_family)
70 // if (ACE_OS::strchr (address,':'))
71 return this->ACE_INET_Addr::string_to_addr(address, address_family);
72 // this->htid_ = address;
73 // return 0;
76 ACE_END_VERSIONED_NAMESPACE_DECL