diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-25 21:12:48 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2002-07-25 21:12:48 +0000 |
commit | 10698ffae217c1d43c63989ff9364610d79831f7 (patch) | |
tree | e2213e94be14f91e83f9099b78685c9b605a7ce8 /lib/libc/net/ns_ntoa.c | |
parent | a4a191a6cf68382e7a34931ec0b650933bc897e0 (diff) |
cleanup
Diffstat (limited to 'lib/libc/net/ns_ntoa.c')
-rw-r--r-- | lib/libc/net/ns_ntoa.c | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/lib/libc/net/ns_ntoa.c b/lib/libc/net/ns_ntoa.c index 3c82bc3cee8..5ff410e28aa 100644 --- a/lib/libc/net/ns_ntoa.c +++ b/lib/libc/net/ns_ntoa.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.9 2002/05/24 21:22:37 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.10 2002/07/25 21:12:47 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -42,22 +42,21 @@ static char rcsid[] = "$OpenBSD: ns_ntoa.c,v 1.9 2002/05/24 21:22:37 deraadt Exp static char *spectHex(char *); char * -ns_ntoa(addr) - struct ns_addr addr; +ns_ntoa(struct ns_addr addr) { static char obuf[40]; union { union ns_net net_e; u_int32_t long_e; } net; in_port_t port = htons(addr.x_port); - register char *cp; - char *cp2; - register u_char *up = addr.x_host.c_host; + char *cp, *cp2; + u_char *up = addr.x_host.c_host; u_char *uplim = up + 6; net.net_e = addr.x_net; snprintf(obuf, sizeof obuf, "%x", ntohl(net.long_e)); cp = spectHex(obuf); cp2 = cp + 1; - while (*up==0 && up < uplim) up++; + while (*up==0 && up < uplim) + up++; if (up == uplim) { if (port) { sprintf(cp, ".0"); @@ -66,7 +65,8 @@ ns_ntoa(addr) } else { sprintf(cp, ".%x", *up++); while (up < uplim) { - while (*cp) cp++; + while (*cp) + cp++; sprintf(cp, "%02x", *up++); } cp = spectHex(cp2); @@ -79,23 +79,26 @@ ns_ntoa(addr) } static char * -spectHex(p0) - char *p0; +spectHex(char *p0) { - int ok = 0; - int nonzero = 0; - register char *p = p0; - for (; *p; p++) switch (*p) { + int ok = 0, nonzero = 0; + char *p = p0; - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - *p += ('A' - 'a'); - /* fall into . . . */ - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - ok = 1; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - nonzero = 1; + for (; *p; p++) { + switch (*p) { + case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': + *p += ('A' - 'a'); + /* fall into . . . */ + case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': + ok = 1; + case '1': case '2': case '3': case '4': case '5': + case '6': case '7': case '8': case '9': + nonzero = 1; + } + } + if (nonzero && !ok) { + *p++ = 'H'; + *p = 0; } - if (nonzero && !ok) { *p++ = 'H'; *p = 0; } return (p); } |