# include #include # include # include # include # define UTMP "/etc/utmp" main (ac, argv) char *argv[]; int ac; { FILE *u, *fopen(); struct utmpx ur; char tty[20]; if (!(u = fopen (argv[1], "r"))) { perror (argv[1]); exit (1); } while (read (fileno(u), &ur, sizeof (ur)) == sizeof (ur)) { printf ("line: `%-8.8s', user: `%-8.8s', type: `%d', host:%-30s ,time:%s", ur.ut_line, ur.ut_user, ur.ut_type, ur.ut_host, ctime(&ur.ut_xtime)); } }