Don't attempt to parse %c
This commit is contained in:
parent
fa2b491527
commit
f4d292b799
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74586
@ -37,6 +37,7 @@
|
||||
extern char tbuf[1024]; /* Temp buffer for anybody. */
|
||||
extern int entries; /* Number of people. */
|
||||
extern DB *db; /* Database. */
|
||||
extern int d_first;
|
||||
|
||||
void enter_lastlog __P((PERSON *));
|
||||
PERSON *enter_person __P((struct passwd *));
|
||||
|
@ -89,6 +89,7 @@ static const char rcsid[] =
|
||||
DB *db;
|
||||
time_t now;
|
||||
int entries, lflag, mflag, pplan, sflag, oflag, Tflag;
|
||||
int d_first = -1;
|
||||
char tbuf[1024];
|
||||
|
||||
static void loginlist __P((void));
|
||||
|
@ -47,6 +47,7 @@ static const char rcsid[] =
|
||||
#include <db.h>
|
||||
#include <err.h>
|
||||
#include <fcntl.h>
|
||||
#include <langinfo.h>
|
||||
#include <paths.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
@ -106,9 +107,10 @@ lprint(pn)
|
||||
register int cpr, len, maxlen;
|
||||
struct tm *tp;
|
||||
int oddfield;
|
||||
char *tzn;
|
||||
char t[80];
|
||||
|
||||
if (d_first < 0)
|
||||
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
|
||||
/*
|
||||
* long format --
|
||||
* login name
|
||||
@ -173,10 +175,10 @@ lprint(pn)
|
||||
for (w = pn->whead; w != NULL; w = w->next) {
|
||||
if (w->info == LOGGEDIN) {
|
||||
tp = localtime(&w->loginat);
|
||||
strftime(t, sizeof(t), "%c", tp);
|
||||
tzn = tp->tm_zone;
|
||||
cpr = printf("On since %.16s (%s) on %s",
|
||||
t, tzn, w->tty);
|
||||
strftime(t, sizeof(t),
|
||||
d_first ? "%a %e %b %R (%Z)" : "%a %b %e %R (%Z)",
|
||||
tp);
|
||||
cpr = printf("On since %s on %s", t, w->tty);
|
||||
/*
|
||||
* idle time is tough; if have one, print a comma,
|
||||
* then spaces to pad out the device name, then the
|
||||
@ -204,15 +206,18 @@ lprint(pn)
|
||||
cpr = printf("Never logged in.");
|
||||
} else {
|
||||
tp = localtime(&w->loginat);
|
||||
strftime(t, sizeof(t), "%c", tp);
|
||||
tzn = tp->tm_zone;
|
||||
if (now - w->loginat > 86400 * 365 / 2)
|
||||
cpr =
|
||||
printf("Last login %.16s %.4s (%s) on %s",
|
||||
t, t + 20, tzn, w->tty);
|
||||
else
|
||||
cpr = printf("Last login %.16s (%s) on %s",
|
||||
t, tzn, w->tty);
|
||||
if (now - w->loginat > 86400 * 365 / 2) {
|
||||
strftime(t, sizeof(t),
|
||||
d_first ? "%a %e %b %R %Y (%Z)" :
|
||||
"%a %b %e %R %Y (%Z)",
|
||||
tp);
|
||||
} else {
|
||||
strftime(t, sizeof(t),
|
||||
d_first ? "%a %e %b %R (%Z)" :
|
||||
"%a %b %e %R (%Z)",
|
||||
tp);
|
||||
}
|
||||
cpr = printf("Last login %s on %s", t, w->tty);
|
||||
}
|
||||
if (*w->host) {
|
||||
if (LINE_LEN < (cpr + 6 + strlen(w->host)))
|
||||
@ -225,18 +230,24 @@ lprint(pn)
|
||||
printf("No Mail.\n");
|
||||
else if (pn->mailrecv > pn->mailread) {
|
||||
tp = localtime(&pn->mailrecv);
|
||||
strftime(t, sizeof(t), "%c", tp);
|
||||
tzn = tp->tm_zone;
|
||||
printf("New mail received %.16s %.4s (%s)\n", t, t + 20, tzn);
|
||||
strftime(t, sizeof(t),
|
||||
d_first ? "%a %e %b %R %Y (%Z)" :
|
||||
"%a %b %e %R %Y (%Z)",
|
||||
tp);
|
||||
printf("New mail received %s\n", t);
|
||||
tp = localtime(&pn->mailread);
|
||||
strftime(t, sizeof(t), "%c", tp);
|
||||
tzn = tp->tm_zone;
|
||||
printf(" Unread since %.16s %.4s (%s)\n", t, t + 20, tzn);
|
||||
strftime(t, sizeof(t),
|
||||
d_first ? "%a %e %b %R %Y (%Z)" :
|
||||
"%a %b %e %R %Y (%Z)",
|
||||
tp);
|
||||
printf(" Unread since %s\n", t);
|
||||
} else {
|
||||
tp = localtime(&pn->mailread);
|
||||
strftime(t, sizeof(t), "%c", tp);
|
||||
tzn = tp->tm_zone;
|
||||
printf("Mail last read %.16s %.4s (%s)\n", t, t + 20, tzn);
|
||||
strftime(t, sizeof(t),
|
||||
d_first ? "%a %e %b %R %Y (%Z)" :
|
||||
"%a %b %e %R %Y (%Z)",
|
||||
tp);
|
||||
printf("Mail last read %s\n", t);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@ static const char rcsid[] =
|
||||
|
||||
#include <db.h>
|
||||
#include <err.h>
|
||||
#include <langinfo.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -64,7 +65,10 @@ sflag_print()
|
||||
char p[80];
|
||||
PERSON *tmp;
|
||||
DBT data, key;
|
||||
struct tm *lc;
|
||||
|
||||
if (d_first < 0)
|
||||
d_first = (*nl_langinfo(D_MD_ORDER) == 'd');
|
||||
/*
|
||||
* short format --
|
||||
* login name
|
||||
@ -84,8 +88,8 @@ sflag_print()
|
||||
#define MAXREALNAME 20
|
||||
#define MAXHOSTNAME 17 /* in reality, hosts are never longer than 16 */
|
||||
(void)printf("%-*s %-*s%s %s\n", UT_NAMESIZE, "Login", MAXREALNAME,
|
||||
"Name", " TTY Idle Login Time",
|
||||
oflag ? " Office Phone" : " Where");
|
||||
"Name", " TTY Idle Login Time",
|
||||
oflag ? "Office Phone" : "Where");
|
||||
|
||||
for (sflag = R_FIRST;; sflag = R_NEXT) {
|
||||
r = (*db->seq)(db, &key, &data, sflag);
|
||||
@ -121,18 +125,23 @@ sflag_print()
|
||||
(void)printf(" ");
|
||||
} else
|
||||
(void)printf(" * ");
|
||||
strftime(p, sizeof(p), "%c", localtime(&w->loginat));
|
||||
lc = localtime(&w->loginat);
|
||||
#define SECSPERDAY 86400
|
||||
#define DAYSPERWEEK 7
|
||||
#define DAYSPERNYEAR 365
|
||||
if (now - w->loginat < SECSPERDAY * (DAYSPERWEEK - 1))
|
||||
(void)printf("%.3s ", p);
|
||||
else
|
||||
(void)printf("%.6s", p + 4);
|
||||
if (now - w->loginat >= SECSPERDAY * DAYSPERNYEAR / 2)
|
||||
(void)printf(" %.4s", p + 20);
|
||||
else
|
||||
(void)printf(" %.5s", p + 11);
|
||||
if (now - w->loginat < SECSPERDAY * (DAYSPERWEEK - 1)) {
|
||||
(void)strftime(p, sizeof(p), "%a", lc);
|
||||
} else {
|
||||
(void)strftime(p, sizeof(p),
|
||||
d_first ? "%e %b" : "%b %e", lc);
|
||||
}
|
||||
(void)printf("%-6.6s", p);
|
||||
if (now - w->loginat >= SECSPERDAY * DAYSPERNYEAR / 2) {
|
||||
(void)strftime(p, sizeof(p), "%Y", lc);
|
||||
} else {
|
||||
(void)strftime(p, sizeof(p), "%R", lc);
|
||||
}
|
||||
(void)printf(" %-5.5s", p);
|
||||
office: if (oflag) {
|
||||
if (pn->office)
|
||||
(void)printf(" %-7.7s", pn->office);
|
||||
|
Loading…
Reference in New Issue
Block a user