1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 14:48:12 +00:00

Move thread_keypress() to terminal.c

This commit is contained in:
jsteube 2016-09-15 04:21:41 +02:00
parent 3f5ce6bb8e
commit 1ce58f51d1
3 changed files with 137 additions and 109 deletions

View File

@ -28,6 +28,8 @@
void send_prompt ();
void clear_prompt ();
void *thread_keypress (void *p);
#if defined (_WIN)
void SetConsoleWindowSize (const int x);
#endif

View File

@ -457,115 +457,6 @@ static void *thread_monitor (void *p)
static void *thread_keypress (void *p)
{
uint quiet = data.quiet;
tty_break();
while (data.shutdown_outer == 0)
{
int ch = tty_getchar();
if (ch == -1) break;
if (ch == 0) continue;
//https://github.com/hashcat/hashcat/issues/302
//#if defined (_POSIX)
//if (ch != '\n')
//#endif
hc_thread_mutex_lock (mux_display);
log_info ("");
switch (ch)
{
case 's':
case '\r':
case '\n':
log_info ("");
status_display ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'b':
log_info ("");
bypass ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'p':
log_info ("");
SuspendThreads ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'r':
log_info ("");
ResumeThreads ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'c':
log_info ("");
stop_at_checkpoint ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'q':
log_info ("");
myabort ();
break;
}
//https://github.com/hashcat/hashcat/issues/302
//#if defined (_POSIX)
//if (ch != '\n')
//#endif
hc_thread_mutex_unlock (mux_display);
}
tty_fix();
return (p);
}

View File

@ -4,8 +4,34 @@
*/
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "logging.h"
#include "interface.h"
#include "timer.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "opencl.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
#include "thread.h"
#include "status.h"
#include "terminal.h"
extern hc_global_data_t data;
extern hc_thread_mutex_t mux_display;
const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => ";
void send_prompt ()
@ -29,6 +55,115 @@ void clear_prompt ()
fflush (stdout);
}
void *thread_keypress (void *p)
{
uint quiet = data.quiet;
tty_break();
while (data.shutdown_outer == 0)
{
int ch = tty_getchar();
if (ch == -1) break;
if (ch == 0) continue;
//https://github.com/hashcat/hashcat/issues/302
//#if defined (_POSIX)
//if (ch != '\n')
//#endif
hc_thread_mutex_lock (mux_display);
log_info ("");
switch (ch)
{
case 's':
case '\r':
case '\n':
log_info ("");
status_display ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'b':
log_info ("");
bypass ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'p':
log_info ("");
SuspendThreads ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'r':
log_info ("");
ResumeThreads ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'c':
log_info ("");
stop_at_checkpoint ();
log_info ("");
if (quiet == 0) send_prompt ();
break;
case 'q':
log_info ("");
myabort ();
break;
}
//https://github.com/hashcat/hashcat/issues/302
//#if defined (_POSIX)
//if (ch != '\n')
//#endif
hc_thread_mutex_unlock (mux_display);
}
tty_fix();
return (p);
}
#if defined (_WIN)
void SetConsoleWindowSize (const int x)
{