Fix m 60 a 0 by making modified variable non-const
[hashcat.git] / include / common.h
1 /**
2 * Authors.....: Jens Steube <jens.steube@gmail.com>
3 * magnum <john.magnum@hushmail.com>
4 *
5 * License.....: MIT
6 */
7
8 #ifndef COMMON_H
9 #define COMMON_H
10
11 #define _POSIX_SOURCE
12 #define _GNU_SOURCE
13 #define _FILE_OFFSET_BITS 64
14 #define _CRT_SECURE_NO_WARNINGS
15
16 #include <stdarg.h>
17 #include <stdint.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <stdbool.h>
21 #include <string.h>
22 #include <errno.h>
23 #include <getopt.h>
24 #include <math.h>
25 #include <ctype.h>
26 #include <dirent.h>
27 #include <time.h>
28 #include <unistd.h>
29 #include <signal.h>
30 #include <sys/stat.h>
31 #include <sys/types.h>
32 #include <search.h>
33 #include <fcntl.h>
34
35 #ifdef _POSIX
36 #include <sys/time.h>
37 #include <pthread.h>
38 #include <semaphore.h>
39 #include <dlfcn.h>
40 #include <pwd.h>
41 #include <limits.h>
42
43 #ifdef __linux__
44 #include <termios.h>
45 #include <sys/ioctl.h>
46 #endif
47
48 #ifdef __APPLE__
49 #include <termios.h>
50 #include <sys/ioctl.h>
51 #include <mach-o/dyld.h>
52 #include <mach/mach.h>
53 #endif
54
55 #ifdef __FreeBSD__
56 #include <termios.h>
57 #include <sys/ioctl.h>
58 #endif
59
60 typedef void *OCL_LIB;
61
62 #ifdef HAVE_HWMON
63 typedef void *ADL_LIB;
64 typedef void *NVAPI_LIB;
65 typedef void *NVML_LIB;
66 typedef void *XNVCTRL_LIB;
67 #ifdef __APPLE__
68 #define __stdcall
69 #endif
70 #endif
71
72 #endif // _POSIX
73
74 #ifdef _WIN
75 #define WIN32_LEAN_AND_MEAN
76 #include <windows.h>
77 #include <process.h>
78 #include <conio.h>
79 #include <tchar.h>
80 #include <psapi.h>
81 #include <io.h>
82
83 typedef UINT8 uint8_t;
84 typedef UINT16 uint16_t;
85 typedef UINT32 uint32_t;
86 typedef UINT64 uint64_t;
87 typedef INT8 int8_t;
88 typedef INT16 int16_t;
89 typedef INT32 int32_t;
90 typedef INT64 int64_t;
91
92 typedef UINT32 uint;
93 typedef UINT64 uint64_t;
94
95 typedef HINSTANCE OCL_LIB;
96
97 #ifdef HAVE_HWMON
98 typedef HINSTANCE ADL_LIB;
99 typedef HINSTANCE NVAPI_LIB;
100 typedef HINSTANCE NVML_LIB;
101 typedef HINSTANCE XNVCTRL_LIB;
102 #endif
103
104 #define mkdir(name,mode) mkdir (name)
105
106 #endif // _WIN
107
108 typedef uint8_t u8;
109 typedef uint16_t u16;
110 typedef uint32_t u32;
111 typedef uint64_t u64;
112
113 typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
114
115 #define EXEC_CACHE 128
116
117 #define SPEED_CACHE 128
118 #define SPEED_MAXAGE 4096
119
120 #define HCBUFSIZ 0x50000 // general large space buffer size in case the size is unknown at compile-time
121
122 #define EXPECTED_ITERATIONS 10000
123
124 /**
125 * functions
126 */
127
128 int log_out_nn (FILE *fp, const char *fmt, ...);
129 int log_info_nn (const char *fmt, ...);
130 int log_error_nn (const char *fmt, ...);
131
132 int log_out (FILE *fp, const char *fmt, ...);
133 int log_info (const char *fmt, ...);
134 int log_error (const char *fmt, ...);
135
136 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
137 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
138
139 #define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a)
140
141 #endif // COMMON_H