lprint.c (72109) | lprint.c (74586) |
---|---|
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static char sccsid[] = "@(#)lprint.c 8.3 (Berkeley) 4/28/95"; 40#endif 41static const char rcsid[] = | 1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static char sccsid[] = "@(#)lprint.c 8.3 (Berkeley) 4/28/95"; 40#endif 41static const char rcsid[] = |
42 "$FreeBSD: head/usr.bin/finger/lprint.c 72109 2001-02-06 20:13:48Z charnier $"; | 42 "$FreeBSD: head/usr.bin/finger/lprint.c 74586 2001-03-21 18:43:49Z ache $"; |
43#endif /* not lint */ 44 45#include <sys/stat.h> 46#include <ctype.h> 47#include <db.h> 48#include <err.h> 49#include <fcntl.h> | 43#endif /* not lint */ 44 45#include <sys/stat.h> 46#include <ctype.h> 47#include <db.h> 48#include <err.h> 49#include <fcntl.h> |
50#include <langinfo.h> |
|
50#include <paths.h> 51#include <pwd.h> 52#include <stdio.h> 53#include <string.h> 54#include <unistd.h> 55#include <utmp.h> 56#include "finger.h" 57#include "pathnames.h" --- 43 unchanged lines hidden (view full) --- 101 register PERSON *pn; 102{ 103 extern time_t now; 104 register struct tm *delta; 105 register WHERE *w; 106 register int cpr, len, maxlen; 107 struct tm *tp; 108 int oddfield; | 51#include <paths.h> 52#include <pwd.h> 53#include <stdio.h> 54#include <string.h> 55#include <unistd.h> 56#include <utmp.h> 57#include "finger.h" 58#include "pathnames.h" --- 43 unchanged lines hidden (view full) --- 102 register PERSON *pn; 103{ 104 extern time_t now; 105 register struct tm *delta; 106 register WHERE *w; 107 register int cpr, len, maxlen; 108 struct tm *tp; 109 int oddfield; |
109 char *tzn; | |
110 char t[80]; 111 | 110 char t[80]; 111 |
112 if (d_first < 0) 113 d_first = (*nl_langinfo(D_MD_ORDER) == 'd'); |
|
112 /* 113 * long format -- 114 * login name 115 * real name 116 * home directory 117 * shell 118 * office, office phone, home phone if available 119 * mail status --- 48 unchanged lines hidden (view full) --- 168 /* find out longest device name for this user for formatting */ 169 for (w = pn->whead, maxlen = -1; w != NULL; w = w->next) 170 if ((len = strlen(w->tty)) > maxlen) 171 maxlen = len; 172 /* find rest of entries for user */ 173 for (w = pn->whead; w != NULL; w = w->next) { 174 if (w->info == LOGGEDIN) { 175 tp = localtime(&w->loginat); | 114 /* 115 * long format -- 116 * login name 117 * real name 118 * home directory 119 * shell 120 * office, office phone, home phone if available 121 * mail status --- 48 unchanged lines hidden (view full) --- 170 /* find out longest device name for this user for formatting */ 171 for (w = pn->whead, maxlen = -1; w != NULL; w = w->next) 172 if ((len = strlen(w->tty)) > maxlen) 173 maxlen = len; 174 /* find rest of entries for user */ 175 for (w = pn->whead; w != NULL; w = w->next) { 176 if (w->info == LOGGEDIN) { 177 tp = localtime(&w->loginat); |
176 strftime(t, sizeof(t), "%c", tp); 177 tzn = tp->tm_zone; 178 cpr = printf("On since %.16s (%s) on %s", 179 t, tzn, w->tty); | 178 strftime(t, sizeof(t), 179 d_first ? "%a %e %b %R (%Z)" : "%a %b %e %R (%Z)", 180 tp); 181 cpr = printf("On since %s on %s", t, w->tty); |
180 /* 181 * idle time is tough; if have one, print a comma, 182 * then spaces to pad out the device name, then the 183 * idle time. Follow with a comma if a remote login. 184 */ 185 delta = gmtime(&w->idletime); 186 if (delta->tm_yday || delta->tm_hour || delta->tm_min) { 187 cpr += printf("%-*s idle ", --- 11 unchanged lines hidden (view full) --- 199 } 200 } 201 if (!w->writable) 202 cpr += printf(" (messages off)"); 203 } else if (w->loginat == 0) { 204 cpr = printf("Never logged in."); 205 } else { 206 tp = localtime(&w->loginat); | 182 /* 183 * idle time is tough; if have one, print a comma, 184 * then spaces to pad out the device name, then the 185 * idle time. Follow with a comma if a remote login. 186 */ 187 delta = gmtime(&w->idletime); 188 if (delta->tm_yday || delta->tm_hour || delta->tm_min) { 189 cpr += printf("%-*s idle ", --- 11 unchanged lines hidden (view full) --- 201 } 202 } 203 if (!w->writable) 204 cpr += printf(" (messages off)"); 205 } else if (w->loginat == 0) { 206 cpr = printf("Never logged in."); 207 } else { 208 tp = localtime(&w->loginat); |
207 strftime(t, sizeof(t), "%c", tp); 208 tzn = tp->tm_zone; 209 if (now - w->loginat > 86400 * 365 / 2) 210 cpr = 211 printf("Last login %.16s %.4s (%s) on %s", 212 t, t + 20, tzn, w->tty); 213 else 214 cpr = printf("Last login %.16s (%s) on %s", 215 t, tzn, w->tty); | 209 if (now - w->loginat > 86400 * 365 / 2) { 210 strftime(t, sizeof(t), 211 d_first ? "%a %e %b %R %Y (%Z)" : 212 "%a %b %e %R %Y (%Z)", 213 tp); 214 } else { 215 strftime(t, sizeof(t), 216 d_first ? "%a %e %b %R (%Z)" : 217 "%a %b %e %R (%Z)", 218 tp); 219 } 220 cpr = printf("Last login %s on %s", t, w->tty); |
216 } 217 if (*w->host) { 218 if (LINE_LEN < (cpr + 6 + strlen(w->host))) 219 (void)printf("\n "); 220 (void)printf(" from %s", w->host); 221 } 222 putchar('\n'); 223 } 224 if (pn->mailrecv == -1) 225 printf("No Mail.\n"); 226 else if (pn->mailrecv > pn->mailread) { 227 tp = localtime(&pn->mailrecv); | 221 } 222 if (*w->host) { 223 if (LINE_LEN < (cpr + 6 + strlen(w->host))) 224 (void)printf("\n "); 225 (void)printf(" from %s", w->host); 226 } 227 putchar('\n'); 228 } 229 if (pn->mailrecv == -1) 230 printf("No Mail.\n"); 231 else if (pn->mailrecv > pn->mailread) { 232 tp = localtime(&pn->mailrecv); |
228 strftime(t, sizeof(t), "%c", tp); 229 tzn = tp->tm_zone; 230 printf("New mail received %.16s %.4s (%s)\n", t, t + 20, tzn); | 233 strftime(t, sizeof(t), 234 d_first ? "%a %e %b %R %Y (%Z)" : 235 "%a %b %e %R %Y (%Z)", 236 tp); 237 printf("New mail received %s\n", t); |
231 tp = localtime(&pn->mailread); | 238 tp = localtime(&pn->mailread); |
232 strftime(t, sizeof(t), "%c", tp); 233 tzn = tp->tm_zone; 234 printf(" Unread since %.16s %.4s (%s)\n", t, t + 20, tzn); | 239 strftime(t, sizeof(t), 240 d_first ? "%a %e %b %R %Y (%Z)" : 241 "%a %b %e %R %Y (%Z)", 242 tp); 243 printf(" Unread since %s\n", t); |
235 } else { 236 tp = localtime(&pn->mailread); | 244 } else { 245 tp = localtime(&pn->mailread); |
237 strftime(t, sizeof(t), "%c", tp); 238 tzn = tp->tm_zone; 239 printf("Mail last read %.16s %.4s (%s)\n", t, t + 20, tzn); | 246 strftime(t, sizeof(t), 247 d_first ? "%a %e %b %R %Y (%Z)" : 248 "%a %b %e %R %Y (%Z)", 249 tp); 250 printf("Mail last read %s\n", t); |
240 } 241} 242 243static int 244demi_print(str, oddfield) 245 char *str; 246 int oddfield; 247{ --- 109 unchanged lines hidden --- | 251 } 252} 253 254static int 255demi_print(str, oddfield) 256 char *str; 257 int oddfield; 258{ --- 109 unchanged lines hidden --- |