]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
utmpdump: add NLS and closestream support
authorKarel Zak <kzak@redhat.com>
Fri, 29 Jun 2012 14:59:32 +0000 (16:59 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 29 Jun 2012 14:59:32 +0000 (16:59 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/utmpdump.c

index ebf85023a040926426896b4e0bc5853ae4de8dd2..13d6626db9f80858fd0682843200cf15bbbad54c 100644 (file)
@@ -25,7 +25,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
+#include "c.h"
+#include "nls.h"
+#include "closestream.h"
+
 char *timetostr(const time_t time)
 {
        static char s[29];    /* [Sun Sep 01 00:00:00 1998 PST] */
@@ -126,14 +129,14 @@ int gettok(char *line, char *dest, int size, int eatspace)
 
        bpos = strchr(line, '[') - line;
        if (bpos < 0) {
-               fprintf(stderr, "Extraneous newline in file.  Exiting.");
+               fprintf(stderr, _("Extraneous newline in file.  Exiting."));
                 exit(1);
         }
        line += 1 + bpos;
 
        epos = strchr(line, ']') - line;
        if (epos < 0) {
-               fprintf(stderr, "Extraneous newline in file.  Exiting.");
+               fprintf(stderr, _("Extraneous newline in file.  Exiting."));
                 exit(1);
         }
        line[epos] = '\0';
@@ -186,7 +189,7 @@ void undump(FILE *fp)
 void
 usage(int result)
 {
-       printf("Usage: utmpdump [ -frh ] [ filename ]\n");
+       printf(_("Usage: utmpdump [ -frh ] [ filename ]\n"));
        exit(result);
 }
 
@@ -196,6 +199,11 @@ int main(int argc, char **argv)
        FILE *fp;
        int reverse = 0, forever = 0;
 
+       setlocale(LC_ALL, "");
+       bindtextdomain(PACKAGE, LOCALEDIR);
+       textdomain(PACKAGE);
+       atexit(close_stdout);
+
        while ((c = getopt(argc, argv, "froh")) != EOF) {
                switch (c) {
                case 'r':
@@ -216,14 +224,14 @@ int main(int argc, char **argv)
        }
 
        if (optind < argc) {
-               fprintf(stderr, "Utmp %sdump of %s\n", reverse ? "un" : "", argv[optind]);
+               fprintf(stderr, _("Utmp %sdump of %s\n"), reverse ? "un" : "", argv[optind]);
                if ((fp = fopen(argv[optind], "r")) == NULL) {
                        perror("Unable to open file");
                        exit(1);
                }
        }
        else {
-               fprintf(stderr, "Utmp %sdump of stdin\n", reverse ? "un" : "");
+               fprintf(stderr, _("Utmp %sdump of stdin\n"), reverse ? "un" : "");
                fp = stdin;
        }