summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-12-18 02:55:46 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-12-18 02:55:46 +0000
commitfd53a64fe220b6ead57d1d7443c0fe197eae2e8e (patch)
tree52b4281b9df16db9e7d294d945b35c0aa566d8d0
parent245993641ee7ed006d780646c2eeb0d1481e5de9 (diff)
downloadATCD-fd53a64fe220b6ead57d1d7443c0fe197eae2e8e.tar.gz
on VxWorks: implemented ACE_OS::gethostbyname (), and fixed inet_ntoa () to return -1 on failure
-rw-r--r--ace/OS.h10
-rw-r--r--ace/OS.i30
2 files changed, 33 insertions, 7 deletions
diff --git a/ace/OS.h b/ace/OS.h
index e26669bd882..fbd318a9853 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -1362,7 +1362,14 @@ struct ifafilt;
#endif
#include /**/ <sys/socket.h>
extern "C" {
-#if !defined (VXWORKS)
+#if defined (VXWORKS)
+ struct hostent {
+ char *h_name; /* official name of host */
+ int h_addrtype; /* host address type */
+ int h_length; /* address length */
+ char **h_addr_list; /* (first, only) address from name server */
+ };
+#else
#include /**/ <netdb.h>
#endif /* VXWORKS */
#include /**/ <net/if.h>
@@ -1824,7 +1831,6 @@ typedef const wchar_t * ACE_WIDE_DL_TYPE;
struct ACE_Export siginfo_t
{
siginfo_t (ACE_HANDLE handle);
- siginfo_t (ACE_HANDLE *handle);
ACE_HANDLE si_handle_;
// Win32 HANDLE that has become signaled.
diff --git a/ace/OS.i b/ace/OS.i
index 3f23777440a..5840ac83fcf 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -2143,7 +2143,20 @@ ACE_OS::gethostbyname (const char *name)
{
// ACE_TRACE ("ACE_OS::gethostbyname");
#if defined (VXWORKS)
- ACE_NOTSUP_RETURN (0);
+ // not thread safe!
+ static hostent ret;
+ static char *hostaddr[2];
+
+ if ((hostaddr[0] = (char *) ::hostGetByName ((char *) name)) < 0)
+ return 0;
+ hostaddr[1] = 0;
+
+ ret.h_name = (char *) name; /* might not be official: just echo input arg */
+ ret.h_addrtype = AF_INET;
+ ret.h_length = IP_ADDR_LEN;
+ ret.h_addr_list = hostaddr;
+
+ return &ret;
#elif defined (ACE_HAS_NONCONST_GETBY)
char lname[::strlen (name) + 1];
ACE_OS::strcpy (lname, name);
@@ -2633,12 +2646,13 @@ ACE_OS::inet_addr (const char *name)
// ACE_TRACE ("ACE_OS::inet_addr");
#if defined (VXWORKS)
- u_long retval = 0;
+ u_long ret = 0;
u_int segment;
+ bool valid = true;
for (u_int i = 0; i < 4; ++i)
{
- retval <<= 8;
+ ret <<= 8;
if (*name != '\0')
{
segment = 0;
@@ -2648,7 +2662,13 @@ ACE_OS::inet_addr (const char *name)
segment *= 10;
segment += *name++ - '0';
}
- retval |= segment;
+ if (*name != '.' && *name != '\0')
+ {
+ valid = false;
+ break;
+ }
+
+ ret |= segment;
if (*name == '.')
{
@@ -2656,7 +2676,7 @@ ACE_OS::inet_addr (const char *name)
}
}
}
- return (long) htonl (retval);
+ return valid ? (long) htonl (ret) : -1L;
#elif defined (ACE_HAS_NONCONST_GETBY)
char _name[::strlen (name) + 1];
ACE_OS::strcpy (_name, name);