Commit 0c430306 authored by Bruce Momjian's avatar Bruce Momjian

Re-enable inet code.

parent f4389d52
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* is for IP V4 CIDR notation, but prepared for V6: just * is for IP V4 CIDR notation, but prepared for V6: just
* add the necessary bits where the comments indicate. * add the necessary bits where the comments indicate.
* *
* $Id: inet.c,v 1.3 1998/10/12 04:07:46 momjian Exp $ * $Id: inet.c,v 1.4 1998/10/17 03:59:13 momjian Exp $
*/ */
#include <sys/types.h> #include <sys/types.h>
...@@ -57,9 +57,7 @@ inet_in(char *src) ...@@ -57,9 +57,7 @@ inet_in(char *src)
} }
/* First, try for an IP V4 address: */ /* First, try for an IP V4 address: */
ip_family(dst) = AF_INET; ip_family(dst) = AF_INET;
#ifdef BAD
bits = inet_net_pton(ip_family(dst), src, &ip_v4addr(dst), ip_addrsize(dst), NULL); bits = inet_net_pton(ip_family(dst), src, &ip_v4addr(dst), ip_addrsize(dst), NULL);
#endif
if ((bits < 0) || (bits > 32)) if ((bits < 0) || (bits > 32))
{ {
/* Go for an IPV6 address here, before faulting out: */ /* Go for an IPV6 address here, before faulting out: */
...@@ -86,7 +84,6 @@ inet_out(inet *src) ...@@ -86,7 +84,6 @@ inet_out(inet *src)
if (ip_family(src) == AF_INET) if (ip_family(src) == AF_INET)
{ {
#ifdef BAD
/* It's an IP V4 address: */ /* It's an IP V4 address: */
if (inet_net_ntop(AF_INET, &ip_v4addr(src), 4, ip_bits(src), if (inet_net_ntop(AF_INET, &ip_v4addr(src), 4, ip_bits(src),
tmp, sizeof(tmp)) < 0) tmp, sizeof(tmp)) < 0)
...@@ -94,7 +91,6 @@ inet_out(inet *src) ...@@ -94,7 +91,6 @@ inet_out(inet *src)
elog(ERROR, "unable to print address (%s)", strerror(errno)); elog(ERROR, "unable to print address (%s)", strerror(errno));
return (NULL); return (NULL);
} }
#endif
} }
else else
{ {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
*/ */
#if defined(LIBC_SCCS) && !defined(lint) #if defined(LIBC_SCCS) && !defined(lint)
static const char rcsid[] = "$Id: inet_net_pton.c,v 1.4 1998/10/12 15:56:34 momjian Exp $"; static const char rcsid[] = "$Id: inet_net_pton.c,v 1.5 1998/10/17 03:59:14 momjian Exp $";
#endif #endif
...@@ -100,34 +100,32 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) ...@@ -100,34 +100,32 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
ch = *src++; ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X') if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& isascii(src[1]) && isxdigit(src[1])) && isascii(src[1]) && isxdigit(src[1])) {
{
/* Hexadecimal: Eat nybble string. */ /* Hexadecimal: Eat nybble string. */
if (size <= 0) if (size <= 0)
goto emsgsize; goto emsgsize;
tmp = 0;
dirty = 0; dirty = 0;
src++; /* skip x or X. */ src++; /* skip x or X. */
while ((ch = *src++) != '\0' && while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) {
isascii(ch) && isxdigit(ch))
{
if (isupper(ch)) if (isupper(ch))
ch = tolower(ch); ch = tolower(ch);
n = strchr(xdigits, ch) - xdigits; n = strchr(xdigits, ch) - xdigits;
assert(n >= 0 && n <= 15); assert(n >= 0 && n <= 15);
if (dirty == 0)
tmp = n;
else
tmp = (tmp << 4) | n; tmp = (tmp << 4) | n;
if (++dirty == 2) { if (++dirty == 2) {
if (size-- <= 0) if (size-- <= 0)
goto emsgsize; goto emsgsize;
*dst++ = (u_char) tmp; *dst++ = (u_char) tmp;
tmp = 0, dirty = 0; dirty = 0;
} }
} }
if (dirty) { if (dirty) { /* Odd trailing nybble? */
if (size-- <= 0) if (size-- <= 0)
goto emsgsize; goto emsgsize;
tmp <<= 4; *dst++ = (u_char) (tmp << 4);
*dst++ = (u_char) tmp;
} }
} }
else if (isascii(ch) && isdigit(ch)) else if (isascii(ch) && isdigit(ch))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment