Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 90ffb25a2b |
BIN
otp-x86_64
Executable file
BIN
otp-x86_64
Executable file
Binary file not shown.
23
src/main.c
23
src/main.c
@@ -24,8 +24,9 @@ int main(int argc, char* argv[]) {
|
|||||||
// Load preferences
|
// Load preferences
|
||||||
load_preferences();
|
load_preferences();
|
||||||
|
|
||||||
// Detect interactive mode: only true when running with no arguments
|
// Detect interactive mode: true when running with no arguments AND no piped input
|
||||||
set_interactive_mode((argc == 1));
|
int is_interactive = (argc == 1 && !has_stdin_data());
|
||||||
|
set_interactive_mode(is_interactive);
|
||||||
|
|
||||||
// Check for OTP thumb drive on startup
|
// Check for OTP thumb drive on startup
|
||||||
char otp_drive_path[512];
|
char otp_drive_path[512];
|
||||||
@@ -46,15 +47,25 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int command_line_mode(int argc, char* argv[]) {
|
int command_line_mode(int argc, char* argv[]) {
|
||||||
// Check for help flags first
|
// Check for help flags first (only if we have arguments)
|
||||||
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0 ||
|
if (argc > 1 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--h") == 0 ||
|
||||||
strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0 ||
|
strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0 ||
|
||||||
strcmp(argv[1], "help") == 0) {
|
strcmp(argv[1], "help") == 0)) {
|
||||||
print_usage(argv[0]);
|
print_usage(argv[0]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(argv[1], "generate") == 0 || strcmp(argv[1], "-g") == 0) {
|
// If no arguments but piped input, default to encrypt mode
|
||||||
|
if (argc == 1 && has_stdin_data()) {
|
||||||
|
char* piped_text = read_stdin_text();
|
||||||
|
if (piped_text) {
|
||||||
|
int result = pipe_mode(argc, argv, piped_text);
|
||||||
|
free(piped_text);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argc > 1 && (strcmp(argv[1], "generate") == 0 || strcmp(argv[1], "-g") == 0)) {
|
||||||
if (argc != 3) {
|
if (argc != 3) {
|
||||||
printf("Usage: %s generate|-g <size>\n", argv[0]);
|
printf("Usage: %s generate|-g <size>\n", argv[0]);
|
||||||
printf("Size examples: 1024, 1GB, 5TB, 512MB\n");
|
printf("Size examples: 1024, 1GB, 5TB, 512MB\n");
|
||||||
|
|||||||
@@ -193,8 +193,10 @@ int generate_pad(uint64_t size_bytes, int display_progress) {
|
|||||||
printf("Pad file set to read-only\n");
|
printf("Pad file set to read-only\n");
|
||||||
printf("Use 'Add entropy' in Pads menu to enhance randomness.\n");
|
printf("Use 'Add entropy' in Pads menu to enhance randomness.\n");
|
||||||
|
|
||||||
// Pause before returning to menu to let user see the success message
|
// Pause before returning to menu to let user see the success message (only in interactive mode)
|
||||||
print_centered_header("Pad Generation Complete", 1);
|
if (get_interactive_mode()) {
|
||||||
|
print_centered_header("Pad Generation Complete", 1);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user