static char *sccsid
= "@(#)who.c 4.1 (Berkeley) %G%";
#define NMAX sizeof(utmp.ut_name)
#define LMAX sizeof(utmp.ut_line)
struct passwd
*getpwuid();
char *ttyname(), *rindex(), *ctime(), *strcpy();
tp
= rindex(tp
, '/') + 1;
else { /* no tty - use best guess from passwd file */
strcpy(utmp
.ut_name
, pw
?pw
->pw_name
: "?");
strcpy(utmp
.ut_line
, "tty??");
if ((fi
= fopen(s
, "r")) == NULL
) {
puts("who: cannot open utmp");
while (fread((char *)&utmp
, sizeof(utmp
), 1, fi
) == 1) {
if (strcmp(utmp
.ut_line
, tp
))
if(utmp
.ut_name
[0] == '\0' && argc
==1)
printf("%-*.*s %-*.*s", NMAX
, NMAX
, utmp
.ut_name
, LMAX
, LMAX
, utmp
.ut_line
);
cbuf
= ctime(&utmp
.ut_time
);
printf("%.12s\n", cbuf
+4);