X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/95f51977ddc18faa2e212f30c00a39540b39f325..ca67e7b465996afb3821d6a075c4dc6a7f0f5d52:/usr/src/lib/libc/inet/inet_addr.c diff --git a/usr/src/lib/libc/inet/inet_addr.c b/usr/src/lib/libc/inet/inet_addr.c index 3a1070c145..6d97c1b0cc 100644 --- a/usr/src/lib/libc/inet/inet_addr.c +++ b/usr/src/lib/libc/inet/inet_addr.c @@ -1,12 +1,23 @@ /* * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. The Berkeley software License Agreement - * specifies the terms and conditions for redistribution. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)inet_addr.c 5.2 (Berkeley) 3/9/86"; -#endif LIBC_SCCS and not lint +static char sccsid[] = "@(#)inet_addr.c 5.6 (Berkeley) 6/27/88"; +#endif /* LIBC_SCCS and not lint */ #include #include @@ -34,10 +45,12 @@ again: * 0x=hex, 0=octal, other=decimal. */ val = 0; base = 10; - if (*cp == '0') - base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - base = 16, cp++; + if (*cp == '0') { + if (*++cp == 'x' || *cp == 'X') + base = 16, cp++; + else + base = 8; + } while (c = *cp) { if (isdigit(c)) { val = (val * base) + (c - '0'); @@ -59,7 +72,7 @@ again: * a.b (with b treated as 24 bits) */ if (pp >= parts + 4) - return (-1); + return (INADDR_NONE); *pp++ = val, cp++; goto again; } @@ -67,7 +80,7 @@ again: * Check for trailing characters. */ if (*cp && !isspace(*cp)) - return (-1); + return (INADDR_NONE); *pp++ = val; /* * Concoct the address according to @@ -95,7 +108,7 @@ again: break; default: - return (-1); + return (INADDR_NONE); } val = htonl(val); return (val);