Clean up
This commit is contained in:
52
otp.c
52
otp.c
@@ -4215,7 +4215,7 @@ int handle_pads_menu(void) {
|
|||||||
printf(" \033[4mA\033[0mdd entropy to pad\n");
|
printf(" \033[4mA\033[0mdd entropy to pad\n");
|
||||||
printf(" \033[4mS\033[0met default pad\n");
|
printf(" \033[4mS\033[0met default pad\n");
|
||||||
printf(" E\033[4mx\033[0mit\n");
|
printf(" E\033[4mx\033[0mit\n");
|
||||||
printf("\nSelect pad (by prefix): ");
|
printf("\nSelect action: ");
|
||||||
|
|
||||||
char input[MAX_HASH_LENGTH];
|
char input[MAX_HASH_LENGTH];
|
||||||
if (!fgets(input, sizeof(input), stdin)) {
|
if (!fgets(input, sizeof(input), stdin)) {
|
||||||
@@ -4224,7 +4224,7 @@ int handle_pads_menu(void) {
|
|||||||
}
|
}
|
||||||
input[strcspn(input, "\n")] = 0;
|
input[strcspn(input, "\n")] = 0;
|
||||||
|
|
||||||
// Handle actions first
|
// Handle actions
|
||||||
if (toupper(input[0]) == 'G') {
|
if (toupper(input[0]) == 'G') {
|
||||||
int result = handle_generate_menu();
|
int result = handle_generate_menu();
|
||||||
if (result == 0) {
|
if (result == 0) {
|
||||||
@@ -4306,54 +4306,10 @@ int handle_pads_menu(void) {
|
|||||||
return handle_pads_menu();
|
return handle_pads_menu();
|
||||||
} else if (toupper(input[0]) == 'X') {
|
} else if (toupper(input[0]) == 'X') {
|
||||||
return 0; // Exit to main menu
|
return 0; // Exit to main menu
|
||||||
}
|
|
||||||
|
|
||||||
// Find matching pad by prefix
|
|
||||||
int selected_pad = -1;
|
|
||||||
for (int i = 0; i < pad_count; i++) {
|
|
||||||
if (strncmp(input, pads[i].chksum, strlen(input)) == 0) {
|
|
||||||
if (selected_pad == -1) {
|
|
||||||
selected_pad = i;
|
|
||||||
} else {
|
} else {
|
||||||
// Multiple matches - ambiguous
|
printf("Invalid action. Please select G, A, S, or X.\n");
|
||||||
printf("Ambiguous prefix. Multiple matches found.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selected_pad == -1) {
|
|
||||||
printf("No pad found matching prefix '%s'\n", input);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show selected pad actions
|
|
||||||
printf("\n=== Pad: %.16s... ===\n", pads[selected_pad].chksum);
|
|
||||||
printf("Size: %s\n", pads[selected_pad].size_str);
|
|
||||||
printf("Used: %s (%.1f%%)\n", pads[selected_pad].used_str, pads[selected_pad].percentage);
|
|
||||||
|
|
||||||
printf("\nPad Actions:\n");
|
|
||||||
printf(" \033[4mI\033[0mnfo - Show detailed pad information\n");
|
|
||||||
printf(" \033[4mA\033[0mdd entropy - Enhance pad randomness\n");
|
|
||||||
printf(" \033[4mB\033[0mack to pad list\n");
|
|
||||||
printf("\nSelect action: ");
|
|
||||||
|
|
||||||
char action[10];
|
|
||||||
if (!fgets(action, sizeof(action), stdin)) {
|
|
||||||
printf("Error: Failed to read input\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
char action_choice = toupper(action[0]);
|
|
||||||
if (action_choice == 'I') {
|
|
||||||
return show_pad_info(pads[selected_pad].chksum);
|
|
||||||
} else if (action_choice == 'A') {
|
|
||||||
// Handle entropy addition
|
|
||||||
return handle_add_entropy_to_pad(pads[selected_pad].chksum);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default: back to pad list (recursive call)
|
|
||||||
return handle_pads_menu();
|
return handle_pads_menu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_directory_display(const char* file_path, char* result, size_t result_size) {
|
void get_directory_display(const char* file_path, char* result, size_t result_size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user