Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / OS_NS_arpa_inet.cpp
blob93a896520d0d78719c2815fbe482a13aae331a57
1 // -*- C++ -*-
2 // $Id: OS_NS_arpa_inet.cpp 80826 2008-03-04 14:51:23Z wotte $
4 #include "ace/OS_NS_arpa_inet.h"
6 ACE_RCSID(ace, OS_NS_arpa_inet, "$Id: OS_NS_arpa_inet.cpp 80826 2008-03-04 14:51:23Z wotte $")
8 #if !defined (ACE_HAS_INLINED_OSCALLS)
9 # include "ace/OS_NS_arpa_inet.inl"
10 #endif /* ACE_HAS_INLINED_OSCALLS */
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 int
15 ACE_OS::inet_aton (const char *host_name, struct in_addr *addr)
17 #if defined (ACE_LACKS_INET_ATON)
18 # if defined (ACE_WIN32)
19 // Windows Server 2003 changed the behavior of a zero-length input
20 // string to inet_addr(). It used to return 0 (INADDR_ANY) but now
21 // returns -1 (INADDR_NONE). It will return INADDR_ANY for a 1-space
22 // string, though, as do previous versions of Windows.
23 if (host_name == 0 || host_name[0] == '\0')
24 host_name = " ";
25 # endif /* ACE_WIN32 */
26 unsigned long ip_addr = ACE_OS::inet_addr (host_name);
28 if (ip_addr == INADDR_NONE
29 // Broadcast addresses are weird...
30 && ACE_OS::strcmp (host_name, "255.255.255.255") != 0)
31 return 0;
32 else if (addr == 0)
33 return 0;
34 else
36 addr->s_addr = ip_addr; // Network byte ordered
37 return 1;
39 #elif defined (ACE_VXWORKS) && (ACE_VXWORKS <= 0x660)
40 // inet_aton() returns OK (0) on success and ERROR (-1) on failure.
41 // Must reset errno first. Refer to WindRiver SPR# 34949, SPR# 36026
42 ::errnoSet(0);
43 int result = ERROR;
44 ACE_OSCALL (::inet_aton (const_cast <char*>(host_name), addr), int, ERROR, result);
45 return (result == ERROR) ? 0 : 1;
46 #else
47 // inet_aton() returns 0 upon failure, not -1 since -1 is a valid
48 // address (255.255.255.255).
49 ACE_OSCALL_RETURN (::inet_aton (host_name, addr), int, 0);
50 #endif /* ACE_LACKS_INET_ATON */
53 ACE_END_VERSIONED_NAMESPACE_DECL