feat: CLI-only version (without GTK)

Modify the build system and the source
files to support building a CLI-only
version with only glib2 as a dependency.
Use CLI_ONLY=1 ./configure, then make clean all.
This commit is contained in:
Stéphane Lesimple
2020-08-18 18:26:24 +02:00
parent 4f480905dc
commit 99b27b982a
59 changed files with 9419 additions and 7349 deletions

View File

@@ -39,9 +39,9 @@ INTL_LIBS = $(CFG_INTL_LIBS)
CAM_LFLAGS = $(CFG_CAM_LFLAGS)
CAM_LIBS = $(CFG_CAM_LIBS)
GTK_CFLAGS = $(CFG_GTK2_CFLAGS)
GTK_LIBS = $(CFG_GTK2_LIBS)
GTK_BINDIR = $(CFG_GTK2_BINDIR)
GTK_CFLAGS = $(CFG_GTK2_CFLAGS) $(CFG_GLIB2_CFLAGS)
GTK_LIBS = $(CFG_GTK2_LIBS) $(CFG_GLIB2_LIBS)
GTK_BINDIR = $(CFG_GTK2_BINDIR) $(CFG_GLIB2_BINDIR)
EFENCE_LFLAGS = $(CFG_EFENCE_LFLAGS)
EFENCE_LIBS = $(CFG_EFENCE_LIBS)
@@ -80,7 +80,7 @@ all: time-stamp dvdisaster
time-stamp:
@$(SRCDIR)/scripts/time-stamper.bash $(SRCDIR)/build.h
dvdisaster: inlined-icons.h $(OFILES)
dvdisaster: $(ICONS) $(OFILES)
@echo "Linking : dvdisaster"
@$(CC) $(LOPTS) $(OFILES) $(LIBS) -o dvdisaster
@if test -e locale/de/LC_MESSAGES/dvdisaster.mo \

View File

@@ -4,7 +4,9 @@
all:
@echo
@echo "Please run \`bash configure' first."
@echo "Please run \`./configure' first."
@echo "To build a CLI-only version,"
@echo "run \`CLI_ONLY=1 ./configure' instead."
@echo "Note that dvdisaster requires GNU make to build."
@echo "Under non-Linux systems, it might be known as \`gmake'."
@echo

View File

@@ -89,6 +89,7 @@ find_dotfile:
* Update color string for the <span color="#f00baa">...</span> string
*/
#ifndef CLI
void UpdateMarkup(char **string, GdkColor *color)
{ int hexval;
@@ -173,6 +174,7 @@ static void get_color(GdkColor *color, char *value)
color->green = hex&0xff00;
color->blue = (hex<<8)&0xff00;
}
#endif
/***
*** Save and restore user settings to/from the .dvdisaster file
@@ -196,7 +198,8 @@ void ReadDotfile()
/* Get first MAX_LINE_LEN bytes of line, discard the rest */
line[MAX_LINE_LEN-1] = 1;
fgets(line, MAX_LINE_LEN, dotfile);
if (fgets(line, MAX_LINE_LEN, dotfile) == NULL)
break;
if(!line[MAX_LINE_LEN-1]) /* line longer than buffer */
while(!feof(dotfile) && fgetc(dotfile) != '\n')
;
@@ -288,6 +291,7 @@ void ReadDotfile()
if(!strcmp(symbol, "verbose")) { Closure->verbose = atoi(value); continue; }
if(!strcmp(symbol, "welcome-msg")) { Closure->welcomeMessage = atoi(value); continue; }
#ifndef CLI
if(!strcmp(symbol, "positive-text")) { get_color(Closure->greenText, value);
UpdateMarkup(&Closure->greenMarkup, Closure->greenText);
continue;
@@ -305,6 +309,7 @@ void ReadDotfile()
if(!strcmp(symbol, "ignored-sector")) { get_color(Closure->blueSector, value); continue; }
if(!strcmp(symbol, "highlit-sector")) { get_color(Closure->whiteSector, value); continue; }
if(!strcmp(symbol, "present-sector")) { get_color(Closure->darkSector, value); continue; }
#endif
}
if(fclose(dotfile))
@@ -391,6 +396,7 @@ static void update_dotfile()
g_fprintf(dotfile, "verbose: %d\n", Closure->verbose);
g_fprintf(dotfile, "welcome-msg: %d\n\n", Closure->welcomeMessage);
#ifndef CLI
save_colors(dotfile, "positive-text", Closure->greenText);
save_colors(dotfile, "negative-text", Closure->redText);
save_colors(dotfile, "bar-color", Closure->barColor);
@@ -402,6 +408,7 @@ static void update_dotfile()
save_colors(dotfile, "ignored-sector", Closure->blueSector);
save_colors(dotfile, "highlit-sector", Closure->whiteSector);
save_colors(dotfile, "present-sector", Closure->darkSector);
#endif
if(fclose(dotfile))
g_printf("Error closing configuration file %s: %s\n",
@@ -502,6 +509,7 @@ void InitClosure()
Closure->bdSize2 = Closure->savedBDSize2 = BD_DL_SIZE;
Closure->bdSize3 = Closure->savedBDSize3 = BDXL_TL_SIZE;
#ifndef CLI
Closure->logString = g_string_sized_new(1024);
Closure->logLock = g_malloc0(sizeof(GMutex));
g_mutex_init(Closure->logLock);
@@ -523,6 +531,7 @@ void InitClosure()
Closure->darkSector = g_malloc0(sizeof(GdkColor));
DefaultColors();
#endif
memset(Closure->bs, '\b', 255);
memset(Closure->sp, ' ', 255);
@@ -567,7 +576,10 @@ void cond_free_ptr_array(GPtrArray *a)
void FreeClosure()
{
#ifndef CLI
if(Closure->guiMode)
#endif
/* in CLI-only mode, always update dotfile */
update_dotfile();
cond_free(Closure->cookedVersion);
@@ -594,6 +606,7 @@ void FreeClosure()
cond_free(Closure->dDumpDir);
cond_free(Closure->dDumpPrefix);
#ifndef CLI
if(Closure->prefsContext)
FreePreferences(Closure->prefsContext);
@@ -644,6 +657,7 @@ void FreeClosure()
if(Closure->readAdaptiveErrorMsg)
g_free(Closure->readAdaptiveErrorMsg);
#endif
g_free(Closure);
}

26
configure vendored
View File

@@ -4,9 +4,13 @@
BASH_BASED_CONFIGURE=./scripts/bash-based-configure
REQUIRED_CFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -I."
RECOMMENDED_CFLAGS="-O2 -fomit-frame-pointer -Wall"
RECOMMENDED_CFLAGS="-O2 -fomit-frame-pointer -Wall -Werror -Wno-deprecated-declarations -Wno-stringop-truncation"
DEBUG_CFLAGS="-ggdb -Wall"
if [ "$CLI_ONLY" = 1 ]; then
REQUIRED_CFLAGS="-DCLI $REQUIRED_CFLAGS"
fi
CFG_USE_CYGWIN="no" # do not change
if test -e $BASH_BASED_CONFIGURE; then
@@ -48,7 +52,9 @@ GET_BUILDTMP
PRINT_MESSAGE "\nLooking for includes and libraries:"
REQUIRE_GLIB2 2 32 0
REQUIRE_GTK2 2 6 0 WITH_THREADS
if [ "$CLI_ONLY" != 1 ]; then
REQUIRE_GTK2 2 6 0 WITH_THREADS
fi
echo
if ! CHECK_INCLUDE locale.h locale || ! CHECK_INCLUDE libintl.h intl ; then
@@ -110,10 +116,12 @@ if ! EXECUTE_PROGRAM "xgettext --help" xgettext \
cfg_force_with_nls=no
fi
if ! EXECUTE_PROGRAM "gdk-pixbuf-csource --help" gdk_pixbuf_csource ; then
echo "* gdk-pixbuf not installed"
echo "* or path to gdk-pixbuf-csource is missing."
exit 1
if [ "$CLI_ONLY" != 1 ]; then
if ! EXECUTE_PROGRAM "gdk-pixbuf-csource --help" gdk_pixbuf_csource ; then
echo "* gdk-pixbuf not installed"
echo "* or path to gdk-pixbuf-csource is missing."
exit 1
fi
fi
# Evaluate the --with* customization options
@@ -151,6 +159,9 @@ cfiles="method-link.c"
ofiles="$BUILDTMP/method-link.o"
for cfile in *.c; do
if [ "$CLI_ONLY" = 1 ]; then
grep -q 'DVDISASTER_GUI_FILE' "$cfile" && continue
fi
cfile_prefix=`echo $cfile | sed -e 's/\.c//'`
cfiles="$cfiles $cfile"
ofiles="$ofiles $BUILDTMP/$cfile_prefix.o"
@@ -160,6 +171,9 @@ done
echo
echo -e "\nCFG_CFILES = $cfiles" >> Makefile.config
echo "CFG_OFILES = $ofiles" >> Makefile.config
if [ "$CLI_ONLY" != 1 ]; then
echo "ICONS = inlined-icons.h" >> Makefile.config
fi
# Create the method wrapper

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -260,15 +260,20 @@ int CheckForMissingSectors(unsigned char *buf, guint64 sector,
*** Dialogue for indicating problem with the missing sector
***/
#ifndef CLI
static void insert_buttons(GtkDialog *dialog)
{
gtk_dialog_add_buttons(dialog,
_utf("Stop reporting these errors"), 1,
_utf("Continue reporting"), 0, NULL);
}
#endif
void ExplainMissingSector(unsigned char *buf, guint64 sector, int error, int source_type, int *number)
{ int answer;
{
#ifndef CLI
int answer;
#endif
guint64 recorded_number;
char *vol_label, *label_msg;
@@ -288,7 +293,11 @@ void ExplainMissingSector(unsigned char *buf, guint64 sector, int error, int sou
/* In CLI mode, only report the first unrecoverable sector unless verbose is given. */
#ifndef CLI
if(!Closure->guiMode && !Closure->verbose && *number > 0)
#else
if(!Closure->verbose && *number > 0)
#endif
{ if(*number == 1)
PrintLog(_("* ... more unrecoverable sectors found ...\n"
"* further messages are suppressed unless the -v option is given.\n"));
@@ -303,9 +312,13 @@ void ExplainMissingSector(unsigned char *buf, guint64 sector, int error, int sou
vol_label = get_volume_label(buf);
if(vol_label)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
label_msg = g_strdup_printf(_("\n\nThe label of the original (defective) medium was:\n%s\n\n"), vol_label);
else label_msg = g_strdup_printf(_("\n* \n* The label of the original (defective) medium was:\n* \n* %s\n* "), vol_label);
else
#endif
label_msg = g_strdup_printf(_("\n* \n* The label of the original (defective) medium was:\n* \n* %s\n* "), vol_label);
g_free(vol_label);
}
else label_msg = g_strdup("\n");
@@ -326,14 +339,18 @@ void ExplainMissingSector(unsigned char *buf, guint64 sector, int error, int sou
"repaired by dvdisaster. Also it will not be possible to create\n"
"error correction data for it. Sorry for the bad news.\n");
#ifndef CLI
if(!Closure->guiMode)
#endif
PrintLogWithAsterisks(msg,sector, recorded_number, label_msg);
#ifndef CLI
else
{ answer = ModalDialog(GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, insert_buttons, msg,
sector, recorded_number, label_msg);
if(answer) Closure->noMissingWarnings = TRUE;
}
#endif
}
break;
@@ -349,13 +366,17 @@ void ExplainMissingSector(unsigned char *buf, guint64 sector, int error, int sou
"repaired by dvdisaster. Also it will not be possible to create\n"
"error correction data for it. Sorry for the bad news.\n");
#ifndef CLI
if(!Closure->guiMode)
#endif
PrintLogWithAsterisks(msg,sector, label_msg);
#ifndef CLI
else
{ answer = ModalDialog(GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, insert_buttons, msg,
sector, label_msg);
if(answer) Closure->noMissingWarnings = TRUE;
}
#endif
}
break;
}
@@ -374,14 +395,18 @@ void ExplainMissingSector(unsigned char *buf, guint64 sector, int error, int sou
"repaired by dvdisaster. Also it will not be possible to create\n"
"error correction data for it. Sorry for the bad news.\n");
#ifndef CLI
if(!Closure->guiMode)
#endif
PrintLogWithAsterisks(msg, sector);
#ifndef CLI
else
{ answer = ModalDialog(GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, insert_buttons, msg,
sector);
if(answer) Closure->noMissingWarnings = TRUE;
}
#endif
}
/* Error was found while reading an ecc file */
@@ -394,14 +419,18 @@ void ExplainMissingSector(unsigned char *buf, guint64 sector, int error, int sou
"in the ecc file are missing and its error correction\n"
"capacity will be reduced.\n");
#ifndef CLI
if(!Closure->guiMode)
#endif
PrintLogWithAsterisks(msg, sector);
#ifndef CLI
else
{ answer = ModalDialog(GTK_MESSAGE_ERROR, GTK_BUTTONS_NONE, insert_buttons, msg,
sector);
if(answer) Closure->noMissingWarnings = TRUE;
}
#endif
}
g_free(label_msg);

View File

@@ -96,7 +96,9 @@ typedef enum
int main(int argc, char *argv[])
{ int mode = MODE_NONE;
int sequence = MODE_NONE;
#ifndef CLI
int devices_queried = FALSE;
#endif
char *debug_arg = NULL;
char *read_range = NULL;
#ifdef WITH_NLS_YES
@@ -724,7 +726,9 @@ int main(int argc, char *argv[])
if(!Closure->device && mode == MODE_SEQUENCE
&& (sequence & (1<<MODE_READ | 1<<MODE_SCAN)))
{ Closure->device = DefaultDevice();
#ifndef CLI
devices_queried = TRUE;
#endif
}
/*** Dispatch action depending on mode.
@@ -879,7 +883,11 @@ int main(int argc, char *argv[])
/*** If no mode was selected, print the help screen. */
#ifndef CLI
if(mode == MODE_HELP)
#else
if(mode == MODE_HELP || mode == MODE_NONE)
#endif
{
/* TRANSLATORS: Program options like -r and --read are not to be translated
to avoid confusion when discussing the program in international forums. */
@@ -971,6 +979,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
#ifndef CLI
/* If no mode was selected at the command line,
start the graphical user interface. */
@@ -1001,6 +1010,7 @@ int main(int argc, char *argv[])
ReadDotfile();
CreateMainWindow(&argc, &argv);
}
#endif
FreeClosure();
exit(exitCode);

View File

@@ -40,7 +40,9 @@
#include <glib.h>
#include <glib/gprintf.h>
#ifndef CLI
#include <gtk/gtk.h>
#endif
#include <ctype.h>
#include <errno.h>
@@ -83,6 +85,12 @@
#define round(x) rint(x)
#endif
#ifdef CLI
#define STATUS_LABEL_OR_NULL NULL
#else
#define STATUS_LABEL_OR_NULL Closure->status
#endif
/* Some standard media sizes */
/* WARNING: These values affect RS03 in non-obvious ways.
@@ -244,12 +252,15 @@ typedef struct _GlobalClosure
struct _CrcBuf *crcBuf; /* crcBuf of last image read */
#ifndef CLI
/*** GUI-related things */
int guiMode; /* TRUE if GUI is active */
int stopActions; /* crude method to stop ongoing action(s) */
#endif
int noMissingWarnings; /* suppress warnings about inconsistent missing sectors */
#ifndef CLI
GtkWidget *logWidget; /* Dialog for the log display */
GtkScrolledWindow *logScroll; /* and its scrolled window */
GtkTextBuffer *logBuffer; /* Text buffer for the log output */
@@ -330,7 +341,9 @@ typedef struct _GlobalClosure
GtkWidget *readLinearErrors;
GtkWidget *readLinearFootline;
GtkWidget *readLinearFootlineBox;
#endif
gint64 crcErrors, readErrors; /* these are passed between threads and must therefore be global */
#ifndef CLI
/*** Widgets for the adaptive reading action */
@@ -340,6 +353,7 @@ typedef struct _GlobalClosure
char *readAdaptiveSubtitle;
char *readAdaptiveErrorMsg;
int additionalSpiralColor;
#endif
} GlobalClosure;
@@ -477,8 +491,10 @@ int ProbeCacheLineSize();
void InitClosure(void);
void LocalizedFileDefaults(void);
#ifndef CLI
void UpdateMarkup(char**, GdkColor*);
void DefaultColors(void);
#endif
void FreeClosure(void);
void ReadDotfile(void);
void WriteSignature(void);
@@ -550,6 +566,7 @@ int CrcBufValid(CrcBuf*, struct _Image*, EccHeader*);
void PrintCrcBuf(CrcBuf*);
#ifndef CLI
/***
*** curve.c
***/
@@ -593,6 +610,7 @@ int CurveY(Curve*, gdouble);
int CurveLogY(Curve*, gdouble);
void RedrawAxes(Curve*);
void RedrawCurve(Curve*, int);
#endif
/***
*** debug.c
@@ -659,7 +677,9 @@ void PrintEccHeader(EccHeader*);
*** fix-window.c
***/
#ifndef CLI
void CreateFixWindow(GtkWidget*);
#endif
/***
*** galois.c
@@ -717,6 +737,7 @@ void FreeGaloisTables(GaloisTables*);
ReedSolomonTables *CreateReedSolomonTables(GaloisTables*, gint32, gint32, int);
void FreeReedSolomonTables(ReedSolomonTables*);
#ifndef CLI
/***
*** help-dialogs.c
***/
@@ -757,6 +778,7 @@ void AboutDialog();
void AboutText(GtkWidget*, char*, ...);
void AboutLink(GtkWidget*, char*, char*);
void AboutTextWithLink(GtkWidget*, char*, char*);
#endif
/***
*** heuristic-lec.c
@@ -993,6 +1015,7 @@ int forget(void*);
void check_memleaks(void);
#ifndef CLI
/***
*** menubar.c
***/
@@ -1000,6 +1023,7 @@ void check_memleaks(void);
void AttachTooltip(GtkWidget*, char*, char*);
GtkWidget* CreateMenuBar(GtkWidget*);
GtkWidget* CreateToolBar(GtkWidget*);
#endif
/***
*** method.c / method-link.c
@@ -1012,7 +1036,7 @@ GtkWidget* CreateToolBar(GtkWidget*);
#define ECC_MD5_BAD (1<<2)
typedef struct _Method
{ char name[4]; /* Method name tag */
{ char name[5]; /* Method name tag */
guint32 properties; /* see definition above */
char *description; /* Fulltext description */
char *menuEntry; /* Text for use in preferences menu */
@@ -1027,6 +1051,7 @@ typedef struct _Method
void (*updateCksums)(Image*, gint64, unsigned char*);/* checksum while reading an image */
int (*finalizeCksums)(Image*);
void *ckSumClosure; /* working closure for above */
#ifndef CLI
void (*createVerifyWindow)(struct _Method*, GtkWidget*);
void (*createCreateWindow)(struct _Method*, GtkWidget*);
void (*createFixWindow)(struct _Method*, GtkWidget*);
@@ -1036,9 +1061,12 @@ typedef struct _Method
void (*resetFixWindow)(struct _Method*);
void (*resetPrefsPage)(struct _Method*);
void (*readPreferences)(struct _Method*);
#endif
void (*destroy)(struct _Method*);
#ifndef CLI
int tabWindowIndex; /* our position in the (invisible) notebook */
void *widgetList; /* linkage to window system */
#endif
} Method;
void BindMethods(void); /* created by configure in method-link.c */
@@ -1068,7 +1096,11 @@ void Verbose(char*, ...);
void PrintTimeToLog(GTimer*, char*, ...);
void PrintProgress(char*, ...);
void ClearProgress(void);
#ifndef CLI
void PrintCLIorLabel(GtkLabel*, char*, ...);
#else
void PrintCLIorLabel(void*, char*, ...);
#endif
int GetLongestTranslation(char*, ...);
void LogWarning(char*, ...);
@@ -1078,6 +1110,7 @@ void UnregisterCleanup(void);
GThread* CreateGThread(GThreadFunc, gpointer);
#ifndef CLI
void ShowWidget(GtkWidget*);
void AllowActions(gboolean);
@@ -1088,7 +1121,13 @@ void SetProgress(GtkWidget*, int, int);
int ModalDialog(GtkMessageType, GtkButtonsType, void (*)(GtkDialog*), char*, ...);
int ModalWarning(GtkMessageType, GtkButtonsType, void (*)(GtkDialog*), char*, ...);
#define ModalWarningOrCLI(a,b,c,d,...) ModalWarning(a,b,c,d,__VA_ARGS__)
#else
int ModalWarning(char*, ...);
#define ModalWarningOrCLI(a,b,c,d,...) ModalWarning(d,__VA_ARGS__)
#endif
#ifndef CLI
void SetText(PangoLayout*, char*, int*, int*);
void SwitchAndSetFootline(GtkWidget*, int, GtkWidget*, char*, ...);
@@ -1097,10 +1136,12 @@ void TimedInsensitive(GtkWidget*, int);
int GetLabelWidth(GtkLabel*, char*, ...);
void LockLabelSize(GtkLabel*, char*, ...);
#endif
int ConfirmImageDeletion(char *);
int ConfirmEccDeletion(char *);
#ifndef CLI
/***
*** preferences.c
***/
@@ -1113,6 +1154,7 @@ void FreePreferences(void*);
void UpdatePrefsExhaustiveSearch(void);
void UpdatePrefsConfirmDeletion(void);
void RegisterPreferencesHelpWindow(LabelWithOnlineHelp*);
#endif
/***
*** print-sense.c
@@ -1125,7 +1167,7 @@ void GetLastSense(int*, int*, int*);
/***
*** random.c
***/
**/
#define MY_RAND_MAX 2147483647
@@ -1169,6 +1211,7 @@ void ReadDefectiveSectorFile(DefectiveSectorHeader *, struct _RawBuffer*, char*)
void ReadMediumLinear(gpointer);
#ifndef CLI
/***
*** read-linear-window.c
***/
@@ -1180,6 +1223,7 @@ void InitializeCurve(void*, int, int);
void AddCurveValues(void*, int, int, int);
void MarkExistingSectors(void);
void RedrawReadLinearWindow(void);
#endif
/***
*** read-adaptive.c
@@ -1189,6 +1233,7 @@ void GetReadingRange(gint64, gint64*, gint64*);
void ReadMediumAdaptive(gpointer);
#ifndef CLI
/***
*** read-adaptive-window.c
***/
@@ -1205,6 +1250,7 @@ void SetAdaptiveReadFootline(char*, GdkColor*);
void UpdateAdaptiveResults(gint64, gint64, gint64, int);
void ChangeSegmentColor(GdkColor*, int);
void RemoveFillMarkers();
#endif
/***
*** recover-raw.c
@@ -1362,6 +1408,7 @@ void *PrepareIterativeSmartLEC(RawBuffer*);
void SmartLECIteration(void*, char*);
void EndIterativeSmartLEC(void*);
#ifndef CLI
/***
*** spiral.c
***/
@@ -1397,5 +1444,6 @@ void MoveSpiralCursor(Spiral*, int);
***/
void CreateWelcomePage(GtkNotebook*);
#endif
#endif /* DVDISASTER_H */

View File

@@ -37,7 +37,7 @@ void register_rs01(void)
/*** Standard infomation and methods */
strncpy(method->name, "RS01", 4);
strncpy(method->name, "RS01", 5);
method->menuEntry = g_strdup(_("Error correction file (RS01)"));
method->description = g_strdup(_("Classic Reed-Solomon method based on polynomial arithmetic"));
method->create = RS01Create;
@@ -53,6 +53,7 @@ void register_rs01(void)
method->finalizeCksums = RS01FinalizeCksums;
method->expectedImageSize = RS01ExpectedImageSize;
#ifndef CLI
/*** Linkage to rs01-window.c */
method->createCreateWindow = CreateRS01EWindow;
@@ -68,6 +69,7 @@ void register_rs01(void)
method->createVerifyWindow = CreateRS01VerifyWindow;
method->resetVerifyWindow = ResetRS01VerifyWindow;
#endif
/*** Register ourself */
@@ -77,10 +79,14 @@ void register_rs01(void)
}
static void destroy(Method *method)
{ RS01Widgets *wl = (RS01Widgets*)method->widgetList;
{
#ifndef CLI
RS01Widgets *wl = (RS01Widgets*)method->widgetList;
#endif
g_free(method->ckSumClosure);
#ifndef CLI
if(wl)
{ if(wl->fixCurve) FreeCurve(wl->fixCurve);
@@ -92,6 +98,7 @@ static void destroy(Method *method)
g_free(wl);
}
#endif
}

View File

@@ -38,7 +38,7 @@ void register_rs02(void)
/*** Standard infomation and methods */
strncpy(method->name, "RS02", 4);
strncpy(method->name, "RS02", 5);
method->menuEntry = g_strdup(_("Augmented image (RS02)"));
method->description = g_strdup(_("Reed-Solomon method with improved tolerance for defective ecc data"));
method->create = RS02Create;
@@ -54,6 +54,7 @@ void register_rs02(void)
method->finalizeCksums = RS02FinalizeCksums;
method->expectedImageSize = RS02ExpectedImageSize;
#ifndef CLI
/*** Linkage to rs02-window.c */
method->createCreateWindow = CreateRS02EncWindow;
@@ -70,6 +71,7 @@ void register_rs02(void)
method->createVerifyWindow = CreateRS02VerifyWindow;
method->resetVerifyWindow = ResetRS02VerifyWindow;
#endif
/*** Register ourself */
@@ -79,13 +81,17 @@ void register_rs02(void)
}
static void destroy(Method *method)
{ RS02Widgets *wl = (RS02Widgets*)method->widgetList;
{
#ifndef CLI
RS02Widgets *wl = (RS02Widgets*)method->widgetList;
#endif
RS02CksumClosure *csc = (RS02CksumClosure*)method->ckSumClosure;
if(csc->lay)
g_free(csc->lay);
g_free(method->ckSumClosure);
#ifndef CLI
if(wl)
{ if(wl->fixCurve) FreeCurve(wl->fixCurve);
@@ -97,5 +103,6 @@ static void destroy(Method *method)
g_free(wl);
}
#endif
}

View File

@@ -38,7 +38,7 @@ void register_rs03(void)
/*** Standard infomation and methods */
strncpy(method->name, "RS03", 4);
strncpy(method->name, "RS03", 5);
method->menuEntry = g_strdup(_("Multithreaded RS codec (RS03)"));
method->description = g_strdup(_("Multithreaded Reed-Solomon codec for error correction files and augmented images"));
method->create = RS03Create;
@@ -55,6 +55,7 @@ void register_rs03(void)
method->recognizeEccFile = RS03RecognizeFile;
method->recognizeEccImage = RS03RecognizeImage;
#ifndef CLI
/*** Linkage to rs03-window.c */
method->createCreateWindow = CreateRS03EncWindow;
@@ -71,6 +72,7 @@ void register_rs03(void)
method->createVerifyWindow = CreateRS03VerifyWindow;
method->resetVerifyWindow = ResetRS03VerifyWindow;
#endif
/*** Register ourself */
@@ -80,13 +82,17 @@ void register_rs03(void)
}
static void destroy(Method *method)
{ RS03Widgets *wl = (RS03Widgets*)method->widgetList;
{
#ifndef CLI
RS03Widgets *wl = (RS03Widgets*)method->widgetList;
#endif
RS03CksumClosure *csc = (RS03CksumClosure*)method->ckSumClosure;
if(csc->lay)
g_free(csc->lay);
g_free(method->ckSumClosure);
#ifndef CLI
if(wl)
{ if(wl->fixCurve) FreeCurve(wl->fixCurve);
@@ -98,5 +104,6 @@ static void destroy(Method *method)
g_free(wl);
}
#endif
}

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -148,11 +148,13 @@ int ReportImageEccInconsistencies(Image *image)
if(!image || image->type == IMAGE_NONE)
{ if(image) CloseImage(image);
#ifndef CLI
if(Closure->guiMode)
{ CreateMessage(_("Image file %s not present or permission denied.\n"), GTK_MESSAGE_ERROR, Closure->imageName);
return TRUE;
}
else
#endif
{ Stop(_("Image file %s not present or permission denied.\n"), Closure->imageName);
}
}
@@ -161,11 +163,13 @@ int ReportImageEccInconsistencies(Image *image)
if(image->eccFile && !image->eccFileMethod)
{ CloseImage(image);
#ifndef CLI
if(Closure->guiMode)
{ CreateMessage(_("\nError correction file type unknown.\n"), GTK_MESSAGE_ERROR);
return TRUE;
}
else
#endif
{ Stop(_("\nError correction file type unknown.\n"));
}
}
@@ -174,12 +178,14 @@ int ReportImageEccInconsistencies(Image *image)
if(!image->eccFile && image->eccFileState == ECCFILE_NOPERM)
{ CloseImage(image);
#ifndef CLI
if(Closure->guiMode)
{ CreateMessage(_("\nPermission denied on ecc file (perhaps not writeable?).\n"),
GTK_MESSAGE_ERROR);
return TRUE;
}
else
#endif
{ Stop(_("\nPermission denied on ecc file (perhaps not writeable?).\n"));
}
}
@@ -189,12 +195,14 @@ int ReportImageEccInconsistencies(Image *image)
if(!image->eccFile && !image->eccMethod)
{ CloseImage(image);
#ifndef CLI
if(Closure->guiMode)
{ CreateMessage(_("\nNo error correction file present.\n"
"No error correction data recognized in image.\n"), GTK_MESSAGE_ERROR);
return TRUE;
}
else
#endif
{ Stop(_("\nNo error correction file present.\n"
"No error correction data recognized in image.\n"));
}

View File

@@ -178,12 +178,14 @@ ssize_t LargeRead(LargeFile *lf, void *buf, size_t count)
* Writing large files
*/
#ifndef CLI
static void insert_buttons(GtkDialog *dialog)
{
gtk_dialog_add_buttons(dialog,
GTK_STOCK_REDO , 1,
GTK_STOCK_CANCEL, 0, NULL);
}
#endif
static ssize_t xwrite(int fdes, void *buf_base, size_t count)
{ unsigned char *buf = (unsigned char*)buf_base;
@@ -191,7 +193,9 @@ static ssize_t xwrite(int fdes, void *buf_base, size_t count)
/* Simply fail when going out of space in command line mode */
#ifndef CLI
if(!Closure->guiMode)
#endif
{ while(count)
{ ssize_t n = write(fdes, buf, count);
@@ -206,6 +210,7 @@ static ssize_t xwrite(int fdes, void *buf_base, size_t count)
return total;
}
#ifndef CLI
/* Give the user a chance to free more space in GUI mode.
When running out of space, the last write() may complete
with n<count but no error condition, so we try writing
@@ -235,6 +240,7 @@ static ssize_t xwrite(int fdes, void *buf_base, size_t count)
}
return total;
#endif
}
ssize_t LargeWrite(LargeFile *lf, void *buf, size_t count)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -25,6 +25,7 @@
#include "scsi-layer.h"
#include "udf.h"
#ifndef CLI
/*
* Local data
*/
@@ -65,6 +66,7 @@ static void print_defaults(medium_info *mi)
SetLabelText(mi->eccSize, "-");
SetLabelText(mi->eccVersion, "-");
}
#endif
static void print_tab(char *label, int tab_width)
{ char *translation=_(label);
@@ -83,18 +85,24 @@ static void print_tab(char *label, int tab_width)
void PrintMediumInfo(void *mi_ptr)
{ Image *image;
DeviceHandle *dh;
#ifndef CLI
medium_info *mi=(medium_info*)mi_ptr;
#endif
char *disc_status;
char *sess_status;
int tab_width=30;
#ifndef CLI
if(!mi) /* create dummy medium_info in CLI mode so that PrintCLIorLabel() won't crash */
{ mi=alloca(sizeof(medium_info));
memset(mi, 0, sizeof(medium_info));
}
#endif
#ifndef CLI
if(Closure->guiMode)
print_defaults(mi);
#endif
image = OpenImageFromDevice(Closure->device);
if(!image) return;
@@ -116,13 +124,37 @@ void PrintMediumInfo(void *mi_ptr)
NULL)+1;
print_tab("Medium type:",tab_width);
PrintCLIorLabel(mi->physicalType, "%s\n", dh->typeDescr);
PrintCLIorLabel(
#ifndef CLI
mi->physicalType,
#else
NULL,
#endif
"%s\n", dh->typeDescr);
print_tab("Book type:",tab_width);
PrintCLIorLabel(mi->bookType, "%s\n", dh->bookDescr);
PrintCLIorLabel(
#ifndef CLI
mi->bookType,
#else
NULL,
#endif
"%s\n", dh->bookDescr);
print_tab("Manuf.-ID:",tab_width);
PrintCLIorLabel(mi->manufID, "%s\n", dh->manuID);
PrintCLIorLabel(
#ifndef CLI
mi->manufID,
#else
NULL,
#endif
"%s\n", dh->manuID);
print_tab("Drive profile:",tab_width);
PrintCLIorLabel(mi->profileDescr, "%s\n", dh->profileDescr);
PrintCLIorLabel(
#ifndef CLI
mi->profileDescr,
#else
NULL,
#endif
"%s\n", dh->profileDescr);
switch(dh->discStatus&3)
{ case 0: disc_status = g_strdup(_("empty")); break;
@@ -139,20 +171,44 @@ void PrintMediumInfo(void *mi_ptr)
print_tab("Disc status:",tab_width);
PrintCLIorLabel(mi->discStatus, _("%s (%d sessions; last session %s)\n"),
PrintCLIorLabel(
#ifndef CLI
mi->discStatus,
#else
NULL,
#endif
_("%s (%d sessions; last session %s)\n"),
disc_status, dh->sessions, sess_status);
g_free(disc_status);
g_free(sess_status);
print_tab("Used sectors:",tab_width);
PrintCLIorLabel(mi->usedCapacity1, _("%lld sectors (%lld MiB), from READ CAPACITY\n"),
PrintCLIorLabel(
#ifndef CLI
mi->usedCapacity1,
#else
NULL,
#endif
_("%lld sectors (%lld MiB), from READ CAPACITY\n"),
dh->readCapacity+1, (dh->readCapacity+1)>>9);
print_tab(" ",tab_width);
PrintCLIorLabel(mi->usedCapacity2, _("%lld sectors (%lld MiB), from DVD structure\n"),
PrintCLIorLabel(
#ifndef CLI
mi->usedCapacity2,
#else
NULL,
#endif
_("%lld sectors (%lld MiB), from DVD structure\n"),
dh->userAreaSize, dh->userAreaSize>>9);
print_tab("Blank capacity:",tab_width);
PrintCLIorLabel(mi->blankCapacity, _("%lld sectors (%lld MiB)\n"),
PrintCLIorLabel(
#ifndef CLI
mi->blankCapacity,
#else
NULL,
#endif
_("%lld sectors (%lld MiB)\n"),
dh->blankCapacity, (dh->blankCapacity)>>9);
/* Filesystem properties */
@@ -168,12 +224,30 @@ void PrintMediumInfo(void *mi_ptr)
PrintCLI("\n\n");
print_tab("Medium label:",tab_width);
PrintCLIorLabel(mi->isoLabel, "%s\n", image->isoInfo->volumeLabel);
PrintCLIorLabel(
#ifndef CLI
mi->isoLabel,
#else
NULL,
#endif
"%s\n", image->isoInfo->volumeLabel);
print_tab("File system size:",tab_width);
PrintCLIorLabel(mi->isoSize, _("%d sectors (%lld MiB)\n"),
PrintCLIorLabel(
#ifndef CLI
mi->isoSize,
#else
NULL,
#endif
_("%d sectors (%lld MiB)\n"),
image->isoInfo->volumeSize, (gint64)image->isoInfo->volumeSize>>9);
print_tab("Creation time:",tab_width);
PrintCLIorLabel(mi->isoTime, "%s\n", image->isoInfo->creationDate);
PrintCLIorLabel(
#ifndef CLI
mi->isoTime,
#else
NULL,
#endif
"%s\n", image->isoInfo->creationDate);
}
/* Augmented image properties
@@ -197,18 +271,35 @@ void PrintMediumInfo(void *mi_ptr)
memcpy(method, eh->method, 4);
method[4] = 0;
print_tab("Error correction data:",tab_width);
#ifndef CLI
PrintCLIorLabel(mi->eccState, _("%s, %d roots, %4.1f%% redundancy.\n"),
#else
PrintCLIorLabel(NULL, _("%s, %d roots, %4.1f%% redundancy.\n"),
#endif
method, eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
print_tab("Augmented image size:",tab_width);
#ifndef CLI
PrintCLIorLabel(mi->eccSize, _("%lld sectors (%lld MiB)\n"),
#else
PrintCLIorLabel(NULL, _("%lld sectors (%lld MiB)\n"),
#endif
image->expectedSectors, image->expectedSectors>>9);
print_tab("dvdisaster version:", tab_width);
if(micro)
#ifndef CLI
PrintCLIorLabel(mi->eccVersion, "%d.%d.%d", major, minor, micro);
else PrintCLIorLabel(mi->eccVersion, "%d.%d", major, minor);
#else
PrintCLIorLabel(NULL, "%d.%d.%d", major, minor, micro);
#endif
else
#ifndef CLI
PrintCLIorLabel(mi->eccVersion, "%d.%d", major, minor);
#else
PrintCLIorLabel(NULL, "%d.%d", major, minor);
#endif
}
/* Clean up */
@@ -219,6 +310,7 @@ void PrintMediumInfo(void *mi_ptr)
/***
*** GUI callbacks
***/
#ifndef CLI
/*
* Callback for drive selection
@@ -496,3 +588,4 @@ void CreateMediumInfoWindow()
PrintMediumInfo(mi);
}
#endif

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"
@@ -414,7 +415,7 @@ void set_path(GtkWidget *entry, char *path)
else
{ char buf[PATH_MAX + strlen(path) + 2];
getcwd(buf, PATH_MAX);
if (getcwd(buf, PATH_MAX) == NULL) return;
strcat(buf,"/");
strcat(buf,path);

View File

@@ -58,7 +58,7 @@ void ListMethods(void)
for(i=0; i<Closure->methodList->len; i++)
{ Method *method = g_ptr_array_index(Closure->methodList, i);
strncpy(name, method->name, 4);
strncpy(name, method->name, 5);
PrintCLI("%s -- %s\n",name,method->description);
}
}

68
misc.c
View File

@@ -52,8 +52,11 @@ char *sgettext(char *msgid)
}
char *sgettext_utf8(char *msgid)
{ static gchar ringbuf[20][1024];
{
#ifndef CLI
static gchar ringbuf[20][1024];
static int ringptr;
#endif
char *msgval;
#ifdef WITH_NLS_YES
@@ -72,6 +75,7 @@ char *sgettext_utf8(char *msgid)
/*** If we are running the GUI, convert to UTF8 for Gtk+ */
#ifndef CLI
if(Closure->guiMode)
{ char *msg_utf8 = g_locale_to_utf8(msgval, -1, NULL, NULL, NULL);
@@ -81,6 +85,7 @@ char *sgettext_utf8(char *msgid)
return ringbuf[ringptr];
}
#endif
return msgval;
}
@@ -138,6 +143,8 @@ void CalcSectors(guint64 size, guint64 *sectors, int *in_last)
* Append message to the log window.
*/
#ifndef CLI
#define MAX_LOG_WIN_SIZE 10240
static void clamp_gstring(GString *string)
@@ -191,6 +198,7 @@ static void log_window_append(char *text)
g_free(utf_tmp);
}
#endif
/*
* Output of the greetings is delayed until the first message is printed.
@@ -228,6 +236,7 @@ void PrintCLI(char *format, ...)
va_end(argp);
}
#ifndef CLI
if(Closure->guiMode)
{ if(Closure->verbose)
{ va_start(argp, format);
@@ -236,6 +245,7 @@ void PrintCLI(char *format, ...)
}
return;
}
#endif
va_start(argp, format);
g_vprintf(format, argp);
@@ -256,8 +266,10 @@ void PrintProgress(char *format, ...)
va_list argp;
int n;
#ifndef CLI
if(Closure->guiMode)
return;
#endif
print_greetings(stdout);
@@ -321,9 +333,11 @@ void PrintLog(char *format, ...)
va_start(argp, format);
#ifndef CLI
if(Closure->guiMode)
log_window_vprintf(format, argp);
else
#endif
{
print_greetings(stdout);
g_vprintf(format, argp);
@@ -370,9 +384,11 @@ void PrintLogWithAsterisks(char *format, ...)
va_start(argp, format);
#ifndef CLI
if(Closure->guiMode)
log_window_vprintf(new_format, argp);
else
#endif
{
print_greetings(stdout);
g_vprintf(new_format, argp);
@@ -402,9 +418,11 @@ void Verbose(char *format, ...)
va_start(argp, format);
#ifndef CLI
if(Closure->guiMode)
log_window_vprintf(format, argp);
else
#endif
{
print_greetings(stdout);
g_vprintf(format, argp);
@@ -436,11 +454,13 @@ void PrintTimeToLog(GTimer *timer, char *format, ...)
tmp2 = g_strdup_printf("%02d:%02d:%04.1f %s", hours, minutes, seconds, tmp1);
va_end(argp);
#ifndef CLI
if(Closure->guiMode)
{
log_window_append(tmp2);
}
else
#endif
{ g_printf("%s", tmp2);
fflush(stdout);
@@ -455,7 +475,11 @@ void PrintTimeToLog(GTimer *timer, char *format, ...)
* or show it in the given label
*/
#ifndef CLI
void PrintCLIorLabel(GtkLabel *label, char *format, ...)
#else
void PrintCLIorLabel(void *unused, char *format, ...)
#endif
{ va_list argp;
if(Closure->logFileEnabled)
@@ -466,6 +490,7 @@ void PrintCLIorLabel(GtkLabel *label, char *format, ...)
va_start(argp, format);
#ifndef CLI
if(Closure->guiMode)
{ char *c,*tmp;
@@ -483,6 +508,7 @@ void PrintCLIorLabel(GtkLabel *label, char *format, ...)
g_free(tmp);
}
else
#endif
{ g_vprintf(format, argp);
fflush(stdout);
@@ -531,12 +557,18 @@ static void vlog_warning(char *format, va_list argp)
prefix[len] = 0;
str = g_string_sized_new(256);
#ifndef CLI
g_string_append_printf(str,"* %s:%c", warn, Closure->guiMode ? '\n' : ' ');
#else
g_string_append_printf(str,"* %s: ", warn);
#endif
do
{ c = strchr(line,'\n');
if(c) *c=0;
#ifndef CLI
if(Closure->guiMode) g_string_append_printf(str,"* %s\n",line);
else
#endif
{ if(line != body)
g_string_append_printf(str,"%s%s\n",prefix,line);
else g_string_append_printf(str,"%s\n",line);
@@ -547,10 +579,12 @@ static void vlog_warning(char *format, va_list argp)
if(Closure->logFileEnabled)
PrintLogFile("%s", str->str);
#ifndef CLI
if(Closure->guiMode)
{ log_window_append(str->str);
}
else
#endif
{ print_greetings(stdout);
g_printf("%s", str->str);
fflush(stdout);
@@ -598,7 +632,9 @@ void Stop(char *format, ...)
/*** CLI mode */
#ifndef CLI
if(!Closure->guiMode)
#endif
{ g_printf("%s", _("\n*\n* dvdisaster - can not continue:\n*\n"));
va_start(argp, format);
g_vprintf(format, argp);
@@ -609,6 +645,7 @@ void Stop(char *format, ...)
/*** GUI mode */
#ifndef CLI
else
{ char *titled,*msg,*utf_msg;
int idx;
@@ -634,6 +671,7 @@ void Stop(char *format, ...)
g_free(msg);
g_free(utf_msg);
}
#endif
/* The cleanup procedure is supposed to terminate any running
threads except for the main thread.
@@ -667,7 +705,9 @@ void Stop(char *format, ...)
/* see above: possibly unreachable in GUI mode! */
#ifndef CLI
if(!Closure->guiMode)
#endif
{ FreeClosure();
exit(EXIT_FAILURE);
}
@@ -737,6 +777,7 @@ void CallIdleFunc(gboolean (*idle_func)(gpointer), gpointer data)
/***
*** Graphical user interface convenience
***/
#ifndef CLI
/*
* Show the given widget
@@ -1055,6 +1096,9 @@ int ModalDialog(GtkMessageType mt, GtkButtonsType bt,
int ModalWarning(GtkMessageType mt, GtkButtonsType bt,
void(*button_fn)(GtkDialog*), char *msg, ...)
#else
int ModalWarning(char *msg, ...)
#endif
{ va_list argp;
int result = 1;
@@ -1062,11 +1106,13 @@ int ModalWarning(GtkMessageType mt, GtkButtonsType bt,
vlog_warning(msg, argp);
va_end(argp);
#ifndef CLI
if(Closure->guiMode)
{ va_start(argp, msg);
result = vmodal_dialog(mt, bt, button_fn, msg, argp);
va_end(argp);
}
#endif
return result;
}
@@ -1075,6 +1121,7 @@ int ModalWarning(GtkMessageType mt, GtkButtonsType bt,
* Set the text in the pango layout and retrieve its extents.
*/
#ifndef CLI
void SetText(PangoLayout *layout, char *text, int *w, int *h)
{ PangoRectangle rect;
char *t = g_locale_to_utf8(text, -1, NULL, NULL, NULL);
@@ -1261,16 +1308,19 @@ static void insert_button(GtkDialog *dialog)
ReverseCancelOK(GTK_DIALOG(dialog));
}
#endif
int ConfirmImageDeletion(char *file)
{ int answer;
{
#ifndef CLI
if(!Closure->guiMode) /* Always delete it in command line mode */
#endif
return TRUE;
#ifndef CLI
if(!Closure->confirmDeletion) /* I told you so... */
return TRUE;
answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
insert_button,
_("Image file already exists and does not match the medium:\n\n"
"%s\n\n"
@@ -1278,18 +1328,21 @@ int ConfirmImageDeletion(char *file)
file);
return answer == GTK_RESPONSE_OK;
#endif
}
int ConfirmEccDeletion(char *file)
{ int answer;
{
#ifndef CLI
if(!Closure->guiMode) /* Always delete it in command line mode */
#endif
return TRUE;
#ifndef CLI
if(!Closure->confirmDeletion) /* I told you so... */
return TRUE;
answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
insert_button,
_("The error correction file is already present:\n\n"
"%s\n\n"
@@ -1297,5 +1350,6 @@ int ConfirmEccDeletion(char *file)
file);
return answer == GTK_RESPONSE_OK;
#endif
}

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -193,7 +193,14 @@ int SaveDefectiveSector(RawBuffer *rb, int can_c2_scan)
(long long)rb->lba);
if(!LargeStat(filename, &length))
{ PrintCLIorLabel(Closure->status,_(" [Creating new cache file %s]\n"), filename);
{
PrintCLIorLabel(
#ifndef CLI
Closure->status,
#else
NULL,
#endif
_(" [Creating new cache file %s]\n"), filename);
init_defective_sector_file(filename, rb, &file, dsh);
}
else
@@ -264,7 +271,12 @@ int SaveDefectiveSector(RawBuffer *rb, int can_c2_scan)
LargeClose(file);
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(
#ifndef CLI
Closure->status,
#else
NULL,
#endif
_(" [Appended %d/%d sectors to cache file %s; LBA=%lld, ssize=%d, %d sectors]\n"),
count, rb->samplesRead, filename, dsh->lba, dsh->sectorSize, dsh->nSectors);
@@ -313,7 +325,13 @@ int TryDefectiveSectorCache(RawBuffer *rb, unsigned char *outbuf)
status = TryCDFrameRecovery(rb, outbuf);
if(!status)
{ PrintCLIorLabel(Closure->status,
{
PrintCLIorLabel(
#ifndef CLI
Closure->status,
#else
NULL,
#endif
" [Success after processing cached sector %d]\n", i+1);
return status;
}

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -368,12 +368,14 @@ static void cleanup(gpointer data)
}
bail_out:
#ifndef CLI
if(Closure->guiMode)
{ if(rc->earlyTermination)
SetAdaptiveReadFootline(_("Aborted by unrecoverable error."), Closure->redText);
AllowActions(TRUE);
}
#endif
if(rc->image)
if(!LargeClose(rc->image))
@@ -399,8 +401,10 @@ bail_out:
g_free(rc);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/***
@@ -486,8 +490,10 @@ static void print_progress(read_closure *rc, int immediate)
int total = rc->readable+rc->correctable;
int percent = (int)((1000LL*(long long)total)/rc->expectedSectors);
#ifndef CLI
if(Closure->guiMode)
return;
#endif
if( rc->lastPercent >= percent
&& rc->lastCorrectable == rc->correctable
@@ -535,7 +541,12 @@ static void print_progress(read_closure *rc, int immediate)
static void clear_progress(read_closure *rc)
{
if(!rc->progressMsgLen || Closure->guiMode)
if(!rc->progressMsgLen ||
#ifndef CLI
Closure->guiMode)
#else
0)
#endif
return;
rc->progressSp[rc->progressMsgLen] = 0;
@@ -553,6 +564,7 @@ static void clear_progress(read_closure *rc)
* Sector markup in the spiral
*/
#ifndef CLI
static void mark_sector(read_closure *rc, gint64 sector, GdkColor *color)
{ int segment;
int changed = FALSE;
@@ -598,6 +610,7 @@ static void mark_sector(read_closure *rc, gint64 sector, GdkColor *color)
rc->expectedSectors-rc->readable-rc->correctable,
(int)((1000LL*(rc->readable+rc->correctable))/rc->expectedSectors));
}
#endif
/***
*** Basic device and image handling and sanity checks.
@@ -639,7 +652,9 @@ static void open_and_determine_mode(read_closure *rc)
rc->rs01LayerSectors = (rc->ei->sectors+rc->eh->dataBytes-1)/rc->eh->dataBytes;
#ifndef CLI
SetAdaptiveReadMinimumPercentage((1000*(rc->eh->dataBytes-rc->eh->eccBytes))/rc->eh->dataBytes);
#endif
}
else /* see if we have RS02 type ecc */
if(rc->medium->eccHeader && !strncmp((char*)rc->medium->eccHeader->method,"RS02",4))
@@ -647,7 +662,9 @@ static void open_and_determine_mode(read_closure *rc)
rc->eh = rc->medium->eccHeader;
rc->lay = RS02LayoutFromImage(rc->medium);
#ifndef CLI
SetAdaptiveReadMinimumPercentage((1000*rc->lay->ndata)/255);
#endif
if(Closure->version < rc->eh->neededVersion)
PrintCLI(_("* Warning: This image requires dvdisaster-%d.%d!\n"
@@ -718,9 +735,10 @@ static void check_size(read_closure *rc)
/* Compare size with answer from drive */
if(rc->sectors < rc->dh->sectors)
{ int answer;
{
int answer;
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Medium contains %lld sectors more as recorded in the .ecc file\n"
"(Medium: %lld sectors; expected from .ecc file: %lld sectors).\n"
"Only the first %lld medium sectors will be processed.\n"),
@@ -728,23 +746,30 @@ static void check_size(read_closure *rc)
rc->sectors);
if(!answer)
{ SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
{
#ifndef CLI
SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
#endif
rc->earlyTermination = FALSE;
cleanup((gpointer)rc);
}
}
if(rc->sectors > rc->dh->sectors)
{ int answer;
{
int answer;
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Medium contains %lld sectors less as recorded in the .ecc file\n"
"(Medium: %lld sectors; expected from .ecc file: %lld sectors).\n"),
rc->sectors-rc->dh->sectors, rc->dh->sectors, rc->sectors,
rc->sectors);
if(!answer)
{ SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
{
#ifndef CLI
SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
#endif
rc->earlyTermination = FALSE;
cleanup((gpointer)rc);
}
@@ -761,10 +786,14 @@ void GetReadingRange(gint64 sectors, gint64 *firstSector, gint64 *lastSector)
{ gint64 first, last;
if(Closure->readStart || Closure->readEnd)
{ if(!Closure->guiMode) /* more range checks are made below */
{
#ifndef CLI
if(!Closure->guiMode) /* more range checks are made below */
#endif
{ first = Closure->readStart;
last = Closure->readEnd < 0 ? sectors-1 : Closure->readEnd;
}
#ifndef CLI
else /* be more permissive in GUI mode */
{ first = 0;
last = sectors-1;
@@ -774,6 +803,7 @@ void GetReadingRange(gint64 sectors, gint64 *firstSector, gint64 *lastSector)
last = Closure->readEnd < sectors ? Closure->readEnd : sectors-1;
}
}
#endif
if(first > last || first < 0 || last >= sectors)
Stop(_("Sectors must be in range [0..%lld].\n"), sectors-1);
@@ -800,15 +830,19 @@ static void check_ecc_fingerprint(read_closure *rc)
fp_read = GetImageFingerprint(rc->medium, digest, rc->eh->fpSector);
if(!fp_read) /* Not readable. Bad luck. */
{ int answer;
{
int answer;
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Sector %d is missing. Can not compare medium and ecc fingerprints.\n"
"Double check that the medium and the ecc file belong together.\n"),
rc->eh->fpSector);
if(!answer)
{ SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
{
#ifndef CLI
SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
#endif
rc->earlyTermination = FALSE;
cleanup((gpointer)rc);
}
@@ -856,8 +890,11 @@ int check_image_fingerprint(read_closure *rc)
if(memcmp(image_fp, medium_fp, 16))
{
#ifndef CLI
if(!Closure->guiMode)
#endif
Stop(_("Image file does not match the optical disc."));
#ifndef CLI
else
{ int answer = ConfirmImageDeletion(Closure->imageName);
@@ -873,6 +910,7 @@ int check_image_fingerprint(read_closure *rc)
return TRUE; /* causes reopen of image in caller */
}
}
#endif
}
return 0; /* okay */
@@ -886,16 +924,20 @@ int check_image_fingerprint(read_closure *rc)
void check_image_size(read_closure *rc, gint64 image_file_sectors)
{
if(image_file_sectors > rc->expectedSectors)
{ int answer;
{
int answer;
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image file is %lld sectors longer than inserted medium\n"
"(Image file: %lld sectors; medium: %lld sectors).\n"),
image_file_sectors-rc->expectedSectors,
image_file_sectors, rc->expectedSectors);
if(!answer)
{ SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
{
#ifndef CLI
SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
#endif
rc->earlyTermination = FALSE;
cleanup((gpointer)rc);
}
@@ -913,11 +955,15 @@ static void load_crc_buf(read_closure *rc)
{
switch(rc->readMode)
{ case ECC_IN_FILE:
#ifndef CLI
SetAdaptiveReadSubtitle(_utf("Loading CRC data."));
#endif
rc->crcBuf = GetCRCFromRS01_obsolete(rc->ei);
break;
case ECC_IN_IMAGE:
#ifndef CLI
SetAdaptiveReadSubtitle(_utf("Loading CRC data."));
#endif
rc->crcBuf = GetCRCFromRS02_obsolete(rc->lay, rc->dh, rc->image);
break;
default:
@@ -948,19 +994,23 @@ static void build_interval_from_image(read_closure *rc)
Check them for "dead sector markers"
and for checksum failures if ecc data is present. */
#ifndef CLI
if(Closure->guiMode)
SetAdaptiveReadSubtitle(_("Analysing existing image file"));
#endif
for(s=0; s<=rc->highestWrittenSector; s++)
{ int n,percent;
/* Check for user interruption. */
#ifndef CLI
if(Closure->stopActions)
{ SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
rc->earlyTermination = FALSE;
cleanup((gpointer)rc);
}
#endif
/* Read the next sector */
@@ -974,7 +1024,9 @@ static void build_interval_from_image(read_closure *rc)
if(current_missing)
{ int fixme=0;
#ifndef CLI
mark_sector(rc, s, Closure->redSector);
#endif
ExplainMissingSector(rc->buf, s, current_missing, SOURCE_IMAGE, &fixme);
}
@@ -994,7 +1046,9 @@ static void build_interval_from_image(read_closure *rc)
make it missing due to the CRC failure. */
if(!current_missing)
{ current_missing = 1;
#ifndef CLI
mark_sector(rc, s, Closure->yellowSector);
#endif
}
}
@@ -1009,7 +1063,9 @@ static void build_interval_from_image(read_closure *rc)
if(rc->map)
SetBit(rc->map, s);
#ifndef CLI
mark_sector(rc, s, Closure->greenSector);
#endif
#ifdef CHECK_VISITED
rc->count[s]++;
@@ -1043,7 +1099,10 @@ static void build_interval_from_image(read_closure *rc)
percent = (100*s)/(rc->highestWrittenSector+1);
if(last_percent != percent)
{ if(!Closure->guiMode)
{
#ifndef CLI
if(!Closure->guiMode)
#endif
PrintProgress(_("Analysing existing image file: %2d%%"),percent);
last_percent = percent;
@@ -1071,8 +1130,10 @@ static void build_interval_from_image(read_closure *rc)
/*** Now that all readable sectors are known,
determine those which can already be corrected. */
#ifndef CLI
if(Closure->guiMode)
SetAdaptiveReadSubtitle(_("Determining correctable sectors"));
#endif
/* RS01 type error correction. */
@@ -1104,7 +1165,9 @@ static void build_interval_from_image(read_closure *rc)
#ifdef CHECK_VISITED
rc->count[layer_idx]++;
#endif
#ifndef CLI
mark_sector(rc, layer_idx, Closure->greenSector);
#endif
}
layer_idx += rc->rs01LayerSectors;
@@ -1137,7 +1200,9 @@ static void build_interval_from_image(read_closure *rc)
&& !GetBit(rc->map, sector))
{ SetBit(rc->map, sector);
rc->correctable++;
#ifndef CLI
mark_sector(rc, sector, Closure->greenSector);
#endif
}
}
}
@@ -1152,10 +1217,12 @@ static void build_interval_from_image(read_closure *rc)
else PrintLog(_("Analysing existing image file: %lld readable, %lld still missing.\n"),
rc->readable, rc->expectedSectors-rc->readable-rc->correctable);
#ifndef CLI
if(Closure->guiMode)
UpdateAdaptiveResults(rc->readable, rc->correctable,
rc->expectedSectors-rc->readable-rc->correctable,
(int)((1000LL*(rc->readable+rc->correctable))/rc->expectedSectors));
#endif
// print_intervals(rc);
}
@@ -1179,12 +1246,16 @@ static void mark_rs02_headers(read_closure *rc)
while(hpos < end)
{ if(!GetBit(rc->map, hpos))
{ SetBit(rc->map, hpos);
#ifndef CLI
mark_sector(rc, hpos, Closure->greenSector);
#endif
rc->correctable++;
}
if(!GetBit(rc->map, hpos+1))
{ SetBit(rc->map, hpos+1);
#ifndef CLI
mark_sector(rc, hpos+1, Closure->greenSector);
#endif
rc->correctable++;
}
@@ -1196,6 +1267,7 @@ static void mark_rs02_headers(read_closure *rc)
*** Main routine for adaptive reading
***/
#ifndef CLI
static void insert_buttons(GtkDialog *dialog)
{
gtk_dialog_add_buttons(dialog,
@@ -1203,6 +1275,7 @@ static void insert_buttons(GtkDialog *dialog)
_utf("Ignore always"), 2,
_utf("Abort"), 0, NULL);
}
#endif
/*
* Fill the gap between rc->intervalStart and rc->highestWrittenSector
@@ -1239,10 +1312,12 @@ void fill_gap(read_closure *rc)
t = g_strdup_printf(_("Filling image area [%lld..%lld]"),
firstUnwritten, rc->intervalStart-1);
clear_progress(rc);
#ifndef CLI
if(Closure->guiMode)
{ SetAdaptiveReadSubtitle(t);
ChangeSpiralCursor(Closure->readAdaptiveSpiral, -1);
}
#endif
PrintCLI(t);
g_free(t);
@@ -1268,20 +1343,25 @@ void fill_gap(read_closure *rc)
/* Check whether user hit the Stop button */
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->guiMode)
{
if(Closure->guiMode)
SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
rc->earlyTermination = FALSE; /* suppress respective error message */
cleanup((gpointer)rc);
}
#endif
/* Cycle the progress animation */
if(j++ % 2000)
{ int seq = (j/2000)%10;
#ifndef CLI
if(!Closure->guiMode)
#endif
{ g_printf("%s", anim[seq]);
fflush(stdout);
}
@@ -1289,21 +1369,25 @@ void fill_gap(read_closure *rc)
/* Show progress in the spiral */
#ifndef CLI
if(Closure->guiMode)
{ int segment = i / rc->sectorsPerSegment;
if(Closure->readAdaptiveSpiral->segmentColor[segment] == Closure->background)
ChangeSegmentColor(Closure->whiteSector, segment);
}
#endif
}
PrintCLI(" \n");
rc->highestWrittenSector = rc->intervalStart-1;
#ifndef CLI
if(Closure->guiMode) /* remove temporary fill markers */
{ RemoveFillMarkers();
SetAdaptiveReadSubtitle(rc->subtitle);
}
#endif
}
@@ -1358,10 +1442,12 @@ void ReadMediumAdaptive(gpointer data)
rc->earlyTermination = TRUE;
RegisterCleanup(_("Reading aborted"), cleanup, rc);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readAdaptiveHeadline), "<big>%s</big>\n<i>%s</i>",
_("Preparing for reading the medium image."),
_("Medium: not yet determined"));
#endif
/* Please note: Commenting the follwing Stop() out will provide
adaptive reading for RS01 and RS02, but behaviour with RS03
@@ -1418,6 +1504,7 @@ void ReadMediumAdaptive(gpointer data)
/*** Initialize segment state counters (only in GUI mode) */
#ifndef CLI
if(Closure->guiMode)
{ //rc->sectorsPerSegment = 1 + (rc->sectors / ADAPTIVE_READ_SPIRAL_SIZE);
rc->sectorsPerSegment = ((rc->expectedSectors+ADAPTIVE_READ_SPIRAL_SIZE-1) / ADAPTIVE_READ_SPIRAL_SIZE);
@@ -1425,6 +1512,7 @@ void ReadMediumAdaptive(gpointer data)
// ClipReadAdaptiveSpiral(rc->sectors/rc->sectorsPerSegment);
ClipReadAdaptiveSpiral((rc->expectedSectors+rc->sectorsPerSegment-1)/rc->sectorsPerSegment);
}
#endif
/*** Initialize the interval list */
@@ -1440,11 +1528,13 @@ reopen_image:
Stop(_("Can't open %s:\n%s"),Closure->imageName,strerror(errno));
PrintLog(_("Creating new %s image.\n"),Closure->imageName);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readAdaptiveHeadline),
"<big>%s</big>\n<i>%s</i>",
_("Reading new medium image."),
rc->dh->mediumDescr);
#endif
/* Mark RS02 header sectors as correctable. */
@@ -1460,11 +1550,13 @@ reopen_image:
else
{ int reopen;
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readAdaptiveHeadline),
"<big>%s</big>\n<i>%s</i>",
_("Completing existing medium image."),
rc->dh->mediumDescr);
#endif
/* Open the existing image file. */
@@ -1500,8 +1592,10 @@ reopen_image:
if(rc->readMode != IMAGE_ONLY)
{ PrintLog(t);
#ifndef CLI
if(Closure->guiMode)
SetAdaptiveReadFootline(t, Closure->greenText);
#endif
}
goto finished;
}
@@ -1519,8 +1613,10 @@ reopen_image:
/*** Read the medium image. */
#ifndef CLI
if(Closure->guiMode)
SetAdaptiveReadSubtitle(rc->subtitle);
#endif
for(;;)
{ int cluster_mask = rc->dh->clusterSize-1;
@@ -1545,6 +1641,7 @@ reopen_image:
for(s=rc->intervalStart; s<=rc->intervalEnd; ) /* s is incremented elsewhere */
{ int nsectors,cnt;
#ifndef CLI
if(Closure->stopActions) /* somebody hit the Stop button */
{ if(Closure->guiMode)
SetAdaptiveReadFootline(_("Aborted by user request!"), Closure->redText);
@@ -1555,6 +1652,7 @@ reopen_image:
if(Closure->guiMode)
ChangeSpiralCursor(Closure->readAdaptiveSpiral, s / rc->sectorsPerSegment);
#endif
/* Determine number of sectors to read. Read the next dh->clusterSize sectors
unless we're at the end of the interval or at a position which is
@@ -1600,13 +1698,17 @@ reread:
if(status && !Closure->ignoreFatalSense
&& rc->dh->sense.sense_key
&& rc->dh->sense.sense_key != 3 && rc->dh->sense.sense_key != 5)
{ int answer;
{
#ifndef CLI
int answer;
if(!Closure->guiMode)
#endif
Stop(_("Sector %lld: %s\nCan not recover from above error.\n"
"Use the --ignore-fatal-sense option to override."),
s, GetLastSenseString(FALSE));
#ifndef CLI
answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, insert_buttons,
_("Sector %lld: %s\n\n"
"It may not be possible to recover from this error.\n"
@@ -1617,11 +1719,12 @@ reread:
Closure->ignoreFatalSense = 2;
if(!answer)
{ SetAdaptiveReadFootline(_("Aborted by unrecoverable error."), Closure->redText);
{
SetAdaptiveReadFootline(_("Aborted by unrecoverable error."), Closure->redText);
rc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
#endif
}
/* When encountering an error during cluster size reads,
@@ -1675,7 +1778,9 @@ reread:
Stop(_("Failed writing to sector %lld in image [%s]: %s"),
b, "unv", strerror(errno));
#ifndef CLI
mark_sector(rc, b, Closure->yellowSector);
#endif
if(rc->highestWrittenSector < b)
rc->highestWrittenSector = b;
@@ -1692,7 +1797,9 @@ reread:
SetBit(rc->map, b);
rc->readable++;
#ifndef CLI
mark_sector(rc, b, Closure->greenSector);
#endif
if(rc->highestWrittenSector < b)
rc->highestWrittenSector = b;
@@ -1745,7 +1852,9 @@ reread:
&& !GetBit(rc->map, layer_idx))
{ SetBit(rc->map, layer_idx);
rc->correctable++;
#ifndef CLI
mark_sector(rc, layer_idx, Closure->greenSector);
#endif
#ifdef CHECK_VISITED
rc->count[layer_idx]++;
@@ -1788,7 +1897,9 @@ reread:
&& !GetBit(rc->map, sector))
{ SetBit(rc->map, sector);
rc->correctable++;
#ifndef CLI
mark_sector(rc, sector, Closure->greenSector);
#endif
fill_correctable_gap(rc, sector);
}
}
@@ -1813,8 +1924,10 @@ reread:
print_progress(rc, TRUE);
if(rc->readMode != IMAGE_ONLY)
{ PrintLog(t);
#ifndef CLI
if(Closure->guiMode && rc->ei)
SetAdaptiveReadFootline(t, Closure->foreground);
#endif
}
if(Closure->eject)
LoadMedium(rc->dh, FALSE);
@@ -1826,10 +1939,20 @@ reread:
{ unsigned char buf[2048];
PrintCLI("\n");
if(nsectors>1) PrintCLIorLabel(Closure->status,
if(nsectors>1) PrintCLIorLabel(
#ifndef CLI
Closure->status,
#else
NULL,
#endif
_("Sectors %lld-%lld: %s\n"),
s, s+nsectors-1, GetLastSenseString(FALSE));
else PrintCLIorLabel(Closure->status,
else PrintCLIorLabel(
#ifndef CLI
Closure->status,
#else
NULL,
#endif
_("Sector %lld: %s\n"),
s, GetLastSenseString(FALSE));
@@ -1849,7 +1972,9 @@ reread:
Stop(_("Failed writing to sector %lld in image [%s]: %s"),
s, "nds", strerror(errno));
#ifndef CLI
mark_sector(rc, s+i, Closure->redSector);
#endif
}
if(rc->highestWrittenSector < s+nsectors)
@@ -1944,10 +2069,12 @@ finished:
/* Force output of final results */
#ifndef CLI
if(Closure->guiMode)
{ ChangeSpiralCursor(Closure->readAdaptiveSpiral, -1);
mark_sector(rc, 0, NULL);
}
#endif
/*** Summarize results. */
@@ -1963,8 +2090,10 @@ finished:
PrintLog(_("\n%s\n"
"(%lld readable, %lld correctable, %lld still missing).\n"),
t, rc->readable, rc->correctable, rc->expectedSectors-total);
#ifndef CLI
if(Closure->guiMode)
SetAdaptiveReadFootline(t, Closure->foreground);
#endif
g_free(t);
exitCode = EXIT_FAILURE;
@@ -1976,8 +2105,10 @@ finished:
{ if(rc->readable == rc->expectedSectors)
{ char *t = _("\nGood! All sectors have been read.\n");
PrintLog(t);
#ifndef CLI
if(Closure->guiMode)
SetAdaptiveReadFootline(t, Closure->foreground);
#endif
if(Closure->eject)
LoadMedium(rc->dh, FALSE);
}
@@ -1990,8 +2121,10 @@ finished:
"%2d.%1d%% of the image have been read (%lld sectors).\n"),
t, percent/10, percent%10, rc->readable);
#ifndef CLI
if(Closure->guiMode)
SetAdaptiveReadFootline(t, Closure->foreground);
#endif
g_free(t);
exitCode = EXIT_FAILURE;
}
@@ -2009,7 +2142,9 @@ finished:
rc->earlyTermination = FALSE;
#ifndef CLI
terminate:
#endif
cleanup((gpointer)rc);
}

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -57,9 +57,11 @@ static void send_eof(read_closure *rc)
static void cleanup(gpointer data)
{ read_closure *rc = (read_closure*)data;
#ifndef CLI
int full_read = FALSE;
int aborted = rc->earlyTermination;
int scan_mode = rc->scanMode;
#endif
int i;
int renderers_left = TRUE;
@@ -70,7 +72,11 @@ static void cleanup(gpointer data)
idle functions. Executing the while loop would create a deadlock
in that case. */
while(renderers_left && Closure->stopActions != STOP_SHUTDOWN_ALL)
while(renderers_left
#ifndef CLI
&& Closure->stopActions != STOP_SHUTDOWN_ALL
#endif
)
{ g_mutex_lock(rc->rendererMutex);
if(rc->activeRenderers<=0)
renderers_left=FALSE;
@@ -106,17 +112,21 @@ static void cleanup(gpointer data)
/* Clean up reader thread */
#ifndef CLI
if(rc->image)
full_read = (rc->readOK == rc->image->dh->sectors && !Closure->crcErrors);
#endif
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
{ if(rc->unreportedError)
SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
_("<span %s>Aborted by unrecoverable error.</span> %lld sectors read, %lld sectors unreadable/skipped so far."),
Closure->redMarkup, rc->readOK, Closure->readErrors);
}
#endif
if(rc->readerImage)
if(!LargeClose(rc->readerImage))
@@ -163,6 +173,7 @@ static void cleanup(gpointer data)
/* Continue with ecc file creation after read.
NOTE: Images are NOT automatically augmented after a read. */
#ifndef CLI
if(Closure->readAndCreate && Closure->guiMode && !scan_mode && !aborted) /* General prerequisites */
{ if( !strncmp(Closure->methodName, "RS01", 4) /* codec prerequisites */
|| (!strncmp(Closure->methodName, "RS03", 4) && Closure->eccTarget == ECC_FILE) )
@@ -185,6 +196,7 @@ static void cleanup(gpointer data)
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/***
@@ -199,19 +211,23 @@ static void register_reader(read_closure *rc)
{
if(rc->scanMode) /* Output messages differ in read and scan mode */
{ RegisterCleanup(_("Scanning aborted"), cleanup, rc);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
"<big>%s</big>\n<i>%s</i>",
_("Scanning medium for read errors."),
_("Medium: not yet determined"));
#endif
}
else
{ RegisterCleanup(_("Reading aborted"), cleanup, rc);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
"<big>%s</big>\n<i>%s</i>",
_("Preparing for reading the medium image."),
_("Medium: not yet determined"));
#endif
}
}
@@ -236,6 +252,7 @@ static void determine_mode(read_closure *rc)
rc->msg = g_strdup(_("Scanning medium for read errors."));
PrintLog("%s\n", rc->msg);
#ifndef CLI
if(Closure->guiMode)
{ if(rc->eccMethod)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
@@ -246,18 +263,23 @@ static void determine_mode(read_closure *rc)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
"<big>%s</big>\n<i>%s</i>", rc->msg, rc->image->dh->mediumDescr);
}
#endif
rc->readMarker = 0;
#ifndef CLI
if(Closure->guiMode)
InitializeCurve(rc, rc->image->dh->maxRate, rc->image->dh->canC2Scan);
#endif
return;
}
/*** If no image file exists, open a new one. */
#ifndef CLI
reopen_image:
#endif
if(!LargeStat(Closure->imageName, &image_size))
{
if(rc->msg) g_free(rc->msg);
@@ -269,6 +291,7 @@ reopen_image:
Stop(_("Can't open %s:\n%s"),Closure->imageName,strerror(errno));
PrintLog(_("Creating new %s image.\n"),Closure->imageName);
#ifndef CLI
if(Closure->guiMode)
{ if(rc->eccMethod)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
@@ -278,11 +301,14 @@ reopen_image:
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
"<big>%s</big>\n<i>%s</i>", rc->msg, rc->image->dh->mediumDescr);
}
#endif
rc->rereading = FALSE;
rc->readMarker = 0;
#ifndef CLI
if(Closure->guiMode)
InitializeCurve(rc, rc->image->dh->maxRate, rc->image->dh->canC2Scan);
#endif
return;
}
@@ -328,8 +354,11 @@ reopen_image:
if(!unknown_fingerprint && memcmp(image_fp, medium_fp, 16))
{
#ifndef CLI
if(!Closure->guiMode)
#endif
Stop(_("Image file does not match the optical disc."));
#ifndef CLI
else
{ int answer = ConfirmImageDeletion(Closure->imageName);
@@ -347,6 +376,7 @@ reopen_image:
goto reopen_image;
}
}
#endif
}
/*** If the image is not complete yet, first aim to read the
@@ -358,19 +388,25 @@ reopen_image:
{ PrintLog(_("Completing image %s. Continuing with sector %lld.\n"),
Closure->imageName, rc->readMarker);
rc->firstSector = rc->readMarker;
#ifndef CLI
Closure->additionalSpiralColor = 0; /* blue */
#endif
}
else
{ PrintLog(_("Completing image %s. Only missing sectors will be read.\n"), Closure->imageName);
#ifndef CLI
Closure->additionalSpiralColor = 3; /* dark green*/
#endif
}
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
"<big>%s</big>\n<i>%s</i>",rc->msg,rc->image->dh->mediumDescr);
if(Closure->guiMode)
InitializeCurve(rc, rc->image->dh->maxRate, rc->image->dh->canC2Scan);
#endif
}
/*
@@ -427,17 +463,21 @@ static void prepare_crc_cache(read_closure *rc)
// FIXME: reuse CrcBuf and write respective message
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
"<big>%s</big>\n<i>%s</i>",
_("Reading CRC information from ecc data"),
rc->image->dh->mediumDescr);
#endif
if(rc->eccMethod->getCrcBuf)
{ Closure->crcBuf = rc->eccMethod->getCrcBuf(rc->image);
Closure->crcBuf->crcCached = TRUE;
#ifndef CLI
if(Closure->guiMode)
RedrawReadLinearWindow();
#endif
/* Augmented image codecs provide the CRCs and md5sums for
the data portion, but not for the full image.
@@ -453,9 +493,11 @@ static void prepare_crc_cache(read_closure *rc)
rc->eccMethod->resetCksums(rc->image);
}
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
"<big>%s</big>\n<i>%s</i>", rc->msg, rc->image->dh->mediumDescr);
#endif
PrintCLI(_("done.\n"));
return;
}
@@ -474,14 +516,18 @@ static void prepare_crc_cache(read_closure *rc)
static void prepare_timer(read_closure *rc)
{
#ifndef CLI
if(Closure->guiMode && Closure->spinupDelay)
SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
_("Waiting %d seconds for drive to spin up...\n"), Closure->spinupDelay);
#endif
SpinupDevice(rc->image->dh);
#ifndef CLI
if(Closure->guiMode && Closure->spinupDelay)
SwitchAndSetFootline(Closure->readLinearNotebook, 0, Closure->readLinearFootline, "ignore");
#endif
if(Closure->spinupDelay) /* eliminate initial seek time from timing */
ReadSectors(rc->image->dh, rc->alignedBuf[0]->buf, rc->firstSector, 1);
@@ -496,24 +542,29 @@ static void prepare_timer(read_closure *rc)
static void show_progress(read_closure *rc)
{ int percent;
#ifndef CLI
if(Closure->guiMode && rc->lastErrorsPrinted != Closure->readErrors)
{ SetLabelText(GTK_LABEL(Closure->readLinearErrors),
_("Unreadable / skipped sectors: %lld"), Closure->readErrors);
rc->lastErrorsPrinted = Closure->readErrors;
}
#endif
if(rc->readPos>rc->readMarker) rc->readMarker=rc->readPos;
percent = (1000*rc->readPos)/rc->image->dh->sectors;
if(rc->lastPercent != percent)
{ gulong ignore;
#ifndef CLI
int color;
if(Closure->guiMode)
ChangeSpiralCursor(Closure->readLinearSpiral, percent);
#endif
if(rc->readOK <= rc->lastReadOK) /* nothing read since last sample? */
{ rc->speed = 0.0;
#ifndef CLI
if(Closure->readErrors - rc->previousReadErrors > 0)
color = 2;
else if(Closure->crcErrors - rc->previousCRCErrors > 0)
@@ -522,6 +573,7 @@ static void show_progress(read_closure *rc)
if(Closure->guiMode)
AddCurveValues(rc, percent, color, rc->maxC2);
#endif
rc->lastPercent = percent;
rc->lastSpeed = rc->speed;
rc->previousReadErrors = Closure->readErrors;
@@ -533,19 +585,23 @@ static void show_progress(read_closure *rc)
double elapsed = g_timer_elapsed(rc->speedTimer, &ignore);
double kb_sec = kb_read / elapsed;
#ifndef CLI
if(Closure->readErrors - rc->previousReadErrors > 0)
color = 2;
else if(Closure->crcErrors - rc->previousCRCErrors > 0)
color = 4;
else color = 1;
#endif
if(rc->firstSpeedValue)
{ rc->speed = kb_sec / rc->image->dh->singleRate;
#ifndef CLI
if(Closure->guiMode)
{ AddCurveValues(rc, rc->lastPercent, color, rc->maxC2);
AddCurveValues(rc, percent, color, rc->maxC2);
}
#endif
rc->firstSpeedValue = FALSE;
rc->lastPercent = percent;
@@ -568,8 +624,10 @@ static void show_progress(read_closure *rc)
cut_peaks=3;
}
#ifndef CLI
if(Closure->guiMode)
AddCurveValues(rc, percent, color, rc->maxC2);
#endif
if(Closure->speedWarning && rc->lastSpeed > 0.5)
{ double delta = rc->speed - rc->lastSpeed;
@@ -719,6 +777,7 @@ update_mutex:
*** The reader part
***/
#ifndef CLI
static void insert_buttons(GtkDialog *dialog)
{
gtk_dialog_add_buttons(dialog,
@@ -726,6 +785,7 @@ static void insert_buttons(GtkDialog *dialog)
_utf("Ignore always"), 2,
_utf("Abort"), 0, NULL);
}
#endif
void ReadMediumLinear(gpointer data)
{ read_closure *rc = g_malloc0(sizeof(read_closure));
@@ -806,11 +866,11 @@ void ReadMediumLinear(gpointer data)
/*** Make sure we are compatible with the ecc data */
if(rc->eccHeader && (Closure->version < rc->eccHeader->neededVersion))
{ if(Closure->guiMode)
{ int answer;
{
int answer;
if(rc->image->eccFileState == ECCFILE_PRESENT)
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("This ecc file requires dvdisaster-%d.%d!\n\n"
"Proceeding could trigger incorrect behaviour.\n"
"Please read the image without using this ecc file\n"
@@ -818,7 +878,7 @@ void ReadMediumLinear(gpointer data)
rc->eccHeader->neededVersion/10000,
(rc->eccHeader->neededVersion%10000)/100);
else
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("This image requires dvdisaster-%d.%d!\n\n"
"Proceeding could trigger incorrect behaviour.\n"
"Please visit http://www.dvdisaster.org for an upgrade.\n\n"),
@@ -826,35 +886,24 @@ void ReadMediumLinear(gpointer data)
(rc->eccHeader->neededVersion%10000)/100);
if(!answer)
{ SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
{
#ifndef CLI
SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup, rc->readOK,Closure->readErrors);
#endif
rc->unreportedError = FALSE; /* suppress respective error message */
goto terminate;
}
}
else
{ if(rc->image->eccFileState == ECCFILE_PRESENT)
PrintCLI(_("* Warning: This ecc file requires dvdisaster-%d.%d!\n"
"* Proceeding could trigger incorrect behaviour.\n"
"* Please read the image without using this ecc file\n"
"* or visit http://www.dvdisaster.org for an upgrade.\n\n"),
rc->eccHeader->neededVersion/10000,
(rc->eccHeader->neededVersion%10000)/100);
else
PrintCLI(_("* Warning: This image requires dvdisaster-%d.%d!\n"
"* Proceeding could trigger incorrect behaviour.\n"
"* Please visit http://www.dvdisaster.org for an upgrade.\n\n"),
rc->eccHeader->neededVersion/10000,
(rc->eccHeader->neededVersion%10000)/100);
}
}
/*** See if user wants to limit the read range. */
GetReadingRange(rc->image->dh->sectors, &rc->firstSector, &rc->lastSector);
if(rc->firstSector > 0) /* Mark skipped sectors */
#ifndef CLI
Closure->additionalSpiralColor = 0; /* blue */
#endif
/*** Determine the reading mode. There are three possibilities:
1. scanning (rc->scanMode == TRUE)
@@ -919,8 +968,10 @@ next_reading_pass:
break;
}
Closure->sectorSkip = 0;
#ifndef CLI
if(Closure->guiMode)
MarkExistingSectors();
#endif
rc->lastCopied = 0; /* Start rendering the spiral from the beginning */
}
@@ -937,6 +988,7 @@ next_reading_pass:
while(rc->readPos<=rc->lastSector)
{ int cluster_mask = rc->image->dh->clusterSize-1;
#ifndef CLI
if(Closure->stopActions) /* somebody hit the Stop button */
{
if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
@@ -947,6 +999,7 @@ next_reading_pass:
rc->unreportedError = FALSE; /* suppress respective error message */
goto terminate;
}
#endif
/*** Decide between reading in fast mode (dh->clusterSize sectors at once)
or reading one sector at a time.
@@ -1047,13 +1100,17 @@ reread:
if(status && !Closure->ignoreFatalSense
&& rc->image->dh->sense.sense_key && rc->image->dh->sense.sense_key != 3 && rc->image->dh->sense.sense_key != 5)
{ int answer;
{
#ifndef CLI
int answer;
if(!Closure->guiMode)
#endif
Stop(_("Sector %lld: %s\nCan not recover from above error.\n"
"Use the --ignore-fatal-sense option to override."),
rc->readPos, GetLastSenseString(FALSE));
#ifndef CLI
answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, insert_buttons,
_("Sector %lld: %s\n\n"
"It may not be possible to recover from this error.\n"
@@ -1064,12 +1121,14 @@ reread:
Closure->ignoreFatalSense = 2;
if(!answer)
{ SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
{
SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
_("<span %s>Aborted by user request!</span> %lld sectors read, %lld sectors unreadable/skipped so far."),
Closure->redMarkup, rc->readOK,Closure->readErrors);
rc->unreportedError = FALSE; /* suppress respective error message */
goto terminate;
}
#endif
}
/*** Evaluate C2 scan results */
@@ -1211,7 +1270,12 @@ reread:
if(Closure->sectorSkip && nsectors > 1)
{ int i;
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(
#ifndef CLI
Closure->status,
#else
NULL,
#endif
_("Sector %lld: %s Skipping %d sectors.\n"),
rc->readPos, GetLastSenseString(FALSE), nfill-1);
for(i=0; i<nfill; i++) /* workaround: large values for nfill */
@@ -1239,7 +1303,12 @@ reread:
goto reread;
}
else
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(
#ifndef CLI
Closure->status,
#else
NULL,
#endif
_("Sector %lld: %s\n"),
rc->readPos, GetLastSenseString(FALSE));
if(rc->readPos >= rc->image->dh->sectors - 2) tao_tail++;
@@ -1262,8 +1331,10 @@ step_counter:
to checksum means we have ecc data - we can fix the image using ecc
rather than by re-reading it. */
#ifndef CLI
if(Closure->guiMode)
ChangeSpiralCursor(Closure->readLinearSpiral, -1); /* switch cursor off */
#endif
rc->pass++;
rc->image->dh->pass = rc->pass;
@@ -1273,11 +1344,14 @@ step_counter:
&& rc->pass < Closure->readingPasses)
{ int renderers_left = TRUE;
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(Closure->readLinearHeadline),
_("<big>Trying to complete image, reading pass %d of %d.</big>\n%s"),
rc->pass+1, Closure->readingPasses, rc->image->dh->mediumDescr);
else PrintCLI(_("\nTrying to complete image, reading pass %d of %d.\n"),
else
#endif
PrintCLI(_("\nTrying to complete image, reading pass %d of %d.\n"),
rc->pass+1, Closure->readingPasses);
@@ -1360,12 +1434,14 @@ step_counter:
}
PrintLog("\n%s\n",t);
#ifndef CLI
if(Closure->guiMode)
{ if(rc->scanMode) SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
"%s%s",_("Scanning finished: "),t);
else SwitchAndSetFootline(Closure->readLinearNotebook, 1, Closure->readLinearFootline,
"%s%s",_("Reading finished: "),t);
}
#endif
if(t) g_free(t);
if(!Closure->fixedSpeedValues)
@@ -1374,14 +1450,16 @@ step_counter:
if(rc->image->dh->mainType == CD && tao_tail && tao_tail == Closure->readErrors && !Closure->noTruncate)
{ int answer;
#ifndef CLI
if(Closure->guiMode)
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("%d sectors missing at the end of the disc.\n"
"This is okay if the CD was written in TAO (track at once) mode.\n"
"The Image will be truncated accordingly. See the manual for details.\n"),
tao_tail);
else
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
else
#endif
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("%d sectors missing at the end of the disc.\n"
"This is okay if the CD was written in TAO (track at once) mode.\n"
"The Image will be truncated accordingly. See the manual for details.\n"

View File

@@ -476,7 +476,7 @@ static int simple_lec(RawBuffer *rb, unsigned char *frame, char *msg)
if(q_failures || p_failures || q_corrected || p_corrected)
{
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld L-EC P/Q results: %d/%d failures, %d/%d corrected (%s).\n",
rb->lba, p_failures, q_failures, p_corrected, q_corrected, msg);
return 1;
@@ -558,7 +558,7 @@ int ValidateRawSector(RawBuffer *rb, unsigned char *frame, char *msg)
/* Tell user that L-EC succeeded */
if(lec_did_sth)
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by L-EC.\n",
rb->lba);
@@ -891,7 +891,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Good. Data section passes EDC test.\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -907,7 +907,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader after correcting sync pattern.\n",
rb->lba);
@@ -924,7 +924,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by iterative L-EC.\n",
rb->lba);
@@ -947,7 +947,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by smart L-EC.\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -959,7 +959,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by plausible sector search (0).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -970,7 +970,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by brute force plausible sector search (0).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -981,7 +981,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by mutual ack heuristic (0).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -992,7 +992,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by heuristic L-EC (0).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -1003,7 +1003,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by plausible sector search (1).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -1014,7 +1014,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by brute force plausible sector search (1).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -1025,7 +1025,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by mutual ack heuristic (1).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);
@@ -1036,7 +1036,7 @@ int TryCDFrameRecovery(RawBuffer *rb, unsigned char *outbuf)
if(CheckEDC(rb->recovered, rb->xaMode)
&& CheckMSF(rb->recovered, rb->lba, STRICT_MSF_CHECK))
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
"Sector %lld: Recovered in raw reader by heuristic L-EC (1).\n",
rb->lba);
memcpy(outbuf, rb->recovered+rb->dataOffset, 2048);

View File

@@ -206,22 +206,29 @@ void RS01ReadSector(Image *image, unsigned char *buf, gint64 s)
#define CRCBUFSIZE (1024*256)
void RS01ScanImage(Method *method, Image* image, struct MD5Context *ecc_ctxt, int mode)
{ RS01Widgets *wl = NULL;
{
#ifndef CLI
RS01Widgets *wl = NULL;
#endif
unsigned char buf[2048];
guint32 *crcbuf = NULL;
int unrecoverable_sectors = 0;
int crcidx = 0;
struct MD5Context image_md5;
gint64 s, first_missing, last_missing;
#ifndef CLI
gint64 prev_missing = 0;
gint64 prev_crc_errors = 0;
#endif
int last_percent,current_missing;
char *msg;
/* Extract widget list from method */
#ifndef CLI
if(method->widgetList)
wl = (RS01Widgets*)method->widgetList;
#endif
/* Position behind the ecc file header,
initialize CRC buffer pointers */
@@ -256,11 +263,13 @@ void RS01ScanImage(Method *method, Image* image, struct MD5Context *ecc_ctxt, in
/* Check for user interruption */
#ifndef CLI
if(Closure->stopActions)
{ image->sectorsMissing += image->sectorSize - s;
if(crcbuf) g_free(crcbuf);
return;
}
#endif
/* Read the next sector */
@@ -352,12 +361,16 @@ void RS01ScanImage(Method *method, Image* image, struct MD5Context *ecc_ctxt, in
MD5Update(&image_md5, buf, n); /* update image md5sum */
#ifndef CLI
if(Closure->guiMode && mode & PRINT_MODE)
percent = (VERIFY_IMAGE_SEGMENTS*(s+1))/image->sectorSize;
else percent = (100*(s+1))/image->sectorSize;
else
#endif
percent = (100*(s+1))/image->sectorSize;
if(last_percent != percent)
{ PrintProgress(msg,percent);
#ifndef CLI
if(Closure->guiMode && mode & CREATE_CRC)
SetProgress(wl->encPBar1, percent, 100);
@@ -369,6 +382,7 @@ void RS01ScanImage(Method *method, Image* image, struct MD5Context *ecc_ctxt, in
prev_missing = image->sectorsMissing;
prev_crc_errors = image->crcErrors;
}
#endif
last_percent = percent;
}

View File

@@ -97,20 +97,29 @@ static int calculate_redundancy(char *image_name)
*** Remove the image file
***/
#ifndef CLI
static void unlink_image(GtkWidget *label)
#else
static void unlink_image(void *label)
#endif
{
if(LargeUnlink(Closure->imageName))
{ PrintLog(_("\nImage file %s deleted.\n"),Closure->imageName);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(label),
_("\nImage file %s deleted.\n"), Closure->imageName);
#endif
}
else
{ if(!Closure->guiMode)
{
#ifndef CLI
if(!Closure->guiMode)
#endif
PrintLog("\n");
ModalWarning(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, NULL,
ModalWarningOrCLI(GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, NULL,
_("Image file %s not deleted: %s\n"),
Closure->imageName, strerror(errno));
}
@@ -126,7 +135,9 @@ static void unlink_image(GtkWidget *label)
typedef struct
{ Method *self;
#ifndef CLI
RS01Widgets *wl;
#endif
GaloisTables *gt;
ReedSolomonTables *rt;
Image *image;
@@ -142,6 +153,7 @@ static void ecc_cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
{ if(ec->earlyTermination)
SetLabelText(GTK_LABEL(ec->wl->encFootline),
@@ -149,6 +161,7 @@ static void ecc_cleanup(gpointer data)
Closure->redMarkup);
AllowActions(TRUE);
}
#endif
/** Clean up */
@@ -163,13 +176,17 @@ static void ecc_cleanup(gpointer data)
if(Closure->enableCurveSwitch)
{ Closure->enableCurveSwitch = FALSE;
#ifndef CLI
RS01ShowCurveButton(ec->self);
#endif
}
g_free(ec);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/*
@@ -180,7 +197,9 @@ enum { NORMAL, HIGH, GENERIC };
void RS01Create(void)
{ Method *self = FindMethod("RS01");
#ifndef CLI
RS01Widgets *wl = (RS01Widgets*)self->widgetList;
#endif
GaloisTables *gt;
ReedSolomonTables *rt;
ecc_closure *ec = g_malloc0(sizeof(ecc_closure));
@@ -205,7 +224,9 @@ void RS01Create(void)
/*** Register the cleanup procedure for GUI mode */
ec->self = self;
#ifndef CLI
ec->wl = wl;
#endif
ec->earlyTermination = TRUE;
RegisterCleanup(_("Error correction file creation aborted"), ecc_cleanup, ec);
@@ -234,9 +255,11 @@ void RS01Create(void)
nroots,
((double)nroots*100.0)/(double)ndata);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->encHeadline),
_("<big>Creating the error correction file.</big>\n<i>%s</i>"), ec->msg);
#endif
/*** Test the image file and create the CRC sums */
@@ -246,6 +269,7 @@ void RS01Create(void)
{
if(ConfirmEccDeletion(Closure->eccName))
LargeUnlink(Closure->eccName);
#ifndef CLI /* ConfirmEccDeletion always return true if CLI */
else
{ SetLabelText(GTK_LABEL(ec->wl->encFootline),
_("<span %s>Aborted to keep existing ecc file.</span>"),
@@ -253,6 +277,7 @@ void RS01Create(void)
ec->earlyTermination = FALSE;
goto terminate;
}
#endif
}
/* Open image and ecc files */
@@ -286,9 +311,11 @@ void RS01Create(void)
int percent, last_percent = 0;
char *msg = _("Writing sector checksums: %3d%%");
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->encLabel1),
_("<b>1. Writing image sector checksums:</b>"));
#endif
memcpy(image->mediumSum, Closure->crcBuf->imageMD5sum, 16);
MD5Init(&md5Ctxt); /* md5sum of CRC portion of ecc file */
@@ -319,8 +346,10 @@ void RS01Create(void)
if(last_percent != percent)
{ PrintProgress(msg,percent);
#ifndef CLI
if(Closure->guiMode)
SetProgress(wl->encPBar1, percent, 100);
#endif
last_percent = percent;
}
@@ -333,9 +362,12 @@ void RS01Create(void)
Scan image for missing sectors and calculate the checksums.
Checksums are only computed locally and not provided in the cache. */
else
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->encLabel1),
_("<b>1. Calculating image sector checksums:</b>"));
#endif
FreeCrcBuf(Closure->crcBuf); /* just a defensive measure */
Closure->crcBuf = NULL;
@@ -348,6 +380,7 @@ void RS01Create(void)
LargeUnlink(Closure->eccName); /* Do not leave a CRC-only .ecc file behind */
#ifndef CLI
if(Closure->stopActions)
{
if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
@@ -358,8 +391,12 @@ void RS01Create(void)
goto terminate;
}
else
{ if(Closure->guiMode)
#endif
{
#ifndef CLI
if(Closure->guiMode)
SetProgress(wl->encPBar1, 100, 100);
#endif
Stop(_("%lld sectors unread or missing due to errors.\n"), image->sectorsMissing);
}
@@ -368,6 +405,7 @@ void RS01Create(void)
PrintTimeToLog(ec->timer, "for CRC writing/generation.\n");
#ifndef CLI
if(Closure->guiMode)
{ SetProgress(wl->encPBar1, 100, 100);
ShowWidget(wl->encPBar2);
@@ -375,6 +413,7 @@ void RS01Create(void)
}
if(!Closure->guiMode)
#endif
PrintLog("%s\n",ec->msg);
/*** Prepare Ecc file header.
@@ -492,6 +531,7 @@ void RS01Create(void)
{ int offset = 0;
unsigned char *par_idx = ec->parity;
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->encFootline),
@@ -503,6 +543,7 @@ void RS01Create(void)
LargeUnlink(Closure->eccName); /* Do not leave partial .ecc file behind */
goto terminate;
}
#endif
/* Read the next data sectors of this layer. */
@@ -569,9 +610,12 @@ void RS01Create(void)
progress++;
percent = (1000*progress)/max_percent;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetProgress(wl->encPBar2, percent, 1000);
else
#endif
PrintProgress(_("Ecc generation: %3d.%1d%%"), percent/10, percent%10);
last_percent = percent;
}
@@ -585,6 +629,7 @@ void RS01Create(void)
{ int offset = 0;
unsigned char *par_idx = ec->parity;
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->encFootline),
@@ -596,6 +641,7 @@ void RS01Create(void)
LargeUnlink(Closure->eccName); /* Do not leave partial .ecc file behind */
goto terminate;
}
#endif
/* Read the next data sectors of this layer. */
@@ -694,9 +740,12 @@ void RS01Create(void)
progress++;
percent = (1000*progress)/max_percent;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetProgress(wl->encPBar2, percent, 1000);
else
#endif
PrintProgress(_("Ecc generation: %3d.%1d%%"), percent/10, percent%10);
last_percent = percent;
}
@@ -713,6 +762,7 @@ void RS01Create(void)
{ int offset = 0;
unsigned char *par_idx = ec->parity;
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->encFootline),
@@ -724,6 +774,7 @@ void RS01Create(void)
LargeUnlink(Closure->eccName); /* Do not leave partial .ecc file behind */
goto terminate;
}
#endif
/* Read the next data sectors of this layer. */
@@ -989,9 +1040,12 @@ void RS01Create(void)
progress++;
percent = (1000*progress)/max_percent;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetProgress(wl->encPBar2, percent, 1000);
else
#endif
PrintProgress(_("Ecc generation: %3d.%1d%%"), percent/10, percent%10);
last_percent = percent;
}
@@ -1033,6 +1087,7 @@ void RS01Create(void)
"Make sure to keep this file on a reliable medium.\n"),
Closure->eccName);
#ifndef CLI
if(Closure->guiMode)
{ SetProgress(wl->encPBar2, 100, 100);
@@ -1040,6 +1095,7 @@ void RS01Create(void)
_("The error correction file has been successfully created.\n"
"Make sure to keep this file on a reliable medium."));
}
#endif
/*** If the --unlink option or respective GUI switch is set,
unlink the image. */
@@ -1047,14 +1103,20 @@ void RS01Create(void)
if(Closure->unlinkImage)
{ if(ec->image) CloseImage(ec->image);
ec->image = NULL;
#ifndef CLI
unlink_image(Closure->guiMode ? wl->encFootline2 : NULL);
#else
unlink_image(NULL);
#endif
}
/*** Clean up */
ec->earlyTermination = FALSE;
#ifndef CLI
terminate:
#endif
ecc_cleanup((gpointer)ec);
}

View File

@@ -54,7 +54,10 @@ static void read_crc(LargeFile *ecc, guint32 *buf, int first_sector, int n_secto
*/
typedef struct
{ RS01Widgets *wl;
{
#ifndef CLI
RS01Widgets *wl;
#endif
GaloisTables *gt;
ReedSolomonTables *rt;
Image *image;
@@ -70,6 +73,7 @@ static void fix_cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
{ if(fc->earlyTermination)
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -78,6 +82,7 @@ static void fix_cleanup(gpointer data)
Closure->redMarkup);
AllowActions(TRUE);
}
#endif
/** Clean up */
@@ -96,8 +101,10 @@ static void fix_cleanup(gpointer data)
g_free(fc);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/*
@@ -105,8 +112,11 @@ static void fix_cleanup(gpointer data)
*/
void RS01Fix(Image *image)
{ Method *method = FindMethod("RS01");
{
#ifndef CLI
Method *method = FindMethod("RS01");
RS01Widgets *wl = (RS01Widgets*)method->widgetList;
#endif
GaloisTables *gt;
ReedSolomonTables *rt;
fix_closure *fc = g_malloc0(sizeof(fix_closure));
@@ -131,7 +141,9 @@ void RS01Fix(Image *image)
/*** Register the cleanup procedure for GUI mode */
fc->image = image;
#ifndef CLI
fc->wl = wl;
#endif
fc->earlyTermination = TRUE;
RegisterCleanup(_("Repairing of image aborted"), fix_cleanup, fc);
@@ -143,11 +155,13 @@ void RS01Fix(Image *image)
eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->fixHeadline),
_("<big>Repairing the image.</big>\n<i>%s</i>"),fc->msg);
RS01SetFixMaxValues(wl, eh->dataBytes, eh->eccBytes, image->sectorSize);
}
#endif
PrintLog(_("\nFix mode(%s): Repairable sectors will be fixed in the image.\n"),
"RS01");
@@ -190,17 +204,21 @@ void RS01Fix(Image *image)
"the image and ecc files do not belong together.\n\n%s");
if(diff>0 && diff<=2)
{ int answer = ModalWarning(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
{
int answer = ModalWarningOrCLI(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image file is %lld sectors longer than expected.\n"
"Assuming this is a TAO mode medium.\n"
"%lld sectors will be removed from the image end.\n"),
diff, diff);
if(!answer)
{ SwitchAndSetFootline(fc->wl->fixNotebook, 1,
{
#ifndef CLI
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
fc->wl->fixFootline,
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup);
#endif
fc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
@@ -212,6 +230,7 @@ void RS01Fix(Image *image)
Stop(_("Could not truncate %s: %s\n"),Closure->imageName,strerror(errno));
}
#ifndef CLI
if(diff>2 && Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
trans,
@@ -235,8 +254,14 @@ void RS01Fix(Image *image)
PrintLog(_("Image has been truncated by %lld sectors.\n"), diff);
}
#endif
if(diff>2 && !Closure->guiMode)
if(diff>2 &&
#ifndef CLI
!Closure->guiMode)
#else
1)
#endif
{ if(!Closure->truncate)
Stop(trans,
diff,
@@ -256,6 +281,7 @@ void RS01Fix(Image *image)
if(image->sectorSize == image->expectedSectors && image->inLast > eh->inLast)
{ int difference = image->inLast - eh->inLast;
#ifndef CLI
if(Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("The image file is %d bytes longer than noted\n"
@@ -272,8 +298,13 @@ void RS01Fix(Image *image)
goto terminate;
}
}
#endif
#ifndef CLI
if(!Closure->guiMode && !Closure->truncate)
#else
if(!Closure->truncate)
#endif
Stop(_("The image file is %d bytes longer than noted\n"
"in the ecc file.\n"
"Add the --truncate option to the program call\n"
@@ -290,14 +321,17 @@ void RS01Fix(Image *image)
if(image->sectorSize < image->expectedSectors)
{ int answer;
answer = ModalWarning(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image file appears to be truncated.\n"
"Consider completing it with another reading pass before going on.\n"));
"Consider completing it with another reading pass before going on.\n"), NULL);
if(!answer)
{ SwitchAndSetFootline(fc->wl->fixNotebook, 1,
{
#ifndef CLI
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
fc->wl->fixFootline,
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup);
#endif
fc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
@@ -306,15 +340,18 @@ void RS01Fix(Image *image)
if(image->fpState != FP_PRESENT)
{ int answer;
answer = ModalWarning(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("Sector %d is missing. Can not compare image and ecc fingerprints.\n"
"Double check that image and ecc file belong together.\n"),
eh->fpSector);
if(!answer)
{ SwitchAndSetFootline(fc->wl->fixNotebook, 1,
{
#ifndef CLI
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
fc->wl->fixFootline,
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup);
#endif
fc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
@@ -362,6 +399,7 @@ void RS01Fix(Image *image)
for(si=0; si<s; si++)
{
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -371,6 +409,7 @@ void RS01Fix(Image *image)
fc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
#endif
/* Read the next batch of (cache_size * ndata) medium sectors
if the cache ran empty. */
@@ -433,7 +472,10 @@ void RS01Fix(Image *image)
and try to correct them. */
if(erasure_count>nroots) /* uncorrectable */
{ if(!Closure->guiMode)
{
#ifndef CLI
if(!Closure->guiMode)
#endif
{ PrintCLI(_("* %3d unrepairable sectors: "), erasure_count);
for(i=0; i<erasure_count; i++)
@@ -742,14 +784,18 @@ skip:
percent = (1000*(si+1))/s;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
{
RS01AddFixValues(wl, percent, local_plot_max);
local_plot_max = 0;
RS01UpdateFixResults(wl, corrected, uncorrected);
}
else PrintProgress(_("Ecc progress: %3d.%1d%%"),percent/10,percent%10);
else
#endif
PrintProgress(_("Ecc progress: %3d.%1d%%"),percent/10,percent%10);
last_percent = percent;
}
@@ -765,11 +811,13 @@ skip:
if(corrected > 0) PrintLog(_("Repaired sectors: %lld \n"),corrected);
if(uncorrected > 0)
{ PrintLog(_("Unrepaired sectors: %lld\n"), uncorrected);
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
_("Image sectors could not be fully restored "
"(%lld repaired; <span %s>%lld unrepaired</span>)"),
corrected, Closure->redMarkup, uncorrected);
#endif
}
else
{ if(!corrected)
@@ -785,9 +833,11 @@ skip:
PrintLog(_("Erasure counts per ecc block: avg = %.1f; worst = %d.\n"),
(double)damaged_sec/(double)damaged_ecc,worst_ecc);
#ifndef CLI
if(Closure->guiMode && t)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
"%s %s", _("Repair results:"), t);
#endif
/*** Clean up */

View File

@@ -23,6 +23,7 @@
#ifndef RS01INCLUDES_H
#define RS01INCLUDES_H
#ifndef CLI
/* Data structs from rs01-window.c */
typedef struct
@@ -96,6 +97,7 @@ typedef struct
int dataBytes;
int percent, lastPercent;
} RS01Widgets;
#endif
/*
* local working closure for internal checksums
@@ -105,6 +107,7 @@ typedef struct
{ struct MD5Context md5ctxt; /* Complete image checksum */
} RS01CksumClosure;
#ifndef CLI
/*
* These are exported via the Method struct
*/
@@ -120,6 +123,7 @@ void RS01ShowCurveButton(Method*);
void ResetRS01VerifyWindow(Method*);
void CreateRS01VerifyWindow(Method*, GtkWidget*);
#endif
/*
* These are exported (resp. only used) in ecc-rs01.c and rs01*.c
@@ -155,11 +159,13 @@ void RS01Create(void);
void RS01Fix(Image*);
#ifndef CLI
/* rs01-window.c */
void RS01AddFixValues(RS01Widgets*, int, int);
void RS01SetFixMaxValues(RS01Widgets*, int, int, gint64);
void RS01UpdateFixResults(RS01Widgets*, gint64, gint64);
#endif
/* rs01-verify.c */

View File

@@ -24,6 +24,8 @@
#include "rs01-includes.h"
#ifndef CLI
/***
*** Reset the verify output window
***/
@@ -339,6 +341,7 @@ void CreateRS01VerifyWindow(Method *self, GtkWidget *parent)
gtk_misc_set_alignment(GTK_MISC(lab), 0.0, 0.0);
gtk_table_attach(GTK_TABLE(table2), lab, 0, 2, 8, 9, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 5, 4);
}
#endif
/***
*** Verify the prefix.* files
@@ -353,23 +356,31 @@ static void cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
AllowActions(TRUE);
#endif
if(vc->image) CloseImage(vc->image);
g_free(vc);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
void RS01Verify(Image *image)
{ verify_closure *vc = g_malloc0(sizeof(verify_closure));
Method *self = FindMethod("RS01");
#ifndef CLI
RS01Widgets *wl = (RS01Widgets*)self->widgetList;
#endif
char idigest[33],edigest[33];
gint64 excess_sectors = 0;
#ifndef CLI
char *ecc_advice = NULL;
#endif
EccHeader *eh;
gint8 method[5];
@@ -388,12 +399,15 @@ void RS01Verify(Image *image)
/*** Examine the .iso file */
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpHeadline), "<big>%s</big>\n<i>%s</i>",
_("Comparing image and error correction files."),
_("- Checking image file -"));
#endif
vc->image = image;
#ifndef CLI
if(image && image->eccFile)
{ if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpChkSumErrors), "0");
@@ -401,6 +415,7 @@ void RS01Verify(Image *image)
else
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpChkSumErrors), _("n/a"));
#endif
/* Report basic image properties */
@@ -408,27 +423,34 @@ void RS01Verify(Image *image)
if(!image || !image->file)
{ PrintLog(_("not present\n"));
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->cmpImageNotebook, 0, NULL, NULL);
#endif
goto process_ecc;
}
if(image->inLast == 2048)
{ PrintLog(_("present, contains %lld medium sectors.\n"), image->sectorSize);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpImageSectors), "%lld", image->sectorSize);
#endif
}
else
{ PrintLog(_("present, contains %lld medium sectors and %d bytes.\n"),
image->sectorSize-1, image->inLast);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpImageSectors), _("%lld sectors + %d bytes"),
image->sectorSize-1, image->inLast);
#endif
}
if(!Closure->quickVerify)
RS01ScanImage(self, image, NULL, PRINT_MODE);
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->cmpImageResult),
@@ -436,6 +458,7 @@ void RS01Verify(Image *image)
Closure->redMarkup);
goto terminate;
}
#endif
/*** Peek into the ecc file to get expected sector count */
@@ -446,10 +469,12 @@ void RS01Verify(Image *image)
{ diff = image->expectedSectors - image->sectorSize;
PrintLog(_("* truncated image : %lld sectors too short\n"), diff);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpImageSectors),
_("<span %s>%lld (%lld sectors too short)</span>"),
Closure->redMarkup, image->sectorSize, diff);
#endif
image->sectorsMissing += diff;
}
if(image->sectorSize > image->expectedSectors)
@@ -459,6 +484,7 @@ void RS01Verify(Image *image)
/*** Show summary of image read */
#ifndef CLI
if(Closure->guiMode)
{ if(image->crcErrors)
SetLabelText(GTK_LABEL(wl->cmpChkSumErrors),
@@ -467,9 +493,11 @@ void RS01Verify(Image *image)
SetLabelText(GTK_LABEL(wl->cmpMissingSectors),
"<span %s>%lld</span>", Closure->redMarkup, image->sectorsMissing);
}
#endif
if(excess_sectors)
{ PrintLog(_("* image too long : %lld excess sectors\n"), excess_sectors);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpImageSectors),
_("<span %s>%lld (%lld excess sectors)</span>"),
@@ -478,6 +506,7 @@ void RS01Verify(Image *image)
_("<span %s>Bad image.</span>"),
Closure->redMarkup);
}
#endif
}
else if(Closure->quickVerify)
{ PrintLog(_("* quick mode : image NOT scanned\n"));
@@ -490,19 +519,23 @@ void RS01Verify(Image *image)
if(!image->crcErrors)
{ PrintLog(_("- good image : all sectors present\n"
"- image md5sum : %s\n"),idigest);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpImageResult),_("<span %s>Good image.</span>"), Closure->greenMarkup);
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "%s", idigest);
}
#endif
}
else
{ PrintLog(_("* suspicious image : all sectors present, but %lld CRC errors\n"
"- image md5sum : %s\n"),image->crcErrors,idigest);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpImageResult), _("<span %s>Image complete, but contains checksum errors!</span>"), Closure->redMarkup);
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "%s", idigest);
}
#endif
}
}
else /* sectors are missing */
@@ -510,27 +543,33 @@ void RS01Verify(Image *image)
PrintLog(_("* BAD image : %lld sectors missing\n"), image->sectorsMissing);
else PrintLog(_("* BAD image : %lld sectors missing, %lld CRC errors\n"),
image->sectorsMissing, image->crcErrors);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpImageResult),
_("<span %s>Bad image.</span>"), Closure->redMarkup);
#endif
}
}
/*** The .ecc file */
process_ecc:
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpHeadline), "<big>%s</big>\n<i>%s</i>",
_("Comparing image and error correction files."),
_("- Checking ecc file -"));
#endif
PrintLog("\n%s: ", Closure->eccName);
if(!image)
{ PrintLog(_("not present\n"));
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->cmpEccNotebook, 0,
wl->cmpEccEmptyMsg,_("No error correction file present."));
#endif
goto skip_ecc;
}
@@ -556,9 +595,11 @@ process_ecc:
PrintLog(_("unusable\n"));
break;
}
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->cmpEccNotebook, 0,
wl->cmpEccEmptyMsg,_("No error correction file present."));
#endif
goto skip_ecc;
}
@@ -584,29 +625,35 @@ process_ecc:
PrintLog(format, _("created by dvdisaster"), major, minor, micro, unstable);
PrintLog("\n");
#ifndef CLI
if(Closure->guiMode)
{ SwitchAndSetFootline(wl->cmpEccNotebook, 1,
wl->cmpEccCreatedBy,
format, "dvdisaster",
major, minor, micro, unstable);
}
#endif
}
else /* version format x.xx */
{ char *format = "%s-%d.%d%s";
PrintLog(format, _("created by dvdisaster"),
major, minor, unstable);
PrintLog("\n");
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
wl->cmpEccCreatedBy, format, "dvdisaster",
major, minor, unstable);
#endif
}
}
else
{ PrintLog(_("created by dvdisaster-0.41.x.\n"));
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
wl->cmpEccCreatedBy, "dvdisaster-0.41.x");
#endif
}
/* Information on RS01 properties */
@@ -616,10 +663,12 @@ process_ecc:
PrintLog(_("- method : %4s, %d roots, %4.1f%% redundancy.\n"),
method, eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMethod), _("%4s, %d roots, %4.1f%% redundancy"),
method, eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
#endif
/* Show and verify needed version */
@@ -627,10 +676,12 @@ process_ecc:
{ PrintLog(_("- requires : dvdisaster-%d.%d (good)\n"),
eh->neededVersion/10000,
(eh->neededVersion%10000)/100);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccRequires), "dvdisaster-%d.%d",
eh->neededVersion/10000,
(eh->neededVersion%10000)/100);
#endif
}
else
{ PrintLog(_("* requires : dvdisaster-%d.%d (BAD)\n"
@@ -639,6 +690,7 @@ process_ecc:
eh->neededVersion/10000,
(eh->neededVersion%10000)/100);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccRequires),
"<span %s>dvdisaster-%d.%d</span>",
@@ -648,6 +700,7 @@ process_ecc:
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Please upgrade your version of dvdisaster!</span>"), Closure->redMarkup);
}
#endif
}
@@ -659,16 +712,20 @@ process_ecc:
if(!image->file)
{ if(!ecc_in_last)
{ PrintLog(_("- medium sectors : %lld\n"), image->expectedSectors);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "%lld", image->expectedSectors);
#endif
}
else
{ PrintLog(_("- medium sectors : %lld sectors + %d bytes\n"),
image->expectedSectors-1, ecc_in_last);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
_("%lld sectors + %d bytes"),
image->expectedSectors-1, ecc_in_last);
#endif
}
}
@@ -678,16 +735,20 @@ process_ecc:
&& (!ecc_in_last || image->inLast == eh->inLast))
{ if(!ecc_in_last)
{ PrintLog(_("- medium sectors : %lld (good)\n"), image->expectedSectors);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "%lld", image->expectedSectors);
#endif
}
else
{ PrintLog(_("- medium sectors : %lld sectors + %d bytes (good)\n"),
image->expectedSectors-1, ecc_in_last);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
_("%lld sectors + %d bytes"),
image->expectedSectors-1, ecc_in_last);
#endif
}
}
@@ -695,6 +756,7 @@ process_ecc:
{ /* TAO case (1 or 2 sectors more than expected) */
if(image->sectorSize > image->expectedSectors && image->sectorSize - image->expectedSectors <= 2)
{ PrintLog(_("* medium sectors : %lld (BAD, perhaps TAO/DAO mismatch)\n"), image->expectedSectors);
#ifndef CLI
if(Closure->guiMode)
{ if(!ecc_in_last)
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld</span>",
@@ -702,20 +764,24 @@ process_ecc:
else SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld sectors + %d bytes</span>",
Closure->redMarkup, image->expectedSectors-1, ecc_in_last);
}
#endif
}
else /* more than 2 Sectors difference */
{ if(!ecc_in_last)
{ PrintLog(_("* medium sectors : %lld (BAD)\n"), image->expectedSectors);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "<span %s>%lld</span>",
Closure->redMarkup, image->expectedSectors);
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Image size does not match error correction file.</span>"), Closure->redMarkup);
}
#endif
}
else /* byte size difference */
{ PrintLog(_("* medium sectors : %lld sectors + %d bytes (BAD)\n"),
image->expectedSectors-1, ecc_in_last);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
_("<span %s>%lld sectors + %d bytes</span>"),
@@ -723,6 +789,7 @@ process_ecc:
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Image size does not match error correction file.</span>"), Closure->redMarkup);
}
#endif
}
}
}
@@ -736,6 +803,7 @@ process_ecc:
{ int n = !memcmp(eh->mediumSum, image->mediumSum, 16);
if(n) PrintLog(_("- image md5sum : %s (good)\n"),edigest);
else PrintLog(_("* image md5sum : %s (BAD)\n"),edigest);
#ifndef CLI
if(Closure->guiMode)
{ if(n) SetLabelText(GTK_LABEL(wl->cmpEccImgMd5Sum), "%s", edigest);
else
@@ -743,25 +811,31 @@ process_ecc:
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "<span %s>%s</span>", Closure->redMarkup, idigest);
}
}
#endif
}
else
{ PrintLog(_("- image md5sum : %s\n"),edigest);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccImgMd5Sum), "%s", edigest);
#endif
}
}
if(image && image->file)
{ if(image->fpState != FP_PRESENT)
{ PrintLog(_("* fingerprint match: NOT POSSIBLE - related sector is missing in image!\n"));
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("<span %s>missing sector prevents calculation</span>"), Closure->redMarkup);
#endif
}
else
{
if(memcmp(image->imageFP, eh->mediumFP, 16))
{ PrintLog(_("* fingerprint match: MISMATCH - .iso and .ecc don't belong together!\n"));
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccFingerprint),
_("<span %s>mismatch</span>"), Closure->redMarkup);
@@ -769,11 +843,14 @@ process_ecc:
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Image and error correction files do not belong together!</span>"), Closure->redMarkup);
}
#endif
}
else
{ PrintLog(_("- fingerprint match: good\n"));
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("good"));
#endif
}
}
}
@@ -790,13 +867,17 @@ process_ecc:
if(ecc_expected == ecc_blocks)
{ PrintLog(_("- ecc blocks : %lld (good)\n"),ecc_blocks);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccBlocks), "%lld", ecc_blocks);
#endif
}
else
{ PrintLog(_("* ecc blocks : %lld (BAD, expected %lld)\n"),ecc_blocks,ecc_expected);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccBlocks), _("<span %s>%lld (bad, expected %lld)</span>"),Closure->redMarkup,ecc_blocks,ecc_expected);
#endif
}
/*** Test ecc file against its own md5sum */
@@ -817,18 +898,25 @@ process_ecc:
count += n;
percent = (100*count)/image->eccFile->size;
if(last_percent != percent)
{ if(!Closure->guiMode)
{
#ifndef CLI
if(!Closure->guiMode)
#endif
PrintProgress(_("- ecc md5sum : %3d%%"),percent);
#ifndef CLI
else SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), "%3d%%", percent);
#endif
last_percent = percent;
}
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->cmpEccResult),
_("<span %s>Aborted by user request!</span>"), Closure->redMarkup);
goto terminate;
}
#endif
}
MD5Final(digest, &md5ctxt);
@@ -836,21 +924,26 @@ process_ecc:
if(memcmp(eh->eccSum, digest, 16))
{ PrintLog(_("* ecc md5sum : BAD, ecc file may be damaged!\n"));
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), _("<span %s>bad</span>"), Closure->redMarkup);
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Error correction file may be damaged!</span>"), Closure->redMarkup);
}
#endif
}
else
{ PrintLog(_("- ecc md5sum : %s (good)\n"),edigest);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMd5Sum), "%s", edigest);
#endif
}
skip_ecc:
PrintLog("\n");
#ifndef CLI
if(Closure->guiMode)
{ if(ecc_advice)
{ SetLabelText(GTK_LABEL(wl->cmpEccResult), ecc_advice);
@@ -860,6 +953,7 @@ skip_ecc:
_("<span %s>Good error correction file.</span>"),
Closure->greenMarkup);
}
#endif
/*** Close and clean up */

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -430,14 +430,19 @@ RS02Layout *CalcRS02Layout(Image *image)
/* See if user wants to pick a certain redundancy */
#ifndef CLI
if(!Closure->guiMode && Closure->redundancy)
#else
if(Closure->redundancy)
#endif
{ int len = strlen(Closure->redundancy);
switch(Closure->redundancy[len-1])
{ case 'r': /* pick number of roots */
{ char buf[len];
{ char buf[len+1];
strncpy(buf, Closure->redundancy, len-1);
memcpy(buf, Closure->redundancy, len);
buf[len] = '\0';
requested_roots = atoi(buf);
break;
}
@@ -445,7 +450,8 @@ RS02Layout *CalcRS02Layout(Image *image)
{ char buf[len];
int percent;
strncpy(buf, Closure->redundancy, len-1);
memcpy(buf, Closure->redundancy, len-1);
buf[len-1] = '\0';
percent = atoi(buf);
for(requested_roots = 7; requested_roots < 171; requested_roots++)

View File

@@ -31,7 +31,9 @@
typedef struct
{ Image *image;
Method *self;
#ifndef CLI
RS02Widgets *wl;
#endif
RS02Layout *lay;
GaloisTables *gt;
ReedSolomonTables *rt;
@@ -54,6 +56,7 @@ static void ecc_cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
{ if(ec->earlyTermination && ec->wl)
SetLabelText(GTK_LABEL(ec->wl->encFootline),
@@ -61,6 +64,7 @@ static void ecc_cleanup(gpointer data)
Closure->redMarkup);
AllowActions(TRUE);
}
#endif
/*** We must invalidate the CRC cache as it does only cover the
data portion of the image, not the full RS02 enhanced image. */
@@ -88,8 +92,10 @@ static void ecc_cleanup(gpointer data)
g_free(ec);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/***
@@ -101,23 +107,30 @@ static void ecc_cleanup(gpointer data)
*/
static void abort_encoding(ecc_closure *ec, int truncate)
{ RS02Widgets *wl = ec->wl;
{
#ifndef CLI
RS02Widgets *wl = ec->wl;
#endif
if(truncate && ec->lay)
{ if(!LargeTruncate(ec->image->file, (gint64)(2048*ec->lay->dataSectors)))
Stop(_("Could not truncate %s: %s\n"),Closure->imageName,strerror(errno));
#ifndef CLI
if(Closure->stopActions == STOP_CURRENT_ACTION)
SetLabelText(GTK_LABEL(wl->encFootline),
_("<span %s>Aborted by user request!</span> (partial ecc data removed from image)"),
Closure->redMarkup);
#endif
}
#ifndef CLI
else
{ if(Closure->stopActions == STOP_CURRENT_ACTION)
SetLabelText(GTK_LABEL(wl->encFootline),
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup);
}
#endif
ec->earlyTermination = FALSE; /* suppress respective error message */
@@ -136,12 +149,16 @@ static void remove_old_ecc(ecc_closure *ec)
guint64 data_bytes;
int answer;
#ifndef CLI
if(Closure->confirmDeletion || !Closure->guiMode)
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
#endif
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image \"%s\" already contains error correction information.\n"
"Truncating image to data part (%lld sectors).\n"),
Closure->imageName, data_sectors);
#ifndef CLI
else answer = TRUE;
#endif
if(!answer)
abort_encoding(ec, FALSE);
@@ -196,8 +213,10 @@ static void check_image(ecc_closure *ec)
{ unsigned char buf[2048];
int expected,n,err;
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
abort_encoding(ec, FALSE);
#endif
if(sectors < image->sectorSize-1) expected = 2048;
else
@@ -237,8 +256,10 @@ static void check_image(ecc_closure *ec)
if(last_percent != percent)
{ PrintProgress(_("Preparing image (checksums, adding space): %3d%%") ,percent);
#ifndef CLI
if(Closure->guiMode)
SetProgress(ec->wl->encPBar1, percent, 100);
#endif
last_percent = percent;
}
@@ -287,8 +308,10 @@ static void expand_image(ecc_closure *ec)
{ unsigned char buf[2048];
int n;
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
abort_encoding(ec, TRUE);
#endif
CreateMissingSector(buf, lay->dataSectors+sectors,
image->imageFP, FINGERPRINT_SECTOR,
@@ -303,8 +326,10 @@ static void expand_image(ecc_closure *ec)
PrintProgress(_("Preparing image (checksums taken from cache, adding space): %3d%%") ,percent);
else PrintProgress(_("Preparing image (checksums, adding space): %3d%%"), percent);
#ifndef CLI
if(Closure->guiMode)
SetProgress(ec->wl->encPBar1, percent, 100);
#endif
last_percent = percent;
}
@@ -315,8 +340,10 @@ static void expand_image(ecc_closure *ec)
else PrintProgress(_("Preparing image (checksums, adding space): %3d%%"), 100);
PrintProgress("\n");
#ifndef CLI
if(Closure->guiMode)
SetProgress(ec->wl->encPBar1, 100, 100);
#endif
}
/*
@@ -468,10 +495,12 @@ static gint32 *enc_alpha_to;
/*** Show the second progress bar */
#ifndef CLI
if(Closure->guiMode)
{ ShowWidget(ec->wl->encPBar2);
ShowWidget(ec->wl->encLabel2);
}
#endif
/*** Adjust image bounds to include the CRC sectors */
@@ -578,8 +607,10 @@ static gint32 *enc_alpha_to;
{ int offset = 0;
unsigned char *par_idx = ec->parity;
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
abort_encoding(ec, TRUE);
#endif
/* Read the next data sectors of this layer. */
@@ -966,9 +997,12 @@ static gint32 *enc_alpha_to;
percent = (1000*progress)/max_percent;
if(last_percent != percent)
{
#ifndef CLI
if(Closure->guiMode)
SetProgress(ec->wl->encPBar2, percent, 1000);
else PrintProgress(_("Ecc generation: %3d.%1d%%"), percent/10, percent%10);
else
#endif
PrintProgress(_("Ecc generation: %3d.%1d%%"), percent/10, percent%10);
last_percent = percent;
}
@@ -1026,7 +1060,9 @@ static gint32 *enc_alpha_to;
void RS02Create(void)
{ Method *self = FindMethod("RS02");
#ifndef CLI
RS02Widgets *wl = (RS02Widgets*)self->widgetList;
#endif
Image *image = NULL;
RS02Layout *lay;
ecc_closure *ec = g_malloc0(sizeof(ecc_closure));
@@ -1054,14 +1090,18 @@ void RS02Create(void)
ec->image = image;
ec->self = self;
#ifndef CLI
ec->wl = wl;
#endif
ec->eh = g_malloc0(sizeof(EccHeader));
ec->timer = g_timer_new();
#ifndef CLI
if(Closure->guiMode) /* Preliminary fill text for the head line */
SetLabelText(GTK_LABEL(wl->encHeadline),
_("<big>Augmenting the image with error correction data.</big>\n<i>%s</i>"),
_("- checking image -"));
#endif
/*** If the image already contains error correction information, remove it. */
@@ -1073,6 +1113,7 @@ void RS02Create(void)
/*** Announce what we are going to do */
#ifndef CLI
if(Closure->guiMode) /* Preliminary fill text for the head line */
{ ec->msg = g_strdup_printf(_("Encoding with Method RS02: %lld MiB data, %lld MiB ecc (%d roots; %4.1f%% redundancy)."),
lay->dataSectors/512, lay->eccSectors/512, lay->nroots, lay->redundancy);
@@ -1082,6 +1123,7 @@ void RS02Create(void)
ec->msg);
}
else
#endif
{ ec->msg = g_strdup_printf(_("Augmenting image with Method RS02:\n %lld MiB data, %lld MiB ecc (%d roots; %4.1f%% redundancy)."),
lay->dataSectors/512, lay->eccSectors/512, lay->nroots, lay->redundancy);
@@ -1100,9 +1142,9 @@ void RS02Create(void)
if(lay->redundancy < 20)
{ int answer;
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Using redundancies below 20%%%% may not give\n"
"the expected data loss protection.\n"));
"the expected data loss protection.\n"), NULL);
if(!answer)
abort_encoding(ec, FALSE);
@@ -1138,6 +1180,7 @@ void RS02Create(void)
(lay->dataSectors + lay->eccSectors)/512,
lay->dataSectors+lay->eccSectors);
#ifndef CLI
if(Closure->guiMode)
{ SetProgress(wl->encPBar2, 100, 100);
@@ -1147,6 +1190,7 @@ void RS02Create(void)
(lay->dataSectors + lay->eccSectors)/512,
lay->dataSectors+lay->eccSectors);
}
#endif
/*** Clean up */

View File

@@ -32,7 +32,9 @@
typedef struct
{ Image *image;
EccHeader *eh;
#ifndef CLI
RS02Widgets *wl;
#endif
RS02Layout *lay;
GaloisTables *gt;
ReedSolomonTables *rt;
@@ -47,6 +49,7 @@ static void fix_cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
{ if(fc->earlyTermination)
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -55,6 +58,7 @@ static void fix_cleanup(gpointer data)
Closure->redMarkup);
AllowActions(TRUE);
}
#endif
/** Clean up */
@@ -73,8 +77,10 @@ static void fix_cleanup(gpointer data)
g_free(fc);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/*
@@ -104,17 +110,24 @@ static void expand_image(fix_closure *fc, gint64 new_size)
percent = (100*sectors) / new_sectors;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
;
else PrintProgress(_("Expanding image: %3d%%"), percent);
else
#endif
PrintProgress(_("Expanding image: %3d%%"), percent);
last_percent = percent;
}
}
#ifndef CLI
if(Closure->guiMode)
;
else
{ PrintProgress(_("Expanding image: %3d%%"), 100);
#endif
{
PrintProgress(_("Expanding image: %3d%%"), 100);
PrintProgress("\n");
}
@@ -127,8 +140,11 @@ static void expand_image(fix_closure *fc, gint64 new_size)
***/
void RS02Fix(Image *image)
{ Method *self = FindMethod("RS02");
{
#ifndef CLI
Method *self = FindMethod("RS02");
RS02Widgets *wl = (RS02Widgets*)self->widgetList;
#endif
RS02Layout *lay;
fix_closure *fc = g_malloc0(sizeof(fix_closure));
EccHeader *eh;
@@ -167,16 +183,20 @@ void RS02Fix(Image *image)
/*** Register the cleanup procedure for GUI mode */
fc->image = image;
#ifndef CLI
fc->wl = wl;
#endif
fc->earlyTermination = TRUE;
RegisterCleanup(_("Repairing of image aborted"), fix_cleanup, fc);
/*** Open the image file */
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->fixHeadline),
_("<big>Repairing the image.</big>\n<i>%s</i>"),
_("Opening files..."));
#endif
eh = fc->eh = image->eccHeader;
lay = fc->lay = RS02LayoutFromImage(image);
@@ -199,6 +219,7 @@ void RS02Fix(Image *image)
/*** Announce what we going to do */
#ifndef CLI
if(Closure->guiMode)
{ char *msg = g_strdup_printf(_("Image contains error correction data: Method RS02, %d roots, %4.1f%% redundancy."),
eh->eccBytes,
@@ -209,6 +230,7 @@ void RS02Fix(Image *image)
RS02SetFixMaxValues(wl, eh->dataBytes, eh->eccBytes, expected_sectors);
g_free(msg);
}
#endif
PrintLog(_("\nFix mode(%s): Repairable sectors will be fixed in the image.\n"),
"RS02");
@@ -223,18 +245,22 @@ void RS02Fix(Image *image)
"the error correction information.\n\n%s");
if(diff>0 && diff<=2)
{ int answer = ModalWarning(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
{ int answer;
answer = ModalWarningOrCLI(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image file is %lld sectors longer than expected.\n"
"Assuming this is a TAO mode medium.\n"
"%lld sectors will be removed from the image end.\n"),
diff, diff);
if(!answer)
{ SwitchAndSetFootline(fc->wl->fixNotebook, 1,
{
#ifndef CLI
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
fc->wl->fixFootline,
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup);
fc->earlyTermination = FALSE; /* suppress respective error message */
#endif
goto terminate;
}
@@ -242,6 +268,7 @@ void RS02Fix(Image *image)
Stop(_("Could not truncate %s: %s\n"),Closure->imageName,strerror(errno));
}
#ifndef CLI
if(diff>2 && Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
trans,
@@ -262,8 +289,13 @@ void RS02Fix(Image *image)
PrintLog(_("Image has been truncated by %lld sectors.\n"), diff);
}
#endif
#ifndef CLI
if(diff>2 && !Closure->guiMode)
#else
if(diff>2)
#endif
{ if(!Closure->truncate)
Stop(trans,
diff,
@@ -332,6 +364,7 @@ void RS02Fix(Image *image)
/* See if user hit the Stop button */
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -341,6 +374,7 @@ void RS02Fix(Image *image)
fc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
#endif
/* Make sure to wrap the block_idx[] ptr properly */
@@ -458,7 +492,10 @@ void RS02Fix(Image *image)
/* Trivially reject uncorrectable ecc block */
if(erasure_count>lay->nroots) /* uncorrectable */
{ if(!Closure->guiMode)
{
#ifndef CLI
if(!Closure->guiMode)
#endif
{ PrintCLI(_("* Ecc block %lld: %3d unrepairable sectors: "), s, erasure_count);
for(i=0; i<erasure_count; i++)
@@ -783,7 +820,9 @@ skip:
percent = (1000*s)/lay->sectorsPerLayer;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
{
RS02AddFixValues(wl, percent, local_plot_max);
local_plot_max = 0;
@@ -791,7 +830,9 @@ skip:
//if(last_corrected != corrected || last_uncorrected != uncorrected)
RS02UpdateFixResults(wl, corrected, uncorrected);
}
else PrintProgress(_("Ecc progress: %3d.%1d%%"),percent/10,percent%10);
else
#endif
PrintProgress(_("Ecc progress: %3d.%1d%%"),percent/10,percent%10);
last_percent = percent;
}
@@ -811,11 +852,13 @@ skip:
corrected, data_corr, ecc_corr);
if(uncorrected > 0)
{ PrintLog(_("Unrepaired sectors: %lld\n"), uncorrected);
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
_("Image sectors could not be fully restored "
"(%lld repaired; <span %s>%lld unrepaired</span>)"),
corrected, Closure->redMarkup, uncorrected);
#endif
}
else
{ if(!corrected)
@@ -831,9 +874,11 @@ skip:
PrintLog(_("Erasure counts per ecc block: avg = %.1f; worst = %d.\n"),
(double)damaged_sectors/(double)damaged_eccsecs,worst_ecc);
#ifndef CLI
if(Closure->guiMode && t)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
"%s %s", _("Repair results:"), t);
#endif
Verbose("\nSummary of processed sectors:\n");
Verbose("%lld damaged sectors\n", damaged_sectors);

View File

@@ -23,6 +23,7 @@
#ifndef RS02INCLUDES_H
#define RS02INCLUDES_H
#ifndef CLI
/* Data structs from rs02-window.c */
typedef struct
@@ -102,6 +103,7 @@ typedef struct
int dataBytes;
int percent, lastPercent;
} RS02Widgets;
#endif
/*
* local working closure for internal checksums
@@ -120,6 +122,7 @@ typedef struct
* These are exported via the Method struct
*/
#ifndef CLI
void CreateRS02EncWindow(Method*, GtkWidget*);
void CreateRS02FixWindow(Method*, GtkWidget*);
void CreateRS02PrefsPage(Method*, GtkWidget*);
@@ -130,6 +133,7 @@ void ReadRS02Preferences(Method*);
void ResetRS02VerifyWindow(Method*);
void CreateRS02VerifyWindow(Method*, GtkWidget*);
#endif
/*
* These are exported (resp. only used) in ecc-rs02.c and rs02*.c
@@ -184,11 +188,13 @@ void RS02Fix(Image*);
int RS02Recognize(Image*);
#ifndef CLI
/* rs02-window.c */
void RS02AddFixValues(RS02Widgets*, int, int);
void RS02SetFixMaxValues(RS02Widgets*, int, int, gint64);
void RS02UpdateFixResults(RS02Widgets*, gint64, gint64);
#endif
/* rs02-verify.c */

View File

@@ -29,6 +29,8 @@
*** Recognize RS02 error correction data in the image
***/
#ifndef CLI
/*
* Dialog components for disabling RS02 search
*/
@@ -59,6 +61,7 @@ static void insert_buttons(GtkDialog *dialog)
gtk_widget_show(align);
gtk_widget_show(check);
}
#endif
/*
* See whether a given header is valid for RS02
@@ -247,8 +250,10 @@ int RS02Recognize(Image *image)
while(pos > 0)
{ int result;
#ifndef CLI
if(Closure->stopActions)
goto bail_out;
#endif
if(GetBit(try_next_header, pos))
{ Verbose("Sector %lld cached; skipping\n", pos);
@@ -267,7 +272,9 @@ int RS02Recognize(Image *image)
SetBit(try_next_header, pos);
read_count++;
if(!answered_continue && read_count > 5)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE, insert_buttons,
_("Faster medium initialization\n\n"
"Searching this medium for error correction data may take a long time.\n"
@@ -277,6 +284,7 @@ int RS02Recognize(Image *image)
if(answer) goto bail_out;
answered_continue = TRUE;
}
#endif
}
goto check_next_header;
case TRY_NEXT_MODULO:
@@ -297,7 +305,9 @@ int RS02Recognize(Image *image)
header_modulo >>= 1;
}
#ifndef CLI
bail_out:
#endif
FreeBitmap(try_next_header);
FreeBitmap(try_next_modulo);
FreeAlignedBuffer(ab);

View File

@@ -28,6 +28,8 @@
*** Reset the verify output window
***/
#ifndef CLI
void ResetRS02VerifyWindow(Method *self)
{ RS02Widgets *wl = (RS02Widgets*)self->widgetList;
@@ -328,6 +330,7 @@ void CreateRS02VerifyWindow(Method *self, GtkWidget *parent)
gtk_table_attach(GTK_TABLE(table2), lab, 0, 2, 7, 8, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 5, 4);
}
#endif
/***
*** Check the consistency of the augmented image
@@ -341,7 +344,9 @@ typedef struct
{ Image *image;
EccHeader *eh;
RS02Layout *lay;
#ifndef CLI
RS02Widgets *wl;
#endif
Bitmap *map;
guint32 *crcBuf;
gint8 *crcValid;
@@ -353,8 +358,10 @@ static void cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
AllowActions(TRUE);
#endif
if(cc->image) CloseImage(cc->image);
if(cc->lay) g_free(cc->lay);
@@ -364,8 +371,10 @@ static void cleanup(gpointer data)
g_free(cc);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/***
@@ -462,6 +471,7 @@ static void read_crc(verify_closure *cc, RS02Layout *lay)
* Prognosis for correctability
*/
#ifndef CLI
static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
{ int j,eccblock;
int worst_ecc = 0;
@@ -506,6 +516,7 @@ static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
PrintLog(_("- prognosis : %lld of %lld sectors recoverable (%d.%d%%)\n"),
recoverable, expected, percentage/10, percentage%10);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(vc->wl->cmpEcc1Name), "");
SetLabelText(GTK_LABEL(vc->wl->cmpEcc1Msg), "");
@@ -522,6 +533,7 @@ static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
recoverable < expected ? Closure->redMarkup : Closure->greenMarkup,
recoverable, expected, percentage/10, percentage%10);
}
#endif
}
/* Why the first test?
@@ -530,6 +542,7 @@ static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
return TRUE;
else return FALSE;
}
#endif
/*
* The verify action
@@ -537,8 +550,10 @@ static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
void RS02Verify(Image *image)
{ verify_closure *cc = g_malloc0(sizeof(verify_closure));
#ifndef CLI
Method *self = FindMethod("RS02");
RS02Widgets *wl = self->widgetList;
#endif
EccHeader *eh;
RS02Layout *lay;
struct MD5Context image_md5;
@@ -561,20 +576,26 @@ void RS02Verify(Image *image)
gint64 hdr_missing, hdr_crc_errors;
gint64 hdr_ok,hdr_pos,hdr_correctable;
gint64 ecc_sector,expected_sectors;
#ifndef CLI
int ecc_md5_failure = FALSE;
#endif
int ecc_slice;
int major,minor,micro;
char *unstable="";
char method[5];
#ifndef CLI
char *img_advice = NULL;
char *ecc_advice = NULL;
int try_it;
#endif
int unrecoverable_sectors = 0;
/*** Prepare for early termination */
RegisterCleanup(_("Check aborted"), cleanup, cc);
#ifndef CLI
cc->wl = wl;
#endif
/* extract some important information */
@@ -590,14 +611,17 @@ void RS02Verify(Image *image)
/*** Print information on image size */
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpHeadline), "<big>%s</big>\n<i>%s</i>",
_("Checking the image file."),
_("Image contains error correction data."));
#endif
PrintLog("\n%s: ",Closure->imageName);
PrintLog(_("present, contains %lld medium sectors.\n"),image->sectorSize);
#ifndef CLI
if(Closure->guiMode)
{ if(expected_sectors == image->sectorSize)
{ SetLabelText(GTK_LABEL(wl->cmpImageSectors), "%lld", image->sectorSize);
@@ -610,6 +634,7 @@ void RS02Verify(Image *image)
else img_advice = g_strdup_printf(_("<span %s>Image file is %lld sectors longer than expected.</span>"), Closure->redMarkup, image->sectorSize - expected_sectors);
}
}
#endif
/*** Check integrity of the ecc headers */
@@ -666,6 +691,7 @@ void RS02Verify(Image *image)
hdr_pos = (lay->protectedSectors + lay->headerModulo - 1) & ~(lay->headerModulo-1);
else hdr_pos += lay->headerModulo;
#ifndef CLI
if(Closure->guiMode)
{ if(!hdr_crc_errors && !hdr_missing)
SetLabelText(GTK_LABEL(wl->cmpEccHeaders), _("complete"));
@@ -674,6 +700,7 @@ void RS02Verify(Image *image)
Closure->redMarkup, hdr_ok, hdr_crc_errors, hdr_missing);
}
}
#endif
}
/* take shortcut in quick mode */
@@ -709,6 +736,7 @@ void RS02Verify(Image *image)
/* Check for user interruption */
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->cmpImageResult),
@@ -716,6 +744,7 @@ void RS02Verify(Image *image)
Closure->redMarkup);
goto terminate;
}
#endif
/* Read the next sector */
@@ -793,12 +822,16 @@ void RS02Verify(Image *image)
}
}
#ifndef CLI
if(Closure->guiMode)
percent = (VERIFY_IMAGE_SEGMENTS*(s+1))/expected_sectors;
else percent = (100*(s+1))/expected_sectors;
else
#endif
percent = (100*(s+1))/expected_sectors;
if(last_percent != percent)
{ PrintProgress(_("- testing sectors : %3d%%") ,percent);
#ifndef CLI
if(Closure->guiMode)
{ add_verify_values(self, percent, new_missing, new_crc_errors);
if(data_missing || data_crc_errors)
@@ -814,6 +847,7 @@ void RS02Verify(Image *image)
_("<span %s>%lld sectors missing</span>"),
Closure->redMarkup, ecc_missing);
}
#endif
last_percent = percent;
new_missing = new_crc_errors = 0;
}
@@ -821,6 +855,7 @@ void RS02Verify(Image *image)
/* Complete damage summary */
#ifndef CLI
if(Closure->guiMode)
{ if(data_missing || data_crc_errors)
SetLabelText(GTK_LABEL(wl->cmpDataSection),
@@ -835,6 +870,7 @@ void RS02Verify(Image *image)
_("<span %s>%lld sectors missing</span>"),
Closure->redMarkup, ecc_missing);
}
#endif
/* The image md5sum is only useful if all blocks have been successfully read. */
@@ -873,6 +909,7 @@ void RS02Verify(Image *image)
PrintLog(_(" ... ecc section : %lld sectors missing\n"), ecc_missing);
}
#ifndef CLI
if(Closure->guiMode)
{ if(!data_missing && !data_crc_errors)
SetLabelText(GTK_LABEL(wl->cmpDataSection), _("complete"));
@@ -896,6 +933,7 @@ void RS02Verify(Image *image)
Closure->redMarkup);
}
}
#endif
/*** Print some information on the ecc portion */
continue_with_ecc:
@@ -915,12 +953,14 @@ continue_with_ecc:
PrintLog(format, _("created by dvdisaster"), major, minor, micro, unstable);
PrintLog("\n");
#ifndef CLI
if(Closure->guiMode)
{ SwitchAndSetFootline(wl->cmpEccNotebook, 1,
wl->cmpEccCreatedBy,
format, "dvdisaster",
major, minor, micro, unstable);
}
#endif
}
else
{ char *format = "%s-%d.%d%s";
@@ -928,11 +968,13 @@ continue_with_ecc:
PrintLog(format, _("created by dvdisaster"), major, minor, unstable);
PrintLog("\n");
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->cmpEccNotebook, 1,
wl->cmpEccCreatedBy,
format, "dvdisaster",
major, minor, unstable);
#endif
}
/* Error correction method */
@@ -943,10 +985,12 @@ continue_with_ecc:
method, eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMethod), _("%4s, %d roots, %4.1f%% redundancy"),
method, eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
#endif
/* required dvdisaster version */
@@ -956,10 +1000,12 @@ continue_with_ecc:
(eh->neededVersion%10000)/100);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccRequires), "dvdisaster-%d.%d",
eh->neededVersion/10000,
(eh->neededVersion%10000)/100);
#endif
}
else
{ PrintLog(_("* requires : dvdisaster-%d.%d (BAD)\n"
@@ -969,6 +1015,7 @@ continue_with_ecc:
(eh->neededVersion%10000)/100);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccRequires),
"<span %s>dvdisaster-%d.%d</span>",
@@ -978,6 +1025,7 @@ continue_with_ecc:
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Please upgrade your version of dvdisaster!</span>"), Closure->redMarkup);
}
#endif
}
/* Number of sectors medium is supposed to have */
@@ -986,9 +1034,11 @@ continue_with_ecc:
{ PrintLog(_("- medium sectors : %lld / %lld (good)\n"),
expected_sectors, lay->dataSectors);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors), "%lld / %lld",
expected_sectors, lay->dataSectors);
#endif
}
else
{ if(image->sectorSize > expected_sectors && image->sectorSize - expected_sectors <= 2)
@@ -996,12 +1046,14 @@ continue_with_ecc:
expected_sectors);
else PrintLog(_("* medium sectors : %lld (BAD)\n"),expected_sectors);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccMediumSectors),
"<span %s>%lld</span>", Closure->redMarkup, expected_sectors);
if(!ecc_advice && image->sectorSize > expected_sectors)
ecc_advice = g_strdup_printf(_("<span %s>Image size does not match recorded size.</span>"), Closure->redMarkup);
}
#endif
}
if(Closure->quickVerify) /* take shortcut again */
@@ -1017,6 +1069,7 @@ continue_with_ecc:
if(n) PrintLog(_("- data md5sum : %s (good)\n"),hdr_digest);
else PrintLog(_("* data md5sum : %s (BAD)\n"),hdr_digest);
#ifndef CLI
if(Closure->guiMode)
{ if(n) SetLabelText(GTK_LABEL(wl->cmpEcc1Msg), "%s", hdr_digest);
else
@@ -1024,12 +1077,15 @@ continue_with_ecc:
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "<span %s>%s</span>", Closure->redMarkup, data_digest);
}
}
#endif
}
else
{ PrintLog(_("- data md5sum : %s\n"), "-");
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEcc1Msg), "%s", "-");
#endif
}
/*** md5sum of the crc portion */
@@ -1039,22 +1095,28 @@ continue_with_ecc:
if(!crc_missing)
{ if(!memcmp(eh->crcSum, cc->crcSum, 16))
{ PrintLog(_("- crc md5sum : %s (good)\n"),digest);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEcc2Msg), "%s", digest);
#endif
}
else
{ PrintLog(_("* crc md5sum : %s (BAD)\n"),digest);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEcc2Msg), "<span %s>%s</span>", Closure->redMarkup, digest);
}
ecc_md5_failure = TRUE;
#endif
}
}
else
{ PrintLog(_("- crc md5sum : %s\n"), "-");
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEcc2Msg), "%s", "-");
#endif
}
/*** meta md5sum of the ecc slices */
@@ -1064,27 +1126,34 @@ continue_with_ecc:
if(!ecc_missing)
{ if(!memcmp(eh->eccSum, ecc_sum, 16))
{ PrintLog(_("- ecc md5sum : %s (good)\n"),digest);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEcc3Msg), "%s", digest);
#endif
}
else
{ PrintLog(_("* ecc md5sum : %s (BAD)\n"),digest);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEcc3Msg), "<span %s>%s</span>", Closure->redMarkup, digest);
}
ecc_md5_failure = TRUE;
#endif
}
}
else
{ PrintLog(_("- ecc md5sum : %s\n"), "-");
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEcc3Msg), "%s", "-");
#endif
}
/*** Print final results */
#ifndef CLI
try_it = prognosis(cc, total_missing + data_crc_errors - hdr_correctable, expected_sectors);
if(Closure->guiMode)
@@ -1106,6 +1175,7 @@ continue_with_ecc:
Closure->redMarkup);
}
}
#endif
/*** Close and clean up */

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -60,7 +60,9 @@
typedef struct
{ Method *self;
Image *image;
#ifndef CLI
RS03Widgets *wl;
#endif
RS03Layout *lay;
EccHeader *eh; /* ecc header in native byte order */
EccHeader *eh_le; /* ecc header in little endian order */
@@ -138,6 +140,7 @@ static void ecc_cleanup(gpointer data)
}
}
#ifndef CLI
if(Closure->guiMode)
{ if(ec->earlyTermination)
SetLabelText(GTK_LABEL(ec->wl->encFootline),
@@ -145,6 +148,7 @@ static void ecc_cleanup(gpointer data)
Closure->redMarkup);
AllowActions(TRUE);
}
#endif
/*** We must invalidate the CRC cache as it does only cover the
data portion of the image, not the full RS03 enhanced image
@@ -218,8 +222,10 @@ static void ecc_cleanup(gpointer data)
if(ec->encoderData) g_free(ec->encoderData);
g_free(ec);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/***
@@ -231,7 +237,10 @@ static void ecc_cleanup(gpointer data)
*/
static void abort_encoding(ecc_closure *ec, int truncate)
{ RS03Widgets *wl = ec->wl;
{
#ifndef CLI
RS03Widgets *wl = ec->wl;
#endif
if(truncate && ec->lay)
{ if(Closure->eccTarget == ECC_FILE)
@@ -239,17 +248,21 @@ static void abort_encoding(ecc_closure *ec, int truncate)
else if(!LargeTruncate(ec->image->file, (gint64)(2048*ec->lay->dataSectors)))
Stop(_("Could not truncate %s: %s\n"),Closure->imageName,strerror(errno));
#ifndef CLI
if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->encFootline),
_("<span %s>Aborted by user request!</span> (partial ecc data removed from image)"),
Closure->redMarkup);
#endif
}
#ifndef CLI
else
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->encFootline),
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup);
}
#endif
ec->earlyTermination = FALSE; /* suppress respective error message */
@@ -271,6 +284,7 @@ static void remove_old_ecc(ecc_closure *ec)
{
if(ConfirmEccDeletion(Closure->eccName))
LargeUnlink(Closure->eccName);
#ifndef CLI
else
{ SetLabelText(GTK_LABEL(ec->wl->encFootline),
_("<span %s>Aborted to keep existing ecc file.</span>"),
@@ -278,6 +292,7 @@ static void remove_old_ecc(ecc_closure *ec)
ec->earlyTermination = FALSE;
ecc_cleanup((gpointer)ec);
}
#endif
}
return;
}
@@ -289,12 +304,16 @@ static void remove_old_ecc(ecc_closure *ec)
guint64 data_bytes;
int answer;
#ifndef CLI
if(Closure->confirmDeletion || !Closure->guiMode)
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
#endif
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image \"%s\" already contains error correction information.\n"
"Truncating image to data part (%lld sectors).\n"),
Closure->imageName, data_sectors);
#ifndef CLI
else answer = TRUE;
#endif
if(!answer)
abort_encoding(ec, FALSE);
@@ -488,8 +507,10 @@ static void expand_image(ecc_closure *ec)
{ unsigned char dead_sector[2048];
int n;
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
abort_encoding(ec, TRUE);
#endif
CreateMissingSector(dead_sector, lay->firstEccPos+sectors, image->imageFP, FINGERPRINT_SECTOR,
"ECC padding by expand_image()");
@@ -503,8 +524,10 @@ static void expand_image(ecc_closure *ec)
if(last_percent != percent)
{ PrintProgress(_(progress_msg), percent);
#ifndef CLI
if(Closure->guiMode)
SetProgress(ec->wl->encPBar1, percent, 100);
#endif
last_percent = percent;
}
@@ -513,8 +536,10 @@ static void expand_image(ecc_closure *ec)
PrintProgress(_(progress_msg), 100);
PrintProgress("\n");
#ifndef CLI
if(Closure->guiMode)
SetProgress(ec->wl->encPBar1, 100, 100);
#endif
}
/*
@@ -597,10 +622,12 @@ static void read_next_chunk(ecc_closure *ec, guint64 chunk)
guint64 page_offset;
#endif
#ifndef CLI
if(Closure->stopActions) /* User hit the Stop button */
{ ec->abortImmediately = TRUE;
abort_encoding(ec, TRUE);
}
#endif
/* Read the next data sectors of this layer.
Note that the last layer is made from CRC sums. */
@@ -825,7 +852,10 @@ static gpointer io_thread(ecc_closure *ec)
verbose("NOTE: sectors per layer = %lld\n", (long long)lay->sectorsPerLayer);
for(chunk=0; chunk<lay->sectorsPerLayer; chunk+=ec->chunkSize)
{ int cpu_bound = 0;
{
#ifndef CLI
int cpu_bound = 0;
#endif
verbose("Starting IO processing for chunk %d\n", chunk);
@@ -880,7 +910,9 @@ static gpointer io_thread(ecc_closure *ec)
/* Wait until the encoders have finished */
g_mutex_lock(ec->lock);
#ifndef CLI
cpu_bound = ec->buffersToEncode;
#endif
while(ec->buffersToEncode)
{ verbose("IO: Waiting for encoders to finish\n");
g_cond_wait(ec->ioCond, ec->lock);
@@ -891,6 +923,7 @@ static gpointer io_thread(ecc_closure *ec)
verbose("IO: chunk %d finished\n", ec->ioChunk);
#ifndef CLI
if(Closure->guiMode)
{ if(cpu_bound)
{ SetLabelText(GTK_LABEL(ec->wl->encBottleneck), _("CPU bound"));
@@ -901,6 +934,7 @@ static gpointer io_thread(ecc_closure *ec)
ec->ioBound++;
}
}
#endif
} /* chunk finished */
/* Broadcast read to the worker threads */
@@ -1096,6 +1130,7 @@ static gpointer encoder_thread(ecc_closure *ec)
{
ec->lastPercent = percent;
g_mutex_unlock(ec->lock);
#ifndef CLI
if(Closure->guiMode)
{ gdouble elapsed;
gulong ignore;
@@ -1110,7 +1145,9 @@ static gpointer encoder_thread(ecc_closure *ec)
}
SetProgress(ec->wl->encPBar2, percent, 1000);
}
else PrintProgress(_("Ecc generation: %3d.%1d%%"), percent/10, percent%10);
else
#endif
PrintProgress(_("Ecc generation: %3d.%1d%%"), percent/10, percent%10);
}
else g_mutex_unlock(ec->lock);
@@ -1134,11 +1171,14 @@ static void create_reed_solomon(ecc_closure *ec)
{ int nroots = ec->lay->nroots;
int ndata = ec->lay->ndata;
int i;
#ifndef CLI
char *alg="none";
char *iostrat="none";
#endif
/*** Show the second progress bar */
#ifndef CLI
if(Closure->guiMode)
{ ShowWidget(ec->wl->encPBar2);
ShowWidget(ec->wl->encLabel2);
@@ -1157,6 +1197,7 @@ static void create_reed_solomon(ecc_closure *ec)
SetLabelText(GTK_LABEL(ec->wl->encPerformance), "");
SetLabelText(GTK_LABEL(ec->wl->encBottleneck), "");
}
#endif
/*** Calculate buffer size for the parity calculation and image data caching.
@@ -1233,7 +1274,9 @@ static void create_reed_solomon(ecc_closure *ec)
void RS03Create(void)
{ Method *method = FindMethod("RS03");
Image *image = NULL;
#ifndef CLI
RS03Widgets *wl = (RS03Widgets*)method->widgetList;
#endif
RS03Layout *lay;
ecc_closure *ec = g_malloc0(sizeof(ecc_closure));
gdouble elapsed,mbs;
@@ -1243,15 +1286,19 @@ void RS03Create(void)
/*** Register the cleanup procedure for GUI mode */
ec->self = method;
#ifndef CLI
ec->wl = wl;
#endif
ec->earlyTermination = TRUE;
RegisterCleanup(_("Error correction data creation aborted"), ecc_cleanup, ec);
#ifndef CLI
if(Closure->guiMode) /* Preliminary fill text for the head line */
SetLabelText(GTK_LABEL(wl->encHeadline),
_("<big>Augmenting the image with error correction data.</big>\n<i>%s</i>"),
_("- checking image -"));
#endif
/*** Open image file. */
@@ -1297,6 +1344,7 @@ void RS03Create(void)
/*** Announce what we are going to do */
ecc_sectors = lay->nroots*lay->sectorsPerLayer;
#ifndef CLI
if(Closure->guiMode) /* Preliminary fill text for the head line */
{ ec->msg = g_strdup_printf(_("Encoding with Method RS03: %lld MiB data, %lld MiB ecc (%d roots; %4.1f%% redundancy)."),
lay->dataSectors/512, ecc_sectors/512, lay->nroots, lay->redundancy);
@@ -1312,6 +1360,7 @@ void RS03Create(void)
}
else
#endif
{ char *alg, *iostrat;
DescribeRSEncoder(&alg, &iostrat);
@@ -1341,9 +1390,9 @@ void RS03Create(void)
if(Closure->eccTarget == ECC_IMAGE && lay->redundancy < 20)
{ int answer;
answer = ModalWarning(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Using redundancies below 20%%%% may not give\n"
"the expected data loss protection.\n"));
"the expected data loss protection.\n"), NULL);
if(!answer)
abort_encoding(ec, FALSE);
@@ -1378,13 +1427,16 @@ void RS03Create(void)
mbs = ((double)lay->ndata*lay->sectorsPerLayer)/(512.0*elapsed);
PrintLog(_("Avg performance: %5.2fs (%5.2fMiB/s) total\n"),
elapsed, mbs);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->encPerformance), _("%5.2fMiB/s average"), mbs);
SetLabelText(GTK_LABEL(ec->wl->encBottleneck),
_("%d times CPU bound; %d times I/O bound"),
ec->cpuBound, ec->ioBound);
}
#endif
#ifndef CLI
if(Closure->guiMode)
{ SetProgress(wl->encPBar2, 100, 100);
@@ -1400,6 +1452,7 @@ void RS03Create(void)
"Make sure to keep this file on a reliable medium."));
}
#endif
/*** Clean up */

View File

@@ -30,7 +30,10 @@
***/
typedef struct
{ RS03Widgets *wl;
{
#ifndef CLI
RS03Widgets *wl;
#endif
RS03Layout *lay;
GaloisTables *gt;
ReedSolomonTables *rt;
@@ -46,6 +49,7 @@ static void fix_cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
{ if(fc->earlyTermination)
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -54,6 +58,7 @@ static void fix_cleanup(gpointer data)
Closure->redMarkup);
AllowActions(TRUE);
}
#endif
/** Clean up */
@@ -71,8 +76,10 @@ static void fix_cleanup(gpointer data)
g_free(fc);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/*
@@ -106,17 +113,24 @@ static void expand_image(Image *image, EccHeader *eh, gint64 new_size)
percent = (100*sectors) / new_sectors;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
;
else PrintProgress(_("Expanding image: %3d%%"), percent);
else
#endif
PrintProgress(_("Expanding image: %3d%%"), percent);
last_percent = percent;
}
}
#ifndef CLI
if(Closure->guiMode)
;
else
{ PrintProgress(_("Expanding image: %3d%%"), 100);
#endif
{
PrintProgress(_("Expanding image: %3d%%"), 100);
PrintProgress("\n");
}
}
@@ -126,8 +140,11 @@ static void expand_image(Image *image, EccHeader *eh, gint64 new_size)
***/
void RS03Fix(Image *image)
{ Method *self = FindMethod("RS03");
{
#ifndef CLI
Method *self = FindMethod("RS03");
RS03Widgets *wl = (RS03Widgets*)self->widgetList;
#endif
RS03Layout *lay;
fix_closure *fc = g_malloc0(sizeof(fix_closure));
EccHeader *eh;
@@ -157,12 +174,17 @@ void RS03Fix(Image *image)
gint64 damaged_eccblocks=0;
gint64 damaged_eccsecs=0;
gint64 expected_sectors;
char *t=NULL,*msg;
char *t=NULL;
#ifndef CLI
char *msg;
#endif
/*** Register the cleanup procedure for GUI mode */
fc->image = image;
#ifndef CLI
fc->wl = wl;
#endif
fc->earlyTermination = TRUE;
RegisterCleanup(_("Repairing of image aborted"), fix_cleanup, fc);
@@ -172,10 +194,12 @@ void RS03Fix(Image *image)
/*** Open the image file */
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->fixHeadline),
_("<big>Repairing the image.</big>\n<i>%s</i>"),
_("Opening files..."));
#endif
/* Calculate the layout and optinally open thee ecc file */
@@ -213,6 +237,7 @@ void RS03Fix(Image *image)
/*** Announce what we are going to do */
#ifndef CLI
if(Closure->guiMode)
{ if(eh->methodFlags[0] & MFLAG_ECC_FILE)
msg = g_strdup_printf(_("Error correction file using Method RS03, %d roots, %4.1f%% redundancy."),
@@ -228,6 +253,7 @@ void RS03Fix(Image *image)
RS03SetFixMaxValues(wl, eh->dataBytes, eh->eccBytes, expected_sectors);
g_free(msg);
}
#endif
PrintLog(_("\nFix mode(%s): Repairable sectors will be fixed in the image.\n"),
eh->methodFlags[0] & MFLAG_ECC_FILE ? "RS03f" : "RS03i");
@@ -238,6 +264,7 @@ void RS03Fix(Image *image)
{ int difference = image->inLast - eh->inLast;
guint64 expected_image_size = 2048*(expected_sectors-1)+eh->inLast;
#ifndef CLI
if(Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("The image file is %d bytes longer than noted\n"
@@ -254,8 +281,13 @@ void RS03Fix(Image *image)
goto terminate;
}
}
#endif
#ifndef CLI
if(!Closure->guiMode && !Closure->truncate)
#else
if(!Closure->truncate)
#endif
Stop(_("The image file is %d bytes longer than noted\n"
"in the ecc file.\n"
"Add the --truncate option to the program call\n"
@@ -280,17 +312,21 @@ void RS03Fix(Image *image)
"the error correction information.\n\n%s");
if(diff>0 && diff<=2)
{ int answer = ModalWarning(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
{ int answer;
answer = ModalWarningOrCLI(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image file is %lld sectors longer than expected.\n"
"Assuming this is a TAO mode medium.\n"
"%lld sectors will be removed from the image end.\n"),
diff, diff);
if(!answer)
{ SwitchAndSetFootline(fc->wl->fixNotebook, 1,
{
#ifndef CLI
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
fc->wl->fixFootline,
_("<span %s>Aborted by user request!</span>"),
Closure->redMarkup);
#endif
fc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
@@ -301,6 +337,7 @@ void RS03Fix(Image *image)
Stop(_("Could not truncate %s: %s\n"),Closure->imageName,strerror(errno));
}
#ifndef CLI
if(diff>2 && Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
trans,
@@ -323,8 +360,13 @@ void RS03Fix(Image *image)
PrintLog(_("Image has been truncated by %lld sectors.\n"), diff);
}
#endif
#ifndef CLI
if(diff>2 && !Closure->guiMode)
#else
if(diff>2)
#endif
{ if(!Closure->truncate)
Stop(trans,
diff,
@@ -379,6 +421,7 @@ void RS03Fix(Image *image)
/* See if user hit the Stop button */
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -388,6 +431,7 @@ void RS03Fix(Image *image)
fc->earlyTermination = FALSE; /* suppress respective error message */
goto terminate;
}
#endif
/* Fill cache with the next batch of cache_size ecc blocks. */
@@ -506,7 +550,10 @@ void RS03Fix(Image *image)
/* Trivially reject uncorrectable ecc block */
if(erasure_count>lay->nroots) /* uncorrectable */
{ if(!Closure->guiMode)
{
#ifndef CLI
if(!Closure->guiMode)
#endif
{ int sep_printed = 0;
PrintCLI(_("* Ecc block %lld: %3d unrepairable sectors: "), s, erasure_count);
@@ -865,7 +912,9 @@ skip:
percent = (1000*s)/lay->sectorsPerLayer;
if(last_percent != percent)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
{
RS03AddFixValues(wl, percent, local_plot_max);
local_plot_max = 0;
@@ -873,7 +922,9 @@ skip:
//if(last_corrected != corrected || last_uncorrected != uncorrected)
RS03UpdateFixResults(wl, corrected, uncorrected);
}
else PrintProgress(_("Ecc progress: %3d.%1d%%"),percent/10,percent%10);
else
#endif
PrintProgress(_("Ecc progress: %3d.%1d%%"),percent/10,percent%10);
last_percent = percent;
}
@@ -891,11 +942,13 @@ skip:
corrected, data_corr, ecc_corr);
if(uncorrected > 0)
{ PrintLog(_("Unrepaired sectors: %lld\n"), uncorrected);
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
_("Image sectors could not be fully restored "
"(%lld repaired; <span %s>%lld unrepaired</span>)"),
corrected, Closure->redMarkup, uncorrected);
#endif
exitCode = 2;
}
else
@@ -914,9 +967,11 @@ skip:
PrintLog(_("Erasure counts per ecc block: avg = %.1f; worst = %d.\n"),
(double)damaged_sectors/(double)damaged_eccsecs,worst_ecc);
#ifndef CLI
if(Closure->guiMode && t)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
"%s %s", _("Repair results:"), t);
#endif
Verbose("\nSummary of processed sectors:\n");
Verbose("%lld damaged sectors\n", damaged_sectors);

View File

@@ -23,6 +23,7 @@
#ifndef RS03INCLUDES_H
#define RS03INCLUDES_H
#ifndef CLI
/* Data structs from rs03-window.c */
typedef struct
@@ -117,6 +118,7 @@ typedef struct
int dataBytes;
int percent, lastPercent;
} RS03Widgets;
#endif
/*
* local working closure for internal checksums
@@ -131,6 +133,7 @@ typedef struct
* These are exported via the Method struct
*/
#ifndef CLI
void CreateRS03EncWindow(Method*, GtkWidget*);
void CreateRS03FixWindow(Method*, GtkWidget*);
void CreateRS03PrefsPage(Method*, GtkWidget*);
@@ -141,6 +144,7 @@ void ReadRS03Preferences(Method*);
void ResetRS03VerifyWindow(Method*);
void CreateRS03VerifyWindow(Method*, GtkWidget*);
#endif
/*
* These are exported (resp. only used) in ecc-rs03.c and rs03*.c
@@ -196,11 +200,13 @@ void RS03Fix(Image*);
int RS03RecognizeFile(LargeFile*, EccHeader**);
int RS03RecognizeImage(Image*);
#ifndef CLI
/* rs03-window.c */
void RS03AddFixValues(RS03Widgets*, int, int);
void RS03SetFixMaxValues(RS03Widgets*, int, int, gint64);
void RS03UpdateFixResults(RS03Widgets*, gint64, gint64);
#endif
/* rs03-verify.c */
@@ -211,7 +217,9 @@ void RS03Verify(Image*);
/* temporary single threaded versions */
void RS03SCreate(void);
#ifndef CLI
void CreateRS03SEncWindow(Method*, GtkWidget*);
void ResetRS03SEncWindow(Method*);
#endif
#endif

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -35,6 +35,7 @@
/***
*** Reset the verify output window
***/
#ifndef CLI
void ResetRS03VerifyWindow(Method *self)
{ RS03Widgets *wl = (RS03Widgets*)self->widgetList;
@@ -361,6 +362,7 @@ void CreateRS03VerifyWindow(Method *self, GtkWidget *parent)
gtk_misc_set_alignment(GTK_MISC(lab), 0.0, 0.0);
gtk_table_attach(GTK_TABLE(table2), lab, 0, 2, y1, y2, GTK_SHRINK | GTK_FILL, GTK_SHRINK, 5, 4);
}
#endif
/***
*** Check the consistency of the augmented image
@@ -374,7 +376,9 @@ typedef struct
{ Image *image;
EccHeader *eh;
RS03Layout *lay;
#ifndef CLI
RS03Widgets *wl;
#endif
CrcBuf *crcBuf;
Bitmap *map;
unsigned char crcSum[16];
@@ -389,8 +393,10 @@ static void cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
if(Closure->guiMode)
AllowActions(TRUE);
#endif
if(vc->image) CloseImage(vc->image);
if(vc->lay)
@@ -408,14 +414,17 @@ static void cleanup(gpointer data)
g_free(vc);
#ifndef CLI
if(Closure->guiMode)
g_thread_exit(0);
#endif
}
/***
*** Prognosis for correctability
***/
#ifndef CLI
static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
{ int j,eccblock;
int worst_ecc = 0;
@@ -452,6 +461,7 @@ static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
PrintLog(_("- prognosis : %lld of %lld sectors recoverable (%d.%d%%)\n"),
recoverable, expected, percentage/10, percentage%10);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(vc->wl->cmpImageErasure), _("Erasure counts:"));
SetLabelText(GTK_LABEL(vc->wl->cmpImagePrognosis), _("Prognosis:"));
@@ -466,17 +476,20 @@ static int prognosis(verify_closure *vc, gint64 missing, gint64 expected)
recoverable < expected ? Closure->redMarkup : Closure->greenMarkup,
recoverable, expected, percentage/10, percentage%10);
}
#endif
}
if(damaged_sectors && worst_ecc <= vc->lay->nroots && recoverable >= expected)
return TRUE;
else return FALSE;
}
#endif
/***
*** Error syndrome check
***/
#ifndef CLI
static int check_syndromes(verify_closure *vc)
{ RS03Layout *lay = vc->lay;
Image *image = vc->image;
@@ -487,10 +500,12 @@ static int check_syndromes(verify_closure *vc)
int bad_counted;
int layer,i,j;
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(vc->wl->cmpHeadline), "<big>%s</big>\n<i>%s</i>",
_("Checking the image and error correction files."),
_("- Checking ecc blocks (deep verify) -"));
#endif
/* Allocate buffers and initialize layer sector addresses */
@@ -503,10 +518,12 @@ static int check_syndromes(verify_closure *vc)
for(j=0; j<i; j++)
g_free(vc->eccBlock[j]);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(vc->wl->cmpEccSyndromes),
_("<span %s>Out of memory; try reducing sector prefetch!</span>"),
Closure->redMarkup);
#endif
PrintLog(_("* Ecc block test : out of memory; try reducing sector prefetch!\n"));
return 0;
}
@@ -527,6 +544,7 @@ static int check_syndromes(verify_closure *vc)
/* Check for user interruption */
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(vc->wl->cmpEccSyndromes),
@@ -534,6 +552,7 @@ static int check_syndromes(verify_closure *vc)
Closure->redMarkup);
return 0;
}
#endif
/* Reload cache? */
@@ -586,18 +605,24 @@ static int check_syndromes(verify_closure *vc)
{ last_percent = percent;
if(!ecc_bad)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(vc->wl->cmpEccSyndromes),
_("%d%% tested"),
percent);
#endif
PrintProgress(_("- Ecc block test : %d%% tested"), percent);
}
else
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(vc->wl->cmpEccSyndromes),
_("<span %s>%lld good, %lld bad; %d%% tested</span>"),
Closure->redMarkup, ecc_good, ecc_bad, percent);
#endif
PrintProgress(_("* Ecc block test : %lld good, %lld bad; %d%% tested")
, ecc_good, ecc_bad, percent);
}
@@ -607,16 +632,22 @@ static int check_syndromes(verify_closure *vc)
/* Tell user about our findings */
if(!ecc_bad)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(vc->wl->cmpEccSyndromes),_("pass"));
#endif
ClearProgress();
PrintLog(_("- Ecc block test : pass\n"));
}
else
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(vc->wl->cmpEccSyndromes),
_("<span %s>%lld good, %lld bad; %lld bad sub blocks</span>"),
Closure->redMarkup, ecc_good, ecc_bad, ecc_bad_sub);
#endif
PrintLog(_("* Ecc block test : %lld good, %lld bad; %lld bad sub blocks\n"),
ecc_good, ecc_bad, ecc_bad_sub);
@@ -624,6 +655,7 @@ static int check_syndromes(verify_closure *vc)
}
return ecc_bad;
}
#endif
/***
*** The verify action
@@ -632,7 +664,9 @@ static int check_syndromes(verify_closure *vc)
void RS03Verify(Image *image)
{ Method *self = FindMethod("RS03");
verify_closure *vc = g_malloc0(sizeof(verify_closure));
#ifndef CLI
RS03Widgets *wl = self->widgetList;
#endif
EccHeader *eh = NULL;
RS03Layout *lay;
RS03CksumClosure *csc;
@@ -653,11 +687,15 @@ void RS03Verify(Image *image)
char *unstable="";
char method[5];
#ifndef CLI
char *img_advice = NULL;
char *ecc_advice = NULL;
#endif
char *version;
#ifndef CLI
int syn_error = 0;
int try_it;
#endif
int missing_sector_explained = 0;
int matching_byte_size = TRUE;
@@ -665,7 +703,9 @@ void RS03Verify(Image *image)
RegisterCleanup(_("Check aborted"), cleanup, vc);
vc->image = image;
#ifndef CLI
vc->wl = wl;
#endif
if(image->eccFileHeader && !strncmp((char*)(image->eccFileHeader->method), "RS03", 4))
{ eh = image->eccFileHeader;
@@ -686,25 +726,31 @@ void RS03Verify(Image *image)
else /* may only happen when ecc file is present */
{ PrintLog("\n%s not present.\n", Closure->imageName);
#ifndef CLI
if(Closure->guiMode)
SwitchAndSetFootline(wl->cmpImageNotebook, 0, NULL, NULL);
#endif
}
if(eh->methodFlags[0] & MFLAG_ECC_FILE)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpHeadline), "<big>%s</big>\n<i>%s</i>",
_("Checking the image and error correction files."),
_("- Checking image file -"));
#endif
PrintLog(_("%s present.\n"), Closure->eccName);
}
else
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpHeadline), "<big>%s</big>\n<i>%s</i>",
_("Checking the image file."),
_("- Checking image file -"));
#endif
}
/*** Calculate the layout */
@@ -732,8 +778,10 @@ void RS03Verify(Image *image)
else msg = g_strdup_printf(_("Ecc file is %lld sectors longer than expected."),
eccfile_sectors - expected_eccfile_sectors);
#ifndef CLI
if(Closure->guiMode)
ecc_advice = g_strdup_printf("<span %s>%s</span>", Closure->redMarkup, msg);
#endif
PrintLog(_("* Warning : %s\n"), msg);
g_free(msg);
@@ -747,11 +795,13 @@ void RS03Verify(Image *image)
PrintLog(_("- type : Error correction file\n"));
else PrintLog(_("- type : Augmented image\n"));
#ifndef CLI
if(Closure->guiMode)
{ if(eh->methodFlags[0] & MFLAG_ECC_FILE)
SetLabelText(GTK_LABEL(wl->cmpEccType), _("Error correction file"));
else SetLabelText(GTK_LABEL(wl->cmpEccType), _("Augmented image"));
}
#endif
/* Error correction method */
@@ -761,10 +811,12 @@ void RS03Verify(Image *image)
method, eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccMethod), _("%4s, %d roots, %4.1f%% redundancy"),
method, eh->eccBytes,
((double)eh->eccBytes*100.0)/(double)eh->dataBytes);
#endif
/* Creator version */
@@ -782,19 +834,23 @@ void RS03Verify(Image *image)
PrintLog(format, _("- created by : dvdisaster"), major, minor, micro, unstable);
PrintLog("\n");
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccCreatedBy), format,
"dvdisaster", major, minor, micro, unstable);
}
#endif
}
else
{ char *format = "%s-%d.%d%s";
PrintLog(format, _("- created by : dvdisaster"), major, minor, unstable);
PrintLog("\n");
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccCreatedBy), format,
"dvdisaster", major, minor, unstable);
#endif
}
/* Required dvdisaster version */
@@ -811,8 +867,10 @@ void RS03Verify(Image *image)
if(Closure->version >= eh->neededVersion)
{ PrintLog(_("- requires : dvdisaster-%s\n"), version);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccRequires), "dvdisaster-%s", version);
#endif
}
else
{ PrintLog(_("* requires : dvdisaster-%s (BAD)\n"
@@ -820,6 +878,7 @@ void RS03Verify(Image *image)
"* : Please visit http://www.dvdisaster.org for an upgrade.\n"),
version);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccRequires),
"<span %s>dvdisaster-%s</span>",
@@ -827,6 +886,7 @@ void RS03Verify(Image *image)
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Please upgrade your version of dvdisaster!</span>"), Closure->redMarkup);
}
#endif
exitCode = EXIT_CODE_VERSION_MISMATCH;
}
@@ -841,8 +901,10 @@ void RS03Verify(Image *image)
PrintLog(_("- data md5sum : %s\n"),hdr_digest);
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccDataCrcVal), "%s", hdr_digest);
#endif
/* compare images in ecc file case */
@@ -851,14 +913,17 @@ void RS03Verify(Image *image)
{ if(image->fpState != FP_PRESENT)
{ PrintLog(_("* fingerprint match: NOT POSSIBLE - related sector is missing in image!\n"));
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("<span %s>missing sector prevents calculation</span>"), Closure->redMarkup);
#endif
}
else
{
if(memcmp(image->imageFP, eh->mediumFP, 16))
{ PrintLog(_("* fingerprint match: MISMATCH - .iso and .ecc don't belong together!\n"));
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccFingerprint),
_("<span %s>mismatch</span>"), Closure->redMarkup);
@@ -866,11 +931,14 @@ void RS03Verify(Image *image)
if(!ecc_advice)
ecc_advice = g_strdup_printf(_("<span %s>Image and error correction files do not belong together!</span>"), Closure->redMarkup);
}
#endif
}
else
{ PrintLog(_("- fingerprint match: good\n"));
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccFingerprint), _("good"));
#endif
}
}
}
@@ -878,6 +946,7 @@ void RS03Verify(Image *image)
/* print advice collected from above tests */
#ifndef CLI
if(Closure->guiMode)
{ if(ecc_advice)
{ SetLabelText(GTK_LABEL(wl->cmpEccResult), ecc_advice);
@@ -887,6 +956,7 @@ void RS03Verify(Image *image)
_("<span %s>Good error correction data.</span>"),
Closure->greenMarkup);
}
#endif
if(!image->file) /* Ecc file but no image */
goto terminate;
@@ -918,7 +988,9 @@ void RS03Verify(Image *image)
if(expected_image_sectors == image->sectorSize && matching_byte_size)
{ if(lay->target == ECC_FILE)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
{ if(image->inLast == 2048)
SetLabelText(GTK_LABEL(wl->cmpImageSectors), _("%lld in image; %lld in ecc file"),
image->sectorSize, eccfile_sectors);
@@ -926,6 +998,7 @@ void RS03Verify(Image *image)
SetLabelText(GTK_LABEL(wl->cmpImageSectors), _("%lld sectors + %d bytes in image; %lld in ecc file"),
image->sectorSize-1, image->inLast, eccfile_sectors);
}
#endif
if(image->inLast == 2048)
PrintLog(_("- sectors : %lld in image; "), image->sectorSize);
@@ -934,9 +1007,12 @@ void RS03Verify(Image *image)
PrintLog(_("%lld in ecc file\n"), eccfile_sectors);
}
else
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpImageSectors), _("%lld total / %lld data"),
image->sectorSize, lay->dataSectors);
#endif
PrintLog(_("- medium sectors : %lld total / %lld data\n"),
image->sectorSize, lay->dataSectors);
}
@@ -952,6 +1028,7 @@ void RS03Verify(Image *image)
expected_size = g_strdup_printf("%lld", (long long int)expected_image_sectors);
else expected_size = g_strdup_printf("%lld sectors + %d bytes", (long long int)expected_image_sectors-1, eh->inLast);
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpImageSectors), _("<span %s>%s (%s expected)</span>"),
Closure->redMarkup, image_size, expected_size);
@@ -971,6 +1048,7 @@ void RS03Verify(Image *image)
img_advice = g_strdup_printf(_("<span %s>Image file is %lld sectors longer than expected.</span>"),
Closure->redMarkup, image->sectorSize - expected_image_sectors);
}
#endif
if(lay->target == ECC_FILE)
PrintLog(_("* sectors : %s (%s expected); %lld sectors in ecc file\n"),
@@ -1015,6 +1093,7 @@ void RS03Verify(Image *image)
/* Check for user interruption */
#ifndef CLI
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->cmpImageResult),
@@ -1022,6 +1101,7 @@ void RS03Verify(Image *image)
Closure->redMarkup);
goto terminate;
}
#endif
/* Read the next sector */
@@ -1135,6 +1215,7 @@ void RS03Verify(Image *image)
if(!defective)
SetBit(vc->map, s);
#ifndef CLI
if(Closure->guiMode)
{ /* data part / spiral animation */
percent = (VERIFY_IMAGE_SEGMENTS*(s+1))/virtual_expected;
@@ -1143,10 +1224,13 @@ void RS03Verify(Image *image)
if(lay->target == ECC_FILE && s >= lay->dataSectors)
percent = (100*(s+1-lay->dataSectors)/(virtual_expected-lay->dataSectors));
}
else percent = (100*(s+1))/virtual_expected;
else
#endif
percent = (100*(s+1))/virtual_expected;
if(last_percent != percent) /* Update sector results */
{ PrintProgress(_("- testing sectors : %3d%%") ,percent);
#ifndef CLI
if(Closure->guiMode)
{ if(lay->target == ECC_IMAGE)
{ add_verify_values(self, percent, new_missing, new_crc_errors);
@@ -1175,6 +1259,7 @@ void RS03Verify(Image *image)
_("<span %s>%lld sectors missing</span>"),
Closure->redMarkup, ecc_missing);
}
#endif
last_percent = percent;
new_missing = new_crc_errors = 0;
}
@@ -1184,6 +1269,7 @@ void RS03Verify(Image *image)
if(lay->target == ECC_FILE && s == lay->dataSectors-1)
{
#ifndef CLI
if(Closure->guiMode)
{ /* flush/complete spiral */
add_verify_values(self, VERIFY_IMAGE_SEGMENTS, new_missing, new_crc_errors);
@@ -1195,11 +1281,13 @@ void RS03Verify(Image *image)
SetLabelText(GTK_LABEL(wl->cmpEccSynLabel), _("Error correction file:"));
last_percent = 0; /* restart counting for ecc file */
}
#endif
}
}
/* Complete damage summary */
#ifndef CLI
if(Closure->guiMode)
{ if(data_missing || data_crc_errors)
SetLabelText(GTK_LABEL(wl->cmpDataSection),
@@ -1214,6 +1302,7 @@ void RS03Verify(Image *image)
_("<span %s>%lld sectors missing</span>"),
Closure->redMarkup, ecc_missing);
}
#endif
/* The image md5sum is only useful if all blocks have been successfully read. */
@@ -1249,6 +1338,7 @@ void RS03Verify(Image *image)
PrintLog(_(" ... ecc section : %lld sectors missing\n"), ecc_missing);
}
#ifndef CLI
if(Closure->guiMode)
{ if(!data_missing && !data_crc_errors)
SetLabelText(GTK_LABEL(wl->cmpDataSection), _("complete"));
@@ -1258,25 +1348,34 @@ void RS03Verify(Image *image)
SetLabelText(GTK_LABEL(wl->cmpImageMd5Sum), "%s", data_missing ? "-" : data_digest);
}
#endif
/*** Test error syndromes */
#ifndef CLI
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->cmpEccSynLabel), _("Ecc block test:"));
SetLabelText(GTK_LABEL(wl->cmpEccSyndromes), "");
}
#endif
if(0&&total_missing + data_crc_errors != 0)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->cmpEccSyndromes),
_("<span %s>Skipped; not useful on known defective image</span>"),
Closure->redMarkup);
#endif
PrintLog(_("* Ecc block test : skipped; not useful on defective image\n"));
}
#ifndef CLI
else syn_error = check_syndromes(vc);
#endif
/*** Print image advice */
#ifndef CLI
if(Closure->guiMode)
{
if(img_advice)
@@ -1294,9 +1393,11 @@ void RS03Verify(Image *image)
Closure->redMarkup);
}
}
#endif
/*** Print final results */
#ifndef CLI
try_it = prognosis(vc, total_missing+data_crc_errors, lay->totalSectors);
if(Closure->guiMode)
@@ -1309,6 +1410,7 @@ void RS03Verify(Image *image)
Closure->redMarkup);
}
}
#endif
/*** Close and clean up */

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -1364,6 +1364,7 @@ EOF
cat >conftest.c <<EOF
#include <glib.h>
#include <stdio.h>
int main(int argc, char *argv[])
{ g_malloc(1024);

View File

@@ -2168,8 +2168,11 @@ int TestUnitReady(DeviceHandle *dh)
cmd[0] = 0x00; /* TEST UNIT READY */
if(SendPacket(dh, cmd, 6, NULL, 0, &dh->sense, DATA_NONE) != -1)
{ if(Closure->guiMode)
{
#ifndef CLI
if(Closure->guiMode)
SetLabelText(Closure->status, "");
#endif
return TRUE;
}
@@ -2184,11 +2187,13 @@ int TestUnitReady(DeviceHandle *dh)
continue_waiting = TRUE;
if(continue_waiting)
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
_("Waiting 10 seconds for drive: %d\n"),9-i);
#ifndef CLI
if(Closure->stopActions)
return FALSE;
#endif
g_usleep(G_USEC_PER_SEC);
continue;
@@ -2198,8 +2203,10 @@ int TestUnitReady(DeviceHandle *dh)
break; /* Something is wrong with the drive */
}
#ifndef CLI
if(Closure->guiMode)
SetLabelText(Closure->status, "");
#endif
return FALSE;
}
@@ -2452,8 +2459,10 @@ int ReadSectors(DeviceHandle *dh, unsigned char *buf, gint64 s, int nsectors)
if(status) /* current try was unsucessful */
{ int last_key, last_asc, last_ascq;
#ifndef CLI
if(Closure->stopActions) /* user break */
return status;
#endif
/* Do not attempt multiple re-reads if nsectors > 1 and sectorSkip == 0
as these will be re-read with nsectors==1 anyways. */
@@ -2461,7 +2470,7 @@ int ReadSectors(DeviceHandle *dh, unsigned char *buf, gint64 s, int nsectors)
// Why only apply this shortcut to raw reading?
// if(dh->canReadDefective && nsectors > 1 && Closure->sectorSkip == 0)
if(nsectors > 1 && Closure->sectorSkip == 0)
{ PrintCLIorLabel(Closure->status,
{ PrintCLIorLabel(STATUS_LABEL_OR_NULL,
_("Sectors %lld - %lld: %s\n"),
s, s+nsectors-1, GetLastSenseString(FALSE));
return status;
@@ -2475,13 +2484,13 @@ int ReadSectors(DeviceHandle *dh, unsigned char *buf, gint64 s, int nsectors)
if(last_key == 3 && last_asc == 255 && last_ascq == 2 && dh->rawBuffer)
{ unsigned char *frame = dh->rawBuffer->workBuf->buf;
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
_("Sector %lld, try %d: %s Sector returned: %d.\n"),
s, retry, GetLastSenseString(FALSE),
MSFtoLBA(frame[12], frame[13], frame[14]));
}
else
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
_("Sector %lld, try %d: %s\n"),
s, retry, GetLastSenseString(FALSE));
@@ -2492,7 +2501,7 @@ int ReadSectors(DeviceHandle *dh, unsigned char *buf, gint64 s, int nsectors)
}
else /* good return status */
{ if(recommended_attempts > 1 && retry > 1)
PrintCLIorLabel(Closure->status,
PrintCLIorLabel(STATUS_LABEL_OR_NULL,
_("Sector %lld, try %d: success\n"), s, retry);
break;

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"

7
udf.c
View File

@@ -364,8 +364,11 @@ static IsoInfo* examine_iso(Image *image)
/*** Iterate over the volume decriptors */
for(sector=16; sector<32; sector++)
{ if(Closure->stopActions)
{
#ifndef CLI
if(Closure->stopActions)
continue;
#endif
if(ImageReadSectors(image, buf, sector, 1) != 1)
{ Verbose(" Sector %2d: unreadable\n", sector);
@@ -794,7 +797,7 @@ void FreeIsoHeader(IsoHeader *ih)
void AddFile(IsoHeader *ih, char *name, guint64 size)
{ static int n;
char iso[20], joliet[strlen(name)+3];
char iso[30], joliet[strlen(name)+3];
n++;
sprintf(iso,"RAN_%04d.DAT;1", n);

View File

@@ -19,6 +19,7 @@
* You should have received a copy of the GNU General Public License
* along with dvdisaster. If not, see <http://www.gnu.org/licenses/>.
*/
// DVDISASTER_GUI_FILE
#include "dvdisaster.h"