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
-/* @(#)getlogin.c 4.1 (Berkeley) %G% */
+/* getlogin.c 4.2 82/11/14 */
+
-static char UTMP[] = "/etc/utmp";
-static struct utmp ubuf;
+static char UTMP[] = "/etc/utmp";
+static struct utmp ubuf;
- 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 ((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++ != ' '; )
- return( ubuf.ut_name );
/* 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>
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) {
-/* 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>
/*
* Internet address interpretation routine.
/*
* Internet address interpretation routine.
-/* inet_lnaof.c 4.2 82/10/07 */
+/* inet_lnaof.c 4.3 82/11/14 */
/*
* 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);
-/* inet_makeaddr.c 4.2 82/10/07 */
+/* inet_makeaddr.c 4.3 82/11/14 */
/*
* Formulate an Internet address from network + host. Used in
/*
* Formulate an Internet address from network + host. Used in
u_long addr;
if (net < 128)
u_long addr;
if (net < 128)
- addr = (net << 24) | host;
+ addr = (net << IN_CLASSA_NSHIFT) | host;
- addr = (net << 16) | host;
+ addr = (net << IN_CLASSB_NSHIFT) | host;
- 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);
}
-/* inet_netof.c 4.2 82/10/07 */
+/* inet_netof.c 4.3 82/11/14 */
/*
* 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);