Skip to content

Commit

Permalink
Make completion footer more informative
Browse files Browse the repository at this point in the history
These changes solve three issues. The first
issue was that it wasn't obvious that the
PDFs are only created once you press return
to exit after all the wipes have finished. It
is now explicitly stated in the footer message if
PDFs are enabled.

It also now specifies the logfile name on the
footer if the user has specified a log file as a
command line option. If no logfile is specified
then STDOUT is displayed.

If the user specified --PDFreportpath=noPDF on the
command line, prior to this commit it had no affect.
This is now fixed so that it disables PDF's irrespective
of what is in nwipe.conf. i.e command line options
override the entries in nwipe.conf

If the user has specified a --PDFreportpath=noPDF=/some/path
then PDF's are enabled irrespective of the value in nwipe.conf
  • Loading branch information
PartialVolume committed Dec 20, 2023
1 parent 78f3a26 commit 807eed0
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 20 deletions.
67 changes: 50 additions & 17 deletions src/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@ const char* end_wipe_footer = "B=[Toggle between dark\\blank\\blue screen] Ctrl+
const char* rounds_footer = "Left=Erase Esc=Cancel Ctrl+C=Quit";
const char* selection_footer_text_entry = "Esc=Cancel Return=Submit Ctrl+C=Quit";

const char* wipes_finished_footer = "Wipe finished - press enter to exit. Logged to STDOUT";

/* The number of lines available in the terminal */
int stdscr_lines;

Expand Down Expand Up @@ -6067,6 +6065,53 @@ void* nwipe_gui_status( void* ptr )
/* Spinner character */
char spinner_string[2];

/* Create the finish message, this changes based on whether PDF creation is enabled
* and whether a logfile has been specified
*/
char finish_message[NWIPE_GUI_FOOTER_W + 132];
if( nwipe_options.logfile[0] == 0 && nwipe_options.PDF_enable != 0 )
{
snprintf( finish_message,
sizeof( finish_message ),
"Wipe finished - press enter to create pdfs & exit. Logged to STDOUT" );
}
else
{
if( nwipe_options.logfile[0] != 0 && nwipe_options.PDF_enable != 0 )
{
snprintf( finish_message,
sizeof( finish_message ),
"Wipe finished - press enter to create pdfs & exit. Logged to %s",
nwipe_options.logfile );
}
else
{
if( nwipe_options.logfile[0] != 0 && nwipe_options.PDF_enable == 0 )
{
snprintf( finish_message,
sizeof( finish_message ),
"Wipe finished - press enter to exit (pdfs disabled in config). Logged to %s",
nwipe_options.logfile );
}
else
{
if( nwipe_options.logfile[0] == 0 && nwipe_options.PDF_enable == 0 )
{
snprintf( finish_message,
sizeof( finish_message ),
"Wipe finished - press enter to exit (pdfs disabled in config). Logged to STDOUT" );
}
else
{
/* This is a catch all something unexpected happens with the above logic */
snprintf( finish_message,
sizeof( finish_message ),
"Wipe finished - press enter to exit. Logged to STDOUT" );
}
}
}
}

/* We count time from when this function is first called. */
static time_t nwipe_time_start = 0;

Expand Down Expand Up @@ -6224,7 +6269,7 @@ void* nwipe_gui_status( void* ptr )
else
{
/* and if the wipes have finished a different footer is required */
nwipe_gui_create_all_windows_on_terminal_resize( 0, wipes_finished_footer );
nwipe_gui_create_all_windows_on_terminal_resize( 0, finish_message );
}
}

Expand All @@ -6242,7 +6287,7 @@ void* nwipe_gui_status( void* ptr )

if( nwipe_active == 0 || terminate_signal == 1 )
{
nwipe_gui_title( footer_window, wipes_finished_footer );
nwipe_gui_title( footer_window, finish_message );

// Refresh the footer_window ;
wnoutrefresh( footer_window );
Expand Down Expand Up @@ -6625,19 +6670,7 @@ void* nwipe_gui_status( void* ptr )

} /* End of while loop */

if( nwipe_options.logfile[0] == '\0' )
{
nwipe_gui_title( footer_window, wipes_finished_footer );
}
else
{
char finish_message[NWIPE_GUI_FOOTER_W];
snprintf( finish_message,
sizeof( finish_message ),
"Wipe finished - press enter to exit. Logged to %s",
nwipe_options.logfile );
nwipe_gui_title( footer_window, finish_message );
}
nwipe_gui_title( footer_window, finish_message );
terminate_signal = 1;

return NULL;
Expand Down
3 changes: 2 additions & 1 deletion src/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,8 @@ void nwipe_log_summary( nwipe_context_t** ptr, int nwipe_selected )
serial_no );

/* Create the PDF report/certificate */
if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) != 0 )
if( nwipe_options.PDF_enable == 1 )
// if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) != 0 )
{
/* to have some progress indication. can help if there are many/slow disks */
fprintf( stderr, "." );
Expand Down
17 changes: 17 additions & 0 deletions src/options.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,23 @@ int nwipe_options_parse( int argc, char** argv )

nwipe_options.PDFreportpath[strlen( optarg )] = '\0';
strncpy( nwipe_options.PDFreportpath, optarg, sizeof( nwipe_options.PDFreportpath ) );

/* Command line options will override what's in nwipe.conf */
if( strcmp( nwipe_options.PDFreportpath, "noPDF" ) == 0 )
{
nwipe_options.PDF_enable = 0;
nwipe_conf_update_setting( "PDF_Certificate.PDF_Enable", "DISABLED" );
}
else
{
if( strcmp( nwipe_options.PDFreportpath, "." ) )
{
/* and if the user has specified a PDF path then enable PDF */
nwipe_options.PDF_enable = 1;
nwipe_conf_update_setting( "PDF_Certificate.PDF_Enable", "ENABLED" );
}
}

break;

case 'e': /* exclude drives option */
Expand Down
4 changes: 2 additions & 2 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* used by configure to dynamically assign those values
* to documentation files.
*/
const char* version_string = "0.35.4";
const char* version_string = "0.35.5";
const char* program_name = "nwipe";
const char* author_name = "Martijn van Brummelen";
const char* email_address = "[email protected]";
Expand All @@ -14,4 +14,4 @@ Modifications to original dwipe Copyright Andy Beverley <[email protected]>\n\
This is free software; see the source for copying conditions.\n\
There is NO warranty; not even for MERCHANTABILITY or FITNESS\n\
FOR A PARTICULAR PURPOSE.\n";
const char* banner = "nwipe 0.35.4";
const char* banner = "nwipe 0.35.5";

0 comments on commit 807eed0

Please sign in to comment.