X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=recover-src%2Fdisplay_commands.c;h=423cfb7e538bd492727c5865766787c04fed5ffb;hb=HEAD;hp=90e181674afc385ea96f3629be90ed1b72b12927;hpb=12179dea039515c06168c0037d048566a3f623de;p=debian%2Famanda diff --git a/recover-src/display_commands.c b/recover-src/display_commands.c index 90e1816..423cfb7 100644 --- a/recover-src/display_commands.c +++ b/recover-src/display_commands.c @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver * Copyright (c) 1991-1998 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -33,6 +34,8 @@ #include "amrecover.h" #include "util.h" +gboolean translate_mode = TRUE; + DIR_ITEM *get_dir_list(void); DIR_ITEM *get_next_dir_item(DIR_ITEM *this); @@ -83,6 +86,7 @@ free_dir_item( amfree(item->date); amfree(item->tape); amfree(item->path); + amfree(item->tpath); amfree(item); item = next; } @@ -99,9 +103,8 @@ add_dir_list_item( { DIR_ITEM *next; - dbprintf(("add_dir_list_item: Adding \"%s\" \"%d\" \"%s\" \"" - OFF_T_FMT "\" \"%s\"\n", - date, level, tape, (OFF_T_FMT_TYPE)fileno, path)); + dbprintf(_("add_dir_list_item: Adding \"%s\" \"%d\" \"%s\" \"%lld\" \"%s\"\n"), + date, level, tape, (long long)fileno, path); next = (DIR_ITEM *)alloc(sizeof(DIR_ITEM)); memset(next, 0, sizeof(DIR_ITEM)); @@ -111,6 +114,7 @@ add_dir_list_item( next->tape = stralloc(tape); next->fileno = fileno; next->path = stralloc(path); + next->tpath = translate_octal(g_strdup(path)); next->next = dir_list; dir_list = next; @@ -143,9 +147,10 @@ suck_dir_list_from_server(void) char *disk_path_slash_dot = NULL; char *s; int ch; + char *qdisk_path; if (disk_path == NULL) { - printf("Directory must be set before getting listing\n"); + g_printf(_("Directory must be set before getting listing\n")); return; } else if(strcmp(disk_path, "/") == 0) { disk_path_slash = stralloc(disk_path); @@ -155,7 +160,9 @@ suck_dir_list_from_server(void) clear_dir_list(); - cmd = stralloc2("OLSD ", disk_path); + qdisk_path = quote_string(disk_path); + cmd = stralloc2("OLSD ", qdisk_path); + amfree(qdisk_path); if (send_command(cmd) == -1) { amfree(cmd); amfree(disk_path_slash); @@ -171,7 +178,7 @@ suck_dir_list_from_server(void) { amfree(disk_path_slash); l = reply_line(); - printf("%s\n", l); + g_printf("%s\n", l); return; } disk_path_slash_dot = stralloc2(disk_path_slash, "."); @@ -197,20 +204,18 @@ suck_dir_list_from_server(void) l = reply_line(); if (!server_happy()) { - printf("%s\n", l); + g_printf("%s\n", l); continue; } -#define sc "201-" - if (strncmp(l, sc, sizeof(sc)-1) != 0) { - err = "bad reply: not 201-"; + s = l; + if (strncmp_const_skip(l, "201-", s, ch) != 0) { + err = _("bad reply: not 201-"); continue; } - s = l + sizeof(sc)-1; ch = *s++; -#undef sc skip_whitespace(s, ch); if(ch == '\0') { - err = "bad reply: missing date field"; + err = _("bad reply: missing date field"); continue; } date = s - 1; @@ -219,29 +224,31 @@ suck_dir_list_from_server(void) 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; - skip_non_whitespace(s, ch); + skip_quoted_string(s, ch); tape_undo = s - 1; tape_undo_ch = *tape_undo; *tape_undo = '\0'; + tape = unquote_string(tape); if(am_has_feature(indexsrv_features, fe_amindexd_fileno_in_OLSD)) { + long long fileno_ = (long long)0; skip_whitespace(s, ch); - if(ch == '\0' || sscanf(s - 1, OFF_T_FMT, - (OFF_T_FMT_TYPE *)&fileno) != 1) { - err = "bad reply: cannot parse fileno field"; + if(ch == '\0' || sscanf(s - 1, "%lld", &fileno_) != 1) { + err = _("bad reply: cannot parse fileno field"); continue; } + fileno = (off_t)fileno_; skip_integer(s, ch); } else { @@ -250,7 +257,7 @@ suck_dir_list_from_server(void) skip_whitespace(s, ch); if(ch == '\0') { - err = "bad reply: missing directory field"; + err = _("bad reply: missing directory field"); continue; } qdir = s - 1; @@ -262,6 +269,7 @@ suck_dir_list_from_server(void) dir = stralloc(disk_path_slash_dot); } add_dir_list_item(date, level, tape, fileno, dir); + amfree(tape); amfree(dir); } amfree(disk_path_slash_dot); @@ -291,7 +299,7 @@ list_directory(void) char *quoted; if (disk_path == NULL) { - printf("Must select a disk before listing files; use the setdisk command.\n"); + g_printf(_("Must select a disk before listing files; use the setdisk command.\n")); return; } @@ -306,16 +314,16 @@ list_directory(void) 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); - i = strlen(disk_path); + i = strlen(disk_tpath); if (i != 1) - i++; /* so disk_path != "/" */ + i++; /* so disk_tpath != "/" */ for (item = get_dir_list(); item != NULL; item=get_next_dir_item(item)) { - quoted = quote_string(item->path + i); - fprintf(fp, "%s %s\n", item->date, quoted); + quoted = quote_string(item->tpath + i); + g_fprintf(fp, "%s %s\n", item->date, quoted); amfree(quoted); } apclose(fp);