static char *sccsid
= "@(#)lastcomm.c 4.3 (Berkeley) %G%";
struct acct acct_buff
[BUFSIZ
/ sizeof (struct acct
)];
while (passwd
= getpwent ())
if (user_list
[passwd
->pw_uid
][0]==0)
move (passwd
->pw_name
, user_list
[passwd
->pw_uid
]);
acct_desc
= open ("/usr/adm/acct", 0);
perror ("/usr/adm/acct");
fstat (acct_desc
, &stat_buff
);
n_blocks
= (stat_buff
.st_size
+ BUFSIZ
- 1) / BUFSIZ
;
for (i_block
= n_blocks
- 1; i_block
>= 0; i_block
--)
lseek (acct_desc
, i_block
* BUFSIZ
, 0);
n_byte
= read (acct_desc
, acct_buff
, BUFSIZ
);
n_entry
= n_byte
/ sizeof acct_buff
[0];
for (i
= n_entry
- 1; i
>= 0; i
--)
if (!*user_list
[acct_buff
[i
].ac_uid
]) continue;
x
= expand (acct_buff
[i
].ac_utime
)
expand (acct_buff
[i
].ac_stime
);
* null terminate the command name
acct_buff
[i
].ac_comm
[10] = 0;
* replace missing command names with question marks
if (!*acct_buff
[i
].ac_comm
)
move ("?", acct_buff
[i
].ac_comm
);
* replace control characters with question marks
for (p
= acct_buff
[i
].ac_comm
; *p
; p
++)
if (*p
< '!' || '~' < *p
) *p
= '?';
for (j
= 1; j
< argc
; j
++)
equal (acct_buff
[i
].ac_comm
, argv
[j
])
user_list
[acct_buff
[i
].ac_uid
],
if (argc
== 1 || j
!= argc
)
"%-10s %-8s %6.2f %.16s\n",
user_list
[acct_buff
[i
].ac_uid
],
ctime (&acct_buff
[i
].ac_btime
)