Received: from SOUTH-STATION-ANNEX.MIT.EDU by po7.MIT.EDU (5.61/4.7) id AA21785; Sat, 30 Sep 95 04:38:14 EDT
Received: from SUN-LAMP.PC.CS.CMU.EDU by MIT.EDU with SMTP
	id AA28298; Sat, 30 Sep 95 04:37:47 EDT
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id EAA06959; Sat, 30 Sep 1995 04:37:40 -0400
Received: (from daemon@localhost) by pain.lcs.mit.edu (8.6.9/8.6.9) id DAA03409; Sat, 30 Sep 1995 03:07:32 -0400
Received: from sun-lamp.pc.cs.cmu.edu by pain.lcs.mit.edu (8.6.9/8.6.9) with ESMTP id DAA03284 for <netbsd-bugs@pain.lcs.mit.edu>; Sat, 30 Sep 1995 03:05:12 -0400
Received: (from gnats@localhost) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) id DAA05457; Sat, 30 Sep 1995 03:05:08 -0400
Resent-Date: Sat, 30 Sep 1995 03:05:08 -0400
Resent-Message-Id: <199509300705.DAA05457@sun-lamp.pc.cs.cmu.edu>
Resent-From: gnats@NetBSD.ORG (GNATS Management)
Resent-To: gnats-admin@sun-lamp.pc.cs.cmu.edu
Resent-Cc: gnats-admin@sun-lamp.pc.cs.cmu.edu, netbsd-bugs@NetBSD.ORG
Resent-Reply-To: gnats-bugs@NetBSD.ORG, jhawk@MIT.EDU
Received: from lola-granola.MIT.EDU (LOLA-GRANOLA.MIT.EDU [18.70.0.26]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id CAA05298 for <gnats-bugs@gnats.NetBSD.ORG>; Sat, 30 Sep 1995 02:51:43 -0400
Received: (from jhawk@localhost) by lola-granola.MIT.EDU (8.6.11/8.6.11) id CAA05849; Sat, 30 Sep 1995 02:51:42 -0400
Message-Id: <199509300651.CAA05849@lola-granola.MIT.EDU>
Date: Sat, 30 Sep 1995 02:51:42 -0400
From: John Hawkinson <jhawk@MIT.EDU>
Reply-To: jhawk@MIT.EDU
To: gnats-bugs@gnats.netbsd.org
X-Send-Pr-Version: 3.2
Subject: bin/1548: last should display seconds
Sender: owner-netbsd-bugs@NetBSD.ORG
Precedence: list
X-Loop: netbsd-bugs@NetBSD.ORG


>Number:         1548
>Category:       bin
>Synopsis:       last should display seconds
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Sep 30 03:05:03 1995
>Last-Modified:
>Originator:     John Hawkinson
>Organization:
MIT SIPB
>Release:        27 Aug
>Environment:
System: NetBSD lola-granola 1.0A NetBSD 1.0A (LOLA) #102: Sun Sep 3 09:48:20 EDT 1995 jhawk@zygorthian-space-raiders:/afs/sipb.mit.edu/project/netbsd/dev/current-source/build/i386_nbsd1/sys/arch/i386/compile/LOLA i386


>Description:
  Even though it has the information available to it, last does not
  display seconds. It even fits conveniently in 80 columns, so this
  must be for historical reasons.

  The below patch adds a -T option (reminicnent of ls(1)) to display
  seconds as well as hours and minutes.
>How-To-Repeat:
	N/A
>Fix:


*** last.1	1995/09/30 06:43:35	1.1
--- last.1	1995/09/30 06:44:59
***************
*** 83,88 ****
--- 83,90 ----
  .It Fl h Ar host
  .Ar Host
  names may be names or internet numbers.
+ .It Fl T
+ Display better time information, including seconds.
  .El
  .Pp
  If
*** last.c	1995/08/12 20:27:54	1.1
--- last.c	1995/09/30 06:43:13
***************
*** 86,91 ****
--- 86,92 ----
  static time_t	currentout;			/* current logout value */
  static long	maxrec;				/* records to display */
  static char	*file = _PATH_WTMP;		/* wtmp file */
+ static int      fulltime = 0;			/* Display seconds? */
  
  void	 addarg __P((int, char *));
  TTY	*addtty __P((char *));
***************
*** 106,112 ****
  	char *p;
  
  	maxrec = -1;
! 	while ((ch = getopt(argc, argv, "0123456789f:h:t:")) != EOF)
  		switch (ch) {
  		case '0': case '1': case '2': case '3': case '4':
  		case '5': case '6': case '7': case '8': case '9':
--- 107,113 ----
  	char *p;
  
  	maxrec = -1;
! 	while ((ch = getopt(argc, argv, "0123456789f:h:t:T")) != EOF)
  		switch (ch) {
  		case '0': case '1': case '2': case '3': case '4':
  		case '5': case '6': case '7': case '8': case '9':
***************
*** 134,143 ****
  		case 't':
  			addarg(TTY_TYPE, ttyconv(optarg));
  			break;
  		case '?':
  		default:
  			(void)fprintf(stderr,
! 	"usage: last [-#] [-f file] [-t tty] [-h hostname] [user ...]\n");
  			exit(1);
  		}
  
--- 135,147 ----
  		case 't':
  			addarg(TTY_TYPE, ttyconv(optarg));
  			break;
+ 		case 'T':
+ 			fulltime=-1;
+ 			break;
  		case '?':
  		default:
  			(void)fprintf(stderr,
! 	"usage: last [-#] [-f file] [-t tty] [-h hostname] [-T] [user ...]\n");
  			exit(1);
  		}
  
***************
*** 167,172 ****
--- 171,177 ----
  	TTY	*T;				/* tty list entry */
  	struct stat	stb;			/* stat of file for size */
  	time_t	bl, delta;			/* time difference */
+ 	int     timesize;			/* how much of time string to print */
  	int	bytes, wfd;
  	char	*ct, *crmsg;
  
***************
*** 174,179 ****
--- 179,190 ----
  		err(1, "%s", file);
  	bl = (stb.st_size + sizeof(buf) - 1) / sizeof(buf);
  
+ 	if (fulltime)
+ 	        timesize = 8;  /* HH:MM:SS */
+ 	else
+ 	        timesize = 5;  /* HH:MM */
+ 
+ 
  	(void)time(&buf[0].ut_time);
  	(void)signal(SIGINT, onintr);
  	(void)signal(SIGQUIT, onintr);
***************
*** 196,207 ****
  				    UT_NAMESIZE) ? "crash" : "shutdown";
  				if (want(bp, NO)) {
  					ct = ctime(&bp->ut_time);
! 				printf("%-*.*s  %-*.*s %-*.*s %10.10s %5.5s \n",
  					    UT_NAMESIZE, UT_NAMESIZE,
  					    bp->ut_name, UT_LINESIZE,
  					    UT_LINESIZE, bp->ut_line,
  					    UT_HOSTSIZE, UT_HOSTSIZE,
! 					    bp->ut_host, ct, ct + 11);
  					if (maxrec != -1 && !--maxrec)
  						return;
  				}
--- 207,219 ----
  				    UT_NAMESIZE) ? "crash" : "shutdown";
  				if (want(bp, NO)) {
  					ct = ctime(&bp->ut_time);
! 				printf("%-*.*s  %-*.*s %-*.*s %10.10s %*.*s \n",
  					    UT_NAMESIZE, UT_NAMESIZE,
  					    bp->ut_name, UT_LINESIZE,
  					    UT_LINESIZE, bp->ut_line,
  					    UT_HOSTSIZE, UT_HOSTSIZE,
! 					    bp->ut_host, ct, timesize,
! 				            timesize, ct + 11);
  					if (maxrec != -1 && !--maxrec)
  						return;
  				}
***************
*** 215,225 ****
  			    && !bp->ut_line[1]) {
  				if (want(bp, NO)) {
  					ct = ctime(&bp->ut_time);
! 				printf("%-*.*s  %-*.*s %-*.*s %10.10s %5.5s \n",
  				    UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
  				    UT_LINESIZE, UT_LINESIZE, bp->ut_line,
  				    UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
! 				    ct, ct + 11);
  					if (maxrec && !--maxrec)
  						return;
  				}
--- 227,237 ----
  			    && !bp->ut_line[1]) {
  				if (want(bp, NO)) {
  					ct = ctime(&bp->ut_time);
! 				printf("%-*.*s  %-*.*s %-*.*s %10.10s %*.*s \n",
  				    UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
  				    UT_LINESIZE, UT_LINESIZE, bp->ut_line,
  				    UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
! 				    ct, timesize, timesize, ct + 11);
  					if (maxrec && !--maxrec)
  						return;
  				}
***************
*** 237,247 ****
  			}
  			if (bp->ut_name[0] && want(bp, YES)) {
  				ct = ctime(&bp->ut_time);
! 				printf("%-*.*s  %-*.*s %-*.*s %10.10s %5.5s ",
  				UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
  				UT_LINESIZE, UT_LINESIZE, bp->ut_line,
  				UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
! 				ct, ct + 11);
  				if (!T->logout)
  					puts("  still logged in");
  				else {
--- 249,259 ----
  			}
  			if (bp->ut_name[0] && want(bp, YES)) {
  				ct = ctime(&bp->ut_time);
! 				printf("%-*.*s  %-*.*s %-*.*s %10.10s %*.*s ",
  				UT_NAMESIZE, UT_NAMESIZE, bp->ut_name,
  				UT_LINESIZE, UT_LINESIZE, bp->ut_line,
  				UT_HOSTSIZE, UT_HOSTSIZE, bp->ut_host,
! 				ct, timesize, timesize, ct + 11);
  				if (!T->logout)
  					puts("  still logged in");
  				else {
***************
*** 250,264 ****
  						printf("- %s", crmsg);
  					}
  					else
! 						printf("- %5.5s",
  						    ctime(&T->logout)+11);
  					delta = T->logout - bp->ut_time;
  					if (delta < SECSPERDAY)
! 						printf("  (%5.5s)\n",
  						    asctime(gmtime(&delta))+11);
  					else
! 						printf(" (%ld+%5.5s)\n",
  						    delta / SECSPERDAY,
  						    asctime(gmtime(&delta))+11);
  				}
  				if (maxrec != -1 && !--maxrec)
--- 262,279 ----
  						printf("- %s", crmsg);
  					}
  					else
! 						printf("- %*.*s",
! 						    timesize, timesize,
  						    ctime(&T->logout)+11);
  					delta = T->logout - bp->ut_time;
  					if (delta < SECSPERDAY)
! 						printf("  (%*.*s)\n",
! 						    timesize, timesize,
  						    asctime(gmtime(&delta))+11);
  					else
! 						printf(" (%ld+%*.*s)\n",
  						    delta / SECSPERDAY,
+ 						    timesize, timesize,
  						    asctime(gmtime(&delta))+11);
  				}
  				if (maxrec != -1 && !--maxrec)
***************
*** 268,274 ****
  		}
  	}
  	ct = ctime(&buf[0].ut_time);
! 	printf("\nwtmp begins %10.10s %5.5s \n", ct, ct + 11);
  }
  
  /*
--- 283,289 ----
  		}
  	}
  	ct = ctime(&buf[0].ut_time);
! 	printf("\nwtmp begins %10.10s %*.*s \n", ct, timesize, timesize, ct + 11);
  }
  
  /*
***************
*** 418,424 ****
  	char *ct;
  
  	ct = ctime(&buf[0].ut_time);
! 	printf("\ninterrupted %10.10s %5.5s \n", ct, ct + 11);
  	if (signo == SIGINT)
  		exit(1);
  	(void)fflush(stdout);			/* fix required for rsh */
--- 433,439 ----
  	char *ct;
  
  	ct = ctime(&buf[0].ut_time);
! 	printf("\ninterrupted %10.10s %8.8s \n", ct, ct + 11);
  	if (signo == SIGINT)
  		exit(1);
  	(void)fflush(stdout);			/* fix required for rsh */
>Audit-Trail:
>Unformatted:
