]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
utmpdump: add long options
authorKarel Zak <kzak@redhat.com>
Fri, 29 Jun 2012 15:22:42 +0000 (17:22 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 29 Jun 2012 15:22:42 +0000 (17:22 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/utmpdump.1
login-utils/utmpdump.c

index b453021cd7adeeb6cebf16b991ea0e959bddf5a0..65dfe329d2b5159b1f612ae55261888ed594ab3d 100644 (file)
@@ -26,16 +26,18 @@ utmpdump \- dump UTMP and WTMP files in raw format
 \fButmpdump\fP is a simple program to dump UTMP and WTMP files
 in raw format, so they can be examined.
 .SH OPTIONS
-.IP \fB\-f\fP
+.IP "\fB\-f, \-\-follow\fP"
 output appended data as the file grows.
-.IP "\fB\-r\fP"
-reverse. Write back edited login information into utmp or wtmp files.
-.IP \fB\-h\fP
-usage information.
-.PP
-utmpdump can be useful in cases of corrupted utmp or wtmp entries.
-It can dump out utmp/wtmp to an ASCII file, then that file can
-be edited to remove bogus entries and reintegrated, using
+.IP "\fB\-r, \-\-reverse\fP
+Undump, write back edited login information into utmp or wtmp files.
+.IP "\fB\-h, \-\-help\fP"
+Print a help text and exit.
+.IP "\fB\-V, \-\-version\fP"
+Output version information and exit.
+.SH NOTES
+utmpdump can be useful in cases of corrupted utmp or wtmp entries.  It can dump
+out utmp/wtmp to an ASCII file, then that file can be edited to remove bogus
+entries and reintegrated, using
 .PP 
 .sp 1
 .in +1c
index 87e65eb05a1558abbf88de1ece4ea2f423f0b40e..b5d6c924ac24ae7cf820f8aade8deaf0c34e7a0d 100644 (file)
@@ -31,6 +31,7 @@
 #include <utmp.h>
 #include <time.h>
 #include <ctype.h>
+#include <getopt.h>
 #include <unistd.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -186,7 +187,7 @@ void undump(FILE *fp)
 void
 usage(int result)
 {
-       printf(_("Usage: utmpdump [ -frh ] [ filename ]\n"));
+       printf(_("Usage: utmpdump [ -frhV ] [ filename ]\n"));
        exit(result);
 }
 
@@ -197,12 +198,20 @@ int main(int argc, char **argv)
        int reverse = 0, forever = 0;
        const char *filename = NULL;
 
+       static const struct option longopts[] = {
+               { "follow",  0, 0, 'f' },
+               { "reverse", 0, 0, 'r' },
+               { "help",    0, 0, 'h' },
+               { "version", 0, 0, 'V' },
+               { NULL, 0, 0, 0 }
+       };
+
        setlocale(LC_ALL, "");
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
        atexit(close_stdout);
 
-       while ((c = getopt(argc, argv, "froh")) != EOF) {
+       while ((c = getopt_long(argc, argv, "frhV", longopts, NULL)) != -1) {
                switch (c) {
                case 'r':
                        reverse = 1;
@@ -215,7 +224,9 @@ int main(int argc, char **argv)
                case 'h':
                        usage(0);
                        break;
-
+               case 'V':
+                       printf(UTIL_LINUX_VERSION);
+                       break;
                default:
                        usage(1);
                }