* Copyright (c) 1989 The Regents of the University of California.
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Berkeley. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
static char sccsid
[] = "@(#)sprint.c 5.3 (Berkeley) %G%";
* 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(" %-11.11s", pn
->office
);
else if (pn
->officephone
)
(void)printf(" %-11.11s", " ");
(void)printf(" %s", 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
);