cmUdpPort.h/c:Added cmHostName().
This commit is contained in:
parent
c6a3496639
commit
353deeee5d
17
cmUdpPort.c
17
cmUdpPort.c
@ -562,3 +562,20 @@ const cmChar_t* cmUdpAddrToString( cmUdpH_t h, const struct sockaddr_in* addr )
|
||||
p->ntopBuf[INET_ADDRSTRLEN]=0;
|
||||
return p->ntopBuf;
|
||||
}
|
||||
|
||||
unsigned cmUdpHostNameMaxCharCount()
|
||||
{ return HOST_NAME_MAX+1; }
|
||||
|
||||
cmUdpRC_t cmUdpHostName( cmChar_t* buf, unsigned bufByteCnt )
|
||||
{
|
||||
if( bufByteCnt > 0 )
|
||||
buf[0] = 0;
|
||||
|
||||
if( bufByteCnt < cmUdpHostNameMaxCharCount() )
|
||||
return kBufTooSmallUdpRC;
|
||||
|
||||
if( gethostname(buf,bufByteCnt-1) != 0 )
|
||||
return kHostNameFailUdpRC;
|
||||
|
||||
return kOkUdpRC;
|
||||
}
|
||||
|
@ -24,6 +24,8 @@ extern "C" {
|
||||
kThreadFailUdpRC,
|
||||
kQueueFailUdpRC,
|
||||
kRecvBufOverflowUdpRC,
|
||||
kBufTooSmallUdpRC,
|
||||
kHostNameFailUdpRC,
|
||||
kTimeOutUdpRC
|
||||
};
|
||||
|
||||
@ -118,6 +120,9 @@ extern "C" {
|
||||
|
||||
const cmChar_t* cmUdpAddrToString( cmUdpH_t h, const struct sockaddr_in* addr );
|
||||
|
||||
unsigned cmUdpHostNameMaxCharCount();
|
||||
cmUdpRC_t cmUdpHostName( cmChar_t* buf, unsigned bufByteCnt );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user