SCCS-vsn: usr.bin/last/last.c 5.13
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)last.c 5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)last.c 5.13 (Berkeley) %G%";
static struct utmp buf[1024]; /* utmp read buffer */
static struct utmp buf[1024]; /* utmp read buffer */
-#define HMAX sizeof(buf[0].ut_host) /* size of utmp host field */
-#define LMAX sizeof(buf[0].ut_line) /* size of utmp tty field */
-#define NMAX sizeof(buf[0].ut_name) /* size of utmp name field */
-
typedef struct arg {
char *name; /* argument */
#define HOST_TYPE -2
typedef struct arg {
char *name; /* argument */
#define HOST_TYPE -2
typedef struct ttytab {
long logout; /* log out time */
typedef struct ttytab {
long logout; /* log out time */
- char tty[LMAX + 1]; /* terminal name */
+ char tty[UT_LINESIZE + 1]; /* terminal name */
struct ttytab *next; /* linked list pointer */
} TTY;
TTY *ttylist; /* head of linked list */
struct ttytab *next; /* linked list pointer */
} TTY;
TTY *ttylist; /* head of linked list */
for (T = ttylist; T; T = T->next)
T->logout = -bp->ut_time;
currentout = -bp->ut_time;
for (T = ttylist; T; T = T->next)
T->logout = -bp->ut_time;
currentout = -bp->ut_time;
- crmsg = strncmp(bp->ut_name, "shutdown", NMAX) ? "crash" : "shutdown";
+ crmsg = strncmp(bp->ut_name, "shutdown",
+ UT_NAMESIZE) ? "crash" : "shutdown";
if (want(bp, NO)) {
ct = ctime(&bp->ut_time);
if (want(bp, NO)) {
ct = ctime(&bp->ut_time);
- printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", NMAX, NMAX, bp->ut_name, LMAX, LMAX, bp->ut_line, HMAX, HMAX, bp->ut_host, ct, ct + 11);
+ printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, UT_LINESIZE, UT_LINESIZE, bp->ut_line, UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, ct, ct + 11);
if (maxrec && !--maxrec)
return;
}
if (maxrec && !--maxrec)
return;
}
&& !bp->ut_line[1]) {
if (want(bp, NO)) {
ct = ctime(&bp->ut_time);
&& !bp->ut_line[1]) {
if (want(bp, NO)) {
ct = ctime(&bp->ut_time);
- printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", NMAX, NMAX, bp->ut_name, LMAX, LMAX, bp->ut_line, HMAX, HMAX, bp->ut_host, ct, ct + 11);
+ printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n", UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, UT_LINESIZE, UT_LINESIZE, bp->ut_line, UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, ct, ct + 11);
if (maxrec && !--maxrec)
return;
}
if (maxrec && !--maxrec)
return;
}
T = addtty(bp->ut_line);
break;
}
T = addtty(bp->ut_line);
break;
}
- if (!strncmp(T->tty, bp->ut_line, LMAX))
+ if (!strncmp(T->tty, bp->ut_line, UT_LINESIZE))
break;
}
if (bp->ut_name[0] && want(bp, YES)) {
ct = ctime(&bp->ut_time);
break;
}
if (bp->ut_name[0] && want(bp, YES)) {
ct = ctime(&bp->ut_time);
- printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s ", NMAX, NMAX, bp->ut_name, LMAX, LMAX, bp->ut_line, HMAX, HMAX, bp->ut_host, ct, ct + 11);
+ printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s ", UT_NAMESIZE, UT_NAMESIZE, bp->ut_name, UT_LINESIZE, UT_LINESIZE, bp->ut_line, UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host, ct, ct + 11);
if (!T->logout)
puts(" still logged in");
else {
if (!T->logout)
puts(" still logged in");
else {
for (step = arglist; step; step = step->next)
switch(step->type) {
case HOST_TYPE:
for (step = arglist; step; step = step->next)
switch(step->type) {
case HOST_TYPE:
- if (!strncasecmp(step->name, bp->ut_host, HMAX))
+ if (!strncasecmp(step->name, bp->ut_host, UT_HOSTSIZE))
return(YES);
break;
case TTY_TYPE:
return(YES);
break;
case TTY_TYPE:
- if (!strncmp(step->name, bp->ut_line, LMAX))
+ if (!strncmp(step->name, bp->ut_line, UT_LINESIZE))
return(YES);
break;
case USER_TYPE:
return(YES);
break;
case USER_TYPE:
- if (!strncmp(step->name, bp->ut_name, NMAX))
+ if (!strncmp(step->name, bp->ut_name, UT_NAMESIZE))
}
cur->next = ttylist;
cur->logout = currentout;
}
cur->next = ttylist;
cur->logout = currentout;
- bcopy(ttyname, cur->tty, LMAX);
+ bcopy(ttyname, cur->tty, UT_LINESIZE);