X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=tape-src%2Famdd.c;h=8a9e391bfa2338ba2cc0b943c17a794d4db75905;hb=94a044f90357edefa6f4ae9f0b1d5885b0e34aee;hp=4c7ba6020a874be7c7418650dd8ecc48bddec4e4;hpb=d3b2175e084f88c8736ad7073eacbf4670147aec;p=debian%2Famanda diff --git a/tape-src/amdd.c b/tape-src/amdd.c index 4c7ba60..8a9e391 100644 --- a/tape-src/amdd.c +++ b/tape-src/amdd.c @@ -30,15 +30,15 @@ static void usage(void); static void usage(void) { - fprintf(stderr, "usage: %s ", pgm); - fprintf(stderr, " [-d]"); - fprintf(stderr, " [-l length]"); - fprintf(stderr, " [if=input]"); - fprintf(stderr, " [of=output]"); - fprintf(stderr, " [bs=blocksize]"); - fprintf(stderr, " [count=count]"); - fprintf(stderr, " [skip=count]"); - fprintf(stderr, "\n"); + g_fprintf(stderr, _("usage: %s "), pgm); + g_fprintf(stderr, _(" [-d]")); + g_fprintf(stderr, _(" [-l length]")); + g_fprintf(stderr, _(" [if=input]")); + g_fprintf(stderr, _(" [of=output]")); + g_fprintf(stderr, _(" [bs=blocksize]")); + g_fprintf(stderr, _(" [count=count]")); + g_fprintf(stderr, _(" [skip=count]")); + g_fprintf(stderr, _("\n")); exit(1); } @@ -66,6 +66,17 @@ main( off_t length = (off_t)0; int have_length = 0; + /* + * Configure program for internationalization: + * 1) Only set the message locale for now. + * 2) Set textdomain for all amanda related programs to "amanda" + * We don't want to be forced to support dozens of message catalogs. + */ + setlocale(LC_MESSAGES, "C"); + textdomain("amanda"); + + fprintf(stderr, _("amdd is deprecated\n")); + if((pgm = strrchr(argv[0], '/')) != NULL) { pgm++; } else { @@ -75,7 +86,7 @@ main( switch(ch) { case 'd': debug_amdd = 1; - fprintf(stderr, "debug mode!\n"); + g_fprintf(stderr, _("debug mode!\n")); break; #ifndef __lint @@ -115,33 +126,33 @@ main( if(0 == strncmp("if", argv[optind], (size_t)len)) { if((infd = tape_open(eq + 1, O_RDONLY, 0)) < 0) { save_errno = errno; - fprintf(stderr, "%s: %s: ", pgm, eq + 1); + g_fprintf(stderr, "%s: %s: ", pgm, eq + 1); errno = save_errno; perror("open"); return 1; } read_func = tapefd_read; if(debug_amdd) { - fprintf(stderr, "input opened \"%s\", got fd %d\n", + g_fprintf(stderr, _("input opened \"%s\", got fd %d\n"), eq + 1, infd); } } else if(0 == strncmp("of", argv[optind], (size_t)len)) { if((outfd = tape_open(eq + 1, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) { save_errno = errno; - fprintf(stderr, "%s: %s: ", pgm, eq + 1); + g_fprintf(stderr, "%s: %s: ", pgm, eq + 1); errno = save_errno; perror("open"); return 1; } write_func = tapefd_write; if(debug_amdd) { - fprintf(stderr, "output opened \"%s\", got fd %d\n", + g_fprintf(stderr, _("output opened \"%s\", got fd %d\n"), eq + 1, outfd); } if(have_length) { if(debug_amdd) { - fprintf(stderr, "length set to " OFF_T_FMT "\n", - (OFF_T_FMT_TYPE)length); + g_fprintf(stderr, _("length set to %lld\n"), + (long long)length); } tapefd_setinfo_length(outfd, length); } @@ -156,37 +167,34 @@ main( } } if(debug_amdd) { - fprintf(stderr, "blocksize set to " SIZE_T_FMT "\n", - (SIZE_T_FMT_TYPE)blocksize); + g_fprintf(stderr, _("blocksize set to %zu\n"), blocksize); } } else if(0 == strncmp("count", argv[optind], (size_t)len)) { count = OFF_T_ATOI(eq + 1); have_count = 1; if(debug_amdd) { - fprintf(stderr, "count set to " OFF_T_FMT "\n", - (OFF_T_FMT_TYPE)count); + g_fprintf(stderr, _("count set to %lld\n"), (long long)count); } } else if(0 == strncmp("skip", argv[optind], (size_t)len)) { skip = OFF_T_ATOI(eq + 1); if(debug_amdd) { - fprintf(stderr, "skip set to " OFF_T_FMT "\n", - (OFF_T_FMT_TYPE)skip); + g_fprintf(stderr, _("skip set to %lld\n"), (long long)skip); } } else { - fprintf(stderr, "%s: bad argument: \"%s\"\n", pgm, argv[optind]); + g_fprintf(stderr, _("%s: bad argument: \"%s\"\n"), pgm, argv[optind]); return 1; } } if(0 == (buf = malloc(blocksize))) { save_errno = errno; - fprintf(stderr, "%s: ", pgm); + g_fprintf(stderr, "%s: ", pgm); errno = save_errno; - perror("malloc error"); + perror(_("malloc error")); return 1; } - eq = "read error"; + eq = _("read error"); pread = fread = pwrite = fwrite = 0; while(0 < (len = (*read_func)(infd, buf, blocksize))) { if((skip -= (off_t)1) > (off_t)0) { @@ -199,7 +207,7 @@ main( } len = (*write_func)(outfd, buf, (size_t)len); if(len < 0) { - eq = "write error"; + eq = _("write error"); break; } else if((size_t)len == blocksize) { fwrite++; @@ -215,27 +223,27 @@ main( } if(len < 0) { save_errno = errno; - fprintf(stderr, "%s: ", pgm); + g_fprintf(stderr, "%s: ", pgm); errno = save_errno; perror(eq); res = 1; } - fprintf(stderr, "%d+%d in\n%d+%d out\n", fread, pread, fwrite, pwrite); + g_fprintf(stderr, _("%d+%d in\n%d+%d out\n"), fread, pread, fwrite, pwrite); if(read_func == tapefd_read) { if(0 != tapefd_close(infd)) { save_errno = errno; - fprintf(stderr, "%s: ", pgm); + g_fprintf(stderr, "%s: ", pgm); errno = save_errno; - perror("input close"); + perror(_("input close")); res = 1; } } if(write_func == tapefd_write) { if(0 != tapefd_close(outfd)) { save_errno = errno; - fprintf(stderr, "%s: ", pgm); + g_fprintf(stderr, "%s: ", pgm); errno = save_errno; - perror("output close"); + perror(_("output close")); res = 1; } }