chore: better use of configure features

This commit is contained in:
Stéphane Lesimple
2021-01-17 11:34:37 +01:00
parent c72b85bb9a
commit 9e5ba80e29
39 changed files with 550 additions and 525 deletions

View File

@@ -31,7 +31,7 @@
typedef struct
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
RS03Widgets *wl;
#endif
RS03Layout *lay;
@@ -49,7 +49,7 @@ static void fix_cleanup(gpointer data)
UnregisterCleanup();
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ if(fc->earlyTermination)
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -76,7 +76,7 @@ static void fix_cleanup(gpointer data)
g_free(fc);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
g_thread_exit(0);
#endif
@@ -114,7 +114,7 @@ static void expand_image(Image *image, EccHeader *eh, gint64 new_size)
percent = (100*sectors) / new_sectors;
if(last_percent != percent)
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
;
else
@@ -124,7 +124,7 @@ static void expand_image(Image *image, EccHeader *eh, gint64 new_size)
}
}
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
;
else
@@ -141,7 +141,7 @@ static void expand_image(Image *image, EccHeader *eh, gint64 new_size)
void RS03Fix(Image *image)
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
Method *self = FindMethod("RS03");
RS03Widgets *wl = (RS03Widgets*)self->widgetList;
#endif
@@ -175,14 +175,14 @@ void RS03Fix(Image *image)
gint64 damaged_eccsecs=0;
gint64 expected_sectors;
char *t=NULL;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
char *msg;
#endif
/*** Register the cleanup procedure for GUI mode */
fc->image = image;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
fc->wl = wl;
#endif
fc->earlyTermination = TRUE;
@@ -194,7 +194,7 @@ void RS03Fix(Image *image)
/*** Open the image file */
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
SetLabelText(GTK_LABEL(wl->fixHeadline),
_("<big>Repairing the image.</big>\n<i>%s</i>"),
@@ -237,7 +237,7 @@ void RS03Fix(Image *image)
/*** Announce what we are going to do */
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
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."),
@@ -264,7 +264,7 @@ void RS03Fix(Image *image)
{ int difference = image->inLast - eh->inLast;
guint64 expected_image_size = 2048*(expected_sectors-1)+eh->inLast;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
_("The image file is %d bytes longer than noted\n"
@@ -283,7 +283,7 @@ void RS03Fix(Image *image)
}
#endif
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(!Closure->guiMode && !Closure->truncate)
#else
if(!Closure->truncate)
@@ -321,7 +321,7 @@ void RS03Fix(Image *image)
if(!answer)
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
fc->wl->fixFootline,
_("<span %s>Aborted by user request!</span>"),
@@ -337,7 +337,7 @@ void RS03Fix(Image *image)
Stop(_("Could not truncate %s: %s\n"),Closure->imageName,strerror(errno));
}
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(diff>2 && Closure->guiMode)
{ int answer = ModalDialog(GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL, NULL,
trans,
@@ -362,7 +362,7 @@ void RS03Fix(Image *image)
}
#endif
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(diff>2 && !Closure->guiMode)
#else
if(diff>2)
@@ -421,7 +421,7 @@ void RS03Fix(Image *image)
/* See if user hit the Stop button */
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->stopActions)
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SwitchAndSetFootline(fc->wl->fixNotebook, 1,
@@ -551,7 +551,7 @@ void RS03Fix(Image *image)
if(erasure_count>lay->nroots) /* uncorrectable */
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(!Closure->guiMode)
#endif
{ int sep_printed = 0;
@@ -913,7 +913,7 @@ skip:
if(last_percent != percent)
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{
RS03AddFixValues(wl, percent, local_plot_max);
@@ -942,7 +942,7 @@ skip:
corrected, data_corr, ecc_corr);
if(uncorrected > 0)
{ PrintLog(_("Unrepaired sectors: %" PRId64 "\n"), uncorrected);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
_("Image sectors could not be fully restored "
@@ -967,7 +967,7 @@ skip:
PrintLog(_("Erasure counts per ecc block: avg = %.1f; worst = %d.\n"),
(double)damaged_sectors/(double)damaged_eccsecs,worst_ecc);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode && t)
SwitchAndSetFootline(wl->fixNotebook, 1, wl->fixFootline,
"%s %s", _("Repair results:"), t);