From: Karel Zak Date: Fri, 29 Jun 2012 15:22:42 +0000 (+0200) Subject: utmpdump: add long options X-Git-Tag: v2.22-rc1~191 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9e15c93d76868b0929dd965a66c3c5ba5fa181ad;p=thirdparty%2Futil-linux.git utmpdump: add long options Signed-off-by: Karel Zak --- diff --git a/login-utils/utmpdump.1 b/login-utils/utmpdump.1 index b453021cd7..65dfe329d2 100644 --- a/login-utils/utmpdump.1 +++ b/login-utils/utmpdump.1 @@ -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 diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index 87e65eb05a..b5d6c924ac 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -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); }