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