Imported Upstream version 2.6.0
[debian/amanda] / client-src / sendbackup.c
index 9cfa39732d122407a17560461fb5338ea52fe63f..9f26dafe2e2d3ccf02db171a2da62cc57d227b12 100644 (file)
@@ -40,9 +40,9 @@
 #include "version.h"
 #include "conffile.h"
 
-#define sendbackup_debug(i,x) do {     \
+#define sendbackup_debug(i, ...) do {  \
        if ((i) <= debug_sendbackup) {  \
-           dbprintf(x);                \
+           dbprintf(__VA_LIST__);      \
        }                               \
 } while (0)
 
@@ -193,16 +193,22 @@ main(
     char *line = NULL;
     char *err_extra = NULL;
     char *s;
-    char *conffile;
     int i;
     int ch;
-    unsigned long malloc_hist_1, malloc_size_1;
-    unsigned long malloc_hist_2, malloc_size_2;
     FILE *toolin;
     int status;
 
     /* initialize */
 
+    /*
+     * 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"); 
+
     safe_fd(DATA_FD_OFFSET, DATA_FD_COUNT*2);
 
     safe_cd();
@@ -215,8 +221,6 @@ main(
     /* Don't die when interrupt received */
     signal(SIGINT, SIG_IGN);
 
-    malloc_size_1 = malloc_inuse(&malloc_hist_1);
-
     if(argc > 1 && strcmp(argv[1],"-t") == 0) {
        interactive = 1;
        argc--;
@@ -228,7 +232,7 @@ main(
     erroutput_type = (ERR_INTERACTIVE|ERR_SYSLOG);
     dbopen(DBG_SUBDIR_CLIENT);
     startclock();
-    dbprintf(("%s: version %s\n", get_pname(), version()));
+    dbprintf(_("Version %s\n"), version());
 
     if(argc > 2 && strcmp(argv[1], "amandad") == 0) {
        amandad_auth = stralloc(argv[2]);
@@ -237,12 +241,9 @@ main(
     our_features = am_init_feature_set();
     our_feature_string = am_feature_to_string(our_features);
 
-    conffile = vstralloc(CONFIG_DIR, "/", "amanda-client.conf", NULL);
-    if (read_clientconf(conffile) > 0) {
-       error("error reading conffile: %s", conffile);
-       /*NOTREACHED*/
-    }
-    amfree(conffile);
+    config_init(CONFIG_INIT_CLIENT, NULL);
+
+    check_running_as(RUNNING_AS_CLIENT_LOGIN);
 
     if(interactive) {
        /*
@@ -251,7 +252,7 @@ main(
         * programs on the tape host are set up.  The index service is
         * run and goes to stdout.
         */
-       fprintf(stderr, "%s: running in interactive test mode\n", get_pname());
+       g_fprintf(stderr, _("%s: running in interactive test mode\n"), get_pname());
        fflush(stderr);
     }
 
@@ -267,7 +268,7 @@ main(
        if (line[0] == '\0')
            continue;
        if(interactive) {
-           fprintf(stderr, "%s> ", get_pname());
+           g_fprintf(stderr, "%s> ", get_pname());
            fflush(stderr);
        }
        if(strncmp_const(line, "OPTIONS ") == 0) {
@@ -279,31 +280,27 @@ main(
            }
 
            if (g_options->config) {
-               conffile = vstralloc(CONFIG_DIR, "/", g_options->config, "/",
-                                    "amanda-client.conf", NULL);
-               if (read_clientconf(conffile) > 0) {
-                   error("error reading conffile: %s", conffile);
-                   /*NOTREACHED*/
-               }
-               amfree(conffile);
+               /* overlay this configuration on the existing (nameless) configuration */
+               config_init(CONFIG_INIT_CLIENT | CONFIG_INIT_EXPLICIT_NAME | CONFIG_INIT_OVERLAY,
+                           g_options->config);
 
-               dbrename(g_options->config, DBG_SUBDIR_CLIENT);
+               dbrename(config_name, DBG_SUBDIR_CLIENT);
            }
            continue;
        }
 
        if (prog != NULL) {
-           err_extra = "multiple requests";
+           err_extra = _("multiple requests");
            goto err;
        }
 
-       dbprintf(("  sendbackup req: <%s>\n", line));
+       dbprintf(_("  sendbackup req: <%s>\n"), line);
        s = line;
        ch = *s++;
 
        skip_whitespace(s, ch);                 /* find the program name */
        if(ch == '\0') {
-           err_extra = "no program name";
+           err_extra = _("no program name");
            goto err;                           /* no program name */
        }
        prog = s - 1;
@@ -324,7 +321,7 @@ main(
 
        skip_whitespace(s, ch);                 /* find the disk name */
        if(ch == '\0') {
-           err_extra = "no disk name";
+           err_extra = _("no disk name");
            goto err;                           /* no disk name */
        }
 
@@ -339,7 +336,7 @@ main(
 
        skip_whitespace(s, ch);                 /* find the device or level */
        if (ch == '\0') {
-           err_extra = "bad level";
+           err_extra = _("bad level");
            goto err;
        }
 
@@ -360,14 +357,14 @@ main(
        }
                                                /* find the level number */
        if(ch == '\0' || sscanf(s - 1, "%d", &level) != 1) {
-           err_extra = "bad level";
+           err_extra = _("bad level");
            goto err;                           /* bad level */
        }
        skip_integer(s, ch);
 
        skip_whitespace(s, ch);                 /* find the dump date */
        if(ch == '\0') {
-           err_extra = "no dumpdate";
+           err_extra = _("no dumpdate");
            goto err;                           /* no dumpdate */
        }
        amfree(dumpdate);
@@ -378,38 +375,43 @@ main(
 
        skip_whitespace(s, ch);                 /* find the options keyword */
        if(ch == '\0') {
-           err_extra = "no options";
+           err_extra = _("no options");
            goto err;                           /* no options */
        }
        if(strncmp_const_skip(s - 1, "OPTIONS ", s, ch) != 0) {
-           err_extra = "no OPTIONS keyword";
+           err_extra = _("no OPTIONS keyword");
            goto err;                           /* no options */
        }
        skip_whitespace(s, ch);                 /* find the options string */
        if(ch == '\0') {
-           err_extra = "bad options string";
+           err_extra = _("bad options string");
            goto err;                           /* no options */
        }
        amfree(stroptions);
        stroptions = stralloc(s - 1);
     }
     amfree(line);
+    if (g_options == NULL) {
+       printf(_("ERROR [Missing OPTIONS line in sendbackup input]\n"));
+       error(_("Missing OPTIONS line in sendbackup input\n"));
+       /*NOTREACHED*/
+    }
 
     if (prog       == NULL ||
        disk       == NULL ||
        amdevice   == NULL ||
        dumpdate   == NULL ||
        stroptions == NULL) {
-       err_extra = "no valid sendbackup request";
+       err_extra = _("no valid sendbackup request");
        goto err;
     }
        
-    dbprintf(("  parsed request as: program `%s'\n", prog));
-    dbprintf(("                     disk `%s'\n", qdisk));
-    dbprintf(("                     device `%s'\n", qamdevice));
-    dbprintf(("                     level %d\n", level));
-    dbprintf(("                     since %s\n", dumpdate));
-    dbprintf(("                     options `%s'\n", stroptions));
+    dbprintf(_("  Parsed request as: program `%s'\n"), prog);
+    dbprintf(_("                     disk `%s'\n"), qdisk);
+    dbprintf(_("                     device `%s'\n"), qamdevice);
+    dbprintf(_("                     level %d\n"), level);
+    dbprintf(_("                     since %s\n"), dumpdate);
+    dbprintf(_("                     options `%s'\n"), stroptions);
 
     if(program_is_backup_api==1) {
        /* check that the backup_api exist */
@@ -421,8 +423,8 @@ main(
            }
        }
        if (programs[i] == NULL) {
-           dbprintf(("ERROR [%s: unknown program %s]\n", get_pname(), prog));
-           error("ERROR [%s: unknown program %s]", get_pname(), prog);
+           dbprintf(_("ERROR [%s: unknown program %s]\n"), get_pname(), prog);
+           error(_("ERROR [%s: unknown program %s]"), get_pname(), prog);
            /*NOTREACHED*/
        }
        program = programs[i];
@@ -440,38 +442,41 @@ main(
 
     if(options->auth && amandad_auth) {
        if(strcasecmp(options->auth, amandad_auth) != 0) {
-           printf("ERROR [client configured for auth=%s while server requested '%s']\n",
+           g_printf(_("ERROR [client configured for auth=%s while server requested '%s']\n"),
                   amandad_auth, options->auth);
            exit(-1);
        }
     }
 
-    printf("CONNECT DATA %d MESG %d INDEX %d\n",
+    if (options->kencrypt) {
+       g_printf("KENCRYPT\n");
+    }
+
+    g_printf(_("CONNECT DATA %d MESG %d INDEX %d\n"),
           DATA_FD_OFFSET, DATA_FD_OFFSET+1,
           indexfd == -1 ? -1 : DATA_FD_OFFSET+2);
-    printf("OPTIONS ");
+    g_printf(_("OPTIONS "));
     if(am_has_feature(g_options->features, fe_rep_options_features)) {
-       printf("features=%s;", our_feature_string);
+       g_printf("features=%s;", our_feature_string);
     }
     if(am_has_feature(g_options->features, fe_rep_options_hostname)) {
-       printf("hostname=%s;", g_options->hostname);
+       g_printf("hostname=%s;", g_options->hostname);
     }
     if(am_has_feature(g_options->features, fe_rep_options_sendbackup_options)) {
-       printf("%s", optionstr(options));
+       g_printf("%s", optionstr(options));
     }
-    printf("\n");
+    g_printf("\n");
     fflush(stdout);
     if (freopen("/dev/null", "w", stdout) == NULL) {
-       dbprintf(("%s: error redirecting stdout to /dev/null: %s\n",
-           debug_prefix_time(NULL), strerror(errno)));
+       dbprintf(_("Error redirecting stdout to /dev/null: %s\n"),
+                strerror(errno));
         exit(1);
     }
 
     if(interactive) {
       if((datafd = open("/dev/null", O_RDWR)) < 0) {
-       s = strerror(errno);
-       error("ERROR [%s: open of /dev/null for debug data stream: %s]\n",
-                 get_pname(), s);
+       error(_("ERROR [open of /dev/null for debug data stream: %s]\n"),
+               strerror(errno));
        /*NOTREACHED*/
       }
       mesgfd = 2;
@@ -495,7 +500,7 @@ main(
        backup_support_option_t *bsu;
 
        if (pipe(property_pipe) < 0) {
-           error("Can't create pipe: %s",strerror(errno));
+           error(_("Can't create pipe: %s"),strerror(errno));
            /*NOTREACHED*/
        }
        bsu = backup_support_option(prog, g_options, disk, amdevice);
@@ -504,24 +509,27 @@ main(
        case 0:
            aclose(property_pipe[1]);
            if(dup2(property_pipe[0], 0) == -1) {
-               error("Can't dup2: %s",strerror(errno));
+               error(_("Can't dup2: %s"),strerror(errno));
                /*NOTREACHED*/
            }
            if(dup2(datafd, 1) == -1) {
-               error("Can't dup2: %s",strerror(errno));
+               error(_("Can't dup2: %s"),strerror(errno));
                /*NOTREACHED*/
            }
            if(dup2(mesgfd, 2) == -1) {
-               error("Can't dup2: %s",strerror(errno));
+               error(_("Can't dup2: %s"),strerror(errno));
                /*NOTREACHED*/
            }
            if(indexfd != 0) {
                if(dup2(indexfd, 3) == -1) {
-                   error("Can't dup2: %s",strerror(errno));
+                   error(_("Can't dup2: %s"),strerror(errno));
                    /*NOTREACHED*/
                }
                fcntl(indexfd, F_SETFD, 0);
                fcntl(3, F_SETFD, 0);
+               safe_fd(3, 1);
+           } else {
+               safe_fd(-1, 0);
            }
            cmd = vstralloc(DUMPER_DIR, "/", prog, NULL);
            i=0;
@@ -547,7 +555,7 @@ main(
            argvchild[i++] = amdevice;
            if (level <= bsu->max_level) {
                argvchild[i++] = "--level";
-               snprintf(levelstr,19,"%d",level);
+               g_snprintf(levelstr,19,"%d",level);
                argvchild[i++] = levelstr;
            }
            if (indexfd != 0 && bsu->index_line == 1) {
@@ -558,9 +566,9 @@ main(
                argvchild[i++] = "--record";
            }
            argvchild[i] = NULL;
-           dbprintf(("%s: running \"%s", get_pname(), cmd));
-           for(j=1;j<i;j++) dbprintf((" %s",argvchild[j]));
-           dbprintf(("\"\n"));
+           dbprintf(_("%s: running \"%s"), get_pname(), cmd);
+           for(j=1;j<i;j++) dbprintf(" %s",argvchild[j]);
+           dbprintf(_("\"\n"));
            backup_api_info_tapeheader(mesgfd, prog, options);
            execve(cmd, argvchild, safe_env());
            exit(1);
@@ -570,7 +578,7 @@ main(
            aclose(property_pipe[0]);
            toolin = fdopen(property_pipe[1],"w");
            if (!toolin) {
-               error("Can't fdopen: %s", strerror(errno));
+               error(_("Can't fdopen: %s"), strerror(errno));
                /*NOTREACHED*/
            }
            output_tool_property(toolin, options);
@@ -578,16 +586,16 @@ main(
            fclose(toolin);
            break;
        case -1:
-           error("%s: fork returned: %s", get_pname(), strerror(errno));
+           error(_("%s: fork returned: %s"), get_pname(), strerror(errno));
        }
        amfree(bsu);
        if (waitpid(backup_api_pid, &status, 0) < 0) {
            if (!WIFEXITED(status)) {
-               dbprintf(("Tool exited with signal %d", WTERMSIG(status)));
+               dbprintf(_("Tool exited with signal %d"), WTERMSIG(status));
            } else if (WEXITSTATUS(status) != 0) {
-               dbprintf(("Tool exited with status %d", WEXITSTATUS(status)));
+               dbprintf(_("Tool exited with status %d"), WEXITSTATUS(status));
            } else {
-               dbprintf(("waitpid returned negative value"));
+               dbprintf(_("waitpid returned negative value"));
            }
        }
      }
@@ -595,8 +603,8 @@ main(
        if(!interactive) {
            /* redirect stderr */
            if(dup2(mesgfd, 2) == -1) {
-               dbprintf(("%s: error redirecting stderr to fd %d: %s\n",
-                         debug_prefix_time(NULL), mesgfd, strerror(errno)));
+               dbprintf(_("Error redirecting stderr to fd %d: %s\n"),
+                        mesgfd, strerror(errno));
                dbclose();
                exit(1);
            }
@@ -604,15 +612,15 @@ main(
  
        if(pipe(mesgpipe) == -1) {
            s = strerror(errno);
-           dbprintf(("error [opening mesg pipe: %s]\n", s));
-           error("error [opening mesg pipe: %s]", s);
+           dbprintf(_("error [opening mesg pipe: %s]\n"), s);
+           error(_("error [opening mesg pipe: %s]"), s);
        }
 
        program->start_backup(g_options->hostname, disk, amdevice, level,
                              dumpdate, datafd, mesgpipe[1], indexfd);
-       dbprintf(("%s: started backup\n", debug_prefix_time(NULL)));
+       dbprintf(_("Started backup\n"));
        parse_backup_messages(mesgpipe[0]);
-       dbprintf(("%s: parsed backup messages\n", debug_prefix_time(NULL)));
+       dbprintf(_("Parsed backup messages\n"));
     }
 
     amfree(prog);
@@ -625,28 +633,17 @@ main(
     amfree(our_feature_string);
     am_release_feature_set(our_features);
     our_features = NULL;
-    am_release_feature_set(g_options->features);
-    g_options->features = NULL;
-    amfree(g_options->hostname);
-    amfree(g_options->str);
-    amfree(g_options);
+    free_g_options(g_options);
 
     dbclose();
 
-    malloc_size_2 = malloc_inuse(&malloc_hist_2);
-
-    if(malloc_size_1 != malloc_size_2) {
-       malloc_list(fileno(stderr), malloc_hist_1, malloc_hist_2);
-    }
-
     return 0;
 
  err:
-    printf("FORMAT ERROR IN REQUEST PACKET\n");
-    dbprintf(("%s: REQ packet is bogus%s%s\n",
-             debug_prefix_time(NULL),
+    g_printf(_("FORMAT ERROR IN REQUEST PACKET\n"));
+    dbprintf(_("REQ packet is bogus%s%s\n"),
              err_extra ? ": " : "",
-             err_extra ? err_extra : ""));
+             err_extra ? err_extra : "");
     dbclose();
     return 1;
 }
@@ -683,8 +680,6 @@ check_status(
     char *thiserr = NULL;
     char *str, *strX;
     int ret, sig, rc;
-    char number[NUM_STR_SIZE];
-    char numberpid[NUM_STR_SIZE];
 
     str = childstr(pid);
 
@@ -703,7 +698,7 @@ check_status(
         * but the failure is noted.
         */
        if(ret != 0) {
-           fprintf(stderr, "? index %s returned %d\n", str, ret);
+           g_fprintf(stderr, _("? index %s returned %d\n"), str, ret);
            rc = 0;
        }
        indexpid = -1;
@@ -752,18 +747,15 @@ check_status(
        return 0;                               /* normal exit */
     }
 
-    snprintf(numberpid, SIZEOF(number), "%d", (int)pid);
     if(ret == 0) {
-       snprintf(number, SIZEOF(number), "%d", sig);
-       thiserr = vstralloc(strX, "(", numberpid, ") ", str, " got signal ", number, NULL);
+       thiserr = vstrallocf(_("%s (%d) %s got signal %d"), strX, (int)pid, str,
+                            sig);
     } else {
-       snprintf(number, SIZEOF(number), "%d", ret);
-       thiserr = vstralloc(strX, "(", numberpid, ") ", str, " returned ", number, NULL);
+       thiserr = vstrallocf(_("%s (%d) %s returned %d"), strX, (int)pid, str, ret);
     }
 
     if(errorstr) {
-       strappend(errorstr, ", ");
-       strappend(errorstr, thiserr);
+       errorstr =  newvstrallocf(errorstr, "%s, %s", errorstr, thiserr);
        amfree(thiserr);
     } else {
        errorstr = thiserr;
@@ -779,11 +771,11 @@ check_status(
 void
 info_tapeheader(void)
 {
-    fprintf(stderr, "%s: info BACKUP=%s\n", get_pname(), program->backup_name);
+    g_fprintf(stderr, "%s: info BACKUP=%s\n", get_pname(), program->backup_name);
 
-    fprintf(stderr, "%s: info RECOVER_CMD=", get_pname());
+    g_fprintf(stderr, "%s: info RECOVER_CMD=", get_pname());
     if (options->compress == COMP_FAST || options->compress == COMP_BEST)
-       fprintf(stderr, "%s %s |", UNCOMPRESS_PATH,
+       g_fprintf(stderr, "%s %s |", UNCOMPRESS_PATH,
 #ifdef UNCOMPRESS_OPT
                UNCOMPRESS_OPT
 #else
@@ -791,13 +783,13 @@ info_tapeheader(void)
 #endif
                );
 
-    fprintf(stderr, "%s -xpGf - ...\n", program->restore_name);
+    g_fprintf(stderr, "%s -xpGf - ...\n", program->restore_name);
 
     if (options->compress == COMP_FAST || options->compress == COMP_BEST)
-       fprintf(stderr, "%s: info COMPRESS_SUFFIX=%s\n",
+       g_fprintf(stderr, "%s: info COMPRESS_SUFFIX=%s\n",
                        get_pname(), COMPRESS_SUFFIX);
 
-    fprintf(stderr, "%s: info end\n", get_pname());
+    g_fprintf(stderr, "%s: info end\n", get_pname());
 }
 
 void
@@ -808,26 +800,26 @@ backup_api_info_tapeheader(
 {
     char line[1024];
 
-    snprintf(line, 1024, "%s: info BACKUP=DUMPER\n", get_pname());
+    g_snprintf(line, 1024, "%s: info BACKUP=DUMPER\n", get_pname());
     if (fullwrite(mesgfd, line, strlen(line)) != (ssize_t)strlen(line)) {
-       dbprintf(("error writing to mesgfd socket: %s", strerror(errno)));
+       dbprintf(_("error writing to mesgfd socket: %s"), strerror(errno));
        return;
     }
 
-    snprintf(line, 1024, "%s: info DUMPER=%s\n", get_pname(), prog);
+    g_snprintf(line, 1024, "%s: info DUMPER=%s\n", get_pname(), prog);
     if (fullwrite(mesgfd, line, strlen(line)) != (ssize_t)strlen(line)) {
-       dbprintf(("error writing to mesgfd socket: %s", strerror(errno)));
+       dbprintf(_("error writing to mesgfd socket: %s"), strerror(errno));
        return;
     }
 
-    snprintf(line, 1024, "%s: info RECOVER_CMD=", get_pname());
+    g_snprintf(line, 1024, "%s: info RECOVER_CMD=", get_pname());
     if (fullwrite(mesgfd, line, strlen(line)) != (ssize_t)strlen(line)) {
-       dbprintf(("error writing to mesgfd socket: %s", strerror(errno)));
+       dbprintf(_("error writing to mesgfd socket: %s"), strerror(errno));
        return;
     }
 
     if (options->compress) {
-       snprintf(line, 1024, "%s %s |", UNCOMPRESS_PATH,
+       g_snprintf(line, 1024, "%s %s |", UNCOMPRESS_PATH,
 #ifdef UNCOMPRESS_OPT
                 UNCOMPRESS_OPT
 #else
@@ -835,28 +827,28 @@ backup_api_info_tapeheader(
 #endif
                 );
        if (fullwrite(mesgfd, line, strlen(line)) != (ssize_t)strlen(line)) {
-           dbprintf(("error writing to mesgfd socket: %s", strerror(errno)));
+           dbprintf(_("error writing to mesgfd socket: %s"), strerror(errno));
            return;
        }
     }
-    snprintf(line, 1024, "%s -f... -\n", prog);
+    g_snprintf(line, 1024, "%s -f... -\n", prog);
     if (fullwrite(mesgfd, line, strlen(line)) != (ssize_t)strlen(line)) {
-       dbprintf(("error writing to mesgfd socket: %s", strerror(errno)));
+       dbprintf(_("error writing to mesgfd socket: %s"), strerror(errno));
        return;
     }
 
     if (options->compress) {
-       snprintf(line, 1024, "%s: info COMPRESS_SUFFIX=%s\n",
+       g_snprintf(line, 1024, "%s: info COMPRESS_SUFFIX=%s\n",
                 get_pname(), COMPRESS_SUFFIX);
        if (fullwrite(mesgfd, line, strlen(line)) != (ssize_t)strlen(line)) {
-           dbprintf(("error writing to mesgfd socket: %s", strerror(errno)));
+           dbprintf(_("error writing to mesgfd socket: %s"), strerror(errno));
            return;
        }
     }
 
-    snprintf(line, 1024, "%s: info end\n", get_pname());
+    g_snprintf(line, 1024, "%s: info end\n", get_pname());
     if (fullwrite(mesgfd, line, strlen(line)) != (ssize_t)strlen(line)) {
-       dbprintf(("error writing to mesgfd socket: %s", strerror(errno)));
+       dbprintf(_("error writing to mesgfd socket: %s"), strerror(errno));
        return;
     }
 }
@@ -872,17 +864,16 @@ pipefork(
     int inpipe[2];
     pid_t pid;
 
-    dbprintf(("%s: forking function %s in pipeline\n",
-       debug_prefix_time(NULL), fname));
+    dbprintf(_("Forking function %s in pipeline\n"), fname);
 
     if(pipe(inpipe) == -1) {
-       error("error [open pipe to %s: %s]", fname, strerror(errno));
+       error(_("error [open pipe to %s: %s]"), fname, strerror(errno));
        /*NOTREACHED*/
     }
 
     switch(pid = fork()) {
     case -1:
-       error("error [fork %s: %s]", fname, strerror(errno));
+       error(_("error [fork %s: %s]"), fname, strerror(errno));
        /*NOTREACHED*/
     default:   /* parent process */
        aclose(inpipe[0]);      /* close input side of pipe */
@@ -892,17 +883,17 @@ pipefork(
        aclose(inpipe[1]);      /* close output side of pipe */
 
        if(dup2(inpipe[0], 0) == -1) {
-           error("error [fork %s: dup2(%d, in): %s]",
+           error(_("error [fork %s: dup2(%d, in): %s]"),
                  fname, inpipe[0], strerror(errno));
            /*NOTRACHED*/
        }
        if(dup2(stdoutfd, 1) == -1) {
-           error("error [fork %s: dup2(%d, out): %s]",
+           error(_("error [fork %s: dup2(%d, out): %s]"),
                  fname, stdoutfd, strerror(errno));
            /*NOTRACHED*/
        }
        if(dup2(stderrfd, 2) == -1) {
-           error("error [fork %s: dup2(%d, err): %s]",
+           error(_("error [fork %s: dup2(%d, err): %s]"),
                  fname, stderrfd, strerror(errno));
            /*NOTRACHED*/
        }
@@ -931,7 +922,7 @@ parse_backup_messages(
     }
 
     if(errno) {
-       error("error [read mesg pipe: %s]", strerror(errno));
+       error(_("error [read mesg pipe: %s]"), strerror(errno));
        /*NOTREACHED*/
     }
 
@@ -946,13 +937,13 @@ parse_backup_messages(
        }
     }
     if (dumppid != -1) {
-       dbprintf(("%s: Sending SIGHUP to dump process %d\n",
-                 debug_prefix_time(NULL), (int)dumppid));
+       dbprintf(_("Sending SIGHUP to dump process %d\n"),
+                 (int)dumppid);
        if(dumppid != -1) {
            if(kill(dumppid, SIGHUP) == -1) {
-               dbprintf(("%s: Can't send SIGHUP to %d: %s\n",
-                         debug_prefix_time(NULL), (int)dumppid,
-                         strerror(errno)));
+               dbprintf(_("Can't send SIGHUP to %d: %s\n"),
+                         (int)dumppid,
+                         strerror(errno));
            }
        }
        sleep(5);
@@ -961,13 +952,13 @@ parse_backup_messages(
        }
     }
     if (dumppid != -1) {
-       dbprintf(("%s: Sending SIGKILL to dump process %d\n",
-                 debug_prefix_time(NULL), (int)dumppid));
+       dbprintf(_("Sending SIGKILL to dump process %d\n"),
+                 (int)dumppid);
        if(dumppid != -1) {
            if(kill(dumppid, SIGKILL) == -1) {
-               dbprintf(("%s: Can't send SIGKILL to %d: %s\n",
-                         debug_prefix_time(NULL), (int)dumppid,
-                         strerror(errno)));
+               dbprintf(_("Can't send SIGKILL to %d: %s\n"),
+                         (int)dumppid,
+                         strerror(errno));
            }
        }
        sleep(5);
@@ -977,17 +968,17 @@ parse_backup_messages(
     }
 
     if(errorstr) {
-       error("error [%s]", errorstr);
+       error(_("error [%s]"), errorstr);
        /*NOTREACHED*/
     } else if(dump_size == -1) {
-       error("error [no backup size line]");
+       error(_("error [no backup size line]"));
        /*NOTREACHED*/
     }
 
     program->end_backup(goterror);
 
-    fprintf(stderr, "%s: size %ld\n", get_pname(), dump_size);
-    fprintf(stderr, "%s: end\n", get_pname());
+    g_fprintf(stderr, _("%s: size %ld\n"), get_pname(), dump_size);
+    g_fprintf(stderr, _("%s: end\n"), get_pname());
 }
 
 
@@ -1061,13 +1052,12 @@ process_dumpline(
        startchr = '!';
        break;
     }
-    dbprintf(("%s: %3d: %7s(%c): %s\n",
-             debug_prefix_time(NULL),
+    dbprintf("%3d: %7s(%c): %s\n",
              rp->srcline,
              type,
              startchr,
-             str));
-    fprintf(stderr, "%c %s\n", startchr, str);
+             str);
+    g_fprintf(stderr, "%c %s\n", startchr, str);
 }
 
 
@@ -1101,13 +1091,11 @@ save_fd(
   while (*fd >= 0 && *fd < min) {
     int newfd = dup(*fd);
     if (newfd == -1)
-      dbprintf(("%s: unable to save file descriptor [%s]\n",
-       debug_prefix_time(NULL), strerror(errno)));
+      dbprintf(_("Unable to save file descriptor [%s]\n"), strerror(errno));
     *fd = newfd;
   }
   if (origfd != *fd)
-    dbprintf(("%s: dupped file descriptor %i to %i\n",
-      debug_prefix_time(NULL), origfd, *fd));
+    dbprintf(_("Dupped file descriptor %i to %i\n"), origfd, *fd);
 }
 
 void
@@ -1126,19 +1114,19 @@ start_index(
     return;
 
   if (pipe(pipefd) != 0) {
-    error("creating index pipe: %s", strerror(errno));
+    error(_("creating index pipe: %s"), strerror(errno));
     /*NOTREACHED*/
   }
 
   switch(indexpid = fork()) {
   case -1:
-    error("forking index tee process: %s", strerror(errno));
+    error(_("forking index tee process: %s"), strerror(errno));
     /*NOTREACHED*/
 
   default:
     aclose(pipefd[0]);
     if (dup2(pipefd[1], input) == -1) {
-      error("dup'ping index tee output: %s", strerror(errno));
+      error(_("dup'ping index tee output: %s"), strerror(errno));
       /*NOTREACHED*/
     }
     aclose(pipefd[1]);
@@ -1157,19 +1145,18 @@ start_index(
   dup2(index, 1);
   dup2(mesg, 2);
   dup2(input, 3);
-  for(index = 4; index < FD_SETSIZE; index++) {
+  for(index = 4; index < (int)FD_SETSIZE; index++) {
     if (index != dbfd()) {
       close(index);
     }
   }
 
   if ((pipe_fp = popen(cmd, "w")) == NULL) {
-    error("couldn't start index creator [%s]", strerror(errno));
+    error(_("couldn't start index creator [%s]"), strerror(errno));
     /*NOTREACHED*/
   }
 
-  dbprintf(("%s: started index creator: \"%s\"\n",
-    debug_prefix_time(NULL), cmd));
+  dbprintf(_("Started index creator: \"%s\"\n"), cmd);
   while(1) {
     char buffer[BUFSIZ], *ptr;
     ssize_t bytes_read;
@@ -1181,7 +1168,7 @@ start_index(
     } while ((bytes_read < 0) && ((errno == EINTR) || (errno == EAGAIN)));
 
     if (bytes_read < 0) {
-      error("index tee cannot read [%s]", strerror(errno));
+      error(_("index tee cannot read [%s]"), strerror(errno));
       /*NOTREACHED*/
     }
 
@@ -1197,8 +1184,8 @@ start_index(
         * just as we waited for write() to complete.
         */
        if (errno != EPIPE) {
-           dbprintf(("%s: index tee cannot write to index creator [%s]\n",
-                           debug_prefix_time(NULL), strerror(errno)));
+           dbprintf(_("Index tee cannot write to index creator [%s]\n"),
+                           strerror(errno));
        }
     } else {
        bytes_written += just_written;
@@ -1211,7 +1198,7 @@ start_index(
     bytes_written = 0;
     just_written = fullwrite(3, ptr, (size_t)bytes_read);
     if (just_written < 0) {
-       error("index tee cannot write [%s]", strerror(errno));
+       error(_("index tee cannot write [%s]"), strerror(errno));
        /*NOTREACHED*/
     } else {
        bytes_written += just_written;
@@ -1224,10 +1211,11 @@ start_index(
   /* finished */
   /* check the exit code of the pipe and moan if not 0 */
   if ((exitcode = pclose(pipe_fp)) != 0) {
-    dbprintf(("%s: index pipe returned %d\n",
-      debug_prefix_time(NULL), exitcode));
+    char *exitstr = str_exit_status("Index pipe", exitcode);
+    dbprintf("%s\n", exitstr);
+    amfree(exitstr);
   } else {
-    dbprintf(("%s: index created successfully\n", debug_prefix_time(NULL)));
+    dbprintf(_("Index created successfully\n"));
   }
   pipe_fp = NULL;