This is Unofficial EPICS BASE Doxygen Site
localHostName Class Reference

#include "localHostName.h"

Public Member Functions

 localHostName ()
 
 ~localHostName ()
 
const char * pointer () const
 
unsigned getName (char *pBuf, unsigned bufLength) const
 
unsigned nameLength () const
 

Detailed Description

Definition at line 28 of file localHostName.h.

Constructor & Destructor Documentation

localHostName::localHostName ( )

Definition at line 27 of file localHostName.cpp.

27  :
28  attachedToSockLib ( osiSockAttach () != 0 ), length ( 0u )
29 {
30  const char * pErrStr = "<unknown host>";
31  int status = -1;
32  if ( this->attachedToSockLib ) {
33  status = gethostname (
34  this->cache, sizeof ( this->cache ) );
35  }
36  if ( status ) {
37  strncpy ( this->cache, pErrStr, sizeof ( this->cache ) );
38  }
39  this->cache [ sizeof ( this->cache ) - 1u ] = '\0';
40  this->length = strlen ( this->cache );
41 }
pvd::Status status
char * cache
Definition: reader.c:18
int osiSockAttach()
Definition: osdSock.c:54
localHostName::~localHostName ( )

Definition at line 43 of file localHostName.cpp.

44 {
45  if ( this->attachedToSockLib ) {
46  osiSockRelease ();
47  }
48 }
void osiSockRelease()
Definition: osdSock.c:62

Member Function Documentation

unsigned localHostName::getName ( char *  pBuf,
unsigned  bufLength 
) const

Definition at line 50 of file localHostName.cpp.

52 {
53  if ( bufLength ) {
54  strncpy ( pBuf, this->cache, bufLength );
55  if ( this->length < bufLength ) {
56  return this->length;
57  }
58  else {
59  unsigned reducedSize = bufLength - 1;
60  pBuf [ reducedSize ] = '\0';
61  return reducedSize;
62  }
63  }
64  return 0u;
65 }
char * cache
Definition: reader.c:18
unsigned localHostName::nameLength ( ) const
inline

Definition at line 43 of file localHostName.h.

44 {
45  return this->length;
46 }
const char * localHostName::pointer ( ) const
inline

Definition at line 48 of file localHostName.h.

49 {
50  return this->cache;
51 }
char * cache
Definition: reader.c:18

The documentation for this class was generated from the following files: