Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hashcat-cli.c: fix build against musl libc #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 5 additions & 58 deletions src/hashcat-cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,11 @@
#include "engine.h"

// for interactive status prompt
#if defined OSX || defined FREEBSD
#if defined OSX || defined FREEBSD || defined LINUX
#include <termios.h>
#include <sys/ioctl.h>
#endif

#if defined LINUX
#include <termio.h>
#endif

#define USAGE_VIEW 0
#define VERSION_VIEW 0
#define QUIET 0
Expand Down Expand Up @@ -2888,7 +2884,7 @@ void save_hash ()
unlink (old_input_file);
}

#if defined OSX || defined FREEBSD
#if defined OSX || defined FREEBSD || defined LINUX

static struct termios savemodes;
static int havemodes = 0;
Expand All @@ -2897,56 +2893,7 @@ int tty_break ()
{
struct termios modmodes;

if (ioctl (fileno (stdin), TIOCGETA, &savemodes) < 0) return -1;

havemodes = 1;

modmodes = savemodes;
modmodes.c_lflag &= ~ICANON;
modmodes.c_cc[VMIN] = 1;
modmodes.c_cc[VTIME] = 0;

return ioctl (fileno (stdin), TIOCSETAW, &modmodes);
}

int tty_getchar ()
{
fd_set rfds;

FD_ZERO (&rfds);

FD_SET (fileno (stdin), &rfds);

struct timeval tv;

tv.tv_sec = 1;
tv.tv_usec = 0;

int retval = select (1, &rfds, NULL, NULL, &tv);

if (retval == 0) return 0;
if (retval == -1) return -1;

return getchar ();
}

int tty_fix ()
{
if (!havemodes) return 0;

return ioctl (fileno (stdin), TIOCSETAW, &savemodes);
}
#endif

#if defined LINUX
static struct termio savemodes;
static int havemodes = 0;

int tty_break ()
{
struct termio modmodes;

if (ioctl (fileno (stdin), TCGETA, &savemodes) < 0) return -1;
if (tcgetattr (fileno (stdin), &savemodes) < 0) return -1;

havemodes = 1;

Expand All @@ -2955,7 +2902,7 @@ int tty_break ()
modmodes.c_cc[VMIN] = 1;
modmodes.c_cc[VTIME] = 0;

return ioctl (fileno (stdin), TCSETAW, &modmodes);
return tcsetattr (fileno (stdin), TCSANOW, &modmodes);
}

int tty_getchar ()
Expand Down Expand Up @@ -2983,7 +2930,7 @@ int tty_fix ()
{
if (!havemodes) return 0;

return ioctl (fileno (stdin), TCSETAW, &savemodes);
return tcsetattr (fileno (stdin), TCSANOW, &savemodes);
}
#endif

Expand Down