Beispiel #1
0
int
ACE_INET_Addr::string_to_addr (const char s[], int address_family)
{
  ACE_TRACE ("ACE_INET_Addr::string_to_addr");
  int result;
  char *ip_buf = 0;
  char *ip_addr = 0;

  // Need to make a duplicate since we'll be overwriting the string.
  ACE_ALLOCATOR_RETURN (ip_buf,
                        ACE_OS::strdup (s),
                        -1);
  ip_addr = ip_buf;
  // We use strrchr because of IPv6 addresses.
  char *port_p = ACE_OS::strrchr (ip_addr, ':');
#if defined (ACE_HAS_IPV6)
  // Check for extended IPv6 format : '[' <ipv6 address> ']' ':' <port>
  if (ip_addr[0] == '[')
    {
      // find closing bracket
      char *cp_pos = ACE_OS::strchr (ip_addr, ']');
      // check for port separator after closing bracket
      // if not found leave it, error will come later
      if (cp_pos)
        {
          *cp_pos = '\0'; // blank out ']'
          ++ip_addr; // skip over '['
          if (cp_pos[1] == ':')
            port_p = cp_pos + 1;
          else
            port_p = cp_pos; // leads to error on missing port
        }
    }
#endif /* ACE_HAS_IPV6 */

  if (port_p == 0) // Assume it's a port number.
    {
      char *endp = 0;
      u_short port =
        static_cast<u_short> (ACE_OS::strtol (ip_addr, &endp, 10));
      if (*endp == '\0')    // strtol scanned the entire string - all digits
        result = this->set (port, ACE_UINT32 (INADDR_ANY));
      else // port name
        result = this->set (ip_addr, ACE_UINT32 (INADDR_ANY));
    }
  else
    {
      *port_p = '\0'; ++port_p; // skip over ':'

      char *endp = 0;
      u_short port = static_cast<u_short> (ACE_OS::strtol (port_p, &endp, 10));
      if (*endp == '\0')    // strtol scanned the entire string - all digits
        result = this->set (port, ip_addr, 1, address_family);
      else
        result = this->set (port_p, ip_addr);
    }

  ACE_OS::free (ACE_MALLOC_T (ip_buf));
  return result;
}
Beispiel #2
0
int
ACE_TLI_Acceptor::close (void)
{
  ACE_TRACE ("ACE_TLI_Acceptor::close");
  if (this->device_ != 0)
    {
      if (this->queue_ != 0)
        {
          this->queue_->close ();
          delete this->queue_;
        }

      ACE_OS::t_free ((char *) this->disp_, T_DIS);
      ACE_OS::free (ACE_MALLOC_T (this->device_));
      this->disp_ = 0;
      this->device_ = 0;
      return this->ACE_TLI::close ();
    }
  return 0;
}
Beispiel #3
0
int
ACE_INET_Addr::string_to_addr (const char s[])
{
  ACE_TRACE ("ACE_INET_Addr::string_to_addr");
  int result;
  char *ip_addr;

  // Need to make a duplicate since we'll be overwriting the string.
  ACE_ALLOCATOR_RETURN (ip_addr,
                        ACE_OS::strdup (s),
                        -1);
  // We use strrchr because of IPv6 addresses.
  char *port_p = ACE_OS::strrchr (ip_addr, ':');

  if (port_p == 0) // Assume it's a port number.
    {
      char *endp = 0;
      u_short port =
        static_cast<u_short> (ACE_OS::strtol (ip_addr, &endp, 10));
      if (port > 0 && *endp == '\0')
        result = this->set (port, ACE_UINT32 (INADDR_ANY));
      else // port name
        result = this->set (ip_addr, ACE_UINT32 (INADDR_ANY));
    }
  else
    {
      *port_p = '\0'; ++port_p; // skip over ':'

      char *endp = 0;
      u_short port = static_cast<u_short> (ACE_OS::strtol (port_p, &endp, 10));
      if (port > 0 && *endp == '\0')
        result = this->set (port, ip_addr);
      else
        result = this->set (port_p, ip_addr);
    }

  ACE_OS::free (ACE_MALLOC_T (ip_addr));
  return result;
}
Beispiel #4
0
void
ACE_OS::free (void *ptr)
{
  ACE_FREE_FUNC (ACE_MALLOC_T (ptr));
}
Beispiel #5
0
void *
ACE_OS::realloc (void *ptr, size_t nbytes)
{
  return ACE_REALLOC_FUNC (ACE_MALLOC_T (ptr), nbytes);
}