Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/last PR/26934: Curt Sampson: Add -x flag to process ...



details:   https://anonhg.NetBSD.org/src/rev/b6512357a16b
branches:  trunk
changeset: 574563:b6512357a16b
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Mar 04 17:16:13 2005 +0000

description:
PR/26934: Curt Sampson: Add -x flag to process wtmpx files that don't end
in `x'.

diffstat:

 usr.bin/last/last.1 |  18 +++++++++++++-----
 usr.bin/last/last.c |  14 +++++++++-----
 2 files changed, 22 insertions(+), 10 deletions(-)

diffs (116 lines):

diff -r 21bdd6e31965 -r b6512357a16b usr.bin/last/last.1
--- a/usr.bin/last/last.1       Fri Mar 04 17:11:19 2005 +0000
+++ b/usr.bin/last/last.1       Fri Mar 04 17:16:13 2005 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: last.1,v 1.14 2004/11/11 01:00:34 wiz Exp $
+.\"    $NetBSD: last.1,v 1.15 2005/03/04 17:16:13 christos Exp $
 .\"
 .\" Copyright (c) 1980, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"     @(#)last.1     8.1 (Berkeley) 6/6/93
 .\"
-.Dd November 10, 2004
+.Dd March 4, 2005
 .Dt LAST 1
 .Os
 .Sh NAME
@@ -38,7 +38,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl Ns Ar n
-.Op Fl nT
+.Op Fl nTx
 .Op Fl f Ar file
 .Op Fl H Ar hostsize
 .Op Fl h Ar host
@@ -94,8 +94,12 @@
 Use the provided namesize as the width to format the login name field.
 .It Fl n
 Print host addresses numerically.
-This option works only on wtmpx entries,
-and prints nothing on wtmp entries.
+This option works only on 
+.Xr wtmpx 5
+entries,
+and prints nothing on
+.Xr wtmp 5
+entries.
 .It Fl T
 Display better time information, including the year and seconds.
 .It Fl t Ar tty
@@ -105,6 +109,10 @@
 .Dq Li "last -t 03"
 is equivalent to
 .Dq Li "last -t tty03" .
+.It Fl x
+Assume that the file given is
+.Xr wtmpx 5
+format, even if the filename does not end with an `x'.
 .El
 .Pp
 If multiple arguments are given, the information which applies to any of the
diff -r 21bdd6e31965 -r b6512357a16b usr.bin/last/last.c
--- a/usr.bin/last/last.c       Fri Mar 04 17:11:19 2005 +0000
+++ b/usr.bin/last/last.c       Fri Mar 04 17:16:13 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: last.c,v 1.25 2004/11/19 21:41:25 christos Exp $       */
+/*     $NetBSD: last.c,v 1.26 2005/03/04 17:16:13 christos Exp $       */
 
 /*
  * Copyright (c) 1987, 1993, 1994
@@ -40,7 +40,7 @@
 #if 0
 static char sccsid[] = "@(#)last.c     8.2 (Berkeley) 4/2/94";
 #endif
-__RCSID("$NetBSD: last.c,v 1.25 2004/11/19 21:41:25 christos Exp $");
+__RCSID("$NetBSD: last.c,v 1.26 2005/03/04 17:16:13 christos Exp $");
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -112,6 +112,7 @@
 static time_t  currentout;             /* current logout value */
 static long    maxrec;                 /* records to display */
 static int     fulltime = 0;           /* Display seconds? */
+static int     xflag;                  /* Assume file is wtmpx format */
 
 int     main(int, char *[]);
 
@@ -131,7 +132,7 @@
 static
 void usage(void)
 {
-       (void)fprintf(stderr, "usage: %s [-#%s] [-nT] [-f file]"
+       (void)fprintf(stderr, "usage: %s [-#%s] [-nTx] [-f file]"
            " [-H hostsize] [-h host] [-L linesize]\n"
            "\t    [-N namesize] [-t tty] [user ...]\n", getprogname(),
 #ifdef NOTYET_SUPPORT_UTMPX
@@ -156,7 +157,7 @@
 
        maxrec = -1;
 
-       while ((ch = getopt(argc, argv, "0123456789f:H:h:L:nN:Tt:")) != -1)
+       while ((ch = getopt(argc, argv, "0123456789f:H:h:L:nN:Tt:x")) != -1)
                switch (ch) {
                case '0': case '1': case '2': case '3': case '4':
                case '5': case '6': case '7': case '8': case '9':
@@ -199,6 +200,9 @@
                case 't':
                        addarg(TTY_TYPE, ttyconv(optarg));
                        break;
+               case 'x':
+                       xflag = 1;
+                       break;
                case '?':
                default:
                        usage();
@@ -238,7 +242,7 @@
 #endif
        }
 #if defined(SUPPORT_UTMPX) && defined(SUPPORT_UTMP)
-       if (file[strlen(file) - 1] == 'x')
+       if (file[strlen(file) - 1] == 'x' || xflag)
                wtmpx(file, namesize, linesize, hostsize, numeric);
        else
                wtmp(file, namesize, linesize, hostsize, numeric);



Home | Main Index | Thread Index | Old Index