aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/xntpd/lib/numtoa.c
blob: ef291c8d6bcd445909040c687f03c812e6ed99e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/*
 * numtoa - return asciized network numbers store in local array space
 */
#include <stdio.h>

#include "ntp_fp.h"
#include "lib_strbuf.h"
#include "ntp_stdlib.h"

char *
numtoa(num)
	u_long num;
{
	register u_long netnum;
	register char *buf;

	netnum = ntohl(num);
	LIB_GETBUF(buf);
	(void) sprintf(buf, "%lu.%lu.%lu.%lu", (netnum >> 24) & 0xff,
	    (netnum >> 16) & 0xff, (netnum >> 8) & 0xff, netnum & 0xff);
	return buf;
}