rename library routines so as not conflict with gethostname
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 6 Oct 1982 14:19:48 +0000 (06:19 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Wed, 6 Oct 1982 14:19:48 +0000 (06:19 -0800)
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

usr/src/lib/libc/net/SCCS/hosttable/gethostent.c
usr/src/lib/libc/net/getnetbyaddr.c
usr/src/lib/libc/net/getnetbyname.c
usr/src/lib/libc/net/getnetent.c
usr/src/lib/libc/net/getproto.c
usr/src/lib/libc/net/getprotoent.c
usr/src/lib/libc/net/getprotoname.c
usr/src/lib/libc/net/getservbyname.c
usr/src/lib/libc/net/getservbyport.c
usr/src/lib/libc/net/getservent.c
usr/src/lib/libc/net/inet_addr.c

index 06bc216..f3dfc59 100644 (file)
@@ -1,19 +1,24 @@
-/*     gethostent.c    4.1     82/08/25        */
+/*     gethostent.c    4.2     82/10/05        */
 
 #include <stdio.h>
 
 #include <stdio.h>
+#include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
 #include <ctype.h>
 
 #include <sys/socket.h>
 #include <netdb.h>
 #include <ctype.h>
 
+/*
+ * Internet version.
+ */
 #define        MAXALIASES      35
 #define        MAXALIASES      35
+#define        MAXADDRSIZE     14
 
 static char HOSTDB[] = "/usr/lib/hosts";
 static FILE *hostf = NULL;
 static char line[BUFSIZ+1];
 
 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 struct hostent host;
 static char *host_aliases[MAXALIASES];
 static int stayopen = 0;
-static unsigned long value();
 static char *any();
 
 sethostent(f)
 static char *any();
 
 sethostent(f)
@@ -55,11 +60,14 @@ again:
        if (cp == NULL)
                goto again;
        *cp++ = '\0';
        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;
        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)
        host.h_aliases = host_aliases;
        cp = any(cp, " \t");
        if (cp != NULL)
@@ -80,68 +88,6 @@ again:
        return (&host);
 }
 
        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;
 static char *
 any(cp, match)
        register char *cp;
index 7c2b808..f1ad757 100644 (file)
@@ -1,9 +1,9 @@
-/*     getnetbyaddr.c  4.1     82/08/25        */
+/*     getnetbyaddr.c  4.2     82/10/05        */
 
 #include <netdb.h>
 
 struct netent *
 
 #include <netdb.h>
 
 struct netent *
-getnetaddr(net)
+getnetbyaddr(net)
        register int net;
 {
        register struct netent *p;
        register int net;
 {
        register struct netent *p;
index 7da81fe..ea5e261 100644 (file)
@@ -1,9 +1,9 @@
-/*     getnetbyname.c  4.1     82/08/25        */
+/*     getnetbyname.c  4.2     82/10/05        */
 
 #include <netdb.h>
 
 struct netent *
 
 #include <netdb.h>
 
 struct netent *
-getnetname(name)
+getnetbyname(name)
        register char *name;
 {
        register struct netent *p;
        register char *name;
 {
        register struct netent *p;
index 75bcf00..d51c89c 100644 (file)
@@ -1,4 +1,4 @@
-/*     getnetent.c     4.1     82/08/25        */
+/*     getnetent.c     4.2     82/10/05        */
 
 #include <stdio.h>
 #include <sys/socket.h>
 
 #include <stdio.h>
 #include <sys/socket.h>
@@ -13,7 +13,6 @@ static char line[BUFSIZ+1];
 static struct netent net;
 static char *net_aliases[MAXALIASES];
 static int stayopen = 0;
 static struct netent net;
 static char *net_aliases[MAXALIASES];
 static int stayopen = 0;
-static unsigned long value();
 static char *any();
 
 setnetent(f)
 static char *any();
 
 setnetent(f)
@@ -62,7 +61,7 @@ again:
        p = any(cp, " \t");
        if (p != NULL)
                *p++ = '\0';
        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) {
        net.n_aliases = net_aliases;
        q = net_aliases, cp = p;
        while (*cp) {
@@ -80,68 +79,6 @@ again:
        return (&net);
 }
 
        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;
 static char *
 any(cp, match)
        register char *cp;
index 0ea9f2d..cab54f9 100644 (file)
@@ -1,9 +1,9 @@
-/*     getproto.c      4.1     82/08/25        */
+/*     getproto.c      4.2     82/10/05        */
 
 #include <netdb.h>
 
 struct protoent *
 
 #include <netdb.h>
 
 struct protoent *
-getproto(proto)
+getprotobynumber(proto)
        register int proto;
 {
        register struct protoent *p;
        register int proto;
 {
        register struct protoent *p;
index c779d18..def32cd 100644 (file)
@@ -1,4 +1,4 @@
-/*     getprotoent.c   4.1     82/08/25        */
+/*     getprotoent.c   4.2     82/10/05        */
 
 #include <stdio.h>
 #include <sys/socket.h>
 
 #include <stdio.h>
 #include <sys/socket.h>
@@ -13,7 +13,6 @@ static char line[BUFSIZ+1];
 static struct protoent proto;
 static char *proto_aliases[MAXALIASES];
 static int stayopen = 0;
 static struct protoent proto;
 static char *proto_aliases[MAXALIASES];
 static int stayopen = 0;
-static unsigned long value();
 static char *any();
 
 setprotoent(f)
 static char *any();
 
 setprotoent(f)
index 30ca3d4..08b1df0 100644 (file)
@@ -1,9 +1,9 @@
-/*     getprotoname.c  4.1     82/08/25        */
+/*     getprotoname.c  4.2     82/10/05        */
 
 #include <netdb.h>
 
 struct protoent *
 
 #include <netdb.h>
 
 struct protoent *
-getprotoname(name)
+getprotobyname(name)
        register char *name;
 {
        register struct protoent *p;
        register char *name;
 {
        register struct protoent *p;
index 2077cec..4e7eed8 100644 (file)
@@ -1,9 +1,9 @@
-/*     getservbyname.c 4.1     82/08/25        */
+/*     getservbyname.c 4.2     82/10/05        */
 
 #include <netdb.h>
 
 struct servent *
 
 #include <netdb.h>
 
 struct servent *
-getservname(name, proto)
+getservbyname(name, proto)
        char *name, *proto;
 {
        register struct servent *p;
        char *name, *proto;
 {
        register struct servent *p;
index 00970d7..9136d38 100644 (file)
@@ -1,9 +1,9 @@
-/*     getservbyport.c 4.1     82/08/25        */
+/*     getservbyport.c 4.2     82/10/05        */
 
 #include <netdb.h>
 
 struct servent *
 
 #include <netdb.h>
 
 struct servent *
-getservport(port, proto)
+getservbyport(port, proto)
        int port;
        char *proto;
 {
        int port;
        char *proto;
 {
index 7264c50..f23a6d2 100644 (file)
@@ -1,4 +1,4 @@
-/*     getservent.c    4.1     82/08/25        */
+/*     getservent.c    4.2     82/10/05        */
 
 #include <stdio.h>
 #include <sys/socket.h>
 
 #include <stdio.h>
 #include <sys/socket.h>
@@ -13,7 +13,6 @@ static char line[BUFSIZ+1];
 static struct servent serv;
 static char *serv_aliases[MAXALIASES];
 static int stayopen = 0;
 static struct servent serv;
 static char *serv_aliases[MAXALIASES];
 static int stayopen = 0;
-static unsigned long value();
 static char *any();
 
 setservent(f)
 static char *any();
 
 setservent(f)
index e42ec4b..8a8414a 100644 (file)
@@ -1,4 +1,8 @@
-/*     inet_addr.c     4.1     82/10/05        */
+/*     inet_addr.c     4.2     82/10/05        */
+
+#include <sys/types.h>
+#include <ctype.h>
+
 /*
  * Internet address interpretation routine.
  * All the network library routines call this
 /*
  * Internet address interpretation routine.
  * All the network library routines call this