-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdutmp.c
72 lines (63 loc) · 1.77 KB
/
dutmp.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* CHK=0xD757 */
char *revision = "1.2";
/*+-----------------------------------------------------------------------
dutmp.c -- dump /etc/utmp
------------------------------------------------------------------------*/
/*+:EDITS:*/
/*:04-26-2000-11:15-wht@bob-RELEASE 4.42 */
/*:01-24-1997-02:36-wht@yuriatin-SOURCE RELEASE 4.00 */
/*:09-11-1996-19:[email protected] telnet,curses,structural overhaul */
/*:11-23-1995-11:20-wht@kepler-source control 3.37 for tsx-11 */
/*:11-14-1995-10:[email protected] control point: SOCKETS */
/*:05-04-1994-04:38-wht@n4hgf-ECU release 3.30 */
/*:09-10-1992-13:58-wht@n4hgf-ECU release 3.20 */
/*:08-22-1992-15:38-wht@n4hgf-ECU release 3.20 BETA */
/*:04-28-1992-13:05-wht@n4hgf-clean up for inclusion in ecu */
/*:11-19-1989-16:34-wht-creation */
#include <stdio.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
#include <utmp.h>
char *utmp_file = "/etc/utmp";
extern char *ctime();
/*+-------------------------------------------------------------------------
main(argc,argv)
--------------------------------------------------------------------------*/
main(argc, argv)
int argc;
char **argv;
{
struct utmp ut;
int ufd;
printf("dutmp %s\n", revision);
if ((ufd = open(utmp_file, O_RDONLY, 755)) < 0)
{
perror(utmp_file);
exit(1);
}
while (read(ufd, &ut, sizeof(ut)) > 0)
{
#if defined(sun)
if (!*ut.ut_name || (ut.ut_time < 0))
continue;
printf("%-10.10s %-14.14s %-15.15s %s",
ut.ut_name,
ut.ut_line,
ut.ut_host,
ctime(&ut.ut_time));
#else
printf("%-10.10s %-7.7s %-14.14s %6u %s",
ut.ut_user,
ut.ut_id,
ut.ut_line,
ut.ut_pid,
ctime(&ut.ut_time));
#endif
}
close(ufd);
exit(0);
} /* end of main */
/* vi: set tabstop=4 shiftwidth=4: */
/* end of dutmp.c */