From 6bda1f82f2fb7905e0abd64e2a76514686c9287e Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 5 Aug 1999 16:57:22 +0000 Subject: [PATCH] added ipAddrToHostName --- src/libCom/os/VMS/bsdSockResource.c | 46 +++++++---------------------- 1 file changed, 11 insertions(+), 35 deletions(-) diff --git a/src/libCom/os/VMS/bsdSockResource.c b/src/libCom/os/VMS/bsdSockResource.c index eb3af12af..547405e2a 100644 --- a/src/libCom/os/VMS/bsdSockResource.c +++ b/src/libCom/os/VMS/bsdSockResource.c @@ -55,48 +55,24 @@ void bsdSockRelease() } /* - * ipAddrToA() - * (convert IP address to ASCII host name) + * ipAddrToHostName */ -void epicsShareAPI ipAddrToA - (const struct sockaddr_in *paddr, char *pBuf, unsigned bufSize) +epicsShareFunc unsigned epicsShareAPI ipAddrToHostName + (const struct in_addr *pAddr, char *pBuf, unsigned bufSize) { - char *pString; struct hostent *ent; -# define maxPortDigits 5u - if (bufSize<1) { - return; + if (bufSize<1) { + return 0; } - if (paddr->sin_family!=AF_INET) { - strncpy(pBuf, "", bufSize-1); - /* - * force null termination - */ - pBuf[bufSize-1] = '\0'; - } - else { - ent = gethostbyaddr((char *) &paddr->sin_addr, - sizeof(paddr->sin_addr), AF_INET); - if(ent){ - pString = ent->h_name; - } - else{ - pString = inet_ntoa (paddr->sin_addr); - } - - /* - * allow space for the port number - */ - if (bufSize>maxPortDigits+strlen(pString)) { - sprintf (pBuf, "%.*s:%u", bufSize-maxPortDigits-1, - pString, ntohs(paddr->sin_port)); - } - else { - sprintf (pBuf, "%.*s", bufSize-1, pString); - } + ent = gethostbyaddr((char *) pAddr, sizeof (*pAddr), AF_INET); + if (ent) { + strncpy (pBuf, ent->h_name, bufSize); + pBuf[bufSize-1] = '\0'; + return strlen (pBuf); } + return 0; } /*