From: Sam Leffler Date: Wed, 6 Oct 1982 14:19:48 +0000 (-0800) Subject: rename library routines so as not conflict with gethostname X-Git-Tag: BSD-4_1c_2-Snapshot-Development~2340 X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/commitdiff_plain/5e649950eb2c1d05ae0599e74f86cfc60cd33392?hp=9bce7b730d99a04f62e0b80d1c8eb466c74e465b rename library routines so as not conflict with gethostname SCCS-vsn: lib/libc/net/SCCS/hosttable/gethostent.c 4.2 SCCS-vsn: lib/libc/net/getnetbyaddr.c 4.2 SCCS-vsn: lib/libc/net/getnetbyname.c 4.2 SCCS-vsn: lib/libc/net/getnetent.c 4.2 SCCS-vsn: lib/libc/net/getproto.c 4.2 SCCS-vsn: lib/libc/net/getprotoent.c 4.2 SCCS-vsn: lib/libc/net/getprotoname.c 4.2 SCCS-vsn: lib/libc/net/getservbyname.c 4.2 SCCS-vsn: lib/libc/net/getservbyport.c 4.2 SCCS-vsn: lib/libc/net/getservent.c 4.2 SCCS-vsn: lib/libc/net/inet_addr.c 4.2 --- diff --git a/usr/src/lib/libc/net/SCCS/hosttable/gethostent.c b/usr/src/lib/libc/net/SCCS/hosttable/gethostent.c index 06bc2161ad..f3dfc59028 100644 --- a/usr/src/lib/libc/net/SCCS/hosttable/gethostent.c +++ b/usr/src/lib/libc/net/SCCS/hosttable/gethostent.c @@ -1,19 +1,24 @@ -/* gethostent.c 4.1 82/08/25 */ +/* gethostent.c 4.2 82/10/05 */ #include +#include #include #include #include +/* + * Internet version. + */ #define MAXALIASES 35 +#define MAXADDRSIZE 14 static char HOSTDB[] = "/usr/lib/hosts"; static FILE *hostf = NULL; static char line[BUFSIZ+1]; +static char hostaddr[MAXADDRSIZE]; static struct hostent host; static char *host_aliases[MAXALIASES]; static int stayopen = 0; -static unsigned long value(); static char *any(); sethostent(f) @@ -55,11 +60,14 @@ again: if (cp == NULL) goto again; *cp++ = '\0'; - host.h_addr = value(p); + /* THIS STUFF IS INTERNET SPECIFIC */ + host.h_addr = hostaddr; + *((u_long *)host.h_addr) = inet_addr(p); + host.h_length = sizeof (u_long); + host.h_addrtype = AF_INET; while (*cp == ' ' || *cp == '\t') cp++; host.h_name = cp; - host.h_addrtype = AF_INET; host.h_aliases = host_aliases; cp = any(cp, " \t"); if (cp != NULL) @@ -80,68 +88,6 @@ again: return (&host); } -static unsigned long -value(cp) - register char *cp; -{ - register unsigned long val, base, n; - register char c; - unsigned long parts[4], *pp = parts; - -again: - val = 0; base = 10; - if (*cp == '0') - base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - base = 16, cp++; - while (c = *cp) { - if (isdigit(c)) { - val = (val * base) + (c - '0'); - cp++; - continue; - } - if (base == 16 && isxdigit(c)) { - val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); - cp++; - continue; - } - break; - } - if (*cp == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16-bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 4) - return (-1); - *pp++ = val, cp++; - goto again; - } - if (*cp && !isspace(*cp)) - return (-1); - n = pp - parts; - if (n > 0) { - if (n > 4) - return (-1); - *pp++ = val; n++; - val = parts[0]; - if (n > 1) - val <<= 24; - if (n > 2) - val |= (parts[1] & 0xff) << 16; - if (n > 3) - val |= (parts[2] & 0xff) << 8; - if (n > 1) - val |= parts[n - 1]; -#if vax || pdp11 - val = htonl(val); -#endif - } - return (val); -} - static char * any(cp, match) register char *cp; diff --git a/usr/src/lib/libc/net/getnetbyaddr.c b/usr/src/lib/libc/net/getnetbyaddr.c index 7c2b808987..f1ad75734d 100644 --- a/usr/src/lib/libc/net/getnetbyaddr.c +++ b/usr/src/lib/libc/net/getnetbyaddr.c @@ -1,9 +1,9 @@ -/* getnetbyaddr.c 4.1 82/08/25 */ +/* getnetbyaddr.c 4.2 82/10/05 */ #include struct netent * -getnetaddr(net) +getnetbyaddr(net) register int net; { register struct netent *p; diff --git a/usr/src/lib/libc/net/getnetbyname.c b/usr/src/lib/libc/net/getnetbyname.c index 7da81fea1a..ea5e261ae1 100644 --- a/usr/src/lib/libc/net/getnetbyname.c +++ b/usr/src/lib/libc/net/getnetbyname.c @@ -1,9 +1,9 @@ -/* getnetbyname.c 4.1 82/08/25 */ +/* getnetbyname.c 4.2 82/10/05 */ #include struct netent * -getnetname(name) +getnetbyname(name) register char *name; { register struct netent *p; diff --git a/usr/src/lib/libc/net/getnetent.c b/usr/src/lib/libc/net/getnetent.c index 75bcf00f61..d51c89c4d9 100644 --- a/usr/src/lib/libc/net/getnetent.c +++ b/usr/src/lib/libc/net/getnetent.c @@ -1,4 +1,4 @@ -/* getnetent.c 4.1 82/08/25 */ +/* getnetent.c 4.2 82/10/05 */ #include #include @@ -13,7 +13,6 @@ static char line[BUFSIZ+1]; static struct netent net; static char *net_aliases[MAXALIASES]; static int stayopen = 0; -static unsigned long value(); static char *any(); setnetent(f) @@ -62,7 +61,7 @@ again: p = any(cp, " \t"); if (p != NULL) *p++ = '\0'; - net.n_net = value(cp); + net.n_net = inet_addr(cp); net.n_aliases = net_aliases; q = net_aliases, cp = p; while (*cp) { @@ -80,68 +79,6 @@ again: return (&net); } -static unsigned long -value(cp) - register char *cp; -{ - register unsigned long val, base, n; - register char c; - unsigned long parts[4], *pp = parts; - -again: - val = 0; base = 10; - if (*cp == '0') - base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - base = 16, cp++; - while (c = *cp) { - if (isdigit(c)) { - val = (val * base) + (c - '0'); - cp++; - continue; - } - if (base == 16 && isxdigit(c)) { - val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); - cp++; - continue; - } - break; - } - if (*cp == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16-bits) - * a.b (with b treated as 24 bits) - */ - if (pp >= parts + 4) - return (-1); - *pp++ = val, cp++; - goto again; - } - if (*cp && !isspace(*cp)) - return (-1); - n = pp - parts; - if (n > 0) { - if (n > 4) - return (-1); - *pp++ = val; n++; - val = parts[0]; - if (n > 1) - val <<= 24; - if (n > 2) - val |= (parts[1] & 0xff) << 16; - if (n > 3) - val |= (parts[2] & 0xff) << 8; - if (n > 1) - val |= parts[n - 1]; -#if vax || pdp11 - val = htonl(val); -#endif - } - return (val); -} - static char * any(cp, match) register char *cp; diff --git a/usr/src/lib/libc/net/getproto.c b/usr/src/lib/libc/net/getproto.c index 0ea9f2d39c..cab54f9f23 100644 --- a/usr/src/lib/libc/net/getproto.c +++ b/usr/src/lib/libc/net/getproto.c @@ -1,9 +1,9 @@ -/* getproto.c 4.1 82/08/25 */ +/* getproto.c 4.2 82/10/05 */ #include struct protoent * -getproto(proto) +getprotobynumber(proto) register int proto; { register struct protoent *p; diff --git a/usr/src/lib/libc/net/getprotoent.c b/usr/src/lib/libc/net/getprotoent.c index c779d18cb7..def32cd41e 100644 --- a/usr/src/lib/libc/net/getprotoent.c +++ b/usr/src/lib/libc/net/getprotoent.c @@ -1,4 +1,4 @@ -/* getprotoent.c 4.1 82/08/25 */ +/* getprotoent.c 4.2 82/10/05 */ #include #include @@ -13,7 +13,6 @@ static char line[BUFSIZ+1]; static struct protoent proto; static char *proto_aliases[MAXALIASES]; static int stayopen = 0; -static unsigned long value(); static char *any(); setprotoent(f) diff --git a/usr/src/lib/libc/net/getprotoname.c b/usr/src/lib/libc/net/getprotoname.c index 30ca3d400e..08b1df0446 100644 --- a/usr/src/lib/libc/net/getprotoname.c +++ b/usr/src/lib/libc/net/getprotoname.c @@ -1,9 +1,9 @@ -/* getprotoname.c 4.1 82/08/25 */ +/* getprotoname.c 4.2 82/10/05 */ #include struct protoent * -getprotoname(name) +getprotobyname(name) register char *name; { register struct protoent *p; diff --git a/usr/src/lib/libc/net/getservbyname.c b/usr/src/lib/libc/net/getservbyname.c index 2077cecb7b..4e7eed8288 100644 --- a/usr/src/lib/libc/net/getservbyname.c +++ b/usr/src/lib/libc/net/getservbyname.c @@ -1,9 +1,9 @@ -/* getservbyname.c 4.1 82/08/25 */ +/* getservbyname.c 4.2 82/10/05 */ #include struct servent * -getservname(name, proto) +getservbyname(name, proto) char *name, *proto; { register struct servent *p; diff --git a/usr/src/lib/libc/net/getservbyport.c b/usr/src/lib/libc/net/getservbyport.c index 00970d7bb4..9136d38c5a 100644 --- a/usr/src/lib/libc/net/getservbyport.c +++ b/usr/src/lib/libc/net/getservbyport.c @@ -1,9 +1,9 @@ -/* getservbyport.c 4.1 82/08/25 */ +/* getservbyport.c 4.2 82/10/05 */ #include struct servent * -getservport(port, proto) +getservbyport(port, proto) int port; char *proto; { diff --git a/usr/src/lib/libc/net/getservent.c b/usr/src/lib/libc/net/getservent.c index 7264c502d6..f23a6d29b7 100644 --- a/usr/src/lib/libc/net/getservent.c +++ b/usr/src/lib/libc/net/getservent.c @@ -1,4 +1,4 @@ -/* getservent.c 4.1 82/08/25 */ +/* getservent.c 4.2 82/10/05 */ #include #include @@ -13,7 +13,6 @@ static char line[BUFSIZ+1]; static struct servent serv; static char *serv_aliases[MAXALIASES]; static int stayopen = 0; -static unsigned long value(); static char *any(); setservent(f) diff --git a/usr/src/lib/libc/net/inet_addr.c b/usr/src/lib/libc/net/inet_addr.c index e42ec4b336..8a8414a1f9 100644 --- a/usr/src/lib/libc/net/inet_addr.c +++ b/usr/src/lib/libc/net/inet_addr.c @@ -1,4 +1,8 @@ -/* inet_addr.c 4.1 82/10/05 */ +/* inet_addr.c 4.2 82/10/05 */ + +#include +#include + /* * Internet address interpretation routine. * All the network library routines call this