From 23031b9904cd9c4056c9a7580a1bbf72ab95aa4e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 29 Jun 2012 16:59:32 +0200 Subject: utmpdump: add NLS and closestream support Signed-off-by: Karel Zak --- login-utils/utmpdump.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'login-utils/utmpdump.c') diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index ebf85023a..13d6626db 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -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 #include #include @@ -36,6 +35,10 @@ #include #include +#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; } -- cgit v1.2.3-55-g7522