Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / bsd / ntp / dist / libntp / numtoa.c
blobc0f5ec141e0f7239921a618c138926f6e331690d
1 /* $NetBSD$ */
3 /*
4 * numtoa - return asciized network numbers store in local array space
5 */
6 #include <config.h>
8 #include <sys/types.h>
9 #ifdef HAVE_NETINET_IN_H
10 #include <netinet/in.h> /* ntohl */
11 #endif
13 #include <stdio.h>
15 #include "ntp_fp.h"
16 #include "lib_strbuf.h"
17 #include "ntp_stdlib.h"
19 char *
20 numtoa(
21 u_int32 num
24 register u_int32 netnum;
25 register char *buf;
27 netnum = ntohl(num);
28 LIB_GETBUF(buf);
29 snprintf(buf, LIB_BUFLENGTH, "%lu.%lu.%lu.%lu",
30 ((u_long)netnum >> 24) & 0xff,
31 ((u_long)netnum >> 16) & 0xff,
32 ((u_long)netnum >> 8) & 0xff,
33 (u_long)netnum & 0xff);
34 return buf;