xref: /freebsd/contrib/ntp/libntp/refnumtoa.c (revision daf1cffce2e07931f27c6c6998652e90df6ba87e)
1 /*
2  * refnumtoa - return asciized refclock addresses stored in local array space
3  */
4 #include <stdio.h>
5 
6 #include "ntp_fp.h"
7 #include "lib_strbuf.h"
8 #include "ntp_stdlib.h"
9 
10 char *
11 refnumtoa(
12 	u_int32 num
13 	)
14 {
15 	register u_int32 netnum;
16 	register char *buf;
17 	register const char *rclock;
18 
19 	netnum = ntohl(num);
20 
21 	LIB_GETBUF(buf);
22 
23 	rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
24 
25 	if (rclock != NULL)
26 	    (void)sprintf(buf, "%s(%lu)", rclock, (u_long)netnum & 0xff);
27 	else
28 	    (void)sprintf(buf, "REFCLK(%lu,%lu)",
29 			  ((u_long)netnum >> 8) & 0xff, (u_long)netnum & 0xff);
30 	return buf;
31 }
32