Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / libntp / refnumtoa.c
blob16afaf158d4bf1a58fffeb7b5ab4ed991b585a3a
1 /* $NetBSD$ */
3 /*
4 * refnumtoa - return asciized refclock addresses stored in local array space
5 */
6 #include <stdio.h>
8 #include "ntp_net.h"
9 #include "lib_strbuf.h"
10 #include "ntp_stdlib.h"
12 char *
13 refnumtoa(
14 sockaddr_u *num
17 register u_int32 netnum;
18 register char *buf;
19 register const char *rclock;
21 LIB_GETBUF(buf);
23 if (ISREFCLOCKADR(num)) {
24 netnum = SRCADR(num);
25 rclock = clockname((int)((u_long)netnum >> 8) & 0xff);
27 if (rclock != NULL)
28 snprintf(buf, LIB_BUFLENGTH, "%s(%lu)",
29 rclock, (u_long)netnum & 0xff);
30 else
31 snprintf(buf, LIB_BUFLENGTH, "REFCLK(%lu,%lu)",
32 ((u_long)netnum >> 8) & 0xff,
33 (u_long)netnum & 0xff);
37 return buf;