home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
unix
/
volume26
/
modempool
/
part01
/
utmplist.c
< prev
Wrap
C/C++ Source or Header
|
1993-04-05
|
706b
|
28 lines
#include <stdio.h>
#include <sys/types.h>
#include <utmp.h>
main()
{
FILE *fp;
struct utmp buf;
if ((fp = fopen(UTMP_FILE, "r")) == NULL) {
fprintf(stderr, "failed to open UTMP\n");
exit(1);
}
while(fread(&buf, sizeof buf, 1, fp) == 1) {
printf("User: %s\n", buf.ut_user);
printf("Id: %s\n", buf.ut_id);
printf("Line: %s\n", buf.ut_line);
printf("Pid: %d\n", buf.ut_pid);
printf("Type: %d\n", buf.ut_type);
printf("Termination status: %d\n", buf.ut_exit.e_termination);
printf("Exit status: %d\n", buf.ut_exit.e_exit);
printf("Dead process exit status: %d\n", buf.ut_exit);
printf("Time entry was made: %d\n", buf.ut_time);
printf("\n");
}
fclose(fp);
}