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

@@ -67,7 +67,7 @@
typedef struct
{ Method *self;
Image *image;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
RS03Widgets *wl;
#endif
RS03Layout *lay;
@@ -147,7 +147,7 @@ static void ecc_cleanup(gpointer data)
}
}
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ if(ec->earlyTermination)
SetLabelText(GTK_LABEL(ec->wl->encFootline),
@@ -229,7 +229,7 @@ static void ecc_cleanup(gpointer data)
if(ec->encoderData) g_free(ec->encoderData);
g_free(ec);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
g_thread_exit(0);
#endif
@@ -245,7 +245,7 @@ static void ecc_cleanup(gpointer data)
static void abort_encoding(ecc_closure *ec, int truncate)
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
RS03Widgets *wl = ec->wl;
#endif
@@ -255,14 +255,14 @@ 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
#ifndef WITH_CLI_ONLY_YES
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
#ifndef WITH_CLI_ONLY_YES
else
{ if(Closure->stopActions == STOP_CURRENT_ACTION) /* suppress memleak warning when closing window */
SetLabelText(GTK_LABEL(wl->encFootline),
@@ -291,7 +291,7 @@ static void remove_old_ecc(ecc_closure *ec)
{
if(ConfirmEccDeletion(Closure->eccName))
LargeUnlink(Closure->eccName);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
else
{ SetLabelText(GTK_LABEL(ec->wl->encFootline),
_("<span %s>Aborted to keep existing ecc file.</span>"),
@@ -311,14 +311,14 @@ static void remove_old_ecc(ecc_closure *ec)
guint64 data_bytes;
int answer;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->confirmDeletion || !Closure->guiMode)
#endif
answer = ModalWarningOrCLI(GTK_MESSAGE_WARNING, GTK_BUTTONS_OK_CANCEL, NULL,
_("Image \"%s\" already contains error correction information.\n"
"Truncating image to data part (%" PRId64 " sectors).\n"),
Closure->imageName, data_sectors);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
else answer = TRUE;
#endif
@@ -514,7 +514,7 @@ static void expand_image(ecc_closure *ec)
{ unsigned char dead_sector[2048];
int n;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->stopActions) /* User hit the Stop button */
abort_encoding(ec, TRUE);
#endif
@@ -531,7 +531,7 @@ static void expand_image(ecc_closure *ec)
if(last_percent != percent)
{ PrintProgress(_(progress_msg), percent);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
SetProgress(ec->wl->encPBar1, percent, 100);
#endif
@@ -543,7 +543,7 @@ static void expand_image(ecc_closure *ec)
PrintProgress(_(progress_msg), 100);
PrintProgress("\n");
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
SetProgress(ec->wl->encPBar1, 100, 100);
#endif
@@ -629,7 +629,7 @@ static void read_next_chunk(ecc_closure *ec, guint64 chunk)
guint64 page_offset;
#endif
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->stopActions) /* User hit the Stop button */
{ ec->abortImmediately = TRUE;
abort_encoding(ec, TRUE);
@@ -860,7 +860,7 @@ static gpointer io_thread(ecc_closure *ec)
for(chunk=0; chunk<lay->sectorsPerLayer; chunk+=ec->chunkSize)
{
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
int cpu_bound = 0;
#endif
@@ -917,7 +917,7 @@ static gpointer io_thread(ecc_closure *ec)
/* Wait until the encoders have finished */
g_mutex_lock(ec->lock);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
cpu_bound = ec->buffersToEncode;
#endif
while(ec->buffersToEncode)
@@ -930,7 +930,7 @@ static gpointer io_thread(ecc_closure *ec)
verbose("IO: chunk %d finished\n", ec->ioChunk);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ if(cpu_bound)
{ SetLabelText(GTK_LABEL(ec->wl->encBottleneck), _("CPU bound"));
@@ -1137,7 +1137,7 @@ static gpointer encoder_thread(ecc_closure *ec)
{
ec->lastPercent = percent;
g_mutex_unlock(ec->lock);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ gdouble elapsed;
gulong ignore;
@@ -1178,14 +1178,14 @@ static void create_reed_solomon(ecc_closure *ec)
{ int nroots = ec->lay->nroots;
int ndata = ec->lay->ndata;
int i;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
char *alg="none";
char *iostrat="none";
#endif
/*** Show the second progress bar */
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ ShowWidget(ec->wl->encPBar2);
ShowWidget(ec->wl->encLabel2);
@@ -1289,7 +1289,7 @@ static void create_reed_solomon(ecc_closure *ec)
void RS03Create(void)
{ Method *method = FindMethod("RS03");
Image *image = NULL;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
RS03Widgets *wl = (RS03Widgets*)method->widgetList;
#endif
RS03Layout *lay;
@@ -1301,14 +1301,14 @@ void RS03Create(void)
/*** Register the cleanup procedure for GUI mode */
ec->self = method;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
ec->wl = wl;
#endif
ec->earlyTermination = TRUE;
RegisterCleanup(_("Error correction data creation aborted"), ecc_cleanup, ec);
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
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>"),
@@ -1359,7 +1359,7 @@ void RS03Create(void)
/*** Announce what we are going to do */
ecc_sectors = lay->nroots*lay->sectorsPerLayer;
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode) /* Preliminary fill text for the head line */
{ ec->msg = g_strdup_printf(_("Encoding with Method RS03: %" PRId64 " MiB data, %" PRId64 " MiB ecc (%d roots; %4.1f%% redundancy)."),
lay->dataSectors/512, ecc_sectors/512, lay->nroots, lay->redundancy);
@@ -1458,7 +1458,7 @@ 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
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ SetLabelText(GTK_LABEL(wl->encPerformance), _("%5.2fMiB/s average"), mbs);
SetLabelText(GTK_LABEL(ec->wl->encBottleneck),
@@ -1467,7 +1467,7 @@ void RS03Create(void)
}
#endif
#ifndef CLI
#ifndef WITH_CLI_ONLY_YES
if(Closure->guiMode)
{ SetProgress(wl->encPBar2, 100, 100);