summaryrefslogtreecommitdiffstats
path: root/login-utils/utmpdump.c
diff options
context:
space:
mode:
authorKarel Zak2012-06-29 16:59:32 +0200
committerKarel Zak2012-06-29 16:59:32 +0200
commit23031b9904cd9c4056c9a7580a1bbf72ab95aa4e (patch)
tree1cba99e8c33244cd056381b6bfd3df70d202cb65 /login-utils/utmpdump.c
parentutmpdump: remove dead code (diff)
downloadkernel-qcow2-util-linux-23031b9904cd9c4056c9a7580a1bbf72ab95aa4e.tar.gz
kernel-qcow2-util-linux-23031b9904cd9c4056c9a7580a1bbf72ab95aa4e.tar.xz
kernel-qcow2-util-linux-23031b9904cd9c4056c9a7580a1bbf72ab95aa4e.zip
utmpdump: add NLS and closestream support
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/utmpdump.c')
-rw-r--r--login-utils/utmpdump.c20
1 files changed, 14 insertions, 6 deletions
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 <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -36,6 +35,10 @@
#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;
}