summaryrefslogtreecommitdiff
path: root/ace/HTBP/HTBP_Addr.cpp
blob: 0ea811bb10872abe7aa6a8c7d58758855df08651 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// $Id$

#include "HTBP_Addr.h"
#include "ace/OS_NS_string.h"

ACE_RCSID (HTBP,
           ACE_HTBP_Addr,
           "$Id$")

  // Constructor
  ACE::HTBP::Addr::Addr ()
{
}

// Creates a ACE_INET_Addr from a PORT_NUMBER and the remote
// HOST_NAME.

ACE::HTBP::Addr::Addr (u_short port_number,
                       const char host_name[],
                       int address_family)
  : ACE_INET_Addr (port_number, host_name, address_family),
    htid_ ()
{
}

ACE::HTBP::Addr::Addr (const char *htid)
  : htid_(htid)
{
}

ACE::HTBP::Addr::Addr (const ACE::HTBP::Addr &other)
  : ACE_INET_Addr (other),
    htid_(other.htid_)
{

}

// Destructor
ACE::HTBP::Addr::~Addr ()
{
}

int
ACE::HTBP::Addr::set (u_short port,
                      const char host[],
                      const char *htid)
{
  if (htid != 0 && ACE_OS::strlen (htid) != 0)
    return this->set_htid (htid);
  return this->ACE_INET_Addr::set(port,host);
}

int
ACE::HTBP::Addr::set_htid (const char *htid)
{
  this->htid_ = htid;
  this->set_port_number (0);
  return 0;
}

const char *
ACE::HTBP::Addr::get_htid (void) const
{
  return this->htid_.c_str();
}

int
ACE::HTBP::Addr::addr_to_string (ACE_TCHAR buffer[],
                                 size_t size,
                                 int ipaddr_format) const
{
  if (this->htid_.length() == 0)
    return this->ACE_INET_Addr::addr_to_string(buffer,size,ipaddr_format);
  if (size < htid_.length())
    return -1;
  ACE_OS::strncpy (buffer,
                   ACE_TEXT_CHAR_TO_TCHAR(htid_.c_str()),
                   size);
  return 0;
}

int
ACE::HTBP::Addr::string_to_addr (const char address[])
{
  //  if (ACE_OS::strchr (address,':'))
    return this->ACE_INET_Addr::string_to_addr(address);
    //  this->htid_ = address;
    //  return 0;
}