Imported Upstream version 2.6.0
[debian/amanda] / recover-src / extract_list.c
index e46eb763d1d1160cbd47f439051b7cbdee2722e6..afb6278a58e9cfa7badda94f21b3615512e11742 100644 (file)
@@ -188,7 +188,7 @@ read_buffer(
         nfound = select(datafd+1, &readset, NULL, NULL, &timeout);
         if(nfound < 0 ) {
             /* Select returned an error. */
-           fprintf(stderr,"select error: %s\n", strerror(errno));
+           g_fprintf(stderr,_("select error: %s\n"), strerror(errno));
             size = -1;
            break;
         }
@@ -197,8 +197,8 @@ read_buffer(
             /* Select timed out. */
             if (timeout_s != 0)  {
                 /* Not polling: a real read timeout */
-                fprintf(stderr,"timeout waiting for restore\n");
-                fprintf(stderr,"increase READ_TIMEOUT in recover-src/extract_list.c if your tape is slow\n");
+                g_fprintf(stderr,_("timeout waiting for restore\n"));
+                g_fprintf(stderr,_("increase READ_TIMEOUT in recover-src/extract_list.c if your tape is slow\n"));
             }
             errno = ETIMEDOUT;
             size = -1;
@@ -215,7 +215,7 @@ read_buffer(
                continue;
            }
            if (errno != EPIPE) {
-               fprintf(stderr, "read_buffer: read error - %s",
+               g_fprintf(stderr, _("read_buffer: read error - %s"),
                    strerror(errno));
                break;
            }
@@ -364,8 +364,8 @@ clean_tape_list(
            }
 
            if (remove_fn2) {
-               dbprintf(("removing path %s, it is included in %s\n",
-                         fn2->path, fn1->path));
+               dbprintf(_("removing path %s, it is included in %s\n"),
+                         fn2->path, fn1->path);
                ofn2 = fn2;
                fn2 = fn2->next;
                amfree(ofn2->path);
@@ -379,8 +379,8 @@ clean_tape_list(
 
        if(remove_fn1 != 0) {
            /* fn2->path is always valid */
-           /*@i@*/ dbprintf(("removing path %s, it is included in %s\n",
-           /*@i@*/           fn1->path, fn2->path));
+           /*@i@*/ dbprintf(_("removing path %s, it is included in %s\n"),
+           /*@i@*/           fn1->path, fn2->path);
            ofn1 = fn1;
            fn1 = fn1->next;
            amfree(ofn1->path);
@@ -450,7 +450,7 @@ do_unlink_list(void)
 
     for (ul = unlink_list; ul != NULL; ul = ul->next) {
        if (unlink(ul->path) < 0) {
-           fprintf(stderr,"Can't unlink %s: %s\n", ul->path, strerror(errno));
+           g_fprintf(stderr,_("Can't unlink %s: %s\n"), ul->path, strerror(errno));
            ret = 0;
        }
     }
@@ -500,14 +500,14 @@ check_file_overwrite(
                if (lstat(path, &stat_buf) == 0) {
                    if(!S_ISDIR(stat_buf.st_mode)) {
                        if (add_to_unlink_list(path)) {
-                           printf("WARNING: %s is not a directory, "
-                                  "it will be deleted.\n",
+                           g_printf(_("WARNING: %s is not a directory, "
+                                  "it will be deleted.\n"),
                                   path);
                        }
                    }
                }
                else if (errno != ENOENT) {
-                   printf("Can't stat %s: %s\n", path, strerror(errno));
+                   g_printf(_("Can't stat %s: %s\n"), path, strerror(errno));
                }
                *s = '/';
                s++;
@@ -524,20 +524,20 @@ check_file_overwrite(
            if (lstat(filename, &stat_buf) == 0) {
                if(S_ISDIR(stat_buf.st_mode)) {
                    if(!is_empty_dir(filename)) {
-                       printf("WARNING: All existing files in %s "
-                              "will be deleted.\n", filename);
+                       g_printf(_("WARNING: All existing files in %s "
+                              "will be deleted.\n"), filename);
                    }
                } else if(S_ISREG(stat_buf.st_mode)) {
-                   printf("WARNING: Existing file %s will be overwritten\n",
+                   g_printf(_("WARNING: Existing file %s will be overwritten\n"),
                           filename);
                } else {
                    if (add_to_unlink_list(filename)) {
-                       printf("WARNING: Existing entry %s will be deleted\n",
+                       g_printf(_("WARNING: Existing entry %s will be deleted\n"),
                               filename);
                    }
                }
            } else if (errno != ENOENT) {
-               printf("Can't stat %s: %s\n", filename, strerror(errno));
+               g_printf(_("Can't stat %s: %s\n"), filename, strerror(errno));
            }
            amfree(filename);
        }
@@ -691,9 +691,9 @@ add_glob(
     char *uqglob = unquote_string(glob);
  
     regex = glob_to_regex(uqglob);
-    dbprintf(("add_glob (%s) -> %s\n", uqglob, regex));
+    dbprintf(_("add_glob (%s) -> %s\n"), uqglob, regex);
     if ((s = validate_regexp(regex)) != NULL) {
-       printf("%s is not a valid shell wildcard pattern: ", glob);
+       g_printf(_("%s is not a valid shell wildcard pattern: "), glob);
        puts(s);
     } else {
         /*
@@ -721,7 +721,7 @@ add_regex(
     char *uqregex = unquote_string(regex);
  
     if ((s = validate_regexp(uqregex)) != NULL) {
-       printf("\"%s\" is not a valid regular expression: ", regex);
+       g_printf(_("\"%s\" is not a valid regular expression: "), regex);
        puts(s);
     } else {
         add_file(uqregex, regex);
@@ -751,12 +751,12 @@ add_file(
     int dir_entries;
 
     if (disk_path == NULL) {
-       printf("Must select directory before adding files\n");
+       g_printf(_("Must select directory before adding files\n"));
        return;
     }
     memset(&lditem, 0, sizeof(lditem)); /* Prevent use of bogus data... */
 
-    dbprintf(("add_file: Looking for \"%s\"\n", regex));
+    dbprintf(_("add_file: Looking for \"%s\"\n"), regex);
 
     if(strcmp(regex, "/[/]*$") == 0) { /* "/" behave like "." */
        regex = "\\.[/]*$";
@@ -785,8 +785,8 @@ add_file(
        amfree(clean_disk_path);
     }
 
-    dbprintf(("add_file: Converted path=\"%s\" to path_on_disk=\"%s\"\n",
-             regex, path_on_disk));
+    dbprintf(_("add_file: Converted path=\"%s\" to path_on_disk=\"%s\"\n"),
+             regex, path_on_disk);
 
     found_one = 0;
     dir_entries = 0;
@@ -794,7 +794,7 @@ add_file(
     {
        dir_entries++;
        quoted = quote_string(ditem->path);
-       dbprintf(("add_file: Pondering ditem->path=%s\n", quoted));
+       dbprintf(_("add_file: Pondering ditem->path=%s\n"), quoted);
        amfree(quoted);
        if (match(path_on_disk, ditem->path))
        {
@@ -807,7 +807,7 @@ add_file(
                clean_pathname(ditem_path);
 
                qditem_path = quote_string(ditem_path);
-               cmd = stralloc2("ORLD ", qditem_path);
+               cmd = newstralloc2(cmd, "ORLD ", qditem_path);
                amfree(qditem_path);
                if(send_command(cmd) == -1) {
                    amfree(cmd);
@@ -827,7 +827,7 @@ add_file(
                    amfree(ditem_path);
                    amfree(path_on_disk);
                    l = reply_line();
-                   printf("%s\n", l);
+                   g_printf("%s\n", l);
                    return;
                }
                dir_undo = NULL;
@@ -857,14 +857,14 @@ add_file(
 
                    s = l;
                    if(strncmp_const_skip(l, "201-", s, ch) != 0) {
-                       err = "bad reply: not 201-";
+                       err = _("bad reply: not 201-");
                        continue;
                    }
                    ch = *s++;
 
                    skip_whitespace(s, ch);
                    if(ch == '\0') {
-                       err = "bad reply: missing date field";
+                       err = _("bad reply: missing date field");
                        continue;
                    }
                     fp = s-1;
@@ -875,14 +875,14 @@ add_file(
 
                    skip_whitespace(s, ch);
                    if(ch == '\0' || sscanf(s - 1, "%d", &lditem.level) != 1) {
-                       err = "bad reply: cannot parse level field";
+                       err = _("bad reply: cannot parse level field");
                        continue;
                    }
                    skip_integer(s, ch);
 
                    skip_whitespace(s, ch);
                    if(ch == '\0') {
-                       err = "bad reply: missing tape field";
+                       err = _("bad reply: missing tape field");
                        continue;
                    }
                     fp = s-1;
@@ -892,11 +892,11 @@ add_file(
                     s[-1] = (char)ch;
 
                    if(am_has_feature(indexsrv_features, fe_amindexd_fileno_in_ORLD)) {
-                       OFF_T_FMT_TYPE fileno_ = (OFF_T_FMT_TYPE)0;
+                       long long fileno_ = (long long)0;
                        skip_whitespace(s, ch);
                        if(ch == '\0' ||
-                          sscanf(s - 1, OFF_T_FMT, &fileno_) != 1) {
-                           err = "bad reply: cannot parse fileno field";
+                          sscanf(s - 1, "%lld", &fileno_) != 1) {
+                           err = _("bad reply: cannot parse fileno field");
                            continue;
                        }
                        lditem.fileno = (off_t)fileno_;
@@ -905,7 +905,7 @@ add_file(
 
                    skip_whitespace(s, ch);
                    if(ch == '\0') {
-                       err = "bad reply: missing directory field";
+                       err = _("bad reply: missing directory field");
                        continue;
                    }
                    dir = s - 1;
@@ -916,16 +916,16 @@ add_file(
 
                    switch(add_extract_item(&lditem)) {
                    case -1:
-                       printf("System error\n");
-                       dbprintf(("add_file: (Failed) System error\n"));
+                       g_printf(_("System error\n"));
+                       dbprintf(_("add_file: (Failed) System error\n"));
                        break;
 
                    case  0:
                        quoted = quote_string(lditem.path);
-                       printf("Added dir %s at date %s\n",
+                       g_printf(_("Added dir %s at date %s\n"),
                               quoted, lditem.date);
-                       dbprintf(("add_file: (Successful) Added dir %s at date %s\n",
-                                 quoted, lditem.date));
+                       dbprintf(_("add_file: (Successful) Added dir %s at date %s\n"),
+                                 quoted, lditem.date);
                        amfree(quoted);
                        added=1;
                        break;
@@ -943,8 +943,8 @@ add_file(
                        puts(cmd);
                } else if(added == 0) {
                    quoted = quote_string(ditem_path);
-                   printf("dir %s already added\n", quoted);
-                   dbprintf(("add_file: dir %s already added\n", quoted));
+                   g_printf(_("dir %s already added\n"), quoted);
+                   dbprintf(_("add_file: dir %s already added\n"), quoted);
                    amfree(quoted);
                }
            }
@@ -952,21 +952,21 @@ add_file(
            {
                switch(add_extract_item(ditem)) {
                case -1:
-                   printf("System error\n");
-                   dbprintf(("add_file: (Failed) System error\n"));
+                   g_printf(_("System error\n"));
+                   dbprintf(_("add_file: (Failed) System error\n"));
                    break;
 
                case  0:
                    quoted = quote_string(ditem->path);
-                   printf("Added file %s\n", quoted);
-                   dbprintf(("add_file: (Successful) Added %s\n", quoted));
+                   g_printf(_("Added file %s\n"), quoted);
+                   dbprintf(_("add_file: (Successful) Added %s\n"), quoted);
                    amfree(quoted);
                    break;
 
                case  1:
                    quoted = quote_string(ditem->path);
-                   printf("File %s already added\n", quoted);
-                   dbprintf(("add_file: file %s already added\n", quoted));
+                   g_printf(_("File %s already added\n"), quoted);
+                   dbprintf(_("add_file: file %s already added\n"), quoted);
                    amfree(quoted);
                }
            }
@@ -983,9 +983,9 @@ add_file(
 
     if(! found_one) {
        quoted = quote_string(path);
-       printf("File %s doesn't exist in directory\n", quoted);
-       dbprintf(("add_file: (Failed) File %s doesn't exist in directory\n",
-                 quoted));
+       g_printf(_("File %s doesn't exist in directory\n"), quoted);
+       dbprintf(_("add_file: (Failed) File %s doesn't exist in directory\n"),
+                 quoted);
        amfree(quoted);
     }
 }
@@ -1001,9 +1001,9 @@ delete_glob(
     char *uqglob = unquote_string(glob);
  
     regex = glob_to_regex(uqglob);
-    dbprintf(("delete_glob (%s) -> %s\n", uqglob, regex));
+    dbprintf(_("delete_glob (%s) -> %s\n"), uqglob, regex);
     if ((s = validate_regexp(regex)) != NULL) {
-       printf("\"%s\" is not a valid shell wildcard pattern: ", glob);
+       g_printf(_("\"%s\" is not a valid shell wildcard pattern: "), glob);
        puts(s);
     } else {
         /*
@@ -1031,7 +1031,7 @@ delete_regex(
     char *uqregex = unquote_string(regex);
 
     if ((s = validate_regexp(regex)) != NULL) {
-       printf("\"%s\" is not a valid regular expression: ", regex);
+       g_printf(_("\"%s\" is not a valid regular expression: "), regex);
        puts(s);
     } else {
        delete_file(uqregex, uqregex);
@@ -1065,12 +1065,12 @@ delete_file(
     char *quoted;
 
     if (disk_path == NULL) {
-       printf("Must select directory before deleting files\n");
+       g_printf(_("Must select directory before deleting files\n"));
        return;
     }
     memset(&lditem, 0, sizeof(lditem)); /* Prevent use of bogus data... */
 
-    dbprintf(("delete_file: Looking for \"%s\"\n", path));
+    dbprintf(_("delete_file: Looking for \"%s\"\n"), path);
 
     if (strcmp(regex, "[^/]*[/]*$") == 0) {
        /* Looking for * find everything but single . */
@@ -1101,13 +1101,13 @@ delete_file(
        amfree(clean_disk_path);
     }
 
-    dbprintf(("delete_file: Converted path=\"%s\" to path_on_disk=\"%s\"\n",
-             regex, path_on_disk));
+    dbprintf(_("delete_file: Converted path=\"%s\" to path_on_disk=\"%s\"\n"),
+             regex, path_on_disk);
     found_one = 0;
     for (ditem=get_dir_list(); ditem!=NULL; ditem=get_next_dir_item(ditem))
     {
        quoted = quote_string(ditem->path);
-       dbprintf(("delete_file: Pondering ditem->path=%s\n", quoted));
+       dbprintf(_("delete_file: Pondering ditem->path=%s\n"), quoted);
        amfree(quoted);
        if (match(path_on_disk, ditem->path))
        {
@@ -1120,7 +1120,7 @@ delete_file(
                clean_pathname(ditem_path);
 
                qditem_path = quote_string(ditem_path);
-               cmd = stralloc2("ORLD ", qditem_path);
+               cmd = newstralloc2(cmd, "ORLD ", qditem_path);
                amfree(qditem_path);
                if(send_command(cmd) == -1) {
                    amfree(cmd);
@@ -1140,7 +1140,7 @@ delete_file(
                    amfree(ditem_path);
                    amfree(path_on_disk);
                    l = reply_line();
-                   printf("%s\n", l);
+                   g_printf("%s\n", l);
                    return;
                }
                deleted=0;
@@ -1172,14 +1172,14 @@ delete_file(
 
                    s = l;
                    if(strncmp_const_skip(l, "201-", s, ch) != 0) {
-                       err = "bad reply: not 201-";
+                       err = _("bad reply: not 201-");
                        continue;
                    }
                    ch = *s++;
 
                    skip_whitespace(s, ch);
                    if(ch == '\0') {
-                       err = "bad reply: missing date field";
+                       err = _("bad reply: missing date field");
                        continue;
                    }
                    date = s - 1;
@@ -1188,14 +1188,14 @@ delete_file(
 
                    skip_whitespace(s, ch);
                    if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {
-                       err = "bad reply: cannot parse level field";
+                       err = _("bad reply: cannot parse level field");
                        continue;
                    }
                    skip_integer(s, ch);
 
                    skip_whitespace(s, ch);
                    if(ch == '\0') {
-                       err = "bad reply: missing tape field";
+                       err = _("bad reply: missing tape field");
                        continue;
                    }
                    tape = s - 1;
@@ -1205,11 +1205,11 @@ delete_file(
                    *tape_undo = '\0';
 
                    if(am_has_feature(indexsrv_features, fe_amindexd_fileno_in_ORLD)) {
-                       OFF_T_FMT_TYPE fileno_ = (OFF_T_FMT_TYPE)0;
+                       long long fileno_ = (long long)0;
                        skip_whitespace(s, ch);
                        if(ch == '\0' ||
-                          sscanf(s - 1, OFF_T_FMT, &fileno_) != 1) {
-                           err = "bad reply: cannot parse fileno field";
+                          sscanf(s - 1, "%lld", &fileno_) != 1) {
+                           err = _("bad reply: cannot parse fileno field");
                            continue;
                        }
                        fileno = (off_t)fileno_;
@@ -1218,7 +1218,7 @@ delete_file(
 
                    skip_whitespace(s, ch);
                    if(ch == '\0') {
-                       err = "bad reply: missing directory field";
+                       err = _("bad reply: missing directory field");
                        continue;
                    }
                    skip_non_whitespace(s, ch);
@@ -1231,13 +1231,13 @@ delete_file(
                     lditem.tape = newstralloc(lditem.tape, tape);
                    switch(delete_extract_item(&lditem)) {
                    case -1:
-                       printf("System error\n");
-                       dbprintf(("delete_file: (Failed) System error\n"));
+                       g_printf(_("System error\n"));
+                       dbprintf(_("delete_file: (Failed) System error\n"));
                        break;
                    case  0:
-                       printf("Deleted dir %s at date %s\n", ditem_path, date);
-                       dbprintf(("delete_file: (Successful) Deleted dir %s at date %s\n",
-                                 ditem_path, date));
+                       g_printf(_("Deleted dir %s at date %s\n"), ditem_path, date);
+                       dbprintf(_("delete_file: (Successful) Deleted dir %s at date %s\n"),
+                                 ditem_path, date);
                        deleted=1;
                        break;
                    case  1:
@@ -1252,29 +1252,29 @@ delete_file(
                    if (cmd)
                        puts(cmd);
                } else if(deleted == 0) {
-                   printf("Warning - dir '%s' not on tape list\n",
+                   g_printf(_("Warning - dir '%s' not on tape list\n"),
                           ditem_path);
-                   dbprintf(("delete_file: dir '%s' not on tape list\n",
-                             ditem_path));
+                   dbprintf(_("delete_file: dir '%s' not on tape list\n"),
+                             ditem_path);
                }
            }
            else
            {
                switch(delete_extract_item(ditem)) {
                case -1:
-                   printf("System error\n");
-                   dbprintf(("delete_file: (Failed) System error\n"));
+                   g_printf(_("System error\n"));
+                   dbprintf(_("delete_file: (Failed) System error\n"));
                    break;
                case  0:
-                   printf("Deleted %s\n", ditem->path);
-                   dbprintf(("delete_file: (Successful) Deleted %s\n",
-                             ditem->path));
+                   g_printf(_("Deleted %s\n"), ditem->path);
+                   dbprintf(_("delete_file: (Successful) Deleted %s\n"),
+                             ditem->path);
                    break;
                case  1:
-                   printf("Warning - file '%s' not on tape list\n",
+                   g_printf(_("Warning - file '%s' not on tape list\n"),
                           ditem->path);
-                   dbprintf(("delete_file: file '%s' not on tape list\n",
-                             ditem->path));
+                   dbprintf(_("delete_file: file '%s' not on tape list\n"),
+                             ditem->path);
                    break;
                }
            }
@@ -1285,9 +1285,9 @@ delete_file(
     amfree(path_on_disk);
 
     if(! found_one) {
-       printf("File %s doesn't exist in directory\n", path);
-       dbprintf(("delete_file: (Failed) File %s doesn't exist in directory\n",
-                 path));
+       g_printf(_("File %s doesn't exist in directory\n"), path);
+       dbprintf(_("delete_file: (Failed) File %s doesn't exist in directory\n"),
+                 path);
     }
 }
 
@@ -1317,7 +1317,7 @@ display_extract_list(
        pager_command = stralloc2(pager, " ; /bin/cat > /dev/null");
        if ((fp = popen(pager_command, "w")) == NULL)
        {
-           printf("Warning - can't pipe through %s\n", pager);
+           g_printf(_("Warning - can't pipe through %s\n"), pager);
            fp = stdout;
        }
        amfree(pager_command);
@@ -1327,7 +1327,7 @@ display_extract_list(
        uqfile = unquote_string(file);
        if ((fp = fopen(uqfile, "w")) == NULL)
        {
-           printf("Can't open file %s to print extract list into\n", file);
+           g_printf(_("Can't open file %s to print extract list into\n"), file);
            amfree(uqfile);
            return;
        }
@@ -1336,16 +1336,16 @@ display_extract_list(
 
     for (this = extract_list; this != NULL; this = this->next)
     {
-       fprintf(fp, "TAPE %s LEVEL %d DATE %s\n",
+       g_fprintf(fp, _("TAPE %s LEVEL %d DATE %s\n"),
                this->tape, this->level, this->date);
        for (that = this->files; that != NULL; that = that->next)
-           fprintf(fp, "\t%s\n", that->path);
+           g_fprintf(fp, "\t%s\n", that->path);
     }
 
     if (file == NULL) {
        apclose(fp);
     } else {
-       printf("Extract list written to file %s\n", file);
+       g_printf(_("Extract list written to file %s\n"), file);
        afclose(fp);
     }
 }
@@ -1393,20 +1393,20 @@ okay_to_continue(
     char *line = NULL;
     char *s;
     char *prompt;
-    int get_tape;
+    int get_device;
 
-    get_tape = 0;
+    get_device = 0;
     while (ret < 0) {
-       if (get_tape) {
-           prompt = "New tape device [?]: ";
+       if (get_device) {
+           prompt = _("New device name [?]: ");
        } else if (allow_tape && allow_skip) {
-           prompt = "Continue [?/Y/n/s/t]? ";
+           prompt = _("Continue [?/Y/n/s/d]? ");
        } else if (allow_tape && !allow_skip) {
-           prompt = "Continue [?/Y/n/t]? ";
+           prompt = _("Continue [?/Y/n/d]? ");
        } else if (allow_retry) {
-           prompt = "Continue [?/Y/n/r]? ";
+           prompt = _("Continue [?/Y/n/r]? ");
        } else {
-           prompt = "Continue [?/Y/n]? ";
+           prompt = _("Continue [?/Y/n]? ");
        }
        fputs(prompt, stdout);
        fflush(stdout); fflush(stderr);
@@ -1414,40 +1414,53 @@ okay_to_continue(
        if ((line = agets(stdin)) == NULL) {
            putchar('\n');
            clearerr(stdin);
-           if (get_tape) {
-               get_tape = 0;
+           if (get_device) {
+               get_device = 0;
                continue;
            }
            ret = 0;
            break;
        }
+       dbprintf("User prompt: '%s'; response: '%s'\n", prompt, line);
+
        s = line;
        while ((ch = *s++) != '\0' && isspace(ch)) {
            (void)ch;   /* Quiet empty loop compiler warning */
        }
        if (ch == '?') {
-           if (get_tape) {
-               printf("Enter a new device ([host:]device) or \"default\"\n");
+           if (get_device) {
+               g_printf(_("Enter a new device name or \"default\"\n"));
            } else {
-               printf("Enter \"y\"es to continue, \"n\"o to stop");
+               g_printf(_("Enter \"y\"es to continue, \"n\"o to stop"));
                if(allow_skip) {
-                   printf(", \"s\"kip this tape");
+                   g_printf(_(", \"s\"kip this tape"));
                }
                if(allow_retry) {
-                   printf(" or \"r\"etry this tape");
+                   g_printf(_(" or \"r\"etry this tape"));
                }
                if (allow_tape) {
-                   printf(" or \"t\"ape to change tape drives");
+                   g_printf(_(" or \"d\" to change to a new device"));
                }
                putchar('\n');
            }
-       } else if (get_tape) {
-           set_tape(s - 1);
-           get_tape = 0;
+       } else if (get_device) {
+           char *tmp = stralloc(tape_server_name);
+
+           if (strncmp_const(s - 1, "default") == 0) {
+               set_device(tmp, NULL); /* default device, existing host */
+           } else if (s[-1] != '\0') {
+               set_device(tmp, s - 1); /* specified device, existing host */
+           } else {
+               g_printf(_("No change.\n"));
+           }
+
+           amfree(tmp);
+
+           get_device = 0;
        } else if (ch == '\0' || ch == 'Y' || ch == 'y') {
            ret = 1;
-       } else if (allow_tape && (ch == 'T' || ch == 't')) {
-           get_tape = 1;
+       } else if (allow_tape && (ch == 'D' || ch == 'd' || ch == 'T' || ch == 't')) {
+           get_device = 1; /* ('T' and 't' are for backward-compatibility) */
        } else if (ch == 'N' || ch == 'n') {
            ret = 0;
        } else if (allow_retry && (ch == 'R' || ch == 'r')) {
@@ -1471,7 +1484,7 @@ send_to_tape_server(
 
     if (security_stream_write(stream, msg, strlen(msg)) < 0)
     {
-       error("Error writing to tape server");
+       error(_("Error writing to tape server"));
        exit(101);
        /*NOTREACHED*/
     }
@@ -1496,7 +1509,7 @@ extract_files_setup(
 
     amidxtaped_secdrv = security_getdriver(authopt);
     if (amidxtaped_secdrv == NULL) {
-       error("no '%s' security driver available for host '%s'",
+       error(_("no '%s' security driver available for host '%s'"),
              authopt, tape_server_name);
     }
 
@@ -1582,7 +1595,7 @@ extract_files_setup(
        if(strncmp_const(amidxtaped_line,"FEATURES=") == 0) {
            tapesrv_features = am_string_to_feature(amidxtaped_line+9);
        } else {
-           fprintf(stderr, "amrecover - expecting FEATURES line from amidxtaped\n");
+           g_fprintf(stderr, _("amrecover - expecting FEATURES line from amidxtaped\n"));
            stop_amidxtaped();
            amfree(disk_regex);
            amfree(host_regex);
@@ -1600,7 +1613,7 @@ extract_files_setup(
        am_has_feature(indexsrv_features, fe_amidxtaped_datestamp)) {
 
        if(am_has_feature(indexsrv_features, fe_amidxtaped_config)) {
-           tt = newstralloc2(tt, "CONFIG=", config);
+           tt = newstralloc2(tt, "CONFIG=", config_name);
            send_to_tape_server(amidxtaped_streams[CTLFD].fd, tt);
        }
        if(am_has_feature(indexsrv_features, fe_amidxtaped_label) &&
@@ -1610,7 +1623,7 @@ extract_files_setup(
        }
        if(am_has_feature(indexsrv_features, fe_amidxtaped_fsf)) {
            char v_fsf[100];
-           snprintf(v_fsf, 99, OFF_T_FMT, (OFF_T_FMT_TYPE)fsf);
+           g_snprintf(v_fsf, 99, "%lld", (long long)fsf);
            tt = newstralloc2(tt, "FSF=",v_fsf);
            send_to_tape_server(amidxtaped_streams[CTLFD].fd, tt);
        }
@@ -1644,8 +1657,8 @@ extract_files_setup(
        send_to_tape_server(amidxtaped_streams[CTLFD].fd, disk_regex);
        send_to_tape_server(amidxtaped_streams[CTLFD].fd, clean_datestamp);
 
-       dbprintf(("Started amidxtaped with arguments \"6 -h -p %s %s %s %s\"\n",
-                 dump_device_name, host_regex, disk_regex, clean_datestamp));
+       dbprintf(_("Started amidxtaped with arguments \"6 -h -p %s %s %s %s\"\n"),
+                 dump_device_name, host_regex, disk_regex, clean_datestamp);
     }
 
     amfree(disk_regex);
@@ -1670,16 +1683,17 @@ read_file_header(
     ssize_t bytes_read;
     bytes_read = read_buffer(tapedev, buffer, buflen, READ_TIMEOUT);
     if(bytes_read < 0) {
-       error("error reading header (%s), check amidxtaped.*.debug on server",
+       error(_("error reading header (%s), check amidxtaped.*.debug on server"),
              strerror(errno));
        /*NOTREACHED*/
     }
 
     if((size_t)bytes_read < buflen) {
-       fprintf(stderr, "%s: short block %d byte%s\n",
-               get_pname(), (int)bytes_read, (bytes_read == 1) ? "" : "s");
+       g_fprintf(stderr, plural(_("%s: short block %d byte\n"),
+                              _("%s: short block %d bytes\n"), bytes_read),
+               get_pname(), (int)bytes_read);
        print_header(stdout, file);
-       error("Can't read file header");
+       error(_("Can't read file header"));
        /*NOTREACHED*/
     }
 
@@ -1724,7 +1738,7 @@ extract_files_child(
     /* make in_fd be our stdin */
     if (dup2(in_fd, STDIN_FILENO) == -1)
     {
-       error("dup2 failed in extract_files_child: %s", strerror(errno));
+       error(_("dup2 failed in extract_files_child: %s"), strerror(errno));
        /*NOTREACHED*/
     }
 
@@ -1734,7 +1748,7 @@ extract_files_child(
 
     if(file.type != F_DUMPFILE) {
        print_header(stdout, &file);
-       error("bad header");
+       error(_("bad header"));
        /*NOTREACHED*/
     }
 
@@ -1862,7 +1876,7 @@ extract_files_child(
        restore_args[j++] = stralloc(file.dumper);
        restore_args[j++] = stralloc("restore");
        restore_args[j++] = stralloc("--config");
-       restore_args[j++] = stralloc(config);
+       restore_args[j++] = stralloc(config_name);
        restore_args[j++] = stralloc("--disk");
        restore_args[j++] = stralloc(file.disk);
        break;
@@ -1919,7 +1933,7 @@ extract_files_child(
     case IS_GNUTAR:
     case IS_SAMBA_TAR:
 #ifndef GNUTAR
-       fprintf(stderr, "warning: GNUTAR program not available.\n");
+       g_fprintf(stderr, _("warning: GNUTAR program not available.\n"));
        cmd = stralloc("tar");
 #else
        cmd = stralloc(GNUTAR);
@@ -1949,7 +1963,7 @@ extract_files_child(
        }
 #endif
        if (cmd == NULL) {
-           fprintf(stderr, "warning: restore program for %s not available.\n",
+           g_fprintf(stderr, _("warning: restore program for %s not available.\n"),
                    file.program);
            cmd = stralloc("restore");
        }
@@ -1959,13 +1973,14 @@ extract_files_child(
        break;
     }
     if (cmd) {
-        dbprintf(("Exec'ing %s with arguments:\n", cmd));
+        dbprintf(_("Exec'ing %s with arguments:\n"), cmd);
        for (i = 0; i < j; i++) {
            if( i == passwd_field)
-               dbprintf(("\tXXXXX\n"));
+               dbprintf("\tXXXXX\n");
            else
-               dbprintf(("\t%s\n", restore_args[i]));
+               dbprintf(_("\t%s\n"), restore_args[i]);
        }
+       safe_fd(-1, 0);
         (void)execv(cmd, restore_args);
        /* only get here if exec failed */
        save_errno = errno;
@@ -1974,8 +1989,8 @@ extract_files_child(
        }
        amfree(restore_args);
        errno = save_errno;
-        perror("amrecover couldn't exec");
-        fprintf(stderr, " problem executing %s\n", cmd);
+        perror(_("amrecover couldn't exec"));
+        g_fprintf(stderr, _(" problem executing %s\n"), cmd);
        amfree(cmd);
     }
     exit(1);
@@ -1996,7 +2011,7 @@ writer_intermediary(
     amwait_t extractor_status;
 
     if(pipe(child_pipe) == -1) {
-       error("extract_list - error setting up pipe to extractor: %s\n",
+       error(_("extract_list - error setting up pipe to extractor: %s\n"),
              strerror(errno));
        /*NOTREACHED*/
     }
@@ -2012,7 +2027,7 @@ writer_intermediary(
 
     /* This is the parent */
     if (pid == -1) {
-       printf("writer_intermediary - error forking child");
+       g_printf(_("writer_intermediary - error forking child"));
        return -1;
     }
 
@@ -2027,7 +2042,8 @@ writer_intermediary(
        /* if prompted for a tape, relay said prompt to the user */
        if(sscanf(amidxtaped_line, "FEEDME %132s\n", desired_tape) == 1) {
            int done;
-           printf("Load tape %s now\n", desired_tape);
+           g_printf(_("Load tape %s now\n"), desired_tape);
+           dbprintf(_("Requesting tape %s from user\n"), desired_tape);
            done = okay_to_continue(am_has_feature(indexsrv_features,
                                                   fe_amrecover_feedme_tape),
                                    0, 0);
@@ -2045,9 +2061,9 @@ writer_intermediary(
                break;
            }
        } else if(strncmp_const(amidxtaped_line, "MESSAGE ") == 0) {
-           printf("%s\n",&amidxtaped_line[8]);
+           g_printf("%s\n",&amidxtaped_line[8]);
        } else {
-           fprintf(stderr, "Strange message from tape server: %s",
+           g_fprintf(stderr, _("Strange message from tape server: %s"),
                    amidxtaped_line);
            break;
        }
@@ -2061,7 +2077,7 @@ writer_intermediary(
     if(WEXITSTATUS(extractor_status) != 0){
        int ret = WEXITSTATUS(extractor_status);
         if(ret == 255) ret = -1;
-       printf("Extractor child exited with status %d\n", ret);
+       g_printf(_("Extractor child exited with status %d\n"), ret);
        return -1;
     }
     return(0);
@@ -2090,7 +2106,7 @@ void
 extract_files(void)
 {
     EXTRACT_LIST *elist;
-    char cwd[STR_SIZE];
+    char * cwd;
     char *l;
     int first;
     int otc;
@@ -2098,7 +2114,7 @@ extract_files(void)
 
     if (!is_extract_list_nonempty())
     {
-       printf("Extract list empty - No files to extract!\n");
+       g_printf(_("Extract list empty - No files to extract!\n"));
        return;
     }
 
@@ -2116,7 +2132,7 @@ extract_files(void)
        l = reply_line();
        if (!server_happy())
        {
-           printf("%s\n", l);
+           g_printf("%s\n", l);
            exit(1);
        }
        /* skip reply number */
@@ -2125,7 +2141,7 @@ extract_files(void)
 
     if (strcmp(tape_device_name, "/dev/null") == 0)
     {
-       printf("amrecover: warning: using %s as the tape device will not work\n",
+       g_printf(_("amrecover: warning: using %s as the tape device will not work\n"),
               tape_device_name);
     }
 
@@ -2133,17 +2149,17 @@ extract_files(void)
     for (elist = first_tape_list(); elist != NULL; elist = next_tape_list(elist)) {
        if(elist->tape[0]!='/') {
            if(first) {
-               printf("\nExtracting files using tape drive %s on host %s.\n",
+               g_printf(_("\nExtracting files using tape drive %s on host %s.\n"),
                        tape_device_name, tape_server_name);
-               printf("The following tapes are needed:");
+               g_printf(_("The following tapes are needed:"));
                first=0;
            }
            else
-               printf("                               ");
+               g_printf("                               ");
            tlist = unmarshal_tapelist_str(elist->tape); 
            for(a_tlist = tlist ; a_tlist != NULL; a_tlist = a_tlist->next)
-               printf(" %s", a_tlist->label);
-           printf("\n");
+               g_printf(" %s", a_tlist->label);
+           g_printf("\n");
            free_tapelist(tlist);
        }
     }
@@ -2151,41 +2167,46 @@ extract_files(void)
     for (elist = first_tape_list(); elist != NULL; elist = next_tape_list(elist)) {
        if(elist->tape[0]=='/') {
            if(first) {
-               printf("\nExtracting files from holding disk on host %s.\n",
+               g_printf(_("\nExtracting files from holding disk on host %s.\n"),
                        tape_server_name);
-               printf("The following files are needed:");
+               g_printf(_("The following files are needed:"));
                first=0;
            }
            else
-               printf("                               ");
+               g_printf("                               ");
            tlist = unmarshal_tapelist_str(elist->tape); 
            for(a_tlist = tlist; a_tlist != NULL; a_tlist = a_tlist->next)
-               printf(" %s", a_tlist->label);
-           printf("\n");
+               g_printf(" %s", a_tlist->label);
+           g_printf("\n");
            free_tapelist(tlist);
        }
     }
-    printf("\n");
+    g_printf("\n");
 
-    if (getcwd(cwd, sizeof(cwd)) == NULL) {
-       perror("extract_list: Current working directory unavailable");
+    cwd = g_get_current_dir();
+    if (cwd == NULL) {
+       perror(_("extract_list: Current working directory unavailable"));
        exit(1);
     }
 
-    printf("Restoring files into directory %s\n", cwd);
+    g_printf(_("Restoring files into directory %s\n"), cwd);
     check_file_overwrite(cwd);
 
 #ifdef SAMBA_CLIENT
     if (samba_extract_method == SAMBA_SMBCLIENT)
-      printf("(unless it is a Samba backup, that will go through to the SMB server)\n");
+      g_printf(_("(unless it is a Samba backup, that will go through to the SMB server)\n"));
 #endif
-    if (!okay_to_continue(0,0,0))
+    dbprintf(_("Checking with user before restoring into directory %s\n"), cwd);
+    if (!okay_to_continue(0,0,0)) {
+        amfree(cwd);
        return;
-    printf("\n");
+    }
+    g_printf("\n");
 
     if (!do_unlink_list()) {
-       fprintf(stderr, "Can't recover because I can't cleanup the cwd (%s)\n",
+       g_fprintf(stderr, _("Can't recover because I can't cleanup the cwd (%s)\n"),
                cwd);
+        amfree(cwd);
        return;
     }
     free_unlink_list();
@@ -2194,18 +2215,19 @@ extract_files(void)
     {
        if(elist->tape[0]=='/') {
            dump_device_name = newstralloc(dump_device_name, elist->tape);
-           printf("Extracting from file ");
+           g_printf(_("Extracting from file "));
            tlist = unmarshal_tapelist_str(dump_device_name); 
            for(a_tlist = tlist; a_tlist != NULL; a_tlist = a_tlist->next)
-               printf(" %s", a_tlist->label);
-           printf("\n");
+               g_printf(" %s", a_tlist->label);
+           g_printf("\n");
            free_tapelist(tlist);
        }
        else {
-           printf("Extracting files using tape drive %s on host %s.\n",
+           g_printf(_("Extracting files using tape drive %s on host %s.\n"),
                   tape_device_name, tape_server_name);
            tlist = unmarshal_tapelist_str(elist->tape); 
-           printf("Load tape %s now\n", tlist->label);
+           g_printf(_("Load tape %s now\n"), tlist->label);
+           dbprintf(_("Requesting tape %s from user\n"), tlist->label);
            free_tapelist(tlist);
            otc = okay_to_continue(1,1,0);
            if (otc == 0)
@@ -2221,7 +2243,8 @@ extract_files(void)
        /* connect to the tape handler daemon on the tape drive server */
        if ((extract_files_setup(elist->tape, elist->fileno)) == -1)
        {
-           fprintf(stderr, "amrecover - can't talk to tape server: %s\n",errstr);
+           g_fprintf(stderr, _("amrecover - can't talk to tape server: %s\n"),
+                   errstr);
            return;
        }
 
@@ -2253,8 +2276,7 @@ amidxtaped_response(
     memset(ports, -1, SIZEOF(ports));
 
     if (pkt == NULL) {
-       errstr = newvstralloc(errstr, "[request failed: ",
-                            security_geterror(sech), "]", NULL);
+       errstr = newvstrallocf(errstr, _("[request failed: %s]"), security_geterror(sech));
        *response_error = 1;
        return;
     }
@@ -2262,7 +2284,7 @@ amidxtaped_response(
 
     if (pkt->type == P_NAK) {
 #if defined(PACKET_DEBUG)
-       fprintf(stderr, "got nak response:\n----\n%s\n----\n\n", pkt->body);
+       g_fprintf(stderr, _("got nak response:\n----\n%s\n----\n\n"), pkt->body);
 #endif
 
        tok = strtok(pkt->body, " ");
@@ -2282,14 +2304,14 @@ bad_nak:
     }
 
     if (pkt->type != P_REP) {
-       errstr = newvstralloc(errstr, "received strange packet type ",
-                             pkt_type2str(pkt->type), ": ", pkt->body, NULL);
+       errstr = newvstrallocf(errstr, _("received strange packet type %s: %s"),
+                             pkt_type2str(pkt->type), pkt->body);
        *response_error = 1;
        return;
     }
 
 #if defined(PACKET_DEBUG)
-    fprintf(stderr, "got response:\n----\n%s\n----\n\n", pkt->body);
+    g_fprintf(stderr, _("got response:\n----\n%s\n----\n\n"), pkt->body);
 #endif
 
     for(i = 0; i < NSTREAMS; i++) {
@@ -2308,7 +2330,7 @@ bad_nak:
        if (strcmp(tok, "ERROR") == 0) {
            tok = strtok(NULL, "\n");
            if (tok == NULL)
-               tok = "[bogus error packet]";
+               tok = _("[bogus error packet]");
            errstr = newstralloc(errstr, tok);
            *response_error = 2;
            return;
@@ -2326,22 +2348,16 @@ bad_nak:
            for (i = 0; i < NSTREAMS; i++) {
                tok = strtok(NULL, " ");
                if (tok == NULL || strcmp(tok, amidxtaped_streams[i].name) != 0) {
-                   extra = vstralloc("CONNECT token is \"",
+                   extra = vstrallocf(_("CONNECT token is \"%s\": expected \"%s\""),
                                      tok ? tok : "(null)",
-                                     "\": expected \"",
-                                     amidxtaped_streams[i].name,
-                                     "\"",
-                                     NULL);
+                                     amidxtaped_streams[i].name);
                    goto parse_error;
                }
                tok = strtok(NULL, " \n");
                if (tok == NULL || sscanf(tok, "%d", &ports[i]) != 1) {
-                   extra = vstralloc("CONNECT ",
+                   extra = vstrallocf(_("CONNECT %s token is \"%s\": expected a port number"),
                                      amidxtaped_streams[i].name,
-                                     " token is \"",
-                                     tok ? tok : "(null)",
-                                     "\": expected a port number",
-                                     NULL);
+                                     tok ? tok : "(null)");
                    goto parse_error;
                }
            }
@@ -2354,7 +2370,7 @@ bad_nak:
        if (strcmp(tok, "OPTIONS") == 0) {
            tok = strtok(NULL, "\n");
            if (tok == NULL) {
-               extra = stralloc("OPTIONS token is missing");
+               extra = stralloc(_("OPTIONS token is missing"));
                goto parse_error;
            }
 /*
@@ -2365,7 +2381,7 @@ bad_nak:
                    am_release_feature_set(their_features);
                    if((their_features = am_string_to_feature(tok)) == NULL) {
                        errstr = newvstralloc(errstr,
-                                             "OPTIONS: bad features value: ",
+                                             _("OPTIONS: bad features value: "),
                                              tok,
                                              NULL);
                        goto parse_error;
@@ -2377,10 +2393,8 @@ bad_nak:
            continue;
        }
 /*
-       extra = vstralloc("next token is \"",
-                         tok ? tok : "(null)",
-                         "\": expected \"CONNECT\", \"ERROR\" or \"OPTIONS\"",
-                         NULL);
+       extra = vstrallocf("next token is \"%s\": expected \"CONNECT\", \"ERROR\" or \"OPTIONS\""),
+                         tok ? tok : _("(null)"));
        goto parse_error;
 */
     }
@@ -2392,11 +2406,12 @@ bad_nak:
        if (ports[i] == -1)
            continue;
        amidxtaped_streams[i].fd = security_stream_client(sech, ports[i]);
-       dbprintf(("amidxtaped_streams[%d].fd = %p\n",i, amidxtaped_streams[i].fd));
+       dbprintf(_("amidxtaped_streams[%d].fd = %p\n"),i, amidxtaped_streams[i].fd);
        if (amidxtaped_streams[i].fd == NULL) {
-           errstr = newvstralloc(errstr,
-                       "[could not connect ", amidxtaped_streams[i].name, " stream: ",
-                       security_geterror(sech), "]", NULL);
+           errstr = newvstrallocf(errstr,\
+                       _("[could not connect %s stream: %s]"),
+                       amidxtaped_streams[i].name,
+                       security_geterror(sech));
            goto connect_error;
        }
     }
@@ -2407,9 +2422,10 @@ bad_nak:
        if (amidxtaped_streams[i].fd == NULL)
            continue;
        if (security_stream_auth(amidxtaped_streams[i].fd) < 0) {
-           errstr = newvstralloc(errstr,
-               "[could not authenticate ", amidxtaped_streams[i].name, " stream: ",
-               security_stream_geterror(amidxtaped_streams[i].fd), "]", NULL);
+           errstr = newvstrallocf(errstr,
+               _("[could not authenticate %s stream: %s]"),
+               amidxtaped_streams[i].name,
+               security_stream_geterror(amidxtaped_streams[i].fd));
            goto connect_error;
        }
     }
@@ -2419,11 +2435,11 @@ bad_nak:
      * them, complain.
      */
     if (amidxtaped_streams[CTLFD].fd == NULL) {
-        errstr = newstralloc(errstr, "[couldn't open CTL streams]");
+        errstr = newvstrallocf(errstr, _("[couldn't open CTL streams]"));
         goto connect_error;
     }
     if (amidxtaped_streams[DATAFD].fd == NULL) {
-        errstr = newstralloc(errstr, "[couldn't open DATA streams]");
+        errstr = newvstrallocf(errstr, _("[couldn't open DATA streams]"));
         goto connect_error;
     }
 
@@ -2432,11 +2448,13 @@ bad_nak:
     return;
 
 parse_error:
-    errstr = newvstralloc(errstr,
-                         "[parse of reply message failed: ",
-                         extra ? extra : "(no additional information)",
-                         "]",
-                         NULL);
+    if (extra) {
+       errstr = newvstrallocf(errstr,
+                         _("[parse of reply message failed: %s]"), extra);
+    } else {
+       errstr = newvstrallocf(errstr,
+                         _("[parse of reply message failed: (no additional information)"));
+    }
     amfree(extra);
     *response_error = 2;
     return;
@@ -2517,7 +2535,7 @@ read_amidxtaped_data(
 
     fd = *(int *)cookie;
     if (size < 0) {
-       errstr = newstralloc2(errstr, "amidxtaped read: ",
+       errstr = newstralloc2(errstr, _("amidxtaped read: "),
                 security_stream_geterror(amidxtaped_streams[DATAFD].fd));
        return;
     }