* Copyright (c) 1989 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
* Redistribution and use in source and binary forms are permitted provided
* that: (1) source distributions retain this entire copyright notice and
* comment, and (2) distributions including binaries display the following
* acknowledgement: ``This product includes software developed by the
* University of California, Berkeley and its contributors'' in the
* documentation or other materials provided with the distribution and in
* all advertising materials mentioning features or use of this software.
* Neither the name of the University nor the names of its contributors may
* 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
[] = "@(#)lprint.c 5.12 (Berkeley) 6/24/90";
#define TAB_LEN 8 /* 8 spaces between tabs */
#define _PATH_PLAN ".plan"
#define _PATH_PROJECT ".project"
(void)show_text(pn
->dir
, _PATH_PROJECT
, "Project:");
if (!show_text(pn
->dir
, _PATH_PLAN
, "Plan:"))
(void)printf("No Plan.\n");
register struct tm
*delta
;
register int cpr
, len
, maxlen
;
char *t
, *tzn
, *prphone();
* office, office phone, home phone if available
(void)printf("Login: %-15s\t\t\tName: %s\nDirectory: %-25s",
pn
->name
, pn
->realname
, pn
->dir
);
(void)printf("\tShell: %-s\n", *pn
->shell
? pn
->shell
: _PATH_BSHELL
);
* try and print office, office phone, and home phone on one line;
* if that fails, do line filling so it looks nice.
#define OFFICE_TAG "Office"
#define OFFICE_PHONE_TAG "Office Phone"
if (pn
->office
&& pn
->officephone
&&
strlen(pn
->office
) + strlen(pn
->officephone
) +
sizeof(OFFICE_TAG
) + 2 <= 5 * TAB_LEN
) {
(void)sprintf(tbuf
, "%s: %s, %s", OFFICE_TAG
, pn
->office
,
prphone(pn
->officephone
));
oddfield
= demi_print(tbuf
, oddfield
);
(void)sprintf(tbuf
, "%s: %s", OFFICE_TAG
, pn
->office
);
oddfield
= demi_print(tbuf
, oddfield
);
(void)sprintf(tbuf
, "%s: %s", OFFICE_PHONE_TAG
,
prphone(pn
->officephone
));
oddfield
= demi_print(tbuf
, oddfield
);
(void)sprintf(tbuf
, "%s: %s", "Home Phone",
oddfield
= demi_print(tbuf
, oddfield
);
* long format con't: * if logged in
/* find out longest device name for this user for formatting */
for (w
= pn
->whead
, maxlen
= -1; w
!= NULL
; w
= w
->next
)
if ((len
= strlen(w
->tty
)) > maxlen
)
/* find rest of entries for user */
for (w
= pn
->whead
; w
!= NULL
; w
= w
->next
) {
tp
= localtime(&w
->loginat
);
cpr
= printf("On since %16.16s (%s) on %s",
* idle time is tough; if have one, print a comma,
* then spaces to pad out the device name, then the
* idle time. Follow with a comma if a remote login.
delta
= gmtime(&w
->idletime
);
if (delta
->tm_yday
|| delta
->tm_hour
|| delta
->tm_min
) {
cpr
+= printf("%-*s idle ",
maxlen
- strlen(w
->tty
) + 1, ",");
if (delta
->tm_yday
> 0) {
cpr
+= printf("%d day%s ",
delta
->tm_yday
== 1 ? "" : "s");
delta
->tm_hour
, delta
->tm_min
);
cpr
+= printf(" (messages off)");
(void)printf("Never logged in.");
tp
= localtime(&w
->loginat
);
if (now
- w
->loginat
> SECSPERDAY
* DAYSPERNYEAR
/ 2)
cpr
= printf("Last login %10.10s (%s), %4.4s on %s",
cpr
= printf("Last login %16.16s (%s) on %s",
if (LINE_LEN
< (cpr
+ 6 + strlen(w
->host
)))
(void)printf(" from %s", w
->host
);
demi_print(str
, oddfield
)
* We left off on an odd number of fields. If we haven't
* crossed the midpoint of the screen, and we have room for
* the next field, print it on the same line; otherwise,
* print it on a new line.
* Note: we insist on having the right hand fields start
* no less than 5 tabs out.
if (((((maxlen
/ TAB_LEN
) + 1) * TAB_LEN
) +
while(lenlast
< (4 * TAB_LEN
)) {
(void)printf("\t%s\n", str
); /* force one tab */
(void)printf("\n%s", str
); /* go to next line */
oddfield
= !oddfield
; /* this'll be undone below */
oddfield
= !oddfield
; /* toggle odd/even marker */
show_text(directory
, file_name
, header
)
char *directory
, *file_name
, *header
;
(void)sprintf(tbuf
, "%s/%s", directory
, file_name
);
if ((fp
= fopen(tbuf
, "r")) == NULL
)
(void)printf("%s\n", header
);
while ((ch
= getc(fp
)) != EOF
)
if (isprint(ch
) || !meta
&& (ch
== ' ' || ch
== '\t' || ch
== '\n'))
(void)putchar(ch
== '\177' ? '?' : ch
| 0100);