www.pudn.com > RadiusSrv.rar > misc.cpp, change:2003-10-22,size:570b


#include <string.h> 
#include "../common/GKCommon.h" 
#include "winsock2.h" 
 
/* 
 *	Return an IP address in standard dot notation 
 */ 
char *ip_ntoa(char *buffer, uint32_t ipaddr) 
{ 
	ipaddr = ntohl(ipaddr); 
 
	sprintf(buffer, "%d.%d.%d.%d", 
		(ipaddr >> 24) & 0xff, 
		(ipaddr >> 16) & 0xff, 
		(ipaddr >>  8) & 0xff, 
		(ipaddr      ) & 0xff); 
	return buffer; 
} 
 
/* 
 *	Like strncpy, but always adds \0 
 */ 
char *strNcpy(char *dest, const char *src, int n) 
{ 
	if (n > 0) 
		strncpy(dest, src, n); 
	else 
		n = 1; 
	dest[n - 1] = 0; 
 
	return dest; 
}