summaryrefslogtreecommitdiffstats
path: root/usr.bin/last/last.c
diff options
context:
space:
mode:
authoriedowse <iedowse@FreeBSD.org>2002-03-01 21:12:19 +0000
committeriedowse <iedowse@FreeBSD.org>2002-03-01 21:12:19 +0000
commit1090c48a394abcf2cce634967b761df386323cf1 (patch)
tree57d055b57007cb561106a68993b615d59aaafaa9 /usr.bin/last/last.c
parent5a6428cea6f4a4d6872e985d0e1411bd4ad7724f (diff)
downloadFreeBSD-src-1090c48a394abcf2cce634967b761df386323cf1.zip
FreeBSD-src-1090c48a394abcf2cce634967b761df386323cf1.tar.gz
Add a new "-y" flag which causes the year to be included in the
session start time. This is useful when looking at old or long-running wtmp files. PR: bin/12982 Obtained from: KOJIMA Hajime <kjm@rins.ryukoku.ac.jp>, keramida Reviewed by: keramida MFC after: 1 week
Diffstat (limited to 'usr.bin/last/last.c')
-rw-r--r--usr.bin/last/last.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/last/last.c b/usr.bin/last/last.c
index f548651..eed36f5 100644
--- a/usr.bin/last/last.c
+++ b/usr.bin/last/last.c
@@ -90,6 +90,7 @@ static long currentout, /* current logout value */
static const char *file = _PATH_WTMP; /* wtmp file */
static int sflag = 0; /* show delta in seconds */
static int width = 5; /* show seconds in delta */
+static int yflag; /* show year */
static int d_first;
static int snapfound = 0; /* found snapshot entry? */
static time_t snaptime; /* if != 0, we will only
@@ -112,7 +113,7 @@ void
usage(void)
{
(void)fprintf(stderr,
-"usage: last [-#] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h hostname]\n"
+"usage: last [-#] [-y] [-d [[CC]YY][MMDD]hhmm[.SS]] [-f file] [-h host]\n"
"\t[-t tty] [-s|w] [user ...]\n");
exit(1);
}
@@ -130,7 +131,7 @@ main(argc, argv)
maxrec = -1;
snaptime = 0;
- while ((ch = getopt(argc, argv, "0123456789d:f:h:st:w")) != -1)
+ while ((ch = getopt(argc, argv, "0123456789d:f:h:st:wy")) != -1)
switch (ch) {
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
@@ -167,6 +168,9 @@ main(argc, argv)
case 'w':
width = 8;
break;
+ case 'y':
+ yflag++;
+ break;
case '?':
default:
usage();
@@ -334,8 +338,9 @@ printentry(bp, tt)
exit(0);
t = _int_to_time(bp->ut_time);
tm = localtime(&t);
- (void) strftime(ct, sizeof(ct), d_first ? "%a %e %b %R" :
- "%a %b %e %R", tm);
+ (void) strftime(ct, sizeof(ct), d_first ?
+ (yflag ? "%a %e %b %Y %R" : "%a %e %b %R") :
+ (yflag ? "%a %b %e %Y %R" : "%a %b %e %R"), tm);
printf("%-*.*s %-*.*s %-*.*s %s%c",
UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
UT_LINESIZE, UT_LINESIZE, bp->ut_line,
OpenPOWER on IntegriCloud