View | Details | Raw Unified | Return to bug 12982
Collapse All | Expand All

(-)last.1 (+3 lines)
Lines 45-50 Link Here
45
.Op Fl s
45
.Op Fl s
46
.Op Fl t Ar tty
46
.Op Fl t Ar tty
47
.Op Fl w
47
.Op Fl w
48
.Op Fl y
48
.Op user ...
49
.Op user ...
49
.Sh DESCRIPTION
50
.Sh DESCRIPTION
50
.Nm Last
51
.Nm Last
Lines 89-94 Link Here
89
.It Fl w
90
.It Fl w
90
Widen the duration field to show seconds, as well as the
91
Widen the duration field to show seconds, as well as the
91
default days, hours and minutes.
92
default days, hours and minutes.
93
.It Fl y
94
Report the duration of the login session with year.
92
.El
95
.El
93
.Pp
96
.Pp
94
If
97
If
(-)last.c (-12 / +37 lines)
Lines 85-90 Link Here
85
static char	*file = _PATH_WTMP;		/* wtmp file */
85
static char	*file = _PATH_WTMP;		/* wtmp file */
86
static int	sflag = 0;			/* show delta in seconds */
86
static int	sflag = 0;			/* show delta in seconds */
87
static int	width = 5;			/* show seconds in delta */
87
static int	width = 5;			/* show seconds in delta */
88
static int	showyear = NO;			/* show year */
89
#define	YEAR_SIZE	4			/* Y10K BUG HERE: to fix, change 4 to 5 */
88
90
89
void	 addarg __P((int, char *));
91
void	 addarg __P((int, char *));
90
void	 hostconv __P((char *));
92
void	 hostconv __P((char *));
Lines 97-103 Link Here
97
usage(void)
99
usage(void)
98
{
100
{
99
	(void)fprintf(stderr,
101
	(void)fprintf(stderr,
100
	"usage: last [-#] [-f file] [-h hostname] [-t tty] [-s|w] [user ...]\n");
102
	"usage: last [-#] [-f file] [-h hostname] [-t tty] [-s|w] [-y] [user ...]\n");
101
	exit(1);
103
	exit(1);
102
}
104
}
103
105
Lines 114-120 Link Here
114
	(void) setlocale(LC_TIME, "");
116
	(void) setlocale(LC_TIME, "");
115
117
116
	maxrec = -1;
118
	maxrec = -1;
117
	while ((ch = getopt(argc, argv, "0123456789f:h:st:w")) != -1)
119
	while ((ch = getopt(argc, argv, "0123456789f:h:st:wy")) != -1)
118
		switch (ch) {
120
		switch (ch) {
119
		case '0': case '1': case '2': case '3': case '4':
121
		case '0': case '1': case '2': case '3': case '4':
120
		case '5': case '6': case '7': case '8': case '9':
122
		case '5': case '6': case '7': case '8': case '9':
Lines 148-153 Link Here
148
		case 'w':
150
		case 'w':
149
			width = 8;
151
			width = 8;
150
			break;
152
			break;
153
		case 'y':
154
			showyear = YES;
155
			break;
151
		case '?':
156
		case '?':
152
		default:
157
		default:
153
			usage();
158
			usage();
Lines 240-250 Link Here
240
				if (want(bp)) {
245
				if (want(bp)) {
241
					tm = localtime(&bp->ut_time);
246
					tm = localtime(&bp->ut_time);
242
					(void) strftime(ct, sizeof(ct), "%c", tm);
247
					(void) strftime(ct, sizeof(ct), "%c", tm);
243
					printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n",
248
					if (showyear) {
244
					    UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
249
					    printf("%-*.*s %-*.*s %-*.*s %10.10s %*.*s %5.5s \n",
245
					    UT_LINESIZE, UT_LINESIZE, bp->ut_line,
250
						UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
246
					    UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
251
						UT_LINESIZE, UT_LINESIZE, bp->ut_line,
247
					    ct, ct + 11);
252
						UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
253
						ct, 
254
						YEAR_SIZE, YEAR_SIZE, ct + 20, 
255
						ct + 11);
256
					} else {
257
					    printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s \n",
258
						UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
259
						UT_LINESIZE, UT_LINESIZE, bp->ut_line,
260
						UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
261
						ct, ct + 11);
262
					}
248
					if (maxrec && !--maxrec)
263
					if (maxrec && !--maxrec)
249
						return;
264
						return;
250
				}
265
				}
Lines 278-288 Link Here
278
						bp->ut_line[4] = '\0';
293
						bp->ut_line[4] = '\0';
279
					tm = localtime(&bp->ut_time);
294
					tm = localtime(&bp->ut_time);
280
					(void) strftime(ct, sizeof(ct), "%c", tm);
295
					(void) strftime(ct, sizeof(ct), "%c", tm);
281
					printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s ",
296
					if (showyear) {
282
					    UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
297
					    printf("%-*.*s %-*.*s %-*.*s %10.10s %*.*s %5.5s ",
283
					    UT_LINESIZE, UT_LINESIZE, bp->ut_line,
298
						UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
284
					    UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
299
						UT_LINESIZE, UT_LINESIZE, bp->ut_line,
285
					    ct, ct + 11);
300
						UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
301
						ct, 
302
						YEAR_SIZE, YEAR_SIZE, ct + 20, 
303
						ct + 11);
304
					} else {
305
					    printf("%-*.*s %-*.*s %-*.*s %10.10s %5.5s ",
306
						UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
307
						UT_LINESIZE, UT_LINESIZE, bp->ut_line,
308
						UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
309
						ct, ct + 11);
310
					}
286
					if (!tt->logout)
311
					if (!tt->logout)
287
						puts("  still logged in");
312
						puts("  still logged in");
288
					else {
313
					else {

Return to bug 12982