SCCS-vsn: usr.bin/last/last.c 8.2
- * Copyright (c) 1987, 1993
+ * Copyright (c) 1987, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* %sccs.include.redist.c%
* The Regents of the University of California. All rights reserved.
*
* %sccs.include.redist.c%
#ifndef lint
static char copyright[] =
#ifndef lint
static char copyright[] =
-"@(#) Copyright (c) 1987, 1993\n\
+"@(#) Copyright (c) 1987, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)last.c 8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)last.c 8.2 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
- register struct utmp *bp; /* current structure */
- register TTY *T; /* tty list entry */
+ struct utmp *bp; /* current structure */
+ TTY *T; /* tty list entry */
struct stat stb; /* stat of file for size */
long bl, delta; /* time difference */
int bytes, wfd;
struct stat stb; /* stat of file for size */
long bl, delta; /* time difference */
int bytes, wfd;
- register struct utmp *bp;
else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1))
bp->ut_line[4] = '\0';
if (!arglist)
else if (!strncmp(bp->ut_line, "uucp", sizeof("uucp") - 1))
bp->ut_line[4] = '\0';
if (!arglist)
for (step = arglist; step; step = step->next)
switch(step->type) {
case HOST_TYPE:
if (!strncasecmp(step->name, bp->ut_host, UT_HOSTSIZE))
for (step = arglist; step; step = step->next)
switch(step->type) {
case HOST_TYPE:
if (!strncasecmp(step->name, bp->ut_host, UT_HOSTSIZE))
break;
case TTY_TYPE:
if (!strncmp(step->name, bp->ut_line, UT_LINESIZE))
break;
case TTY_TYPE:
if (!strncmp(step->name, bp->ut_line, UT_LINESIZE))
break;
case USER_TYPE:
if (!strncmp(step->name, bp->ut_name, UT_NAMESIZE))
break;
case USER_TYPE:
if (!strncmp(step->name, bp->ut_name, UT_NAMESIZE))
- if (!(cur = (ARG *)malloc((u_int)sizeof(ARG)))) {
- fputs("last: malloc failure.\n", stderr);
- exit(1);
- }
+ if (!(cur = (ARG *)malloc((u_int)sizeof(ARG))))
+ err(1, "malloc failure");
cur->next = arglist;
cur->type = type;
cur->name = arg;
cur->next = arglist;
cur->type = type;
cur->name = arg;
addtty(ttyname)
char *ttyname;
{
addtty(ttyname)
char *ttyname;
{
- if (!(cur = (TTY *)malloc((u_int)sizeof(TTY)))) {
- fputs("last: malloc failure.\n", stderr);
- exit(1);
- }
+ if (!(cur = (TTY *)malloc((u_int)sizeof(TTY))))
+ err(1, "malloc failure");
cur->next = ttylist;
cur->logout = currentout;
cur->next = ttylist;
cur->logout = currentout;
- bcopy(ttyname, cur->tty, UT_LINESIZE);
- return(ttylist = cur);
+ memmove(cur->tty, ttyname, UT_LINESIZE);
+ return (ttylist = cur);
static char *hostdot, name[MAXHOSTNAMELEN];
char *argdot;
static char *hostdot, name[MAXHOSTNAMELEN];
char *argdot;
- if (!(argdot = index(arg, '.')))
+ if (!(argdot = strchr(arg, '.')))
return;
if (first) {
first = 0;
if (gethostname(name, sizeof(name)))
err(1, "gethostname");
return;
if (first) {
first = 0;
if (gethostname(name, sizeof(name)))
err(1, "gethostname");
- hostdot = index(name, '.');
+ hostdot = strchr(name, '.');
}
if (hostdot && !strcasecmp(hostdot, argdot))
*argdot = '\0';
}
if (hostdot && !strcasecmp(hostdot, argdot))
*argdot = '\0';
*/
if (strlen(arg) == 2) {
/* either 6 for "ttyxx" or 8 for "console" */
*/
if (strlen(arg) == 2) {
/* either 6 for "ttyxx" or 8 for "console" */
- if (!(mval = malloc((u_int)8))) {
- fputs("last: malloc failure.\n", stderr);
- exit(1);
- }
+ if (!(mval = malloc((u_int)8)))
+ err(1, "malloc failure");
if (!strcmp(arg, "co"))
(void)strcpy(mval, "console");
else {
(void)strcpy(mval, "tty");
(void)strcpy(mval + 3, arg);
}
if (!strcmp(arg, "co"))
(void)strcpy(mval, "console");
else {
(void)strcpy(mval, "tty");
(void)strcpy(mval + 3, arg);
}
}
if (!strncmp(arg, _PATH_DEV, sizeof(_PATH_DEV) - 1))
}
if (!strncmp(arg, _PATH_DEV, sizeof(_PATH_DEV) - 1))
- return(arg + 5);
- return(arg);
+ return (arg + 5);
+ return (arg);