Version v0.2.33 - implemented enhanced interactive filename editing for decrypt file functionality with smart defaults
This commit is contained in:
26
otp.c
26
otp.c
@@ -529,16 +529,32 @@ int handle_decrypt_menu(void) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Ask for custom output filename (optional)
|
||||
printf("\nEnter output filename (or press Enter for default): ");
|
||||
// Generate smart default output filename and use enhanced input function
|
||||
char default_output[512];
|
||||
strncpy(default_output, input_file, sizeof(default_output) - 1);
|
||||
default_output[sizeof(default_output) - 1] = '\0';
|
||||
|
||||
// Remove common encrypted extensions to get a better default
|
||||
if (strstr(default_output, ".otp.asc")) {
|
||||
// Replace .otp.asc with original extension or no extension
|
||||
char* ext_pos = strstr(default_output, ".otp.asc");
|
||||
*ext_pos = '\0';
|
||||
} else if (strstr(default_output, ".otp")) {
|
||||
// Replace .otp with original extension or no extension
|
||||
char* ext_pos = strstr(default_output, ".otp");
|
||||
*ext_pos = '\0';
|
||||
} else {
|
||||
// No recognized encrypted extension, add .decrypted suffix
|
||||
strncat(default_output, ".decrypted", sizeof(default_output) - strlen(default_output) - 1);
|
||||
}
|
||||
|
||||
char output_file[512];
|
||||
if (!fgets(output_file, sizeof(output_file), stdin)) {
|
||||
if (get_filename_with_default("Output filename:", default_output, output_file, sizeof(output_file)) != 0) {
|
||||
printf("Error: Failed to read input\n");
|
||||
return 1;
|
||||
}
|
||||
output_file[strcspn(output_file, "\n")] = 0;
|
||||
|
||||
const char* output_filename = (strlen(output_file) > 0) ? output_file : NULL;
|
||||
const char* output_filename = output_file;
|
||||
|
||||
return decrypt_file(input_file, output_filename);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user