* Copyright (c) 1989 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)sprint.c 5.7 (Berkeley) %G%";
char *ctime(), *prphone();
* terminal name (the XX of ttyXX)
* if terminal writeable (add an '*' to the terminal name
* if logged in show idle time and day logged in, else
* show last login date and time. If > 6 moths,
* show year instead of time.
(void)printf("%-*s %-*s %s\n", UT_NAMESIZE
, "Login", MAXREALNAME
,
"Name", "Tty Idle Login Office Office Phone");
for (cnt
= 0; cnt
< entries
; ++cnt
) {
for (w
= pn
->whead
; w
!= NULL
; w
= w
->next
) {
(void)printf("%-*.*s %-*.*s ", UT_NAMESIZE
, UT_NAMESIZE
,
pn
->name
, MAXREALNAME
, MAXREALNAME
,
pn
->realname
? pn
->realname
: "");
(void)printf(" * * No logins ");
(void)putchar(w
->info
== LOGGEDIN
&& !w
->writable
?
w
->tty
[0] != 't' || w
->tty
[1] != 't' ||
w
->tty
[2] != 'y' ? w
->tty
: w
->tty
+ 3);
if (w
->info
== LOGGEDIN
) {
(void)printf("%.6s", p
+ 4);
if (now
- w
->loginat
>= SECSPERDAY
* DAYSPERNYEAR
/ 2)
(void)printf(" %.4s", p
+ 20);
(void)printf(" %.5s", p
+ 11);
(void)printf(" %-10.10s", pn
->office
);
else if (pn
->officephone
)
(void)printf(" %-10.10s", " ");
prphone(pn
->officephone
));
register PERSON
*pn
, **lp
;
if (!(list
= (PERSON
**)malloc((u_int
)(entries
* sizeof(PERSON
*))))) {
(void)fprintf(stderr
, "finger: out of space.\n");
for (lp
= list
, pn
= phead
; pn
!= NULL
; pn
= pn
->next
)
(void)qsort(list
, entries
, sizeof(PERSON
*), psort
);
return(strcmp((*p
)->name
, (*t
)->name
));
register struct tm
*delta
;
delta
= gmtime(&w
->idletime
);
(void)printf("%5d", delta
->tm_min
);
delta
->tm_hour
, delta
->tm_min
);
(void)printf("%4dd", delta
->tm_yday
);