many, many changes

This commit is contained in:
Jeff Hill
2000-08-25 01:52:33 +00:00
parent 0bf430d822
commit f830e99e58
58 changed files with 6266 additions and 4410 deletions

57
src/ca/hostNameCache.cpp Normal file
View File

@@ -0,0 +1,57 @@
/*
* $Id$
*
*
* L O S A L A M O S
* Los Alamos National Laboratory
* Los Alamos, New Mexico 87545
*
* Copyright, 1986, The Regents of the University of California.
*
*
* Author Jeffrey O. Hill
* johill@lanl.gov
*/
#include "iocinf.h"
hostNameCache::hostNameCache ( const osiSockAddr &addr, ipAddrToAsciiEngine &engine ) :
ipAddrToAsciiAsynchronous ( addr ),
pHostName ( 0u )
{
this->ioInitiate ( engine );
}
hostNameCache::~hostNameCache ()
{
if ( this->pHostName ) {
delete [] this->pHostName;
}
}
void hostNameCache::ioCompletionNotify ( const char *pHostNameIn )
{
if ( ! this->pHostName ) {
unsigned size = strlen ( pHostNameIn ) + 1u;
char *pTmp = new char [size];
if ( ! pTmp ) {
// we fail over to using the IP address for the name
return;
}
strcpy ( pTmp, pHostNameIn );
this->pHostName = pTmp;
}
}
void hostNameCache::hostName ( char *pBuf, unsigned bufSize ) const
{
if ( this->pHostName ) {
strncpy ( pBuf, this->pHostName, bufSize);
}
else {
osiSockAddr addr = this->address();
sockAddrToDottedA ( &addr.sa, pBuf, bufSize );
}
pBuf [ bufSize - 1u ] = '\0';
}