Revert to Current Include Style
[ACE_TAO.git] / ACE / ace / UNIX_Addr.cpp
blobbae284b79ca8b2056b28288b269005a9bf5063bc
1 #include "ace/UNIX_Addr.h"
5 #if !defined (ACE_LACKS_UNIX_DOMAIN_SOCKETS)
7 #if defined (ACE_HAS_ALLOC_HOOKS)
8 # include "ace/Malloc_Base.h"
9 #endif /* ACE_HAS_ALLOC_HOOKS */
11 #if !defined (__ACE_INLINE__)
12 #include "ace/UNIX_Addr.inl"
13 #endif /* __ACE_INLINE__ */
15 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 ACE_ALLOC_HOOK_DEFINE(ACE_UNIX_Addr)
19 // Set a pointer to the address.
20 void
21 ACE_UNIX_Addr::set_addr (const void *addr, int len)
23 ACE_TRACE ("ACE_UNIX_Addr::set_addr");
25 this->ACE_Addr::base_set (AF_UNIX, len);
26 ACE_OS::memcpy (&this->unix_addr_, addr, len);
29 // Return a pointer to the underlying address.
31 void *
32 ACE_UNIX_Addr::get_addr () const
34 return (void *) &this->unix_addr_;
37 // Transform the string into the current addressing format.
39 int
40 ACE_UNIX_Addr::string_to_addr (const char addr[])
42 ACE_OS::strsncpy (this->unix_addr_.sun_path, addr,
43 sizeof this->unix_addr_.sun_path);
45 this->set_size (sizeof this->unix_addr_ -
46 sizeof (this->unix_addr_.sun_path) +
47 ACE_OS::strlen (this->unix_addr_.sun_path));
48 return 0;
51 // Transform the current address into string format.
53 int
54 ACE_UNIX_Addr::addr_to_string (ACE_TCHAR s[], size_t len) const
56 ACE_OS::strsncpy (s,
57 ACE_TEXT_CHAR_TO_TCHAR (this->unix_addr_.sun_path),
58 len);
59 return 0;
62 u_long
63 ACE_UNIX_Addr::hash () const
65 return ACE::hash_pjw (this->unix_addr_.sun_path);
68 void
69 ACE_UNIX_Addr::dump () const
71 #if defined (ACE_HAS_DUMP)
72 #endif /* ACE_HAS_DUMP */
75 // Do nothing constructor.
77 ACE_UNIX_Addr::ACE_UNIX_Addr ()
78 : ACE_Addr (AF_UNIX,
79 sizeof this->unix_addr_ - sizeof (this->unix_addr_.sun_path))
81 (void) ACE_OS::memset ((void *) &this->unix_addr_,
83 sizeof this->unix_addr_);
85 this->unix_addr_.sun_family = AF_UNIX;
88 int
89 ACE_UNIX_Addr::set (const ACE_UNIX_Addr &sa)
91 if (sa.get_type () == AF_ANY)
92 (void) ACE_OS::memset ((void *) &this->unix_addr_,
94 sizeof this->unix_addr_);
95 else
96 ACE_OS::strcpy (this->unix_addr_.sun_path,
97 sa.unix_addr_.sun_path);
99 this->unix_addr_.sun_family = AF_UNIX;
100 this->base_set (sa.get_type (), sa.get_size ());
102 return 0;
105 // Copy constructor.
107 ACE_UNIX_Addr::ACE_UNIX_Addr (const ACE_UNIX_Addr &sa)
108 : ACE_Addr (AF_UNIX, sa.get_size ())
110 this->set (sa);
114 ACE_UNIX_Addr::set (const sockaddr_un *un, int len)
116 (void) ACE_OS::memset ((void *) &this->unix_addr_, 0,
117 sizeof this->unix_addr_);
118 this->unix_addr_.sun_family = AF_UNIX;
119 ACE_OS::strcpy (this->unix_addr_.sun_path, un->sun_path);
120 this->base_set (AF_UNIX, len);
121 return 0;
124 ACE_UNIX_Addr::ACE_UNIX_Addr (const sockaddr_un *un, int len)
126 this->set (un, len);
130 ACE_UNIX_Addr::set (const char rendezvous_point[])
132 (void) ACE_OS::memset ((void *) &this->unix_addr_,
134 sizeof this->unix_addr_);
135 this->unix_addr_.sun_family = AF_UNIX;
136 (void) ACE_OS::strsncpy (this->unix_addr_.sun_path,
137 rendezvous_point,
138 sizeof this->unix_addr_.sun_path);
140 this->ACE_Addr::base_set (AF_UNIX,
141 sizeof this->unix_addr_ -
142 sizeof (this->unix_addr_.sun_path) +
143 ACE_OS::strlen (this->unix_addr_.sun_path));
144 return 0;
147 // Create a ACE_Addr from a UNIX pathname.
149 ACE_UNIX_Addr::ACE_UNIX_Addr (const char rendezvous_point[])
151 this->set (rendezvous_point);
154 ACE_END_VERSIONED_NAMESPACE_DECL
156 #endif /* ACE_LACKS_UNIX_DOMAIN_SOCKETS */