merge of 4.1b and 4.1c
authorSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 15 Nov 1982 05:59:12 +0000 (21:59 -0800)
committerSam Leffler <sam@ucbvax.Berkeley.EDU>
Mon, 15 Nov 1982 05:59:12 +0000 (21:59 -0800)
SCCS-vsn: lib/libc/net/inet_addr.c 4.5
SCCS-vsn: lib/libc/net/inet_lnaof.c 4.3
SCCS-vsn: lib/libc/net/inet_makeaddr.c 4.3
SCCS-vsn: lib/libc/net/inet_netof.c 4.3
SCCS-vsn: lib/libc/gen/getlogin.c 4.2
SCCS-vsn: lib/libc/gen/seekdir.c 4.7

usr/src/lib/libc/gen/getlogin.c
usr/src/lib/libc/gen/seekdir.c
usr/src/lib/libc/net/inet_addr.c
usr/src/lib/libc/net/inet_lnaof.c
usr/src/lib/libc/net/inet_makeaddr.c
usr/src/lib/libc/net/inet_netof.c

index 40f6bd1..339c669 100644 (file)
@@ -1,26 +1,29 @@
-/*     @(#)getlogin.c  4.1 (Berkeley) %G%      */
+/*     getlogin.c      4.2     82/11/14        */
+
 #include <utmp.h>
 
 #include <utmp.h>
 
-static char    UTMP[]  = "/etc/utmp";
-static struct  utmp ubuf;
+static char UTMP[]     = "/etc/utmp";
+static struct utmp ubuf;
 
 char *
 getlogin()
 {
 
 char *
 getlogin()
 {
-       register me, uf;
+       register int me, uf;
        register char *cp;
 
        register char *cp;
 
-       if( !(me = ttyslot()) )
-               return(0);
-       if( (uf = open( UTMP, 0 )) < 0 )
-               return(0);
-       lseek( uf, (long)(me*sizeof(ubuf)), 0 );
-       if (read(uf, (char *)&ubuf, sizeof(ubuf)) != sizeof(ubuf))
+       if (!(me = ttyslot()))
                return(0);
                return(0);
+       if ((uf = open(UTMP, 0)) < 0)
+               return (0);
+       lseek (uf, (long)(me*sizeof(ubuf)), 0);
+       if (read(uf, (char *)&ubuf, sizeof (ubuf)) != sizeof (ubuf)) {
+               close(uf);
+               return (0);
+       }
        close(uf);
        ubuf.ut_name[sizeof (ubuf.ut_name)] = ' ';
        close(uf);
        ubuf.ut_name[sizeof (ubuf.ut_name)] = ' ';
-       for (cp=ubuf.ut_name; *cp++!=' ';)
+       for (cp = ubuf.ut_name; *cp++ != ' '; )
                ;
        *--cp = '\0';
                ;
        *--cp = '\0';
-       return( ubuf.ut_name );
+       return (ubuf.ut_name);
 }
 }
index 88628a1..49e8d24 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)seekdir.c 4.6 %G%";
+static char sccsid[] = "@(#)seekdir.c 4.7 %G%";
 
 #include <sys/param.h>
 #include <dir.h>
 
 #include <sys/param.h>
 #include <dir.h>
@@ -22,6 +22,10 @@ seekdir(dirp, loc)
                return;
        base = loc & ~(DIRBLKSIZ - 1);
        offset = loc & (DIRBLKSIZ - 1);
                return;
        base = loc & ~(DIRBLKSIZ - 1);
        offset = loc & (DIRBLKSIZ - 1);
+       if (dirp->dd_loc != 0 && (curloc & ~(DIRBLKSIZ - 1)) == base) {
+               dirp->dd_loc = offset;
+               return;
+       }
        lseek(dirp->dd_fd, base, 0);
        dirp->dd_loc = 0;
        while (dirp->dd_loc < offset) {
        lseek(dirp->dd_fd, base, 0);
        dirp->dd_loc = 0;
        while (dirp->dd_loc < offset) {
index 286124c..98118f0 100644 (file)
@@ -1,8 +1,8 @@
-/*     inet_addr.c     4.4     82/10/07        */
+/*     inet_addr.c     4.5     82/11/14        */
 
 #include <sys/types.h>
 #include <ctype.h>
 
 #include <sys/types.h>
 #include <ctype.h>
-#include <net/in.h>
+#include <netinet/in.h>
 
 /*
  * Internet address interpretation routine.
 
 /*
  * Internet address interpretation routine.
index fde223f..52c56bf 100644 (file)
@@ -1,7 +1,7 @@
-/*     inet_lnaof.c    4.2     82/10/07        */
+/*     inet_lnaof.c    4.3     82/11/14        */
 
 #include <sys/types.h>
 
 #include <sys/types.h>
-#include <net/in.h>
+#include <netinet/in.h>
 
 /*
  * Return the local network address portion of an
 
 /*
  * Return the local network address portion of an
 inet_lnaof(in)
        struct in_addr in;
 {
 inet_lnaof(in)
        struct in_addr in;
 {
-#if vax || pdp11
-#define        IN_LNAOF(in) \
-       (((in).s_addr&IN_CLASSA) == 0 ? (in).s_addr&IN_CLASSA_LNA : \
-               ((in).s_addr&IN_CLASSB) == 0 ? (in).s_addr&IN_CLASSB_LNA : \
-                       (in).s_addr&IN_CLASSC_LNA)
-       return ((int)htonl((u_long)IN_LNAOF(in)));
-#else
-       return (IN_LNAOF(in));
-#endif
+       register u_long i = ntohl(in.s_addr);
+
+       if (IN_CLASSA(i))
+               return ((i)&IN_CLASSA_HOST);
+       else if (IN_CLASSB(i))
+               return ((i)&IN_CLASSB_HOST);
+       else
+               return ((i)&IN_CLASSC_HOST);
 }
 }
index 7620f09..24fba7b 100644 (file)
@@ -1,7 +1,7 @@
-/*     inet_makeaddr.c 4.2     82/10/07        */
+/*     inet_makeaddr.c 4.3     82/11/14        */
 
 #include <sys/types.h>
 
 #include <sys/types.h>
-#include <net/in.h>
+#include <netinet/in.h>
 
 /*
  * Formulate an Internet address from network + host.  Used in
 
 /*
  * Formulate an Internet address from network + host.  Used in
@@ -14,11 +14,11 @@ inet_makeaddr(net, host)
        u_long addr;
 
        if (net < 128)
        u_long addr;
 
        if (net < 128)
-               addr = (net << 24) | host;
+               addr = (net << IN_CLASSA_NSHIFT) | host;
        else if (net < 65536)
        else if (net < 65536)
-               addr = (net << 16) | host;
+               addr = (net << IN_CLASSB_NSHIFT) | host;
        else
        else
-               addr = (net << 8) | host;
+               addr = (net << IN_CLASSC_NSHIFT) | host;
        addr = htonl(addr);
        return (*(struct in_addr *)&addr);
 }
        addr = htonl(addr);
        return (*(struct in_addr *)&addr);
 }
index 2e7e8c3..e1fa947 100644 (file)
@@ -1,7 +1,7 @@
-/*     inet_netof.c    4.2     82/10/07        */
+/*     inet_netof.c    4.3     82/11/14        */
 
 #include <sys/types.h>
 
 #include <sys/types.h>
-#include <net/in.h>
+#include <netinet/in.h>
 
 /*
  * Return the network number from an internet
 
 /*
  * Return the network number from an internet
 inet_netof(in)
        struct in_addr in;
 {
 inet_netof(in)
        struct in_addr in;
 {
-#if vax || pdp11
-       register u_long net;
+       register u_long i = ntohl(in.s_addr);
 
 
-       if ((in.s_addr&IN_CLASSA) == 0)
-               return (in.s_addr & IN_CLASSA_NET);
-       if ((in.s_addr&IN_CLASSB) == 0)
-               return ((int)htons((u_short)(in.s_addr & IN_CLASSB_NET)));
-       net = htonl((u_long)(in.s_addr & IN_CLASSC_NET));
-       net >>= 8;
-       return ((int)net);
-#else
-       return (IN_NETOF(in));
-#endif
+       if (IN_CLASSA(i))
+               return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
+       else if (IN_CLASSB(i))
+               return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
+       else
+               return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
 }
 }