From de21c005fdbd4f065c02a14d196ad42a875834e6 Mon Sep 17 00:00:00 2001 From: jsteube Date: Wed, 28 Sep 2016 23:40:16 +0200 Subject: [PATCH] Move setup_console() to terminal.c --- include/terminal.h | 2 ++ src/hashcat.c | 30 ------------------------------ src/terminal.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 30 deletions(-) diff --git a/include/terminal.h b/include/terminal.h index 5042eea44..a1a7381a9 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -23,6 +23,8 @@ #include #endif // _WIN +int setup_console (); + void send_prompt (); void clear_prompt (); diff --git a/src/hashcat.c b/src/hashcat.c index 90e046eb1..2c0cd75c0 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -130,36 +130,6 @@ static void setup_umask () umask (077); } -static int setup_console () -{ - #if defined (_WIN) - SetConsoleWindowSize (132); - - if (_setmode (_fileno (stdin), _O_BINARY) == -1) - { - log_error ("ERROR: %s: %s", "stdin", strerror (errno)); - - return -1; - } - - if (_setmode (_fileno (stdout), _O_BINARY) == -1) - { - log_error ("ERROR: %s: %s", "stdout", strerror (errno)); - - return -1; - } - - if (_setmode (_fileno (stderr), _O_BINARY) == -1) - { - log_error ("ERROR: %s: %s", "stderr", strerror (errno)); - - return -1; - } - #endif - - return 0; -} - static void setup_seeding (const user_options_t *user_options, const time_t *proc_start) { if (user_options->rp_gen_seed_chgd == true) diff --git a/src/terminal.c b/src/terminal.c index 7f25fe01f..fb80b3fd5 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -36,6 +36,36 @@ extern hc_thread_mutex_t mux_display; const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => "; +int setup_console () +{ + #if defined (_WIN) + SetConsoleWindowSize (132); + + if (_setmode (_fileno (stdin), _O_BINARY) == -1) + { + log_error ("ERROR: %s: %s", "stdin", strerror (errno)); + + return -1; + } + + if (_setmode (_fileno (stdout), _O_BINARY) == -1) + { + log_error ("ERROR: %s: %s", "stdout", strerror (errno)); + + return -1; + } + + if (_setmode (_fileno (stderr), _O_BINARY) == -1) + { + log_error ("ERROR: %s: %s", "stderr", strerror (errno)); + + return -1; + } + #endif + + return 0; +} + void send_prompt () { fprintf (stdout, "%s", PROMPT);