1 /* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #if defined(LIBC_SCCS) && !defined(lint) 9 static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 06/04/93"; 10 #endif /* LIBC_SCCS and not lint */ 11 12 /* 13 * Convert network-format internet address 14 * to base 256 d.d.d.d representation. 15 */ 16 #include <sys/types.h> 17 #include <netinet/in.h> 18 #include <arpa/inet.h> 19 #include <stdio.h> 20 21 char * 22 inet_ntoa(in) 23 struct in_addr in; 24 { 25 static char b[18]; 26 register char *p; 27 28 p = (char *)∈ 29 #define UC(b) (((int)b)&0xff) 30 (void)snprintf(b, sizeof(b), 31 "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3])); 32 return (b); 33 } 34