OSX didn't know about MAX_PATH, had to include limits.h; Use heap not stack memory
[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
42 #ifdef LINUX
43 #include <termio.h>
44 #endif
45
46 #ifdef OSX
47 #include <termios.h>
48 #include <sys/ioctl.h>
49 #include <mach-o/dyld.h>
50 #include <mach/mach.h>
51 #include <limits.h>
52 #endif
53
54 typedef void *OCL_LIB;
55
56 #ifdef HAVE_HWMON
57 typedef void *ADL_LIB;
58 typedef void *NVAPI_LIB;
59 typedef void *NVML_LIB;
60 typedef void *XNVCTRL_LIB;
61 #ifdef OSX
62 #define __stdcall
63 #endif
64 #endif
65
66 #endif // _POSIX
67
68 #ifdef _WIN
69 #define WIN32_LEAN_AND_MEAN
70 #include <windows.h>
71 #include <process.h>
72 #include <conio.h>
73 #include <tchar.h>
74 #include <psapi.h>
75 #include <io.h>
76
77 typedef UINT8 uint8_t;
78 typedef UINT16 uint16_t;
79 typedef UINT32 uint32_t;
80 typedef UINT64 uint64_t;
81 typedef INT8 int8_t;
82 typedef INT16 int16_t;
83 typedef INT32 int32_t;
84 typedef INT64 int64_t;
85
86 typedef UINT32 uint;
87 typedef UINT64 uint64_t;
88
89 typedef HINSTANCE OCL_LIB;
90
91 #ifdef HAVE_HWMON
92 typedef HINSTANCE ADL_LIB;
93 typedef HINSTANCE NVAPI_LIB;
94 typedef HINSTANCE NVML_LIB;
95 typedef HINSTANCE XNVCTRL_LIB;
96 #endif
97
98 #define mkdir(name,mode) mkdir (name)
99
100 #endif // _WIN
101
102 typedef uint8_t u8;
103 typedef uint16_t u16;
104 typedef uint32_t u32;
105 typedef uint64_t u64;
106
107 typedef uint32_t uint; // we need to get rid of this sooner or later, for consistency
108
109 #define EXEC_CACHE 128
110
111 #define SPEED_CACHE 128
112 #define SPEED_MAXAGE 4096
113
114 #define HCBUFSIZ 0x50000 // general large space buffer size in case the size is unknown at compile-time
115
116 #define EXPECTED_ITERATIONS 10000
117
118 /**
119 * functions
120 */
121
122 int log_out_nn (FILE *fp, const char *fmt, ...);
123 int log_info_nn (const char *fmt, ...);
124 int log_error_nn (const char *fmt, ...);
125
126 int log_out (FILE *fp, const char *fmt, ...);
127 int log_info (const char *fmt, ...);
128 int log_error (const char *fmt, ...);
129
130 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
131 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
132
133 #define CEIL(a) ((a - (int) (a)) > 0 ? a + 1 : a)
134
135 #endif // COMMON_H