* License.....: MIT
*/
-#ifdef DARWIN
+#ifdef __APPLE__
#include <stdio.h>
#endif
+#ifdef __FreeBSD__
+#include <stdio.h>
+#include <pthread_np.h>
+#endif
+
#include <shared.h>
#include <limits.h>
* tty
*/
-#ifdef LINUX
+#ifdef __linux__
static struct termios savemodes;
static int havemodes = 0;
{
struct termios modmodes;
- if (ioctl (fileno (stdin), TCGETA, &savemodes) < 0) return -1;
+ if (tcgetattr (fileno (stdin), &savemodes) < 0) return -1;
havemodes = 1;
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()
{
if (!havemodes) return 0;
- return ioctl (fileno (stdin), TCSETAW, &savemodes);
+ return tcsetattr (fileno (stdin), TCSADRAIN, &savemodes);
}
#endif
-#ifdef DARWIN
+#if defined(__APPLE__) || defined(__FreeBSD__)
static struct termios savemodes;
static int havemodes = 0;
{
if (fanpolicy == 1)
{
- NV_GPU_COOLER_LEVELS CoolerLevels = { 0 };
+ NV_GPU_COOLER_LEVELS CoolerLevels;
+
+ memset (&CoolerLevels, 0, sizeof (NV_GPU_COOLER_LEVELS));
CoolerLevels.Version = GPU_COOLER_LEVELS_VER | sizeof (NV_GPU_COOLER_LEVELS);
char *exec_path = (char *) mymalloc (exec_path_len);
- #ifdef LINUX
+ #ifdef __linux__
char tmp[32] = { 0 };
const int len = GetModuleFileName (NULL, exec_path, exec_path_len - 1);
- #elif DARWIN
+ #elif __APPLE__
uint size = exec_path_len;
const int len = strlen (exec_path);
+ #elif __FreeBSD__
+
+ #include <sys/sysctl.h>
+
+ int mib[4];
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_PROC;
+ mib[2] = KERN_PROC_PATHNAME;
+ mib[3] = -1;
+
+ char tmp[32] = { 0 };
+
+ size_t size = exec_path_len;
+ sysctl(mib, 4, exec_path, &size, NULL, 0);
+
+ const int len = readlink (tmp, exec_path, exec_path_len - 1);
+
#else
#error Your Operating System is not supported or detected
#endif
myfree (buf);
}
-#ifdef DARWIN
+#ifdef __APPLE__
int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t *cpu_set)
{
int core;
{
#ifdef _WIN
DWORD_PTR aff_mask = 0;
+ #elif __FreeBSD__
+ cpuset_t cpuset;
+ CPU_ZERO (&cpuset);
#elif _POSIX
cpu_set_t cpuset;
CPU_ZERO (&cpuset);
#ifdef _WIN
SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
SetThreadAffinityMask (GetCurrentThread (), aff_mask);
+ #elif __FreeBSD__
+ pthread_t thread = pthread_self ();
+ pthread_setaffinity_np (thread, sizeof (cpuset_t), &cpuset);
#elif _POSIX
pthread_t thread = pthread_self ();
pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset);
const salt_t *s1 = h1->salt;
const salt_t *s2 = h2->salt;
- // 16 - 2 (since last 2 uints contain the digest)
- uint n = 14;
+ // last 2: salt_buf[10] and salt_buf[11] contain the digest (skip them)
+
+ uint n = 9; // 9 * 4 = 36 bytes (max length of ESSID)
while (n--)
{
dictstat_t *d1 = (dictstat_t *) s1;
dictstat_t *d2 = (dictstat_t *) s2;
- #ifdef _LINUX
+ #ifdef __linux__
d2->stat.st_atim = d1->stat.st_atim;
#else
d2->stat.st_atime = d1->stat.st_atime;
if ((d = opendir (tmp_path)) != NULL)
{
- #ifdef DARWIN
+ #ifdef __APPLE__
+
struct dirent e;
- for (;;) {
+ for (;;)
+ {
memset (&e, 0, sizeof (e));
+
struct dirent *de = NULL;
if (readdir_r (d, &e, &de) != 0)
}
if (de == NULL) break;
+
#else
+
struct dirent *de;
while ((de = readdir (d)) != NULL)
{
+
#endif
+
if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue;
int path_size = strlen (tmp_path) + 1 + strlen (de->d_name);
uint len = 4096;
- uint digest_buf[64] = { 0 };
+ u8 datax[256] = { 0 };
- u64 *digest_buf64 = (u64 *) digest_buf;
+ u64 *digest_buf64 = (u64 *) datax;
+ u32 *digest_buf = (u32 *) datax;
char *digests_buf_ptr = (char *) data.digests_buf;
int enc_md = atoi (enc_md_pos);
- if (enc_md != 1) return (PARSER_SALT_VALUE);
+ if ((enc_md != 0) && (enc_md != 1)) return (PARSER_SALT_VALUE);
const uint id_len = atoi (id_len_pos);
const uint u_len = atoi (u_len_pos);