[Pkg-sysvinit-commits] r1415 - in sysvinit-upstream/trunk: doc man src
Petter Reinholdtsen
pere at alioth.debian.org
Fri Jul 10 19:38:10 UTC 2009
Author: pere
Date: 2009-07-10 19:38:08 +0000 (Fri, 10 Jul 2009)
New Revision: 1415
Modified:
sysvinit-upstream/trunk/doc/Changelog
sysvinit-upstream/trunk/man/last.1
sysvinit-upstream/trunk/src/last.c
Log:
Add new option -F to last, to output full date string instead
of the short form provided by default. Patch from Olaf Dabrunz
and SuSe.
Modified: sysvinit-upstream/trunk/doc/Changelog
===================================================================
--- sysvinit-upstream/trunk/doc/Changelog 2009-07-10 19:35:49 UTC (rev 1414)
+++ sysvinit-upstream/trunk/doc/Changelog 2009-07-10 19:38:08 UTC (rev 1415)
@@ -13,6 +13,9 @@
* Improve handling of IPv6 addresses in last. Patch from Fedora.
* Document last options in usage information, previously only
mentioned in the manual page.
+ * Add new option -F to last, to output full date string instead
+ of the short form provided by default. Patch from Olaf Dabrunz
+ and SuSe.
-- Petter Reinholdtsen <pere at debian.org> Fri, 30 Jul 2004 14:14:58 +0200
Modified: sysvinit-upstream/trunk/man/last.1
===================================================================
--- sysvinit-upstream/trunk/man/last.1 2009-07-10 19:35:49 UTC (rev 1414)
+++ sysvinit-upstream/trunk/man/last.1 2009-07-10 19:38:08 UTC (rev 1415)
@@ -12,7 +12,7 @@
.RB [ \-R ]
.RB [ \-\fInum\fP ]
.RB "[ \-\fBn\fP \fInum\fP ]"
-.RB [ \-adiox ]
+.RB [ \-adFiox ]
.RB "[ \-\fBf\fP \fIfile\fP ]"
.RB "[ \-\fBt\fP \fIYYYYMMDDHHMMSS\fP ]"
.RI [ name... ]
@@ -23,7 +23,7 @@
.RB [ \-\fInum\fP ]
.RB "[ \-\fBn\fP \fInum\fP ]"
.RB "[ \-\fBf\fP \fIfile\fP ]"
-.RB [ \-adiox ]
+.RB [ \-adFiox ]
.RI [ name... ]
.RI [ tty... ]
.\"}}}
@@ -71,6 +71,8 @@
For non-local logins, Linux stores not only the host name of the remote
host but its IP number as well. This option translates the IP number
back into a hostname.
+.IP \fB\-F\fP
+Print full login and logout times and dates.
.IP \fB\-i\fP
This option is like \fB-d\fP in that it displays the IP number of the remote
host, but it displays the IP number in numbers-and-dots notation.
Modified: sysvinit-upstream/trunk/src/last.c
===================================================================
--- sysvinit-upstream/trunk/src/last.c 2009-07-10 19:35:49 UTC (rev 1414)
+++ sysvinit-upstream/trunk/src/last.c 2009-07-10 19:38:08 UTC (rev 1415)
@@ -70,6 +70,7 @@
int altlist = 0; /* Show hostname at the end. */
int usedns = 0; /* Use DNS to lookup the hostname. */
int useip = 0; /* Print IP address in number format */
+int fulltime = 0; /* Print full dates and times */
int oldfmt = 0; /* Use old libc5 format? */
char **show = NULL; /* What do they want us to show */
char *ufile; /* Filename of this file */
@@ -393,9 +394,13 @@
*/
tmp = (time_t)p->ut_time;
strcpy(logintime, ctime(&tmp));
- logintime[16] = 0;
- sprintf(logouttime, "- %s", ctime(&t) + 11);
- logouttime[7] = 0;
+ if (fulltime)
+ sprintf(logouttime, "- %s", ctime(&t));
+ else {
+ logintime[16] = 0;
+ sprintf(logouttime, "- %s", ctime(&t) + 11);
+ logouttime[7] = 0;
+ }
secs = t - p->ut_time;
mins = (secs / 60) % 60;
hours = (secs / 3600) % 24;
@@ -414,13 +419,21 @@
break;
case R_NOW:
length[0] = 0;
- sprintf(logouttime, " still");
- sprintf(length, "logged in");
+ if (fulltime)
+ sprintf(logouttime, " still logged in");
+ else {
+ sprintf(logouttime, " still");
+ sprintf(length, "logged in");
+ }
break;
case R_PHANTOM:
length[0] = 0;
- sprintf(logouttime, " gone");
- sprintf(length, "- no logout");
+ if (fulltime)
+ sprintf(logouttime, " gone - no logout");
+ else {
+ sprintf(logouttime, " gone");
+ sprintf(length, "- no logout");
+ }
break;
case R_REBOOT:
break;
@@ -455,18 +468,23 @@
#endif
if (!altlist) {
snprintf(final, sizeof(final),
- "%-8.8s %-12.12s %-16.16s "
- "%-16.16s %-7.7s %-12.12s\n",
+ fulltime ?
+ "%-8.8s %-12.12s %-16.16s %-24.24s %-26.26s %-12.12s\n" :
+ "%-8.8s %-12.12s %-16.16s %-16.16s %-7.7s %-12.12s\n",
p->ut_name, utline,
domain, logintime, logouttime, length);
} else {
snprintf(final, sizeof(final),
+ fulltime ?
+ "%-8.8s %-12.12s %-24.24s %-26.26s %-12.12s %s\n" :
"%-8.8s %-12.12s %-16.16s %-7.7s %-12.12s %s\n",
p->ut_name, utline,
logintime, logouttime, length, domain);
}
} else
snprintf(final, sizeof(final),
+ fulltime ?
+ "%-8.8s %-12.12s %-24.24s %-26.26s %-12.12s\n" :
"%-8.8s %-12.12s %-16.16s %-7.7s %-12.12s\n",
p->ut_name, utline,
logintime, logouttime, length);
@@ -496,7 +514,7 @@
{
fprintf(stderr, "Usage: %s [-num | -n num] [-f file] "
"[-t YYYYMMDDHHMMSS] "
- "[-R] [-adiox] [username..] [tty..]\n", s);
+ "[-R] [-adioxF] [username..] [tty..]\n", s);
exit(1);
}
@@ -565,7 +583,7 @@
progname = mybasename(argv[0]);
/* Process the arguments. */
- while((c = getopt(argc, argv, "f:n:Rxadiot:0123456789")) != EOF)
+ while((c = getopt(argc, argv, "f:n:RxadFiot:0123456789")) != EOF)
switch(c) {
case 'R':
showhost = 0;
@@ -596,6 +614,9 @@
case 'a':
altlist++;
break;
+ case 'F':
+ fulltime++;
+ break;
case 't':
if ((until = parsetm(optarg)) == (time_t)-1) {
fprintf(stderr, "%s: Invalid time value \"%s\"\n",
More information about the Pkg-sysvinit-commits
mailing list